diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index d104ca3..f9360b1 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -10,27 +10,37 @@ jobs: build: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: [ 8.1, 8.2 ] + + name: PHP ${{ matrix.php }} tests steps: - - uses: actions/checkout@v2 + - uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e + with: + php-version: ${{ matrix.php }} + + - uses: actions/checkout@v3 - - name: Validate composer.json and composer.lock - run: composer validate --strict + - name: Validate composer.json and composer.lock + run: composer validate --strict - - name: Cache Composer packages - id: composer-cache - uses: actions/cache@v2 - with: - path: vendor - key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-php- + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v2 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- - - name: Install dependencies - run: composer install --prefer-dist --no-progress + - name: Install dependencies + run: composer install --prefer-dist --no-progress - # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" - # Docs: https://getcomposer.org/doc/articles/scripts.md + # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" + # Docs: https://getcomposer.org/doc/articles/scripts.md - - name: Run test suite - run: composer run-script test + - name: Run test suite + run: composer run-script test diff --git a/composer.json b/composer.json index b9a3c8a..60331cf 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ } ], "require": { - "php": ">=7.4", + "php": ">=8.1", "adbario/php-dot-notation": "^2.2" }, "require-dev": { diff --git a/composer.lock b/composer.lock index d47d282..363a7d7 100644 --- a/composer.lock +++ b/composer.lock @@ -1,32 +1,32 @@ { - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "8639ce7e8cd7e8973d4f6e2123ca046b", - "packages": [ - { - "name": "adbario/php-dot-notation", - "version": "2.2.0", - "source": { - "type": "git", - "url": "https://github.com/adbario/php-dot-notation.git", - "reference": "eee4fc81296531e6aafba4c2bbccfc5adab1676e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/adbario/php-dot-notation/zipball/eee4fc81296531e6aafba4c2bbccfc5adab1676e", - "reference": "eee4fc81296531e6aafba4c2bbccfc5adab1676e", - "shasum": "" - }, + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "9c1758acc07c28378bd429aff8b859c8", + "packages": [ + { + "name": "adbario/php-dot-notation", + "version": "2.5.0", + "source": { + "type": "git", + "url": "https://github.com/adbario/php-dot-notation.git", + "reference": "081e2cca50c84bfeeea2e3ef9b2c8d206d80ccae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/adbario/php-dot-notation/zipball/081e2cca50c84bfeeea2e3ef9b2c8d206d80ccae", + "reference": "081e2cca50c84bfeeea2e3ef9b2c8d206d80ccae", + "shasum": "" + }, "require": { "ext-json": "*", - "php": ">=5.5" + "php": "^5.5 || ^7.0 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^4.0|^5.0|^6.0", - "squizlabs/php_codesniffer": "^3.0" + "phpunit/phpunit": "^4.8|^5.7|^6.6|^7.5|^8.5|^9.5", + "squizlabs/php_codesniffer": "^3.6" }, "type": "library", "autoload": { @@ -55,38 +55,38 @@ ], "support": { "issues": "https://github.com/adbario/php-dot-notation/issues", - "source": "https://github.com/adbario/php-dot-notation/tree/2.x" + "source": "https://github.com/adbario/php-dot-notation/tree/2.5.0" }, - "time": "2019-01-01T23:59:15+00:00" + "time": "2022-10-14T20:31:46+00:00" } ], "packages-dev": [ - { - "name": "doctrine/instantiator", - "version": "1.4.1", - "source": { - "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/10dcfce151b967d20fde1b34ae6640712c3891bc", - "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc", - "shasum": "" - }, + { + "name": "doctrine/instantiator", + "version": "1.5.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b", + "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b", + "shasum": "" + }, "require": { "php": "^7.1 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^9", - "ext-pdo": "*", - "ext-phar": "*", - "phpbench/phpbench": "^0.16 || ^1", - "phpstan/phpstan": "^1.4", - "phpstan/phpstan-phpunit": "^1", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "vimeo/psalm": "^4.22" + "doctrine/coding-standard": "^9 || ^11", + "ext-pdo": "*", + "ext-phar": "*", + "phpbench/phpbench": "^0.16 || ^1", + "phpstan/phpstan": "^1.4", + "phpstan/phpstan-phpunit": "^1", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "vimeo/psalm": "^4.30 || ^5.4" }, "type": "library", "autoload": { @@ -113,7 +113,7 @@ ], "support": { "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/1.4.1" + "source": "https://github.com/doctrine/instantiator/tree/1.5.0" }, "funding": [ { @@ -129,7 +129,7 @@ "type": "tidelift" } ], - "time": "2022-03-03T08:28:38+00:00" + "time": "2022-12-30T00:15:36+00:00" }, { "name": "myclabs/deep-copy", @@ -190,20 +190,20 @@ ], "time": "2022-03-03T13:19:32+00:00" }, - { - "name": "nikic/php-parser", - "version": "v4.13.2", - "source": { - "type": "git", - "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "210577fe3cf7badcc5814d99455df46564f3c077" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/210577fe3cf7badcc5814d99455df46564f3c077", - "reference": "210577fe3cf7badcc5814d99455df46564f3c077", - "shasum": "" - }, + { + "name": "nikic/php-parser", + "version": "v4.15.2", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "f59bbe44bf7d96f24f3e2b4ddc21cd52c1d2adbc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/f59bbe44bf7d96f24f3e2b4ddc21cd52c1d2adbc", + "reference": "f59bbe44bf7d96f24f3e2b4ddc21cd52c1d2adbc", + "shasum": "" + }, "require": { "ext-tokenizer": "*", "php": ">=7.0" @@ -242,9 +242,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.13.2" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.2" }, - "time": "2021-11-30T19:35:32+00:00" + "time": "2022-11-12T15:38:23+00:00" }, { "name": "phar-io/manifest", @@ -357,261 +357,34 @@ }, "time": "2022-02-21T01:04:05+00:00" }, - { - "name": "phpdocumentor/reflection-common", - "version": "2.2.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-2.x": "2.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" - } - ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", - "keywords": [ - "FQSEN", - "phpDocumentor", - "phpdoc", - "reflection", - "static analysis" - ], - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", - "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" - }, - "time": "2020-06-27T09:03:43+00:00" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "5.3.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170", - "shasum": "" - }, - "require": { - "ext-filter": "*", - "php": "^7.2 || ^8.0", - "phpdocumentor/reflection-common": "^2.2", - "phpdocumentor/type-resolver": "^1.3", - "webmozart/assert": "^1.9.1" - }, - "require-dev": { - "mockery/mockery": "~1.3.2", - "psalm/phar": "^4.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - }, - { - "name": "Jaap van Otterdijk", - "email": "account@ijaap.nl" - } - ], - "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0" - }, - "time": "2021-10-19T17:43:47+00:00" - }, - { - "name": "phpdocumentor/type-resolver", - "version": "1.6.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/93ebd0014cab80c4ea9f5e297ea48672f1b87706", - "reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "phpdocumentor/reflection-common": "^2.0" - }, - "require-dev": { - "ext-tokenizer": "*", - "psalm/phar": "^4.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-1.x": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "support": { - "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.0" - }, - "time": "2022-01-04T19:58:01+00:00" + { + "name": "phpunit/php-code-coverage", + "version": "9.2.23", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "9f1f0f9a2fbb680b26d1cf9b61b6eac43a6e4e9c" }, - { - "name": "phpspec/prophecy", - "version": "v1.15.0", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/bbcd7380b0ebf3961ee21409db7b38bc31d69a13", - "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.2", - "php": "^7.2 || ~8.0, <8.2", - "phpdocumentor/reflection-docblock": "^5.2", - "sebastian/comparator": "^3.0 || ^4.0", - "sebastian/recursion-context": "^3.0 || ^4.0" - }, - "require-dev": { - "phpspec/phpspec": "^6.0 || ^7.0", - "phpunit/phpunit": "^8.0 || ^9.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Prophecy\\": "src/Prophecy" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" - } - ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" - ], - "support": { - "issues": "https://github.com/phpspec/prophecy/issues", - "source": "https://github.com/phpspec/prophecy/tree/v1.15.0" - }, - "time": "2021-12-08T12:19:24+00:00" + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/9f1f0f9a2fbb680b26d1cf9b61b6eac43a6e4e9c", + "reference": "9f1f0f9a2fbb680b26d1cf9b61b6eac43a6e4e9c", + "shasum": "" }, - { - "name": "phpunit/php-code-coverage", - "version": "9.2.15", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2e9da11878c4202f97915c1cb4bb1ca318a63f5f", - "reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f", - "shasum": "" - }, "require": { - "ext-dom": "*", - "ext-libxml": "*", - "ext-xmlwriter": "*", - "nikic/php-parser": "^4.13.0", - "php": ">=7.3", - "phpunit/php-file-iterator": "^3.0.3", - "phpunit/php-text-template": "^2.0.2", - "sebastian/code-unit-reverse-lookup": "^2.0.2", - "sebastian/complexity": "^2.0", - "sebastian/environment": "^5.1.2", - "sebastian/lines-of-code": "^1.0.3", - "sebastian/version": "^3.0.1", - "theseer/tokenizer": "^1.2.0" + "ext-dom": "*", + "ext-libxml": "*", + "ext-xmlwriter": "*", + "nikic/php-parser": "^4.14", + "php": ">=7.3", + "phpunit/php-file-iterator": "^3.0.3", + "phpunit/php-text-template": "^2.0.2", + "sebastian/code-unit-reverse-lookup": "^2.0.2", + "sebastian/complexity": "^2.0", + "sebastian/environment": "^5.1.2", + "sebastian/lines-of-code": "^1.0.3", + "sebastian/version": "^3.0.1", + "theseer/tokenizer": "^1.2.0" }, "require-dev": { "phpunit/phpunit": "^9.3" @@ -651,7 +424,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.15" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.23" }, "funding": [ { @@ -659,7 +432,7 @@ "type": "github" } ], - "time": "2022-03-07T09:28:20+00:00" + "time": "2022-12-28T12:41:10+00:00" }, { "name": "phpunit/php-file-iterator", @@ -902,20 +675,20 @@ ], "time": "2020-10-26T13:16:10+00:00" }, - { - "name": "phpunit/phpunit", - "version": "9.5.19", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "35ea4b7f3acabb26f4bb640f8c30866c401da807" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/35ea4b7f3acabb26f4bb640f8c30866c401da807", - "reference": "35ea4b7f3acabb26f4bb640f8c30866c401da807", - "shasum": "" - }, + { + "name": "phpunit/phpunit", + "version": "9.5.27", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "a2bc7ffdca99f92d959b3f2270529334030bba38" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a2bc7ffdca99f92d959b3f2270529334030bba38", + "reference": "a2bc7ffdca99f92d959b3f2270529334030bba38", + "shasum": "" + }, "require": { "doctrine/instantiator": "^1.3.1", "ext-dom": "*", @@ -925,30 +698,25 @@ "ext-xml": "*", "ext-xmlwriter": "*", "myclabs/deep-copy": "^1.10.1", - "phar-io/manifest": "^2.0.3", - "phar-io/version": "^3.0.2", - "php": ">=7.3", - "phpspec/prophecy": "^1.12.1", - "phpunit/php-code-coverage": "^9.2.13", - "phpunit/php-file-iterator": "^3.0.5", - "phpunit/php-invoker": "^3.1.1", - "phpunit/php-text-template": "^2.0.3", - "phpunit/php-timer": "^5.0.2", - "sebastian/cli-parser": "^1.0.1", - "sebastian/code-unit": "^1.0.6", - "sebastian/comparator": "^4.0.5", - "sebastian/diff": "^4.0.3", - "sebastian/environment": "^5.1.3", - "sebastian/exporter": "^4.0.3", - "sebastian/global-state": "^5.0.1", - "sebastian/object-enumerator": "^4.0.3", - "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^3.0", - "sebastian/version": "^3.0.2" - }, - "require-dev": { - "ext-pdo": "*", - "phpspec/prophecy-phpunit": "^2.0.1" + "phar-io/manifest": "^2.0.3", + "phar-io/version": "^3.0.2", + "php": ">=7.3", + "phpunit/php-code-coverage": "^9.2.13", + "phpunit/php-file-iterator": "^3.0.5", + "phpunit/php-invoker": "^3.1.1", + "phpunit/php-text-template": "^2.0.3", + "phpunit/php-timer": "^5.0.2", + "sebastian/cli-parser": "^1.0.1", + "sebastian/code-unit": "^1.0.6", + "sebastian/comparator": "^4.0.8", + "sebastian/diff": "^4.0.3", + "sebastian/environment": "^5.1.3", + "sebastian/exporter": "^4.0.5", + "sebastian/global-state": "^5.0.1", + "sebastian/object-enumerator": "^4.0.3", + "sebastian/resource-operations": "^3.0.3", + "sebastian/type": "^3.2", + "sebastian/version": "^3.0.2" }, "suggest": { "ext-soap": "*", @@ -991,19 +759,23 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.19" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.27" }, "funding": [ - { - "url": "https://phpunit.de/sponsors.html", - "type": "custom" - }, - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2022-03-15T09:57:31+00:00" + { + "url": "https://phpunit.de/sponsors.html", + "type": "custom" + }, + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", + "type": "tidelift" + } + ], + "time": "2022-12-09T07:31:23+00:00" }, { "name": "sebastian/cli-parser", @@ -1172,20 +944,20 @@ ], "time": "2020-09-28T05:30:19+00:00" }, - { - "name": "sebastian/comparator", - "version": "4.0.6", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "55f4261989e546dc112258c7a75935a81a7ce382" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/55f4261989e546dc112258c7a75935a81a7ce382", - "reference": "55f4261989e546dc112258c7a75935a81a7ce382", - "shasum": "" - }, + { + "name": "sebastian/comparator", + "version": "4.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "fa0f136dd2334583309d32b62544682ee972b51a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa0f136dd2334583309d32b62544682ee972b51a", + "reference": "fa0f136dd2334583309d32b62544682ee972b51a", + "shasum": "" + }, "require": { "php": ">=7.3", "sebastian/diff": "^4.0", @@ -1236,7 +1008,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", - "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.6" + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.8" }, "funding": [ { @@ -1244,7 +1016,7 @@ "type": "github" } ], - "time": "2020-10-26T15:49:45+00:00" + "time": "2022-09-14T12:41:17+00:00" }, { "name": "sebastian/complexity", @@ -1369,20 +1141,20 @@ ], "time": "2020-10-26T13:10:38+00:00" }, - { - "name": "sebastian/environment", - "version": "5.1.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "388b6ced16caa751030f6a69e588299fa09200ac" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/388b6ced16caa751030f6a69e588299fa09200ac", - "reference": "388b6ced16caa751030f6a69e588299fa09200ac", - "shasum": "" - }, + { + "name": "sebastian/environment", + "version": "5.1.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/1b5dff7bb151a4db11d49d90e5408e4e938270f7", + "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7", + "shasum": "" + }, "require": { "php": ">=7.3" }, @@ -1422,7 +1194,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/environment/issues", - "source": "https://github.com/sebastianbergmann/environment/tree/5.1.3" + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.4" }, "funding": [ { @@ -1430,22 +1202,22 @@ "type": "github" } ], - "time": "2020-09-28T05:52:38+00:00" + "time": "2022-04-03T09:37:03+00:00" + }, + { + "name": "sebastian/exporter", + "version": "4.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", + "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", + "shasum": "" }, - { - "name": "sebastian/exporter", - "version": "4.0.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/65e8b7db476c5dd267e65eea9cab77584d3cfff9", - "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9", - "shasum": "" - }, "require": { "php": ">=7.3", "sebastian/recursion-context": "^4.0" @@ -1499,7 +1271,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.4" + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.5" }, "funding": [ { @@ -1507,7 +1279,7 @@ "type": "github" } ], - "time": "2021-11-11T14:18:36+00:00" + "time": "2022-09-14T06:03:37+00:00" }, { "name": "sebastian/global-state", @@ -1860,20 +1632,20 @@ ], "time": "2020-09-28T06:45:17+00:00" }, - { - "name": "sebastian/type", - "version": "3.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/type.git", - "reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b233b84bc4465aff7b57cf1c4bc75c86d00d6dad", - "reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad", - "shasum": "" - }, + { + "name": "sebastian/type", + "version": "3.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", + "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", + "shasum": "" + }, "require": { "php": ">=7.3" }, @@ -1883,7 +1655,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.2-dev" } }, "autoload": { @@ -1906,7 +1678,7 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/3.0.0" + "source": "https://github.com/sebastianbergmann/type/tree/3.2.0" }, "funding": [ { @@ -1914,7 +1686,7 @@ "type": "github" } ], - "time": "2022-03-15T09:54:48+00:00" + "time": "2022-09-12T14:47:03+00:00" }, { "name": "sebastian/version", @@ -1969,102 +1741,20 @@ ], "time": "2020-09-28T06:39:44+00:00" }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.25.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "30885182c981ab175d4d034db0f6f469898070ab" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/30885182c981ab175d4d034db0f6f469898070ab", - "reference": "30885182c981ab175d4d034db0f6f469898070ab", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "provide": { - "ext-ctype": "*" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.23-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.25.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-10-20T20:35:02+00:00" + { + "name": "symfony/polyfill-mbstring", + "version": "v1.27.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534", + "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534", + "shasum": "" }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.25.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "0abb51d2f102e00a4eefcf46ba7fec406d245825" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/0abb51d2f102e00a4eefcf46ba7fec406d245825", - "reference": "0abb51d2f102e00a4eefcf46ba7fec406d245825", - "shasum": "" - }, "require": { "php": ">=7.1" }, @@ -2077,7 +1767,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -2116,7 +1806,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.25.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0" }, "funding": [ { @@ -2132,25 +1822,25 @@ "type": "tidelift" } ], - "time": "2021-11-30T18:21:41+00:00" + "time": "2022-11-03T14:55:06+00:00" + }, + { + "name": "symfony/var-dumper", + "version": "v6.2.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/var-dumper.git", + "reference": "fdbadd4803bc3c96ef89238c9c9e2ebe424ec2e0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/fdbadd4803bc3c96ef89238c9c9e2ebe424ec2e0", + "reference": "fdbadd4803bc3c96ef89238c9c9e2ebe424ec2e0", + "shasum": "" }, - { - "name": "symfony/var-dumper", - "version": "v6.0.6", - "source": { - "type": "git", - "url": "https://github.com/symfony/var-dumper.git", - "reference": "38358405ae948963c50a3aae3dfea598223ba15e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/38358405ae948963c50a3aae3dfea598223ba15e", - "reference": "38358405ae948963c50a3aae3dfea598223ba15e", - "shasum": "" - }, "require": { - "php": ">=8.0.2", - "symfony/polyfill-mbstring": "~1.0" + "php": ">=8.1", + "symfony/polyfill-mbstring": "~1.0" }, "conflict": { "phpunit/phpunit": "<5.4.3", @@ -2204,7 +1894,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v6.0.6" + "source": "https://github.com/symfony/var-dumper/tree/v6.2.3" }, "funding": [ { @@ -2220,7 +1910,7 @@ "type": "tidelift" } ], - "time": "2022-03-02T12:58:14+00:00" + "time": "2022-12-22T17:55:15+00:00" }, { "name": "theseer/tokenizer", @@ -2271,64 +1961,6 @@ } ], "time": "2021-07-28T10:34:58+00:00" - }, - { - "name": "webmozart/assert", - "version": "1.10.0", - "source": { - "type": "git", - "url": "https://github.com/webmozarts/assert.git", - "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webmozarts/assert/zipball/6964c76c7804814a842473e0c8fd15bab0f18e25", - "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "symfony/polyfill-ctype": "^1.8" - }, - "conflict": { - "phpstan/phpstan": "<0.12.20", - "vimeo/psalm": "<4.6.1 || 4.6.2" - }, - "require-dev": { - "phpunit/phpunit": "^8.5.13" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.10-dev" - } - }, - "autoload": { - "psr-4": { - "Webmozart\\Assert\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Assertions to validate method input/output with nice error messages.", - "keywords": [ - "assert", - "check", - "validate" - ], - "support": { - "issues": "https://github.com/webmozarts/assert/issues", - "source": "https://github.com/webmozarts/assert/tree/1.10.0" - }, - "time": "2021-03-09T10:59:23+00:00" } ], "aliases": [], @@ -2337,10 +1969,10 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7.4" + "php": ">=8.1" }, "platform-dev": { "ext-json": "*" }, - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.3.0" } diff --git a/src/CustomValidator.php b/src/CustomValidator.php index 80daee3..baafbf7 100644 --- a/src/CustomValidator.php +++ b/src/CustomValidator.php @@ -11,7 +11,7 @@ class CustomValidator /** * @param string $key - * @param $value + * @param $value */ public function __construct(string $key, $value) { diff --git a/src/ValidationError.php b/src/ValidationError.php index b969f63..b216173 100644 --- a/src/ValidationError.php +++ b/src/ValidationError.php @@ -18,6 +18,7 @@ class ValidationError ValidationRules::MATCH => "The field %s must be equal to the value of %s", ValidationRules::EQUAL => "The field %s must be equal to %s", ValidationRules::ARRAY => "The field %s must be an array", + ValidationRules::LIST => "The field %s must be a list", ValidationRules::BOOLEAN => "The field %s must be a boolean", ValidationRules::BETWEEN => "The field %s must contain between %d and %d characters", ValidationRules::PATTERN => "The field %s must follow the following pattern %s", @@ -27,7 +28,7 @@ class ValidationError /** * @param string $key * @param string $rule - * @param array $attributes + * @param array $attributes */ public function __construct(string $key, string $rule, array $attributes) { diff --git a/src/ValidationRules.php b/src/ValidationRules.php index bacd98d..207e2c9 100644 --- a/src/ValidationRules.php +++ b/src/ValidationRules.php @@ -5,17 +5,18 @@ class ValidationRules { - const NOT_NULL = "not-null"; - const REQUIRED = "required"; - const NOT_EMPTY = "not-empty"; - const LENGTH = "length"; - const DATE_TIME = "date-time"; - const MATCH = "match"; - const EQUAL = "equal"; const ARRAY = "array"; - const BOOLEAN = "boolean"; const BETWEEN = "between"; - const PATTERN = "pattern"; + const BOOLEAN = "boolean"; const CUSTOM = "custom"; + const DATE_TIME = "date-time"; + const EQUAL = "equal"; + const LENGTH = "length"; + const LIST = "list"; + const MATCH = "match"; + const NOT_EMPTY = "not-empty"; + const NOT_NULL = "not-null"; + const PATTERN = "pattern"; + const REQUIRED = "required"; } \ No newline at end of file diff --git a/src/Validator.php b/src/Validator.php index 8088661..e2bed37 100644 --- a/src/Validator.php +++ b/src/Validator.php @@ -9,12 +9,14 @@ class Validator { /** * The body to validate + * * @var array */ private array $body; /** * List of errors that occurred during the validation + * * @var ValidationError[] */ private array $errors = []; @@ -24,7 +26,7 @@ class Validator */ public function __construct(?array $body) { - if ($body == null) { + if ($body == NULL) { $body = []; } $this->body = $body; @@ -38,28 +40,17 @@ public function isValid(): bool return empty($this->errors); } - /** - * @return string[] - */ - public function getErrors(): array - { - $errors = []; - foreach ($this->errors as $error) { - $errors[] = (string)$error; - } - return $errors; - } - /** * Test if the keys are not null * * @param string ...$keys + * * @return $this */ public function notNull(string ...$keys): self { foreach ($keys as $key) { - if ($this->getValue($key) == null) { + if ($this->getValue($key) == NULL) { $this->addError($key, ValidationRules::NOT_NULL); } } @@ -68,9 +59,10 @@ public function notNull(string ...$keys): self /** * @param string $key + * * @return mixed|null */ - public function getValue(string $key, $default = null) + public function getValue(string $key, $default = NULL) { $dot = new Dot($this->body); return $dot->get($key, $default); @@ -79,7 +71,8 @@ public function getValue(string $key, $default = null) /** * @param string $key * @param string $rule - * @param ...$attributes + * @param ...$attributes + * * @return void */ private function addError(string $key, string $rule, ...$attributes) @@ -91,6 +84,7 @@ private function addError(string $key, string $rule, ...$attributes) * Test if the keys are present (required) and not empty * * @param string ...$keys + * * @return Validator */ public function requiredAndNotEmpty(string ...$keys): self @@ -102,6 +96,7 @@ public function requiredAndNotEmpty(string ...$keys): self * Test if the keys are not empty * * @param string ...$keys + * * @return $this */ public function notEmpty(string ...$keys): self @@ -118,6 +113,7 @@ public function notEmpty(string ...$keys): self * Test if the keys are present (required) * * @param string ...$keys + * * @return $this */ public function required(string ...$keys): self @@ -134,16 +130,17 @@ public function required(string ...$keys): self /** * Test if the key is the correct length * - * @param string $key - * @param int $min + * @param string $key + * @param int $min * @param int|null $max + * * @return $this */ public function length(string $key, int $min, ?int $max = NULL): self { $value = $this->getValue($key); - if ($value == null) { + if ($value == NULL) { $this->addError($key, ValidationRules::LENGTH, $min, $max); return $this; } @@ -153,7 +150,7 @@ public function length(string $key, int $min, ?int $max = NULL): self return $this; } - if ($max != null && strlen($value) > $max) { + if ($max != NULL && strlen($value) > $max) { $this->addError($key, ValidationRules::LENGTH, $min, $max); return $this; } @@ -166,6 +163,7 @@ public function length(string $key, int $min, ?int $max = NULL): self * * @param string $key * @param string $format + * * @return $this */ public function dateTime(string $key, string $format = 'Y-m-d H:i:s'): self @@ -177,7 +175,7 @@ public function dateTime(string $key, string $format = 'Y-m-d H:i:s'): self // https://github.com/lefuturiste/validator/blob/9e4e653597437acb277b48167ebd6acbaef65a8f/src/Validator.php#L134 $date = DateTime::createFromFormat($format, $this->getValue($key)); $errors = DateTime::getLastErrors(); - if ($errors['error_count'] > 0 || $errors['warning_count'] > 0 || $date == false) { + if (($errors && ($errors['error_count'] > 0 || $errors['warning_count'] > 0)) || !$date) { $this->addError($key, ValidationRules::DATE_TIME, $format); } @@ -188,6 +186,7 @@ public function dateTime(string $key, string $format = 'Y-m-d H:i:s'): self * Test if the keys are valid slugs * * @param string ...$keys + * * @return $this */ public function slug(string ...$keys): self @@ -200,10 +199,27 @@ public function slug(string ...$keys): self return $this; } + /** + * Test if the key match the provided regex expression + * + * @param string $key + * @param string $pattern + * + * @return $this + */ + public function patternMatch(string $key, string $pattern): self + { + if ($this->getValue($key) != NULL && !preg_match($pattern, $this->getValue($key))) { + $this->addError($key, ValidationRules::PATTERN, $pattern); + } + return $this; + } + /** * Test if the keys are valid urls * * @param string ...$keys + * * @return $this */ public function url(string ...$keys): self @@ -219,8 +235,9 @@ public function url(string ...$keys): self /** * Test if the key match the provided value * - * @param string $key + * @param string $key * @param null|mixed $expected + * * @return $this */ public function match(string $key, $expected): self @@ -237,6 +254,7 @@ public function match(string $key, $expected): self * * @param string $key * @param string $secondKey + * * @return $this */ public function equal(string $key, string $secondKey): self @@ -252,6 +270,7 @@ public function equal(string $key, string $secondKey): self * Test if the key is a valid email address * * @param string ...$keys + * * @return $this */ public function email(string ...$keys): self @@ -268,6 +287,7 @@ public function email(string ...$keys): self * Test if the keys are valid arrays * * @param string ...$keys + * * @return $this */ public function array(string ...$keys): self @@ -285,6 +305,7 @@ public function array(string ...$keys): self * Test if the keys are valid integers * * @param string ...$keys + * * @return $this */ public function integer(string ...$keys): self @@ -301,6 +322,7 @@ public function integer(string ...$keys): self * Test if the keys are valid float numbers * * @param string ...$keys + * * @return $this */ public function float(string ...$keys): self @@ -317,13 +339,14 @@ public function float(string ...$keys): self * Test if the keys are valid booleans * * @param string ...$keys + * * @return $this */ public function boolean(string ...$keys): self { foreach ($keys as $key) { $value = $this->getValue($key); - if ($value !== null && !( + if ($value !== NULL && !( ($value === false) || ($value === true) || ($value === 'false') @@ -344,9 +367,10 @@ public function boolean(string ...$keys): self * Test if the key is between a provided range * * @param string $key - * @param int $min - * @param int $max - * @param bool $strict + * @param int $min + * @param int $max + * @param bool $strict + * * @return $this */ public function between(string $key, int $min, int $max, bool $strict = false): self @@ -363,25 +387,11 @@ public function between(string $key, int $min, int $max, bool $strict = false): return $this; } - /** - * Test if the key match the provided regex expression - * - * @param string $key - * @param string $pattern - * @return $this - */ - public function patternMatch(string $key, string $pattern): self - { - if ($this->getValue($key) != null && !preg_match($pattern, $this->getValue($key))) { - $this->addError($key, ValidationRules::PATTERN, $pattern); - } - return $this; - } - /** * Test if the key is an alphanumerical value * * @param string ...$keys + * * @return $this */ public function alphaNumerical(string ...$keys): self @@ -396,8 +406,9 @@ public function alphaNumerical(string ...$keys): self /** * Test the key against a custom validation function * - * @param string $key + * @param string $key * @param callable $function + * * @return $this */ public function customValidation(string $key, callable $function): self @@ -411,4 +422,25 @@ public function customValidation(string $key, callable $function): self return $this; } + + /** + * @return string[] + */ + public function getErrors(): array + { + $errors = []; + foreach ($this->errors as $error) { + $errors[] = (string)$error; + } + return $errors; + } + + public function isList(string ...$keys) + { + foreach ($keys as $key) { + if (!empty($this->getValue($key)) && !array_is_list($this->getValue($key))) { + $this->addError($key, ValidationRules::LIST); + } + } + } } \ No newline at end of file diff --git a/tests/SimpleTest.php b/tests/SimpleTest.php index cc63c2f..d7be342 100644 --- a/tests/SimpleTest.php +++ b/tests/SimpleTest.php @@ -13,7 +13,7 @@ public function testConstructor() $validator->notNull("abc"); $this->assertCount(1, $validator->getErrors()); - $validator = $this->createValidator(null); // Null body, everything should fail + $validator = $this->createValidator(NULL); // Null body, everything should fail $validator->notNull("abc"); $this->assertCount(1, $validator->getErrors()); } @@ -24,7 +24,7 @@ public function testNotNull() $validator->notNull("abc"); $this->assertCount(0, $validator->getErrors()); - $validator = $this->createValidator(["abc" => null]); + $validator = $this->createValidator(["abc" => NULL]); $validator->notNull("abc"); $this->assertCount(1, $validator->getErrors()); } @@ -219,4 +219,15 @@ public function testCustomValidation() $this->assertEquals("random", $validator->getErrors()[0], json_encode($validator->getErrors())); } + public function testList() + { + $validator = $this->createValidator(["abc" => ["abc", "def"]]); + $validator->isList("abc"); + $this->assertCount(0, $validator->getErrors(), json_encode($validator->getErrors())); + + $validator = $this->createValidator(["abc" => ["abc" => "def", "foo" => "bar"]]); + $validator->isList("abc"); + $this->assertCount(1, $validator->getErrors(), json_encode($validator->getErrors())); + } + } \ No newline at end of file