diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 143a307..c58beb0 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,14 +1,13 @@ imports: - - php + - php build: - environment: - php: '7.4' - tests: - override: - - - command: 'vendor/bin/phpunit --coverage-clover=clover.xml --exclude-group flaky' - coverage: - file: 'clover.xml' - format: 'clover' - - php-scrutinizer-run + environment: + php: "8.1" + tests: + override: + - command: "vendor/bin/phpunit --coverage-clover=clover.xml --exclude-group flaky" + coverage: + file: "clover.xml" + format: "clover" + - php-scrutinizer-run diff --git a/.travis.yml b/.travis.yml index a3aa367..f688af3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,20 +2,16 @@ language: php matrix: include: - - php: 7.4 - dist: bionic + - php: 8.1 env: - psalm=yes - - php: 8.0 - env: - - psalm=yes - dist: bionic -#ppc64le support code - - php: 7.4 + dist: jammy + #ppc64le support code + - php: 8.1 arch: ppc64le env: - psalm=yes - dist: bionic + dist: jammy install: - if [ "$deps" = "low" ]; then composer update --prefer-lowest; else composer install; fi diff --git a/README.md b/README.md index 0bd8503..be1647c 100644 --- a/README.md +++ b/README.md @@ -21,16 +21,17 @@ This library aims to support RFCs: **Current major version with full support is v3** -| Version | Released | EOL | Only critical bug fixes | Full | -| ---- | :----: | :----: | :----: | :----: | -| v3.x | 2020/12/29 | - | X | X | -| v2.1.x | 2016/05/16 | 01/2022 | X | | -| v1.2 | 2013/19/05 | YES | | | +| Version | Released | EOL | Only critical bug fixes | Full | +| ------- | :--------: | :---: | :---------------------: | :---: | +| v4.x | | - | X | X | +| v3.x | 2020/12/29 | - | X | X | +| v2.1.x | 2016/05/16 | YES | X | | +| v1.2 | 2013/19/05 | YES | | | ## Requirements ## - * PHP 7.2 + * PHP 8.1 * [Composer](https://getcomposer.org) is required for installation * [Spoofchecking](/src/Validation/Extra/SpoofCheckValidation.php) and [DNSCheckValidation](/src/Validation/DNSCheckValidation.php) validation requires that your PHP system has the [PHP Internationalization Libraries](https://php.net/manual/en/book.intl.php) (also known as PHP Intl) diff --git a/composer.json b/composer.json index d598d1b..4ead5b8 100644 --- a/composer.json +++ b/composer.json @@ -1,21 +1,21 @@ { - "name": "egulias/email-validator", - "description": "A library for validating emails against several RFCs", - "homepage": "https://github.com/egulias/EmailValidator", - "keywords": ["email", "validation", "validator", "emailvalidation", "emailvalidator"], - "license": "MIT", + "name": "egulias/email-validator", + "description": "A library for validating emails against several RFCs", + "homepage": "https://github.com/egulias/EmailValidator", + "keywords": ["email", "validation", "validator", "emailvalidation", "emailvalidator"], + "license": "MIT", "authors": [ {"name": "Eduardo Gulias Davis"} ], "extra": { "branch-alias": { - "dev-master": "3.0.x-dev" + "dev-master": "4.0.x-dev" } }, "require": { - "php": ">=7.2", - "doctrine/lexer": "^1.2", - "symfony/polyfill-intl-idn": "^1.15" + "php": ">=8.1", + "doctrine/lexer": "^2.0 || ^3.0", + "symfony/polyfill-intl-idn": "^1.26" }, "require-dev": { "php-coveralls/php-coveralls": "^2.2", diff --git a/composer.lock b/composer.lock index 15d9667..9763ec9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,35 +4,36 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a77d36b64bc1213fecf4d4f92d759c3b", + "content-hash": "e171c375692ca089d73dcdc1d451ca3a", "packages": [ { "name": "doctrine/lexer", - "version": "1.2.3", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/doctrine/lexer.git", - "reference": "c268e882d4dbdd85e36e4ad69e02dc284f89d229" + "reference": "84a527db05647743d50373e0ec53a152f2cde568" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/lexer/zipball/c268e882d4dbdd85e36e4ad69e02dc284f89d229", - "reference": "c268e882d4dbdd85e36e4ad69e02dc284f89d229", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/84a527db05647743d50373e0ec53a152f2cde568", + "reference": "84a527db05647743d50373e0ec53a152f2cde568", "shasum": "" }, "require": { - "php": "^7.1 || ^8.0" + "php": "^8.1" }, "require-dev": { - "doctrine/coding-standard": "^9.0", - "phpstan/phpstan": "^1.3", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "vimeo/psalm": "^4.11" + "doctrine/coding-standard": "^10", + "phpstan/phpstan": "^1.9", + "phpunit/phpunit": "^9.5", + "psalm/plugin-phpunit": "^0.18.3", + "vimeo/psalm": "^5.0" }, "type": "library", "autoload": { "psr-4": { - "Doctrine\\Common\\Lexer\\": "lib/Doctrine/Common/Lexer" + "Doctrine\\Common\\Lexer\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -64,7 +65,7 @@ ], "support": { "issues": "https://github.com/doctrine/lexer/issues", - "source": "https://github.com/doctrine/lexer/tree/1.2.3" + "source": "https://github.com/doctrine/lexer/tree/3.0.0" }, "funding": [ { @@ -80,20 +81,20 @@ "type": "tidelift" } ], - "time": "2022-02-28T11:07:21+00:00" + "time": "2022-12-15T16:57:16+00:00" }, { "name": "symfony/polyfill-intl-idn", - "version": "v1.26.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "59a8d271f00dd0e4c2e518104cc7963f655a1aa8" + "reference": "639084e360537a19f9ee352433b84ce831f3d2da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/59a8d271f00dd0e4c2e518104cc7963f655a1aa8", - "reference": "59a8d271f00dd0e4c2e518104cc7963f655a1aa8", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/639084e360537a19f9ee352433b84ce831f3d2da", + "reference": "639084e360537a19f9ee352433b84ce831f3d2da", "shasum": "" }, "require": { @@ -107,7 +108,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -151,7 +152,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.27.0" }, "funding": [ { @@ -167,20 +168,20 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.26.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "219aa369ceff116e673852dce47c3a41794c14bd" + "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/219aa369ceff116e673852dce47c3a41794c14bd", - "reference": "219aa369ceff116e673852dce47c3a41794c14bd", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/19bd1e4fcd5b91116f14d8533c57831ed00571b6", + "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6", "shasum": "" }, "require": { @@ -192,7 +193,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -235,7 +236,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.27.0" }, "funding": [ { @@ -251,20 +252,20 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/polyfill-php72", - "version": "v1.26.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "bf44a9fd41feaac72b074de600314a93e2ae78e2" + "reference": "869329b1e9894268a8a61dabb69153029b7a8c97" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/bf44a9fd41feaac72b074de600314a93e2ae78e2", - "reference": "bf44a9fd41feaac72b074de600314a93e2ae78e2", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/869329b1e9894268a8a61dabb69153029b7a8c97", + "reference": "869329b1e9894268a8a61dabb69153029b7a8c97", "shasum": "" }, "require": { @@ -273,7 +274,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -311,7 +312,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php72/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-php72/tree/v1.27.0" }, "funding": [ { @@ -327,7 +328,7 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2022-11-03T14:55:06+00:00" } ], "packages-dev": [ @@ -572,16 +573,16 @@ }, { "name": "composer/pcre", - "version": "3.0.0", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "e300eb6c535192decd27a85bc72a9290f0d6b3bd" + "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/e300eb6c535192decd27a85bc72a9290f0d6b3bd", - "reference": "e300eb6c535192decd27a85bc72a9290f0d6b3bd", + "url": "https://api.github.com/repos/composer/pcre/zipball/4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", + "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", "shasum": "" }, "require": { @@ -623,7 +624,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.0.0" + "source": "https://github.com/composer/pcre/tree/3.1.0" }, "funding": [ { @@ -639,7 +640,7 @@ "type": "tidelift" } ], - "time": "2022-02-25T20:21:48+00:00" + "time": "2022-11-17T09:50:14+00:00" }, { "name": "composer/semver", @@ -998,16 +999,16 @@ }, { "name": "guzzlehttp/guzzle", - "version": "7.4.5", + "version": "7.5.0", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "1dd98b0564cb3f6bd16ce683cb755f94c10fbd82" + "reference": "b50a2a1251152e43f6a37f0fa053e730a67d25ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/1dd98b0564cb3f6bd16ce683cb755f94c10fbd82", - "reference": "1dd98b0564cb3f6bd16ce683cb755f94c10fbd82", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/b50a2a1251152e43f6a37f0fa053e730a67d25ba", + "reference": "b50a2a1251152e43f6a37f0fa053e730a67d25ba", "shasum": "" }, "require": { @@ -1022,10 +1023,10 @@ "psr/http-client-implementation": "1.0" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.4.1", + "bamarni/composer-bin-plugin": "^1.8.1", "ext-curl": "*", "php-http/client-integration-tests": "^3.0", - "phpunit/phpunit": "^8.5.5 || ^9.3.5", + "phpunit/phpunit": "^8.5.29 || ^9.5.23", "psr/log": "^1.1 || ^2.0 || ^3.0" }, "suggest": { @@ -1035,8 +1036,12 @@ }, "type": "library", "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + }, "branch-alias": { - "dev-master": "7.4-dev" + "dev-master": "7.5-dev" } }, "autoload": { @@ -1102,7 +1107,7 @@ ], "support": { "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.4.5" + "source": "https://github.com/guzzle/guzzle/tree/7.5.0" }, "funding": [ { @@ -1118,20 +1123,20 @@ "type": "tidelift" } ], - "time": "2022-06-20T22:16:13+00:00" + "time": "2022-08-28T15:39:27+00:00" }, { "name": "guzzlehttp/promises", - "version": "1.5.1", + "version": "1.5.2", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "fe752aedc9fd8fcca3fe7ad05d419d32998a06da" + "reference": "b94b2807d85443f9719887892882d0329d1e2598" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/fe752aedc9fd8fcca3fe7ad05d419d32998a06da", - "reference": "fe752aedc9fd8fcca3fe7ad05d419d32998a06da", + "url": "https://api.github.com/repos/guzzle/promises/zipball/b94b2807d85443f9719887892882d0329d1e2598", + "reference": "b94b2807d85443f9719887892882d0329d1e2598", "shasum": "" }, "require": { @@ -1186,7 +1191,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/1.5.1" + "source": "https://github.com/guzzle/promises/tree/1.5.2" }, "funding": [ { @@ -1202,20 +1207,20 @@ "type": "tidelift" } ], - "time": "2021-10-22T20:56:57+00:00" + "time": "2022-08-28T14:55:35+00:00" }, { "name": "guzzlehttp/psr7", - "version": "2.4.0", + "version": "2.4.3", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "13388f00956b1503577598873fffb5ae994b5737" + "reference": "67c26b443f348a51926030c83481b85718457d3d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/13388f00956b1503577598873fffb5ae994b5737", - "reference": "13388f00956b1503577598873fffb5ae994b5737", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/67c26b443f348a51926030c83481b85718457d3d", + "reference": "67c26b443f348a51926030c83481b85718457d3d", "shasum": "" }, "require": { @@ -1229,15 +1234,19 @@ "psr/http-message-implementation": "1.0" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.4.1", + "bamarni/composer-bin-plugin": "^1.8.1", "http-interop/http-factory-tests": "^0.9", - "phpunit/phpunit": "^8.5.8 || ^9.3.10" + "phpunit/phpunit": "^8.5.29 || ^9.5.23" }, "suggest": { "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" }, "type": "library", "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + }, "branch-alias": { "dev-master": "2.4-dev" } @@ -1301,7 +1310,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.4.0" + "source": "https://github.com/guzzle/psr7/tree/2.4.3" }, "funding": [ { @@ -1317,7 +1326,7 @@ "type": "tidelift" } ], - "time": "2022-06-20T21:43:11+00:00" + "time": "2022-10-26T14:07:24+00:00" }, { "name": "myclabs/deep-copy", @@ -1380,16 +1389,16 @@ }, { "name": "netresearch/jsonmapper", - "version": "v4.0.0", + "version": "v4.1.0", "source": { "type": "git", "url": "https://github.com/cweiske/jsonmapper.git", - "reference": "8bbc021a8edb2e4a7ea2f8ad4fa9ec9dce2fcb8d" + "reference": "cfa81ea1d35294d64adb9c68aa4cb9e92400e53f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/8bbc021a8edb2e4a7ea2f8ad4fa9ec9dce2fcb8d", - "reference": "8bbc021a8edb2e4a7ea2f8ad4fa9ec9dce2fcb8d", + "url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/cfa81ea1d35294d64adb9c68aa4cb9e92400e53f", + "reference": "cfa81ea1d35294d64adb9c68aa4cb9e92400e53f", "shasum": "" }, "require": { @@ -1425,22 +1434,22 @@ "support": { "email": "cweiske@cweiske.de", "issues": "https://github.com/cweiske/jsonmapper/issues", - "source": "https://github.com/cweiske/jsonmapper/tree/v4.0.0" + "source": "https://github.com/cweiske/jsonmapper/tree/v4.1.0" }, - "time": "2020-12-01T19:48:11+00:00" + "time": "2022-12-08T20:46:14+00:00" }, { "name": "nikic/php-parser", - "version": "v4.13.2", + "version": "v4.15.2", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "210577fe3cf7badcc5814d99455df46564f3c077" + "reference": "f59bbe44bf7d96f24f3e2b4ddc21cd52c1d2adbc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/210577fe3cf7badcc5814d99455df46564f3c077", - "reference": "210577fe3cf7badcc5814d99455df46564f3c077", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/f59bbe44bf7d96f24f3e2b4ddc21cd52c1d2adbc", + "reference": "f59bbe44bf7d96f24f3e2b4ddc21cd52c1d2adbc", "shasum": "" }, "require": { @@ -1481,9 +1490,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": "openlss/lib-array2xml", @@ -1651,16 +1660,16 @@ }, { "name": "php-coveralls/php-coveralls", - "version": "v2.5.2", + "version": "v2.5.3", "source": { "type": "git", "url": "https://github.com/php-coveralls/php-coveralls.git", - "reference": "007e13afdcdba2cd0efcc5f72c3b7efb356a8bd4" + "reference": "9d8243bbf0e053333692857c98fab7cfba0d60a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-coveralls/php-coveralls/zipball/007e13afdcdba2cd0efcc5f72c3b7efb356a8bd4", - "reference": "007e13afdcdba2cd0efcc5f72c3b7efb356a8bd4", + "url": "https://api.github.com/repos/php-coveralls/php-coveralls/zipball/9d8243bbf0e053333692857c98fab7cfba0d60a9", + "reference": "9d8243bbf0e053333692857c98fab7cfba0d60a9", "shasum": "" }, "require": { @@ -1675,7 +1684,7 @@ "symfony/yaml": "^2.0.5 || ^3.0 || ^4.0 || ^5.0 || ^6.0" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.4.3 || ^6.0 || ^7.0 || ^8.0 || ^9.0", + "phpunit/phpunit": "^4.8.35 || ^5.4.3 || ^6.0 || ^7.0 || >=8.0 <8.5.29 || >=9.0 <9.5.23", "sanmai/phpunit-legacy-adapter": "^6.1 || ^8.0" }, "suggest": { @@ -1728,9 +1737,9 @@ ], "support": { "issues": "https://github.com/php-coveralls/php-coveralls/issues", - "source": "https://github.com/php-coveralls/php-coveralls/tree/v2.5.2" + "source": "https://github.com/php-coveralls/php-coveralls/tree/v2.5.3" }, - "time": "2021-12-06T17:05:08+00:00" + "time": "2022-09-12T20:47:09+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -1844,25 +1853,30 @@ }, { "name": "phpdocumentor/type-resolver", - "version": "1.6.1", + "version": "1.6.2", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "77a32518733312af16a44300404e945338981de3" + "reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/77a32518733312af16a44300404e945338981de3", - "reference": "77a32518733312af16a44300404e945338981de3", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/48f445a408c131e38cab1c235aa6d2bb7a0bb20d", + "reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0", + "php": "^7.4 || ^8.0", "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { "ext-tokenizer": "*", - "psalm/phar": "^4.8" + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-phpunit": "^1.1", + "phpunit/phpunit": "^9.5", + "rector/rector": "^0.13.9", + "vimeo/psalm": "^4.25" }, "type": "library", "extra": { @@ -1888,96 +1902,29 @@ "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.1" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.2" }, - "time": "2022-03-15T21:29:03+00:00" - }, - { - "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" + "time": "2022-10-14T12:47:21+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.15", + "version": "9.2.23", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f" + "reference": "9f1f0f9a2fbb680b26d1cf9b61b6eac43a6e4e9c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2e9da11878c4202f97915c1cb4bb1ca318a63f5f", - "reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/9f1f0f9a2fbb680b26d1cf9b61b6eac43a6e4e9c", + "reference": "9f1f0f9a2fbb680b26d1cf9b61b6eac43a6e4e9c", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.13.0", + "nikic/php-parser": "^4.14", "php": ">=7.3", "phpunit/php-file-iterator": "^3.0.3", "phpunit/php-text-template": "^2.0.2", @@ -2026,7 +1973,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": [ { @@ -2034,7 +1981,7 @@ "type": "github" } ], - "time": "2022-03-07T09:28:20+00:00" + "time": "2022-12-28T12:41:10+00:00" }, { "name": "phpunit/php-file-iterator", @@ -2279,16 +2226,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.20", + "version": "9.5.27", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "12bc8879fb65aef2138b26fc633cb1e3620cffba" + "reference": "a2bc7ffdca99f92d959b3f2270529334030bba38" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/12bc8879fb65aef2138b26fc633cb1e3620cffba", - "reference": "12bc8879fb65aef2138b26fc633cb1e3620cffba", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a2bc7ffdca99f92d959b3f2270529334030bba38", + "reference": "a2bc7ffdca99f92d959b3f2270529334030bba38", "shasum": "" }, "require": { @@ -2303,7 +2250,6 @@ "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", @@ -2311,20 +2257,16 @@ "phpunit/php-timer": "^5.0.2", "sebastian/cli-parser": "^1.0.1", "sebastian/code-unit": "^1.0.6", - "sebastian/comparator": "^4.0.5", + "sebastian/comparator": "^4.0.8", "sebastian/diff": "^4.0.3", "sebastian/environment": "^5.1.3", - "sebastian/exporter": "^4.0.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.0", + "sebastian/type": "^3.2", "sebastian/version": "^3.0.2" }, - "require-dev": { - "ext-pdo": "*", - "phpspec/prophecy-phpunit": "^2.0.1" - }, "suggest": { "ext-soap": "*", "ext-xdebug": "*" @@ -2366,7 +2308,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.20" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.27" }, "funding": [ { @@ -2376,28 +2318,37 @@ { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", + "type": "tidelift" } ], - "time": "2022-04-01T12:37:26+00:00" + "time": "2022-12-09T07:31:23+00:00" }, { "name": "psr/container", - "version": "1.1.2", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", "shasum": "" }, "require": { "php": ">=7.4.0" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, "autoload": { "psr-4": { "Psr\\Container\\": "src/" @@ -2424,9 +2375,9 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/1.1.2" + "source": "https://github.com/php-fig/container/tree/2.0.2" }, - "time": "2021-11-05T16:50:12+00:00" + "time": "2021-11-05T16:47:00+00:00" }, { "name": "psr/http-client", @@ -2590,30 +2541,30 @@ }, { "name": "psr/log", - "version": "1.1.4", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + "reference": "ef29f6d262798707a9edd554e2b82517ef3a9376" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "url": "https://api.github.com/repos/php-fig/log/zipball/ef29f6d262798707a9edd554e2b82517ef3a9376", + "reference": "ef29f6d262798707a9edd554e2b82517ef3a9376", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=8.0.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { "psr-4": { - "Psr\\Log\\": "Psr/Log/" + "Psr\\Log\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -2634,9 +2585,9 @@ "psr-3" ], "support": { - "source": "https://github.com/php-fig/log/tree/1.1.4" + "source": "https://github.com/php-fig/log/tree/2.0.0" }, - "time": "2021-05-03T11:20:27+00:00" + "time": "2021-07-14T16:41:46+00:00" }, { "name": "ralouphie/getallheaders", @@ -2851,16 +2802,16 @@ }, { "name": "sebastian/comparator", - "version": "4.0.6", + "version": "4.0.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "55f4261989e546dc112258c7a75935a81a7ce382" + "reference": "fa0f136dd2334583309d32b62544682ee972b51a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/55f4261989e546dc112258c7a75935a81a7ce382", - "reference": "55f4261989e546dc112258c7a75935a81a7ce382", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa0f136dd2334583309d32b62544682ee972b51a", + "reference": "fa0f136dd2334583309d32b62544682ee972b51a", "shasum": "" }, "require": { @@ -2913,7 +2864,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": [ { @@ -2921,7 +2872,7 @@ "type": "github" } ], - "time": "2020-10-26T15:49:45+00:00" + "time": "2022-09-14T12:41:17+00:00" }, { "name": "sebastian/complexity", @@ -3111,16 +3062,16 @@ }, { "name": "sebastian/exporter", - "version": "4.0.4", + "version": "4.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9" + "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/65e8b7db476c5dd267e65eea9cab77584d3cfff9", - "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", + "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", "shasum": "" }, "require": { @@ -3176,7 +3127,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": [ { @@ -3184,7 +3135,7 @@ "type": "github" } ], - "time": "2021-11-11T14:18:36+00:00" + "time": "2022-09-14T06:03:37+00:00" }, { "name": "sebastian/global-state", @@ -3539,16 +3490,16 @@ }, { "name": "sebastian/type", - "version": "3.0.0", + "version": "3.2.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad" + "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b233b84bc4465aff7b57cf1c4bc75c86d00d6dad", - "reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", + "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", "shasum": "" }, "require": { @@ -3560,7 +3511,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.2-dev" } }, "autoload": { @@ -3583,7 +3534,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": [ { @@ -3591,7 +3542,7 @@ "type": "github" } ], - "time": "2022-03-15T09:54:48+00:00" + "time": "2022-09-12T14:47:03+00:00" }, { "name": "sebastian/version", @@ -3648,35 +3599,33 @@ }, { "name": "symfony/config", - "version": "v5.4.9", + "version": "v6.2.0", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "8f551fe22672ac7ab2c95fe46d899f960ed4d979" + "reference": "ebf27792246165a2a0b6b69ec9c620cac8c5a2f0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/8f551fe22672ac7ab2c95fe46d899f960ed4d979", - "reference": "8f551fe22672ac7ab2c95fe46d899f960ed4d979", + "url": "https://api.github.com/repos/symfony/config/zipball/ebf27792246165a2a0b6b69ec9c620cac8c5a2f0", + "reference": "ebf27792246165a2a0b6b69ec9c620cac8c5a2f0", "shasum": "" }, "require": { - "php": ">=7.2.5", + "php": ">=8.1", "symfony/deprecation-contracts": "^2.1|^3", - "symfony/filesystem": "^4.4|^5.0|^6.0", - "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-php80": "^1.16", - "symfony/polyfill-php81": "^1.22" + "symfony/filesystem": "^5.4|^6.0", + "symfony/polyfill-ctype": "~1.8" }, "conflict": { - "symfony/finder": "<4.4" + "symfony/finder": "<5.4" }, "require-dev": { - "symfony/event-dispatcher": "^4.4|^5.0|^6.0", - "symfony/finder": "^4.4|^5.0|^6.0", - "symfony/messenger": "^4.4|^5.0|^6.0", + "symfony/event-dispatcher": "^5.4|^6.0", + "symfony/finder": "^5.4|^6.0", + "symfony/messenger": "^5.4|^6.0", "symfony/service-contracts": "^1.1|^2|^3", - "symfony/yaml": "^4.4|^5.0|^6.0" + "symfony/yaml": "^5.4|^6.0" }, "suggest": { "symfony/yaml": "To use the yaml reference dumper" @@ -3707,7 +3656,7 @@ "description": "Helps you find, load, combine, autofill and validate configuration values of any kind", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/config/tree/v5.4.9" + "source": "https://github.com/symfony/config/tree/v6.2.0" }, "funding": [ { @@ -3723,50 +3672,47 @@ "type": "tidelift" } ], - "time": "2022-05-17T10:39:36+00:00" + "time": "2022-11-02T09:08:04+00:00" }, { "name": "symfony/console", - "version": "v5.4.9", + "version": "v6.2.3", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "829d5d1bf60b2efeb0887b7436873becc71a45eb" + "reference": "0f579613e771dba2dbb8211c382342a641f5da06" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/829d5d1bf60b2efeb0887b7436873becc71a45eb", - "reference": "829d5d1bf60b2efeb0887b7436873becc71a45eb", + "url": "https://api.github.com/repos/symfony/console/zipball/0f579613e771dba2dbb8211c382342a641f5da06", + "reference": "0f579613e771dba2dbb8211c382342a641f5da06", "shasum": "" }, "require": { - "php": ">=7.2.5", + "php": ">=8.1", "symfony/deprecation-contracts": "^2.1|^3", "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php73": "^1.9", - "symfony/polyfill-php80": "^1.16", "symfony/service-contracts": "^1.1|^2|^3", - "symfony/string": "^5.1|^6.0" + "symfony/string": "^5.4|^6.0" }, "conflict": { - "psr/log": ">=3", - "symfony/dependency-injection": "<4.4", - "symfony/dotenv": "<5.1", - "symfony/event-dispatcher": "<4.4", - "symfony/lock": "<4.4", - "symfony/process": "<4.4" + "symfony/dependency-injection": "<5.4", + "symfony/dotenv": "<5.4", + "symfony/event-dispatcher": "<5.4", + "symfony/lock": "<5.4", + "symfony/process": "<5.4" }, "provide": { - "psr/log-implementation": "1.0|2.0" + "psr/log-implementation": "1.0|2.0|3.0" }, "require-dev": { - "psr/log": "^1|^2", - "symfony/config": "^4.4|^5.0|^6.0", - "symfony/dependency-injection": "^4.4|^5.0|^6.0", - "symfony/event-dispatcher": "^4.4|^5.0|^6.0", - "symfony/lock": "^4.4|^5.0|^6.0", - "symfony/process": "^4.4|^5.0|^6.0", - "symfony/var-dumper": "^4.4|^5.0|^6.0" + "psr/log": "^1|^2|^3", + "symfony/config": "^5.4|^6.0", + "symfony/dependency-injection": "^5.4|^6.0", + "symfony/event-dispatcher": "^5.4|^6.0", + "symfony/lock": "^5.4|^6.0", + "symfony/process": "^5.4|^6.0", + "symfony/var-dumper": "^5.4|^6.0" }, "suggest": { "psr/log": "For using the console logger", @@ -3806,7 +3752,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.9" + "source": "https://github.com/symfony/console/tree/v6.2.3" }, "funding": [ { @@ -3822,29 +3768,29 @@ "type": "tidelift" } ], - "time": "2022-05-18T06:17:34+00:00" + "time": "2022-12-28T14:26:22+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v2.5.1", + "version": "v3.2.0", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66" + "reference": "1ee04c65529dea5d8744774d474e7cbd2f1206d3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/1ee04c65529dea5d8744774d474e7cbd2f1206d3", + "reference": "1ee04c65529dea5d8744774d474e7cbd2f1206d3", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=8.1" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "2.5-dev" + "dev-main": "3.3-dev" }, "thanks": { "name": "symfony/contracts", @@ -3873,7 +3819,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.1" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.2.0" }, "funding": [ { @@ -3889,27 +3835,26 @@ "type": "tidelift" } ], - "time": "2022-01-02T09:53:40+00:00" + "time": "2022-11-25T10:21:52+00:00" }, { "name": "symfony/filesystem", - "version": "v5.4.9", + "version": "v6.2.0", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "36a017fa4cce1eff1b8e8129ff53513abcef05ba" + "reference": "50b2523c874605cf3d4acf7a9e2b30b6a440a016" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/36a017fa4cce1eff1b8e8129ff53513abcef05ba", - "reference": "36a017fa4cce1eff1b8e8129ff53513abcef05ba", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/50b2523c874605cf3d4acf7a9e2b30b6a440a016", + "reference": "50b2523c874605cf3d4acf7a9e2b30b6a440a016", "shasum": "" }, "require": { - "php": ">=7.2.5", + "php": ">=8.1", "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-mbstring": "~1.8", - "symfony/polyfill-php80": "^1.16" + "symfony/polyfill-mbstring": "~1.8" }, "type": "library", "autoload": { @@ -3937,7 +3882,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v5.4.9" + "source": "https://github.com/symfony/filesystem/tree/v6.2.0" }, "funding": [ { @@ -3953,20 +3898,20 @@ "type": "tidelift" } ], - "time": "2022-05-20T13:55:35+00:00" + "time": "2022-11-20T13:01:27+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.25.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "30885182c981ab175d4d034db0f6f469898070ab" + "reference": "5bbc823adecdae860bb64756d639ecfec17b050a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/30885182c981ab175d4d034db0f6f469898070ab", - "reference": "30885182c981ab175d4d034db0f6f469898070ab", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/5bbc823adecdae860bb64756d639ecfec17b050a", + "reference": "5bbc823adecdae860bb64756d639ecfec17b050a", "shasum": "" }, "require": { @@ -3981,7 +3926,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4019,7 +3964,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.25.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.0" }, "funding": [ { @@ -4035,20 +3980,20 @@ "type": "tidelift" } ], - "time": "2021-10-20T20:35:02+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.25.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "81b86b50cf841a64252b439e738e97f4a34e2783" + "reference": "511a08c03c1960e08a883f4cffcacd219b758354" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/81b86b50cf841a64252b439e738e97f4a34e2783", - "reference": "81b86b50cf841a64252b439e738e97f4a34e2783", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/511a08c03c1960e08a883f4cffcacd219b758354", + "reference": "511a08c03c1960e08a883f4cffcacd219b758354", "shasum": "" }, "require": { @@ -4060,7 +4005,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4100,7 +4045,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.25.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.27.0" }, "funding": [ { @@ -4116,20 +4061,20 @@ "type": "tidelift" } ], - "time": "2021-11-23T21:10:46+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.26.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e" + "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e", - "reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534", + "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534", "shasum": "" }, "require": { @@ -4144,7 +4089,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4183,86 +4128,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.26.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": "2022-05-24T11:49:31+00:00" - }, - { - "name": "symfony/polyfill-php73", - "version": "v1.25.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/cc5db0e22b3cb4111010e48785a97f670b350ca5", - "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "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\\Php73\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.25.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0" }, "funding": [ { @@ -4278,20 +4144,20 @@ "type": "tidelift" } ], - "time": "2021-06-05T21:20:04+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.25.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "4407588e0d3f1f52efb65fbe92babe41f37fe50c" + "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/4407588e0d3f1f52efb65fbe92babe41f37fe50c", - "reference": "4407588e0d3f1f52efb65fbe92babe41f37fe50c", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", + "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", "shasum": "" }, "require": { @@ -4300,7 +4166,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4345,86 +4211,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/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": "2022-03-04T08:16:47+00:00" - }, - { - "name": "symfony/polyfill-php81", - "version": "v1.25.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php81.git", - "reference": "5de4ba2d41b15f9bd0e19b2ab9674135813ec98f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/5de4ba2d41b15f9bd0e19b2ab9674135813ec98f", - "reference": "5de4ba2d41b15f9bd0e19b2ab9674135813ec98f", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "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\\Php81\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php81/tree/v1.25.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.27.0" }, "funding": [ { @@ -4440,26 +4227,25 @@ "type": "tidelift" } ], - "time": "2021-09-13T13:58:11+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/service-contracts", - "version": "v2.5.1", + "version": "v3.2.0", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "24d9dc654b83e91aa59f9d167b131bc3b5bea24c" + "reference": "aac98028c69df04ee77eb69b96b86ee51fbf4b75" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/24d9dc654b83e91aa59f9d167b131bc3b5bea24c", - "reference": "24d9dc654b83e91aa59f9d167b131bc3b5bea24c", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/aac98028c69df04ee77eb69b96b86ee51fbf4b75", + "reference": "aac98028c69df04ee77eb69b96b86ee51fbf4b75", "shasum": "" }, "require": { - "php": ">=7.2.5", - "psr/container": "^1.1", - "symfony/deprecation-contracts": "^2.1|^3" + "php": ">=8.1", + "psr/container": "^2.0" }, "conflict": { "ext-psr": "<1.1|>=2" @@ -4470,7 +4256,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "2.5-dev" + "dev-main": "3.3-dev" }, "thanks": { "name": "symfony/contracts", @@ -4480,7 +4266,10 @@ "autoload": { "psr-4": { "Symfony\\Contracts\\Service\\": "" - } + }, + "exclude-from-classmap": [ + "/Test/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -4507,7 +4296,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v2.5.1" + "source": "https://github.com/symfony/service-contracts/tree/v3.2.0" }, "funding": [ { @@ -4523,24 +4312,24 @@ "type": "tidelift" } ], - "time": "2022-03-13T20:07:29+00:00" + "time": "2022-11-25T10:21:52+00:00" }, { "name": "symfony/stopwatch", - "version": "v5.4.5", + "version": "v6.2.0", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "4d04b5c24f3c9a1a168a131f6cbe297155bc0d30" + "reference": "266636bb8f3fbdccc302491df7b3a1b9a8c238a7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/4d04b5c24f3c9a1a168a131f6cbe297155bc0d30", - "reference": "4d04b5c24f3c9a1a168a131f6cbe297155bc0d30", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/266636bb8f3fbdccc302491df7b3a1b9a8c238a7", + "reference": "266636bb8f3fbdccc302491df7b3a1b9a8c238a7", "shasum": "" }, "require": { - "php": ">=7.2.5", + "php": ">=8.1", "symfony/service-contracts": "^1|^2|^3" }, "type": "library", @@ -4569,7 +4358,7 @@ "description": "Provides a way to profile code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/stopwatch/tree/v5.4.5" + "source": "https://github.com/symfony/stopwatch/tree/v6.2.0" }, "funding": [ { @@ -4585,38 +4374,38 @@ "type": "tidelift" } ], - "time": "2022-02-18T16:06:09+00:00" + "time": "2022-09-28T16:00:52+00:00" }, { "name": "symfony/string", - "version": "v5.4.9", + "version": "v6.2.2", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "985e6a9703ef5ce32ba617c9c7d97873bb7b2a99" + "reference": "863219fd713fa41cbcd285a79723f94672faff4d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/985e6a9703ef5ce32ba617c9c7d97873bb7b2a99", - "reference": "985e6a9703ef5ce32ba617c9c7d97873bb7b2a99", + "url": "https://api.github.com/repos/symfony/string/zipball/863219fd713fa41cbcd285a79723f94672faff4d", + "reference": "863219fd713fa41cbcd285a79723f94672faff4d", "shasum": "" }, "require": { - "php": ">=7.2.5", + "php": ">=8.1", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-intl-grapheme": "~1.0", "symfony/polyfill-intl-normalizer": "~1.0", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php80": "~1.15" + "symfony/polyfill-mbstring": "~1.0" }, "conflict": { - "symfony/translation-contracts": ">=3.0" + "symfony/translation-contracts": "<2.0" }, "require-dev": { - "symfony/error-handler": "^4.4|^5.0|^6.0", - "symfony/http-client": "^4.4|^5.0|^6.0", - "symfony/translation-contracts": "^1.1|^2", - "symfony/var-exporter": "^4.4|^5.0|^6.0" + "symfony/error-handler": "^5.4|^6.0", + "symfony/http-client": "^5.4|^6.0", + "symfony/intl": "^6.2", + "symfony/translation-contracts": "^2.0|^3.0", + "symfony/var-exporter": "^5.4|^6.0" }, "type": "library", "autoload": { @@ -4655,7 +4444,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.4.9" + "source": "https://github.com/symfony/string/tree/v6.2.2" }, "funding": [ { @@ -4671,32 +4460,31 @@ "type": "tidelift" } ], - "time": "2022-04-19T10:40:37+00:00" + "time": "2022-12-14T16:11:27+00:00" }, { "name": "symfony/yaml", - "version": "v5.4.3", + "version": "v6.2.2", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "e80f87d2c9495966768310fc531b487ce64237a2" + "reference": "6ed8243aa5f2cb5a57009f826b5e7fb3c4200cf3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/e80f87d2c9495966768310fc531b487ce64237a2", - "reference": "e80f87d2c9495966768310fc531b487ce64237a2", + "url": "https://api.github.com/repos/symfony/yaml/zipball/6ed8243aa5f2cb5a57009f826b5e7fb3c4200cf3", + "reference": "6ed8243aa5f2cb5a57009f826b5e7fb3c4200cf3", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", + "php": ">=8.1", "symfony/polyfill-ctype": "^1.8" }, "conflict": { - "symfony/console": "<5.3" + "symfony/console": "<5.4" }, "require-dev": { - "symfony/console": "^5.3|^6.0" + "symfony/console": "^5.4|^6.0" }, "suggest": { "symfony/console": "For validating YAML files using the lint command" @@ -4730,7 +4518,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v5.4.3" + "source": "https://github.com/symfony/yaml/tree/v6.2.2" }, "funding": [ { @@ -4746,7 +4534,7 @@ "type": "tidelift" } ], - "time": "2022-01-26T16:32:32+00:00" + "time": "2022-12-14T16:11:27+00:00" }, { "name": "theseer/tokenizer", @@ -4800,16 +4588,16 @@ }, { "name": "vimeo/psalm", - "version": "4.23.0", + "version": "4.30.0", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "f1fe6ff483bf325c803df9f510d09a03fd796f88" + "reference": "d0bc6e25d89f649e4f36a534f330f8bb4643dd69" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/f1fe6ff483bf325c803df9f510d09a03fd796f88", - "reference": "f1fe6ff483bf325c803df9f510d09a03fd796f88", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/d0bc6e25d89f649e4f36a534f330f8bb4643dd69", + "reference": "d0bc6e25d89f649e4f36a534f330f8bb4643dd69", "shasum": "" }, "require": { @@ -4848,6 +4636,7 @@ "phpdocumentor/reflection-docblock": "^5", "phpmyadmin/sql-parser": "5.1.0||dev-master", "phpspec/prophecy": ">=1.9.0", + "phpstan/phpdoc-parser": "1.2.* || 1.6.4", "phpunit/phpunit": "^9.0", "psalm/plugin-phpunit": "^0.16", "slevomat/coding-standard": "^7.0", @@ -4901,27 +4690,27 @@ ], "support": { "issues": "https://github.com/vimeo/psalm/issues", - "source": "https://github.com/vimeo/psalm/tree/4.23.0" + "source": "https://github.com/vimeo/psalm/tree/4.30.0" }, - "time": "2022-04-28T17:35:49+00:00" + "time": "2022-11-06T20:37:08+00:00" }, { "name": "webmozart/assert", - "version": "1.10.0", + "version": "1.11.0", "source": { "type": "git", "url": "https://github.com/webmozarts/assert.git", - "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25" + "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozarts/assert/zipball/6964c76c7804814a842473e0c8fd15bab0f18e25", - "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/11cb2199493b2f8a3b53e7f19068fc6aac760991", + "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0", - "symfony/polyfill-ctype": "^1.8" + "ext-ctype": "*", + "php": "^7.2 || ^8.0" }, "conflict": { "phpstan/phpstan": "<0.12.20", @@ -4959,9 +4748,9 @@ ], "support": { "issues": "https://github.com/webmozarts/assert/issues", - "source": "https://github.com/webmozarts/assert/tree/1.10.0" + "source": "https://github.com/webmozarts/assert/tree/1.11.0" }, - "time": "2021-03-09T10:59:23+00:00" + "time": "2022-06-03T18:03:27+00:00" }, { "name": "webmozart/path-util", @@ -5021,7 +4810,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7.2" + "php": ">=8.1" }, "platform-dev": [], "plugin-api-version": "2.3.0" diff --git a/src/EmailLexer.php b/src/EmailLexer.php index 0bfe86f..5c3bf3a 100644 --- a/src/EmailLexer.php +++ b/src/EmailLexer.php @@ -3,11 +3,13 @@ namespace Egulias\EmailValidator; use Doctrine\Common\Lexer\AbstractLexer; +use Doctrine\Common\Lexer\Token; +/** @extends AbstractLexer */ class EmailLexer extends AbstractLexer { //ASCII values - public const S_EMPTY = null; + public const S_EMPTY = -1; public const C_NUL = 0; public const S_HTAB = 9; public const S_LF = 10; @@ -46,7 +48,7 @@ class EmailLexer extends AbstractLexer public const S_CLOSECURLYBRACES = 125; public const S_TILDE = 126; public const C_DEL = 127; - public const INVERT_QUESTIONMARK= 168; + public const INVERT_QUESTIONMARK = 168; public const INVERT_EXCLAMATION = 173; public const GENERIC = 300; public const S_IPV6TAG = 301; @@ -131,36 +133,28 @@ class EmailLexer extends AbstractLexer protected $hasInvalidTokens = false; /** - * @var array - * - * @psalm-var array{value:string, type:null|int, position:int}|array + * @var Token */ - protected $previous = []; + protected Token $previous; /** * The last matched/seen token. * - * @var array - * - * @psalm-suppress NonInvariantDocblockPropertyType - * @psalm-var array{value:string, type:null|int, position:int} - * @psalm-suppress NonInvariantDocblockPropertyType + * @var Token */ - public $token; + public Token $current; /** * The next token in the input. * - * @var array{position: int, type: int|null|string, value: int|string}|null + * @var Token|null */ - public $lookahead; + public Token|null $lookahead; - /** @psalm-var array{value:'', type:null, position:0} */ - private static $nullToken = [ - 'value' => '', - 'type' => null, - 'position' => 0, - ]; + /** + * @var Token + */ + private Token $nullToken; /** @var string */ private $accumulator = ''; @@ -170,15 +164,19 @@ class EmailLexer extends AbstractLexer public function __construct() { - $this->previous = $this->token = self::$nullToken; + /** @var Token $nullToken */ + $nullToken = new Token('', self::S_EMPTY, 0); + $this->nullToken = $nullToken; + + $this->current = $this->previous = $this->nullToken; $this->lookahead = null; } - public function reset() : void + public function reset(): void { $this->hasInvalidTokens = false; parent::reset(); - $this->previous = $this->token = self::$nullToken; + $this->current = $this->previous = $this->nullToken; } /** @@ -188,7 +186,7 @@ public function reset() : void * * @psalm-suppress InvalidScalarArgument */ - public function find($type) : bool + public function find($type): bool { $search = clone $this; $search->skipUntil($type); @@ -204,22 +202,23 @@ public function find($type) : bool * * @return boolean */ - public function moveNext() : bool + public function moveNext(): bool { - if ($this->hasToRecord && $this->previous === self::$nullToken) { - $this->accumulator .= $this->token['value']; + if ($this->hasToRecord && $this->previous === $this->nullToken) { + $this->accumulator .= $this->current->value; } - $this->previous = $this->token; - - if($this->lookahead === null) { - $this->lookahead = self::$nullToken; + $this->previous = $this->current; + + if ($this->lookahead === null) { + $this->lookahead = $this->nullToken; } $hasNext = parent::moveNext(); + $this->current = $this->token ?? $this->nullToken; if ($this->hasToRecord) { - $this->accumulator .= $this->token['value']; + $this->accumulator .= $this->current->value; } return $hasNext; @@ -232,7 +231,7 @@ public function moveNext() : bool * @throws \InvalidArgumentException * @return integer */ - protected function getType(&$value) + protected function getType(&$value): int { $encoded = $value; @@ -253,31 +252,30 @@ protected function getType(&$value) return self::INVALID; } - - return self::GENERIC; + return self::GENERIC; } - protected function isValid(string $value) : bool + protected function isValid(string $value): bool { return isset($this->charValue[$value]); } - protected function isNullType(string $value) : bool + protected function isNullType(string $value): bool { return $value === "\0"; } - protected function isInvalidChar(string $value) : bool + protected function isInvalidChar(string $value): bool { return !preg_match(self::INVALID_CHARS_REGEX, $value); } - protected function isUTF8Invalid(string $value) : bool + protected function isUTF8Invalid(string $value): bool { return preg_match(self::VALID_UTF8_REGEX, $value) !== false; } - public function hasInvalidTokens() : bool + public function hasInvalidTokens(): bool { return $this->hasInvalidTokens; } @@ -285,9 +283,9 @@ public function hasInvalidTokens() : bool /** * getPrevious * - * @return array + * @return Token */ - public function getPrevious() : array + public function getPrevious(): Token { return $this->previous; } @@ -297,7 +295,7 @@ public function getPrevious() : array * * @return string[] */ - protected function getCatchablePatterns() : array + protected function getCatchablePatterns(): array { return self::CATCHABLE_PATTERNS; } @@ -307,32 +305,32 @@ protected function getCatchablePatterns() : array * * @return string[] */ - protected function getNonCatchablePatterns() : array + protected function getNonCatchablePatterns(): array { return self::NON_CATCHABLE_PATTERNS; } - protected function getModifiers() : string + protected function getModifiers(): string { return self::MODIFIERS; } - public function getAccumulatedValues() : string + public function getAccumulatedValues(): string { return $this->accumulator; } - public function startRecording() : void + public function startRecording(): void { $this->hasToRecord = true; } - public function stopRecording() : void + public function stopRecording(): void { $this->hasToRecord = false; } - public function clearRecorded() : void + public function clearRecorded(): void { $this->accumulator = ''; } diff --git a/src/EmailParser.php b/src/EmailParser.php index 352eae4..788d016 100644 --- a/src/EmailParser.php +++ b/src/EmailParser.php @@ -24,7 +24,7 @@ class EmailParser extends Parser */ protected $localPart = ''; - public function parse(string $str) : Result + public function parse(string $str): Result { $result = parent::parse($str); @@ -32,11 +32,11 @@ public function parse(string $str) : Result return $result; } - + protected function preLeftParsing(): Result { if (!$this->hasAtToken()) { - return new InvalidEmail(new NoLocalPart(), $this->lexer->token["value"]); + return new InvalidEmail(new NoLocalPart(), $this->lexer->current->value); } return new ValidEmail(); } @@ -51,7 +51,7 @@ protected function parseRightFromAt(): Result return $this->processDomainPart(); } - private function processLocalPart() : Result + private function processLocalPart(): Result { $localPartParser = new LocalPart($this->lexer); $localPartResult = $localPartParser->parse(); @@ -61,27 +61,27 @@ private function processLocalPart() : Result return $localPartResult; } - private function processDomainPart() : Result + private function processDomainPart(): Result { $domainPartParser = new DomainPart($this->lexer); $domainPartResult = $domainPartParser->parse(); $this->domainPart = $domainPartParser->domainPart(); $this->warnings = array_merge($domainPartParser->getWarnings(), $this->warnings); - + return $domainPartResult; } - public function getDomainPart() : string + public function getDomainPart(): string { return $this->domainPart; } - public function getLocalPart() : string + public function getLocalPart(): string { return $this->localPart; } - private function addLongEmailWarning(string $localPart, string $parsedDomainPart) : void + private function addLongEmailWarning(string $localPart, string $parsedDomainPart): void { if (strlen($localPart . '@' . $parsedDomainPart) > self::EMAIL_MAX_LENGTH) { $this->warnings[EmailTooLong::CODE] = new EmailTooLong(); diff --git a/src/MessageIDParser.php b/src/MessageIDParser.php index b0b6720..9df27db 100644 --- a/src/MessageIDParser.php +++ b/src/MessageIDParser.php @@ -25,7 +25,7 @@ class MessageIDParser extends Parser */ protected $idRight = ''; - public function parse(string $str) : Result + public function parse(string $str): Result { $result = parent::parse($str); @@ -33,11 +33,11 @@ public function parse(string $str) : Result return $result; } - + protected function preLeftParsing(): Result { if (!$this->hasAtToken()) { - return new InvalidEmail(new NoLocalPart(), $this->lexer->token["value"]); + return new InvalidEmail(new NoLocalPart(), $this->lexer->current->value); } return new ValidEmail(); } @@ -52,7 +52,7 @@ protected function parseRightFromAt(): Result return $this->processIDRight(); } - private function processIDLeft() : Result + private function processIDLeft(): Result { $localPartParser = new IDLeftPart($this->lexer); $localPartResult = $localPartParser->parse(); @@ -62,27 +62,27 @@ private function processIDLeft() : Result return $localPartResult; } - private function processIDRight() : Result + private function processIDRight(): Result { $domainPartParser = new IDRightPart($this->lexer); $domainPartResult = $domainPartParser->parse(); $this->idRight = $domainPartParser->domainPart(); $this->warnings = array_merge($domainPartParser->getWarnings(), $this->warnings); - + return $domainPartResult; } - public function getLeftPart() : string + public function getLeftPart(): string { return $this->idLeft; } - public function getRightPart() : string + public function getRightPart(): string { return $this->idRight; } - private function addLongEmailWarning(string $localPart, string $parsedDomainPart) : void + private function addLongEmailWarning(string $localPart, string $parsedDomainPart): void { if (strlen($localPart . '@' . $parsedDomainPart) > self::EMAILID_MAX_LENGTH) { $this->warnings[EmailTooLong::CODE] = new EmailTooLong(); diff --git a/src/Parser.php b/src/Parser.php index b1905f9..d577e3e 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -22,22 +22,22 @@ abstract class Parser /** * id-left "@" id-right */ - abstract protected function parseRightFromAt() : Result; - abstract protected function parseLeftFromAt() : Result; - abstract protected function preLeftParsing() : Result; + abstract protected function parseRightFromAt(): Result; + abstract protected function parseLeftFromAt(): Result; + abstract protected function preLeftParsing(): Result; public function __construct(EmailLexer $lexer) { - $this->lexer = $lexer; + $this->lexer = $lexer; } - public function parse(string $str) : Result + public function parse(string $str): Result { $this->lexer->setInput($str); if ($this->lexer->hasInvalidTokens()) { - return new InvalidEmail(new ExpectingATEXT("Invalid tokens found"), $this->lexer->token["value"]); + return new InvalidEmail(new ExpectingATEXT("Invalid tokens found"), $this->lexer->current->value); } $preParsingResult = $this->preLeftParsing(); @@ -51,7 +51,7 @@ public function parse(string $str) : Result return $localPartResult; } - $domainPartResult = $this->parseRightFromAt(); + $domainPartResult = $this->parseRightFromAt(); if ($domainPartResult->isInvalid()) { return $domainPartResult; @@ -63,16 +63,16 @@ public function parse(string $str) : Result /** * @return Warning\Warning[] */ - public function getWarnings() : array + public function getWarnings(): array { return $this->warnings; } - protected function hasAtToken() : bool + protected function hasAtToken(): bool { $this->lexer->moveNext(); $this->lexer->moveNext(); - return $this->lexer->token['type'] !== EmailLexer::S_AT; + return !$this->lexer->current->isA(EmailLexer::S_AT); } } diff --git a/src/Parser/Comment.php b/src/Parser/Comment.php index d6f3032..9e4ab21 100644 --- a/src/Parser/Comment.php +++ b/src/Parser/Comment.php @@ -29,39 +29,39 @@ public function __construct(EmailLexer $lexer, CommentStrategy $commentStrategy) $this->commentStrategy = $commentStrategy; } - public function parse() : Result + public function parse(): Result { - if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) { + if ($this->lexer->current->isA(EmailLexer::S_OPENPARENTHESIS)) { $this->openedParenthesis++; - if($this->noClosingParenthesis()) { - return new InvalidEmail(new UnclosedComment(), $this->lexer->token['value']); + if ($this->noClosingParenthesis()) { + return new InvalidEmail(new UnclosedComment(), $this->lexer->current->value); } } - if ($this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS) { - return new InvalidEmail(new UnOpenedComment(), $this->lexer->token['value']); + if ($this->lexer->current->isA(EmailLexer::S_CLOSEPARENTHESIS)) { + return new InvalidEmail(new UnOpenedComment(), $this->lexer->current->value); } $this->warnings[WarningComment::CODE] = new WarningComment(); $moreTokens = true; - while ($this->commentStrategy->exitCondition($this->lexer, $this->openedParenthesis) && $moreTokens){ + while ($this->commentStrategy->exitCondition($this->lexer, $this->openedParenthesis) && $moreTokens) { if ($this->lexer->isNextToken(EmailLexer::S_OPENPARENTHESIS)) { $this->openedParenthesis++; } $this->warnEscaping(); - if($this->lexer->isNextToken(EmailLexer::S_CLOSEPARENTHESIS)) { + if ($this->lexer->isNextToken(EmailLexer::S_CLOSEPARENTHESIS)) { $this->openedParenthesis--; } $moreTokens = $this->lexer->moveNext(); } - if($this->openedParenthesis >= 1) { - return new InvalidEmail(new UnclosedComment(), $this->lexer->token['value']); + if ($this->openedParenthesis >= 1) { + return new InvalidEmail(new UnclosedComment(), $this->lexer->current->value); } if ($this->openedParenthesis < 0) { - return new InvalidEmail(new UnOpenedComment(), $this->lexer->token['value']); + return new InvalidEmail(new UnOpenedComment(), $this->lexer->current->value); } $finalValidations = $this->commentStrategy->endOfLoopValidations($this->lexer); @@ -75,10 +75,10 @@ public function parse() : Result /** * @return bool */ - private function warnEscaping() : bool + private function warnEscaping(): bool { //Backslash found - if ($this->lexer->token['type'] !== EmailLexer::S_BACKSLASH) { + if (!$this->lexer->current->isA(EmailLexer::S_BACKSLASH)) { return false; } @@ -87,12 +87,11 @@ private function warnEscaping() : bool } $this->warnings[QuotedPart::CODE] = - new QuotedPart($this->lexer->getPrevious()['type'], $this->lexer->token['type']); + new QuotedPart($this->lexer->getPrevious()->type, $this->lexer->current->type); return true; - } - private function noClosingParenthesis() : bool + private function noClosingParenthesis(): bool { try { $this->lexer->find(EmailLexer::S_CLOSEPARENTHESIS); diff --git a/src/Parser/CommentStrategy/CommentStrategy.php b/src/Parser/CommentStrategy/CommentStrategy.php index 410032f..8834db0 100644 --- a/src/Parser/CommentStrategy/CommentStrategy.php +++ b/src/Parser/CommentStrategy/CommentStrategy.php @@ -4,15 +4,19 @@ use Egulias\EmailValidator\EmailLexer; use Egulias\EmailValidator\Result\Result; +use Egulias\EmailValidator\Warning\Warning; interface CommentStrategy { /** * Return "true" to continue, "false" to exit */ - public function exitCondition(EmailLexer $lexer, int $openedParenthesis) : bool; + public function exitCondition(EmailLexer $lexer, int $openedParenthesis): bool; - public function endOfLoopValidations(EmailLexer $lexer) : Result; + public function endOfLoopValidations(EmailLexer $lexer): Result; - public function getWarnings() : array; + /** + * @return Warning[] + */ + public function getWarnings(): array; } diff --git a/src/Parser/CommentStrategy/DomainComment.php b/src/Parser/CommentStrategy/DomainComment.php index cbbe3f2..a197c27 100644 --- a/src/Parser/CommentStrategy/DomainComment.php +++ b/src/Parser/CommentStrategy/DomainComment.php @@ -10,20 +10,20 @@ class DomainComment implements CommentStrategy { - public function exitCondition(EmailLexer $lexer, int $openedParenthesis) : bool + public function exitCondition(EmailLexer $lexer, int $openedParenthesis): bool { - if (($openedParenthesis === 0 && $lexer->isNextToken(EmailLexer::S_DOT))){ // || !$internalLexer->moveNext()) { + if (($openedParenthesis === 0 && $lexer->isNextToken(EmailLexer::S_DOT))) { // || !$internalLexer->moveNext()) { return false; } return true; } - public function endOfLoopValidations(EmailLexer $lexer) : Result + public function endOfLoopValidations(EmailLexer $lexer): Result { //test for end of string if (!$lexer->isNextToken(EmailLexer::S_DOT)) { - return new InvalidEmail(new ExpectingATEXT('DOT not found near CLOSEPARENTHESIS'), $lexer->token['value']); + return new InvalidEmail(new ExpectingATEXT('DOT not found near CLOSEPARENTHESIS'), $lexer->current->value); } //add warning //Address is valid within the message but cannot be used unmodified for the envelope diff --git a/src/Parser/CommentStrategy/LocalComment.php b/src/Parser/CommentStrategy/LocalComment.php index e72319a..5c18b44 100644 --- a/src/Parser/CommentStrategy/LocalComment.php +++ b/src/Parser/CommentStrategy/LocalComment.php @@ -16,15 +16,15 @@ class LocalComment implements CommentStrategy */ private $warnings = []; - public function exitCondition(EmailLexer $lexer, int $openedParenthesis) : bool + public function exitCondition(EmailLexer $lexer, int $openedParenthesis): bool { return !$lexer->isNextToken(EmailLexer::S_AT); } - public function endOfLoopValidations(EmailLexer $lexer) : Result + public function endOfLoopValidations(EmailLexer $lexer): Result { if (!$lexer->isNextToken(EmailLexer::S_AT)) { - return new InvalidEmail(new ExpectingATEXT('ATEX is not expected after closing comments'), $lexer->token['value']); + return new InvalidEmail(new ExpectingATEXT('ATEX is not expected after closing comments'), $lexer->current->value); } $this->warnings[CFWSNearAt::CODE] = new CFWSNearAt(); return new ValidEmail(); diff --git a/src/Parser/DomainLiteral.php b/src/Parser/DomainLiteral.php index e6d66d0..e99498d 100644 --- a/src/Parser/DomainLiteral.php +++ b/src/Parser/DomainLiteral.php @@ -1,4 +1,5 @@ addTagWarnings(); @@ -39,14 +40,14 @@ public function parse() : Result $addressLiteral = ''; do { - if ($this->lexer->token['type'] === EmailLexer::C_NUL) { - return new InvalidEmail(new ExpectingDTEXT(), $this->lexer->token['value']); + if ($this->lexer->current->isA(EmailLexer::C_NUL)) { + return new InvalidEmail(new ExpectingDTEXT(), $this->lexer->current->value); } $this->addObsoleteWarnings(); if ($this->lexer->isNextTokenAny(array(EmailLexer::S_OPENBRACKET, EmailLexer::S_OPENBRACKET))) { - return new InvalidEmail(new ExpectingDTEXT(), $this->lexer->token['value']); + return new InvalidEmail(new ExpectingDTEXT(), $this->lexer->current->value); } if ($this->lexer->isNextTokenAny( @@ -57,22 +58,21 @@ public function parse() : Result } if ($this->lexer->isNextToken(EmailLexer::S_CR)) { - return new InvalidEmail(new CRNoLF(), $this->lexer->token['value']); + return new InvalidEmail(new CRNoLF(), $this->lexer->current->value); } - if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH) { - return new InvalidEmail(new UnusualElements($this->lexer->token['value']), $this->lexer->token['value']); + if ($this->lexer->current->isA(EmailLexer::S_BACKSLASH)) { + return new InvalidEmail(new UnusualElements($this->lexer->current->value), $this->lexer->current->value); } - if ($this->lexer->token['type'] === EmailLexer::S_IPV6TAG) { + if ($this->lexer->current->isA(EmailLexer::S_IPV6TAG)) { $IPv6TAG = true; } - if ($this->lexer->token['type'] === EmailLexer::S_CLOSEBRACKET) { + if ($this->lexer->current->isA(EmailLexer::S_CLOSEBRACKET)) { break; } - $addressLiteral .= $this->lexer->token['value']; - + $addressLiteral .= $this->lexer->current->value; } while ($this->lexer->moveNext()); @@ -102,10 +102,10 @@ public function parse() : Result * @param string $addressLiteral * @param int $maxGroups */ - public function checkIPV6Tag($addressLiteral, $maxGroups = 8) : void + public function checkIPV6Tag($addressLiteral, $maxGroups = 8): void { $prev = $this->lexer->getPrevious(); - if ($prev['type'] === EmailLexer::S_COLON) { + if ($prev->isA(EmailLexer::S_COLON)) { $this->warnings[IPV6ColonEnd::CODE] = new IPV6ColonEnd(); } @@ -144,8 +144,8 @@ public function checkIPV6Tag($addressLiteral, $maxGroups = 8) : void $this->warnings[IPV6Deprecated::CODE] = new IPV6Deprecated(); } } - - public function convertIPv4ToIPv6(string $addressLiteralIPv4) : string + + public function convertIPv4ToIPv6(string $addressLiteralIPv4): string { $matchesIP = []; $IPv4Match = preg_match(self::IPV4_REGEX, $addressLiteralIPv4, $matchesIP); @@ -168,7 +168,7 @@ public function convertIPv4ToIPv6(string $addressLiteralIPv4) : string * * @return bool */ - protected function checkIPV4Tag($addressLiteral) : bool + protected function checkIPV4Tag($addressLiteral): bool { $matchesIP = []; $IPv4Match = preg_match(self::IPV4_REGEX, $addressLiteral, $matchesIP); @@ -187,14 +187,14 @@ protected function checkIPV4Tag($addressLiteral) : bool return true; } - private function addObsoleteWarnings() : void + private function addObsoleteWarnings(): void { - if(in_array($this->lexer->token['type'], self::OBSOLETE_WARNINGS)) { + if (in_array($this->lexer->current->type, self::OBSOLETE_WARNINGS)) { $this->warnings[ObsoleteDTEXT::CODE] = new ObsoleteDTEXT(); } } - private function addTagWarnings() : void + private function addTagWarnings(): void { if ($this->lexer->isNextToken(EmailLexer::S_COLON)) { $this->warnings[IPV6ColonStart::CODE] = new IPV6ColonStart(); @@ -207,5 +207,4 @@ private function addTagWarnings() : void } } } - } diff --git a/src/Parser/DomainPart.php b/src/Parser/DomainPart.php index a57f4ba..9947c42 100644 --- a/src/Parser/DomainPart.php +++ b/src/Parser/DomainPart.php @@ -2,6 +2,7 @@ namespace Egulias\EmailValidator\Parser; +use Doctrine\Common\Lexer\Token; use Egulias\EmailValidator\EmailLexer; use Egulias\EmailValidator\Warning\TLD; use Egulias\EmailValidator\Result\Result; @@ -37,7 +38,7 @@ class DomainPart extends PartParser */ protected $label = ''; - public function parse() : Result + public function parse(): Result { $this->lexer->clearRecorded(); $this->lexer->startRecording(); @@ -49,8 +50,8 @@ public function parse() : Result return $domainChecks; } - if ($this->lexer->token['type'] === EmailLexer::S_AT) { - return new InvalidEmail(new ConsecutiveAt(), $this->lexer->token['value']); + if ($this->lexer->current->isA(EmailLexer::S_AT)) { + return new InvalidEmail(new ConsecutiveAt(), $this->lexer->current->value); } $result = $this->doParseDomainPart(); @@ -68,67 +69,66 @@ public function parse() : Result $length = strlen($this->domainPart); if ($length > self::DOMAIN_MAX_LENGTH) { - return new InvalidEmail(new DomainTooLong(), $this->lexer->token['value']); + return new InvalidEmail(new DomainTooLong(), $this->lexer->current->value); } return new ValidEmail(); } - private function checkEndOfDomain() : Result + private function checkEndOfDomain(): Result { $prev = $this->lexer->getPrevious(); - if ($prev['type'] === EmailLexer::S_DOT) { - return new InvalidEmail(new DotAtEnd(), $this->lexer->token['value']); + if ($prev->isA(EmailLexer::S_DOT)) { + return new InvalidEmail(new DotAtEnd(), $this->lexer->current->value); } - if ($prev['type'] === EmailLexer::S_HYPHEN) { - return new InvalidEmail(new DomainHyphened('Hypen found at the end of the domain'), $prev['value']); + if ($prev->isA(EmailLexer::S_HYPHEN)) { + return new InvalidEmail(new DomainHyphened('Hypen found at the end of the domain'), $prev->value); } - if ($this->lexer->token['type'] === EmailLexer::S_SP) { - return new InvalidEmail(new CRLFAtTheEnd(), $prev['value']); + if ($this->lexer->current->isA(EmailLexer::S_SP)) { + return new InvalidEmail(new CRLFAtTheEnd(), $prev->value); } return new ValidEmail(); - } - private function performDomainStartChecks() : Result + private function performDomainStartChecks(): Result { $invalidTokens = $this->checkInvalidTokensAfterAT(); if ($invalidTokens->isInvalid()) { return $invalidTokens; } - + $missingDomain = $this->checkEmptyDomain(); if ($missingDomain->isInvalid()) { return $missingDomain; } - if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) { + if ($this->lexer->current->isA(EmailLexer::S_OPENPARENTHESIS)) { $this->warnings[DeprecatedComment::CODE] = new DeprecatedComment(); } return new ValidEmail(); } - private function checkEmptyDomain() : Result + private function checkEmptyDomain(): Result { - $thereIsNoDomain = $this->lexer->token['type'] === EmailLexer::S_EMPTY || - ($this->lexer->token['type'] === EmailLexer::S_SP && - !$this->lexer->isNextToken(EmailLexer::GENERIC)); + $thereIsNoDomain = $this->lexer->current->isA(EmailLexer::S_EMPTY) || + ($this->lexer->current->isA(EmailLexer::S_SP) && + !$this->lexer->isNextToken(EmailLexer::GENERIC)); if ($thereIsNoDomain) { - return new InvalidEmail(new NoDomainPart(), $this->lexer->token['value']); + return new InvalidEmail(new NoDomainPart(), $this->lexer->current->value); } return new ValidEmail(); } - private function checkInvalidTokensAfterAT() : Result + private function checkInvalidTokensAfterAT(): Result { - if ($this->lexer->token['type'] === EmailLexer::S_DOT) { - return new InvalidEmail(new DotAtStart(), $this->lexer->token['value']); + if ($this->lexer->current->isA(EmailLexer::S_DOT)) { + return new InvalidEmail(new DotAtStart(), $this->lexer->current->value); } - if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN) { - return new InvalidEmail(new DomainHyphened('After AT'), $this->lexer->token['value']); + if ($this->lexer->current->isA(EmailLexer::S_HYPHEN)) { + return new InvalidEmail(new DomainHyphened('After AT'), $this->lexer->current->value); } return new ValidEmail(); } @@ -142,7 +142,7 @@ protected function parseComments(): Result return $result; } - protected function doParseDomainPart() : Result + protected function doParseDomainPart(): Result { $tldMissing = true; $hasComments = false; @@ -150,18 +150,20 @@ protected function doParseDomainPart() : Result do { $prev = $this->lexer->getPrevious(); - $notAllowedChars = $this->checkNotAllowedChars($this->lexer->token); + $notAllowedChars = $this->checkNotAllowedChars($this->lexer->current); if ($notAllowedChars->isInvalid()) { return $notAllowedChars; } - if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS || - $this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS ) { + if ( + $this->lexer->current->isA(EmailLexer::S_OPENPARENTHESIS) || + $this->lexer->current->isA(EmailLexer::S_CLOSEPARENTHESIS) + ) { $hasComments = true; $commentsResult = $this->parseComments(); //Invalid comment parsing - if($commentsResult->isInvalid()) { + if ($commentsResult->isInvalid()) { return $commentsResult; } } @@ -171,26 +173,26 @@ protected function doParseDomainPart() : Result return $dotsResult; } - if ($this->lexer->token['type'] === EmailLexer::S_OPENBRACKET) { + if ($this->lexer->current->isA(EmailLexer::S_OPENBRACKET)) { $literalResult = $this->parseDomainLiteral(); $this->addTLDWarnings($tldMissing); return $literalResult; } - $labelCheck = $this->checkLabelLength(); - if ($labelCheck->isInvalid()) { - return $labelCheck; - } + $labelCheck = $this->checkLabelLength(); + if ($labelCheck->isInvalid()) { + return $labelCheck; + } $FwsResult = $this->parseFWS(); - if($FwsResult->isInvalid()) { + if ($FwsResult->isInvalid()) { return $FwsResult; } - $domain .= $this->lexer->token['value']; + $domain .= $this->lexer->current->value; - if ($this->lexer->token['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::GENERIC)) { + if ($this->lexer->current->isA(EmailLexer::S_DOT) && $this->lexer->isNextToken(EmailLexer::GENERIC)) { $tldMissing = false; } @@ -199,8 +201,7 @@ protected function doParseDomainPart() : Result return $exceptionsResult; } $this->lexer->moveNext(); - - } while (null !== $this->lexer->token['type']); + } while (!$this->lexer->current->isA(EmailLexer::S_EMPTY)); $labelCheck = $this->checkLabelLength(true); if ($labelCheck->isInvalid()) { @@ -212,11 +213,16 @@ protected function doParseDomainPart() : Result return new ValidEmail(); } - private function checkNotAllowedChars(array $token) : Result + /** + * @param Token $token + * + * @return Result + */ + private function checkNotAllowedChars(Token $token): Result { - $notAllowed = [EmailLexer::S_BACKSLASH => true, EmailLexer::S_SLASH=> true]; - if (isset($notAllowed[$token['type']])) { - return new InvalidEmail(new CharNotAllowed(), $token['value']); + $notAllowed = [EmailLexer::S_BACKSLASH => true, EmailLexer::S_SLASH => true]; + if (isset($notAllowed[$token->type])) { + return new InvalidEmail(new CharNotAllowed(), $token->value); } return new ValidEmail(); } @@ -224,12 +230,12 @@ private function checkNotAllowedChars(array $token) : Result /** * @return Result */ - protected function parseDomainLiteral() : Result + protected function parseDomainLiteral(): Result { try { $this->lexer->find(EmailLexer::S_CLOSEBRACKET); } catch (\RuntimeException $e) { - return new InvalidEmail(new ExpectingDomainLiteralClose(), $this->lexer->token['value']); + return new InvalidEmail(new ExpectingDomainLiteralClose(), $this->lexer->current->value); } $domainLiteralParser = new DomainLiteralParser($this->lexer); @@ -238,25 +244,33 @@ protected function parseDomainLiteral() : Result return $result; } - protected function checkDomainPartExceptions(array $prev, bool $hasComments) : Result + /** + * @param Token $prev + * @param bool $hasComments + * + * @return Result + */ + protected function checkDomainPartExceptions(Token $prev, bool $hasComments): Result { - if ($this->lexer->token['type'] === EmailLexer::S_OPENBRACKET && $prev['type'] !== EmailLexer::S_AT) { - return new InvalidEmail(new ExpectingATEXT('OPENBRACKET not after AT'), $this->lexer->token['value']); + if ($this->lexer->current->isA(EmailLexer::S_OPENBRACKET) && $prev->type !== EmailLexer::S_AT) { + return new InvalidEmail(new ExpectingATEXT('OPENBRACKET not after AT'), $this->lexer->current->value); } - if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN && $this->lexer->isNextToken(EmailLexer::S_DOT)) { - return new InvalidEmail(new DomainHyphened('Hypen found near DOT'), $this->lexer->token['value']); + if ($this->lexer->current->isA(EmailLexer::S_HYPHEN) && $this->lexer->isNextToken(EmailLexer::S_DOT)) { + return new InvalidEmail(new DomainHyphened('Hypen found near DOT'), $this->lexer->current->value); } - if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH - && $this->lexer->isNextToken(EmailLexer::GENERIC)) { - return new InvalidEmail(new ExpectingATEXT('Escaping following "ATOM"'), $this->lexer->token['value']); + if ( + $this->lexer->current->isA(EmailLexer::S_BACKSLASH) + && $this->lexer->isNextToken(EmailLexer::GENERIC) + ) { + return new InvalidEmail(new ExpectingATEXT('Escaping following "ATOM"'), $this->lexer->current->value); } return $this->validateTokens($hasComments); } - protected function validateTokens(bool $hasComments) : Result + protected function validateTokens(bool $hasComments): Result { $validDomainTokens = array( EmailLexer::GENERIC => true, @@ -269,27 +283,27 @@ protected function validateTokens(bool $hasComments) : Result $validDomainTokens[EmailLexer::S_CLOSEPARENTHESIS] = true; } - if (!isset($validDomainTokens[$this->lexer->token['type']])) { - return new InvalidEmail(new ExpectingATEXT('Invalid token in domain: ' . $this->lexer->token['value']), $this->lexer->token['value']); + if (!isset($validDomainTokens[$this->lexer->current->type])) { + return new InvalidEmail(new ExpectingATEXT('Invalid token in domain: ' . $this->lexer->current->value), $this->lexer->current->value); } return new ValidEmail(); } - private function checkLabelLength(bool $isEndOfDomain = false) : Result + private function checkLabelLength(bool $isEndOfDomain = false): Result { - if ($this->lexer->token['type'] === EmailLexer::S_DOT || $isEndOfDomain) { + if ($this->lexer->current->isA(EmailLexer::S_DOT) || $isEndOfDomain) { if ($this->isLabelTooLong($this->label)) { - return new InvalidEmail(new LabelTooLong(), $this->lexer->token['value']); + return new InvalidEmail(new LabelTooLong(), $this->lexer->current->value); } $this->label = ''; } - $this->label .= $this->lexer->token['value']; + $this->label .= $this->lexer->current->value; return new ValidEmail(); } - private function isLabelTooLong(string $label) : bool + private function isLabelTooLong(string $label): bool { if (preg_match('/[^\x00-\x7F]/', $label)) { idn_to_ascii($label, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46, $idnaInfo); @@ -298,14 +312,14 @@ private function isLabelTooLong(string $label) : bool return strlen($label) > self::LABEL_MAX_LENGTH; } - private function addTLDWarnings(bool $isTLDMissing) : void + private function addTLDWarnings(bool $isTLDMissing): void { if ($isTLDMissing) { $this->warnings[TLD::CODE] = new TLD(); } } - public function domainPart() : string + public function domainPart(): string { return $this->domainPart; } diff --git a/src/Parser/DoubleQuote.php b/src/Parser/DoubleQuote.php index b32e2b6..b96dba5 100644 --- a/src/Parser/DoubleQuote.php +++ b/src/Parser/DoubleQuote.php @@ -1,4 +1,5 @@ checkDQUOTE(); - if($validQuotedString->isInvalid()) return $validQuotedString; + if ($validQuotedString->isInvalid()) return $validQuotedString; $special = [ EmailLexer::S_CR => true, @@ -30,58 +31,57 @@ public function parse() : Result EmailLexer::S_CR => true, EmailLexer::S_LF => true ]; - + $setSpecialsWarning = true; $this->lexer->moveNext(); - while ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE && null !== $this->lexer->token['type']) { - if (isset($special[$this->lexer->token['type']]) && $setSpecialsWarning) { + while (!$this->lexer->current->isA(EmailLexer::S_DQUOTE) && !$this->lexer->current->isA(EmailLexer::S_EMPTY)) { + if (isset($special[$this->lexer->current->type]) && $setSpecialsWarning) { $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS(); $setSpecialsWarning = false; } - if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH && $this->lexer->isNextToken(EmailLexer::S_DQUOTE)) { + if ($this->lexer->current->isA(EmailLexer::S_BACKSLASH) && $this->lexer->isNextToken(EmailLexer::S_DQUOTE)) { $this->lexer->moveNext(); } $this->lexer->moveNext(); - if (!$this->escaped() && isset($invalid[$this->lexer->token['type']])) { - return new InvalidEmail(new ExpectingATEXT("Expecting ATEXT between DQUOTE"), $this->lexer->token['value']); + if (!$this->escaped() && isset($invalid[$this->lexer->current->type])) { + return new InvalidEmail(new ExpectingATEXT("Expecting ATEXT between DQUOTE"), $this->lexer->current->value); } } $prev = $this->lexer->getPrevious(); - if ($prev['type'] === EmailLexer::S_BACKSLASH) { + if ($prev->isA(EmailLexer::S_BACKSLASH)) { $validQuotedString = $this->checkDQUOTE(); - if($validQuotedString->isInvalid()) return $validQuotedString; + if ($validQuotedString->isInvalid()) return $validQuotedString; } - if (!$this->lexer->isNextToken(EmailLexer::S_AT) && $prev['type'] !== EmailLexer::S_BACKSLASH) { - return new InvalidEmail(new ExpectingATEXT("Expecting ATEXT between DQUOTE"), $this->lexer->token['value']); + if (!$this->lexer->isNextToken(EmailLexer::S_AT) && !$prev->isA(EmailLexer::S_BACKSLASH)) { + return new InvalidEmail(new ExpectingATEXT("Expecting ATEXT between DQUOTE"), $this->lexer->current->value); } return new ValidEmail(); } - protected function checkDQUOTE() : Result + protected function checkDQUOTE(): Result { $previous = $this->lexer->getPrevious(); - if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] === EmailLexer::GENERIC) { + if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous->isA(EmailLexer::GENERIC)) { $description = 'https://tools.ietf.org/html/rfc5322#section-3.2.4 - quoted string should be a unit'; - return new InvalidEmail(new ExpectingATEXT($description), $this->lexer->token['value']); + return new InvalidEmail(new ExpectingATEXT($description), $this->lexer->current->value); } try { $this->lexer->find(EmailLexer::S_DQUOTE); } catch (\Exception $e) { - return new InvalidEmail(new UnclosedQuotedString(), $this->lexer->token['value']); + return new InvalidEmail(new UnclosedQuotedString(), $this->lexer->current->value); } - $this->warnings[QuotedString::CODE] = new QuotedString($previous['value'], $this->lexer->token['value']); + $this->warnings[QuotedString::CODE] = new QuotedString($previous->value, $this->lexer->current->value); return new ValidEmail(); } - } diff --git a/src/Parser/FoldingWhiteSpace.php b/src/Parser/FoldingWhiteSpace.php index fff6ec3..348a7af 100644 --- a/src/Parser/FoldingWhiteSpace.php +++ b/src/Parser/FoldingWhiteSpace.php @@ -1,4 +1,5 @@ isFWS()) { return new ValidEmail(); @@ -36,19 +37,19 @@ public function parse() : Result return $resultCRLF; } - if ($this->lexer->token['type'] === EmailLexer::S_CR) { - return new InvalidEmail(new CRNoLF(), $this->lexer->token['value']); + if ($this->lexer->current->isA(EmailLexer::S_CR)) { + return new InvalidEmail(new CRNoLF(), $this->lexer->current->value); } - if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] !== EmailLexer::S_AT) { - return new InvalidEmail(new AtextAfterCFWS(), $this->lexer->token['value']); + if ($this->lexer->isNextToken(EmailLexer::GENERIC) && !$previous->isA(EmailLexer::S_AT)) { + return new InvalidEmail(new AtextAfterCFWS(), $this->lexer->current->value); } - if ($this->lexer->token['type'] === EmailLexer::S_LF || $this->lexer->token['type'] === EmailLexer::C_NUL) { - return new InvalidEmail(new ExpectingCTEXT(), $this->lexer->token['value']); + if ($this->lexer->current->isA(EmailLexer::S_LF) || $this->lexer->current->isA(EmailLexer::C_NUL)) { + return new InvalidEmail(new ExpectingCTEXT(), $this->lexer->current->value); } - if ($this->lexer->isNextToken(EmailLexer::S_AT) || $previous['type'] === EmailLexer::S_AT) { + if ($this->lexer->isNextToken(EmailLexer::S_AT) || $previous->isA(EmailLexer::S_AT)) { $this->warnings[CFWSNearAt::CODE] = new CFWSNearAt(); } else { $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS(); @@ -57,30 +58,30 @@ public function parse() : Result return new ValidEmail(); } - protected function checkCRLFInFWS() : Result + protected function checkCRLFInFWS(): Result { - if ($this->lexer->token['type'] !== EmailLexer::CRLF) { + if (!$this->lexer->current->isA(EmailLexer::CRLF)) { return new ValidEmail(); } if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) { - return new InvalidEmail(new CRLFX2(), $this->lexer->token['value']); + return new InvalidEmail(new CRLFX2(), $this->lexer->current->value); } //this has no coverage. Condition is repeated from above one if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) { - return new InvalidEmail(new CRLFAtTheEnd(), $this->lexer->token['value']); + return new InvalidEmail(new CRLFAtTheEnd(), $this->lexer->current->value); } return new ValidEmail(); } - - protected function isFWS() : bool + + protected function isFWS(): bool { if ($this->escaped()) { return false; } - return in_array($this->lexer->token['type'], self::FWS_TYPES); + return in_array($this->lexer->current->type, self::FWS_TYPES); } } diff --git a/src/Parser/IDLeftPart.php b/src/Parser/IDLeftPart.php index 5fd9cdf..bedcf7b 100644 --- a/src/Parser/IDLeftPart.php +++ b/src/Parser/IDLeftPart.php @@ -10,6 +10,6 @@ class IDLeftPart extends LocalPart { protected function parseComments(): Result { - return new InvalidEmail(new CommentsInIDRight(), $this->lexer->token['value']); + return new InvalidEmail(new CommentsInIDRight(), $this->lexer->current->value); } } diff --git a/src/Parser/IDRightPart.php b/src/Parser/IDRightPart.php index 1a1268f..d2fc1d7 100644 --- a/src/Parser/IDRightPart.php +++ b/src/Parser/IDRightPart.php @@ -10,7 +10,7 @@ class IDRightPart extends DomainPart { - protected function validateTokens(bool $hasComments) : Result + protected function validateTokens(bool $hasComments): Result { $invalidDomainTokens = [ EmailLexer::S_DQUOTE => true, @@ -20,9 +20,9 @@ protected function validateTokens(bool $hasComments) : Result EmailLexer::S_GREATERTHAN => true, EmailLexer::S_LOWERTHAN => true, ]; - - if (isset($invalidDomainTokens[$this->lexer->token['type']])) { - return new InvalidEmail(new ExpectingATEXT('Invalid token in domain: ' . $this->lexer->token['value']), $this->lexer->token['value']); + + if (isset($invalidDomainTokens[$this->lexer->current->type])) { + return new InvalidEmail(new ExpectingATEXT('Invalid token in domain: ' . $this->lexer->current->value), $this->lexer->current->value); } return new ValidEmail(); } diff --git a/src/Parser/LocalPart.php b/src/Parser/LocalPart.php index 154521b..a6087e6 100644 --- a/src/Parser/LocalPart.php +++ b/src/Parser/LocalPart.php @@ -32,42 +32,45 @@ class LocalPart extends PartParser private $localPart = ''; - public function parse() : Result + public function parse(): Result { $this->lexer->startRecording(); - while ($this->lexer->token['type'] !== EmailLexer::S_AT && null !== $this->lexer->token['type']) { + while (!$this->lexer->current->isA(EmailLexer::S_AT) && !$this->lexer->current->isA(EmailLexer::S_EMPTY)) { if ($this->hasDotAtStart()) { - return new InvalidEmail(new DotAtStart(), $this->lexer->token['value']); + return new InvalidEmail(new DotAtStart(), $this->lexer->current->value); } - if ($this->lexer->token['type'] === EmailLexer::S_DQUOTE) { + if ($this->lexer->current->isA(EmailLexer::S_DQUOTE)) { $dquoteParsingResult = $this->parseDoubleQuote(); //Invalid double quote parsing - if($dquoteParsingResult->isInvalid()) { + if ($dquoteParsingResult->isInvalid()) { return $dquoteParsingResult; } } - if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS || - $this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS ) { + if ( + $this->lexer->current->isA(EmailLexer::S_OPENPARENTHESIS) || + $this->lexer->current->isA(EmailLexer::S_CLOSEPARENTHESIS) + ) { $commentsResult = $this->parseComments(); //Invalid comment parsing - if($commentsResult->isInvalid()) { + if ($commentsResult->isInvalid()) { return $commentsResult; } } - if ($this->lexer->token['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_DOT)) { - return new InvalidEmail(new ConsecutiveDot(), $this->lexer->token['value']); + if ($this->lexer->current->isA(EmailLexer::S_DOT) && $this->lexer->isNextToken(EmailLexer::S_DOT)) { + return new InvalidEmail(new ConsecutiveDot(), $this->lexer->current->value); } - if ($this->lexer->token['type'] === EmailLexer::S_DOT && + if ( + $this->lexer->current->isA(EmailLexer::S_DOT) && $this->lexer->isNextToken(EmailLexer::S_AT) ) { - return new InvalidEmail(new DotAtEnd(), $this->lexer->token['value']); + return new InvalidEmail(new DotAtEnd(), $this->lexer->current->value); } $resultEscaping = $this->validateEscaping(); @@ -81,7 +84,7 @@ public function parse() : Result } $resultFWS = $this->parseLocalFWS(); - if($resultFWS->isInvalid()) { + if ($resultFWS->isInvalid()) { return $resultFWS; } @@ -97,20 +100,20 @@ public function parse() : Result return new ValidEmail(); } - protected function validateTokens(bool $hasComments) : Result + protected function validateTokens(bool $hasComments): Result { - if (isset(self::INVALID_TOKENS[$this->lexer->token['type']])) { - return new InvalidEmail(new ExpectingATEXT('Invalid token found'), $this->lexer->token['value']); + if (isset(self::INVALID_TOKENS[$this->lexer->current->type])) { + return new InvalidEmail(new ExpectingATEXT('Invalid token found'), $this->lexer->current->value); } return new ValidEmail(); } - public function localPart() : string + public function localPart(): string { return $this->localPart; } - private function parseLocalFWS() : Result + private function parseLocalFWS(): Result { $foldingWS = new FoldingWhiteSpace($this->lexer); $resultFWS = $foldingWS->parse(); @@ -120,12 +123,12 @@ private function parseLocalFWS() : Result return $resultFWS; } - private function hasDotAtStart() : bool + private function hasDotAtStart(): bool { - return $this->lexer->token['type'] === EmailLexer::S_DOT && null === $this->lexer->getPrevious()['type']; + return $this->lexer->current->isA(EmailLexer::S_DOT) && $this->lexer->getPrevious()->isA(EmailLexer::S_EMPTY); } - private function parseDoubleQuote() : Result + private function parseDoubleQuote(): Result { $dquoteParser = new DoubleQuote($this->lexer); $parseAgain = $dquoteParser->parse(); @@ -139,21 +142,21 @@ protected function parseComments(): Result $commentParser = new Comment($this->lexer, new LocalComment()); $result = $commentParser->parse(); $this->warnings = array_merge($this->warnings, $commentParser->getWarnings()); - if($result->isInvalid()) { + if ($result->isInvalid()) { return $result; } return $result; } - private function validateEscaping() : Result + private function validateEscaping(): Result { //Backslash found - if ($this->lexer->token['type'] !== EmailLexer::S_BACKSLASH) { + if (!$this->lexer->current->isA(EmailLexer::S_BACKSLASH)) { return new ValidEmail(); } if ($this->lexer->isNextToken(EmailLexer::GENERIC)) { - return new InvalidEmail(new ExpectingATEXT('Found ATOM after escaping'), $this->lexer->token['value']); + return new InvalidEmail(new ExpectingATEXT('Found ATOM after escaping'), $this->lexer->current->value); } if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB, EmailLexer::C_DEL))) { diff --git a/src/Parser/PartParser.php b/src/Parser/PartParser.php index a75a172..d0ed5fd 100644 --- a/src/Parser/PartParser.php +++ b/src/Parser/PartParser.php @@ -7,11 +7,12 @@ use Egulias\EmailValidator\Result\Reason\ConsecutiveDot; use Egulias\EmailValidator\Result\Result; use Egulias\EmailValidator\Result\ValidEmail; +use Egulias\EmailValidator\Warning\Warning; abstract class PartParser { /** - * @var array + * @var Warning[] */ protected $warnings = []; @@ -25,17 +26,17 @@ public function __construct(EmailLexer $lexer) $this->lexer = $lexer; } - abstract public function parse() : Result; + abstract public function parse(): Result; /** - * @return \Egulias\EmailValidator\Warning\Warning[] + * @return Warning[] */ public function getWarnings() { return $this->warnings; } - protected function parseFWS() : Result + protected function parseFWS(): Result { $foldingWS = new FoldingWhiteSpace($this->lexer); $resultFWS = $foldingWS->parse(); @@ -43,21 +44,20 @@ protected function parseFWS() : Result return $resultFWS; } - protected function checkConsecutiveDots() : Result + protected function checkConsecutiveDots(): Result { - if ($this->lexer->token['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_DOT)) { - return new InvalidEmail(new ConsecutiveDot(), $this->lexer->token['value']); + if ($this->lexer->current->isA(EmailLexer::S_DOT) && $this->lexer->isNextToken(EmailLexer::S_DOT)) { + return new InvalidEmail(new ConsecutiveDot(), $this->lexer->current->value); } return new ValidEmail(); } - protected function escaped() : bool + protected function escaped(): bool { $previous = $this->lexer->getPrevious(); - return $previous && $previous['type'] === EmailLexer::S_BACKSLASH - && - $this->lexer->token['type'] !== EmailLexer::GENERIC; + return $previous->isA(EmailLexer::S_BACKSLASH) + && !$this->lexer->current->isA(EmailLexer::GENERIC); } } diff --git a/src/Result/InvalidEmail.php b/src/Result/InvalidEmail.php index 180f4d8..82699ac 100644 --- a/src/Result/InvalidEmail.php +++ b/src/Result/InvalidEmail.php @@ -6,11 +6,15 @@ class InvalidEmail implements Result { - private $token; + /** + * @var string + */ + private string $token; + /** * @var Reason */ - protected $reason; + protected Reason $reason; public function __construct(Reason $reason, string $token) { @@ -38,9 +42,8 @@ public function code(): int return $this->reason->code(); } - public function reason() : Reason + public function reason(): Reason { return $this->reason; } - } diff --git a/src/Validation/DNSCheckValidation.php b/src/Validation/DNSCheckValidation.php index 4882b80..d9ffaad 100644 --- a/src/Validation/DNSCheckValidation.php +++ b/src/Validation/DNSCheckValidation.php @@ -9,6 +9,7 @@ use Egulias\EmailValidator\Result\Reason\NoDNSRecord as ReasonNoDNSRecord; use Egulias\EmailValidator\Result\Reason\UnableToGetDNSRecord; use Egulias\EmailValidator\Warning\NoDNSMXRecord; +use Egulias\EmailValidator\Warning\Warning; class DNSCheckValidation implements EmailValidation { @@ -20,6 +21,8 @@ class DNSCheckValidation implements EmailValidation /** * Reserved Top Level DNS Names (https://tools.ietf.org/html/rfc2606#section-2), * mDNS and private DNS Namespaces (https://tools.ietf.org/html/rfc6762#appendix-G) + * + * @var string[] */ public const RESERVED_DNS_TOP_LEVEL_NAMES = [ // Reserved Top Level DNS Names @@ -39,9 +42,9 @@ class DNSCheckValidation implements EmailValidation 'home', 'lan', ]; - + /** - * @var array + * @var Warning[] */ private $warnings = []; @@ -73,7 +76,7 @@ public function __construct(?DNSGetRecordWrapper $dnsGetRecord = null) $this->dnsGetRecord = $dnsGetRecord; } - public function isValid(string $email, EmailLexer $emailLexer) : bool + public function isValid(string $email, EmailLexer $emailLexer): bool { // use the input to check DNS if we cannot extract something similar to a domain $host = $email; @@ -98,12 +101,15 @@ public function isValid(string $email, EmailLexer $emailLexer) : bool return $this->checkDns($host); } - public function getError() : ?InvalidEmail + public function getError(): ?InvalidEmail { return $this->error; } - public function getWarnings() : array + /** + * @return Warning[] + */ + public function getWarnings(): array { return $this->warnings; } @@ -130,7 +136,7 @@ protected function checkDns($host) * * @return bool True on success. */ - private function validateDnsRecords($host) : bool + private function validateDnsRecords($host): bool { $dnsRecordsResult = $this->dnsGetRecord->getRecords($host, static::DNS_RECORD_TYPES_TO_CHECK); @@ -167,7 +173,7 @@ private function validateDnsRecords($host) : bool * * @return bool True if valid. */ - private function validateMxRecord($dnsRecord) : bool + private function validateMxRecord($dnsRecord): bool { if (!isset($dnsRecord['type'])) { $this->error = new InvalidEmail(new ReasonNoDNSRecord(), ''); diff --git a/src/Validation/DNSGetRecordWrapper.php b/src/Validation/DNSGetRecordWrapper.php index f493c57..25e2fa0 100644 --- a/src/Validation/DNSGetRecordWrapper.php +++ b/src/Validation/DNSGetRecordWrapper.php @@ -1,4 +1,5 @@ records = $records; $this->error = $error; } - public function getRecords() : array + /** + * @return array + */ + public function getRecords(): array { return $this->records; } - public function withError() : bool + public function withError(): bool { return $this->error; } - - } diff --git a/src/Validation/MessageIDValidation.php b/src/Validation/MessageIDValidation.php index 0e02043..97d1ea7 100644 --- a/src/Validation/MessageIDValidation.php +++ b/src/Validation/MessageIDValidation.php @@ -6,12 +6,13 @@ use Egulias\EmailValidator\MessageIDParser; use Egulias\EmailValidator\Result\InvalidEmail; use Egulias\EmailValidator\Result\Reason\ExceptionFound; +use Egulias\EmailValidator\Warning\Warning; class MessageIDValidation implements EmailValidation { /** - * @var array + * @var Warning[] */ private $warnings = []; @@ -39,6 +40,9 @@ public function isValid(string $email, EmailLexer $emailLexer): bool return true; } + /** + * @return Warning[] + */ public function getWarnings(): array { return $this->warnings; diff --git a/src/Validation/MultipleValidationWithAnd.php b/src/Validation/MultipleValidationWithAnd.php index abafe75..f23e84b 100644 --- a/src/Validation/MultipleValidationWithAnd.php +++ b/src/Validation/MultipleValidationWithAnd.php @@ -6,6 +6,7 @@ use Egulias\EmailValidator\Result\InvalidEmail; use Egulias\EmailValidator\Validation\Exception\EmptyValidationList; use Egulias\EmailValidator\Result\MultipleErrors; +use Egulias\EmailValidator\Warning\Warning; class MultipleValidationWithAnd implements EmailValidation { @@ -27,7 +28,7 @@ class MultipleValidationWithAnd implements EmailValidation private $validations = []; /** - * @var array + * @var Warning[] */ private $warnings = []; @@ -58,7 +59,7 @@ public function __construct(array $validations, $mode = self::ALLOW_ALL_ERRORS) /** * {@inheritdoc} */ - public function isValid(string $email, EmailLexer $emailLexer) : bool + public function isValid(string $email, EmailLexer $emailLexer): bool { $result = true; foreach ($this->validations as $validation) { @@ -78,14 +79,14 @@ public function isValid(string $email, EmailLexer $emailLexer) : bool return $result; } - private function initErrorStorage() : void + private function initErrorStorage(): void { if (null === $this->error) { $this->error = new MultipleErrors(); } } - private function processError(EmailValidation $validation) : void + private function processError(EmailValidation $validation): void { if (null !== $validation->getError()) { $this->initErrorStorage(); @@ -94,7 +95,7 @@ private function processError(EmailValidation $validation) : void } } - private function shouldStop(bool $result) : bool + private function shouldStop(bool $result): bool { return !$result && $this->mode === self::STOP_ON_ERROR; } @@ -102,15 +103,15 @@ private function shouldStop(bool $result) : bool /** * Returns the validation errors. */ - public function getError() : ?InvalidEmail + public function getError(): ?InvalidEmail { return $this->error; } /** - * {@inheritdoc} + * @return Warning[] */ - public function getWarnings() : array + public function getWarnings(): array { return $this->warnings; } diff --git a/src/Validation/RFCValidation.php b/src/Validation/RFCValidation.php index e2c27ba..f5819d8 100644 --- a/src/Validation/RFCValidation.php +++ b/src/Validation/RFCValidation.php @@ -6,6 +6,7 @@ use Egulias\EmailValidator\EmailParser; use Egulias\EmailValidator\Result\InvalidEmail; use Egulias\EmailValidator\Result\Reason\ExceptionFound; +use Egulias\EmailValidator\Warning\Warning; class RFCValidation implements EmailValidation { @@ -15,16 +16,16 @@ class RFCValidation implements EmailValidation private $parser; /** - * @var array + * @var Warning[] */ - private $warnings = []; + private array $warnings = []; /** * @var ?InvalidEmail */ private $error; - public function isValid(string $email, EmailLexer $emailLexer) : bool + public function isValid(string $email, EmailLexer $emailLexer): bool { $this->parser = new EmailParser($emailLexer); try { @@ -43,12 +44,15 @@ public function isValid(string $email, EmailLexer $emailLexer) : bool return true; } - public function getError() : ?InvalidEmail + public function getError(): ?InvalidEmail { return $this->error; } - public function getWarnings() : array + /** + * @return Warning[] + */ + public function getWarnings(): array { return $this->warnings; } diff --git a/src/Warning/QuotedPart.php b/src/Warning/QuotedPart.php index afa1f9e..c3e017d 100644 --- a/src/Warning/QuotedPart.php +++ b/src/Warning/QuotedPart.php @@ -7,8 +7,8 @@ class QuotedPart extends Warning public const CODE = 36; /** - * @param scalar $prevToken - * @param scalar $postToken + * @param scalar|null $prevToken + * @param scalar|null $postToken */ public function __construct($prevToken, $postToken) { diff --git a/src/Warning/Warning.php b/src/Warning/Warning.php index 8b39d64..e5b6ad8 100644 --- a/src/Warning/Warning.php +++ b/src/Warning/Warning.php @@ -4,6 +4,9 @@ abstract class Warning { + /** + * @var int CODE + */ public const CODE = 0; /** @@ -40,8 +43,11 @@ public function RFCNumber() return $this->rfcNumber; } - public function __toString() + /** + * @return string + */ + public function __toString(): string { - return $this->message() . " rfc: " . $this->rfcNumber . "internal code: " . static::CODE; + return $this->message() . " rfc: " . $this->rfcNumber . "internal code: " . strval(static::CODE); } } diff --git a/tests/EmailValidator/EmailLexerTest.php b/tests/EmailValidator/EmailLexerTest.php index a09ebe2..c800e93 100644 --- a/tests/EmailValidator/EmailLexerTest.php +++ b/tests/EmailValidator/EmailLexerTest.php @@ -24,7 +24,7 @@ public function testLexerTokens($str, $token) $lexer->setInput($str); $lexer->moveNext(); $lexer->moveNext(); - $this->assertEquals($token, $lexer->token['type']); + $this->assertEquals($token, $lexer->current->type); } public function testLexerParsesMultipleSpaces() @@ -33,9 +33,9 @@ public function testLexerParsesMultipleSpaces() $lexer->setInput(' '); $lexer->moveNext(); $lexer->moveNext(); - $this->assertEquals(EmailLexer::S_SP, $lexer->token['type']); + $this->assertEquals(EmailLexer::S_SP, $lexer->current->type); $lexer->moveNext(); - $this->assertEquals(EmailLexer::S_SP, $lexer->token['type']); + $this->assertEquals(EmailLexer::S_SP, $lexer->current->type); } /** @@ -48,7 +48,7 @@ public function testLexerParsesInvalidUTF8($char) $lexer->moveNext(); $lexer->moveNext(); - $this->assertEquals(EmailLexer::INVALID, $lexer->token['type']); + $this->assertEquals(EmailLexer::INVALID, $lexer->current->type); } public function invalidUTF8CharsProvider() @@ -77,18 +77,18 @@ protected function utf8Chr($code_point) } elseif ($code_point < 0x800) { $hex[0] = 0x1C0 | $code_point >> 6; $hex[1] = 0x80 | $code_point & 0x3F; - $ret = chr($hex[0]).chr($hex[1]); + $ret = chr($hex[0]) . chr($hex[1]); } elseif ($code_point < 0x10000) { $hex[0] = 0xE0 | $code_point >> 12; $hex[1] = 0x80 | $code_point >> 6 & 0x3F; $hex[2] = 0x80 | $code_point & 0x3F; - $ret = chr($hex[0]).chr($hex[1]).chr($hex[2]); + $ret = chr($hex[0]) . chr($hex[1]) . chr($hex[2]); } else { $hex[0] = 0xF0 | $code_point >> 18; $hex[1] = 0x80 | $code_point >> 12 & 0x3F; $hex[2] = 0x80 | $code_point >> 6 & 0x3F; $hex[3] = 0x80 | $code_point & 0x3F; - $ret = chr($hex[0]).chr($hex[1]).chr($hex[2]).chr($hex[3]); + $ret = chr($hex[0]) . chr($hex[1]) . chr($hex[2]) . chr($hex[3]); } return $ret; @@ -101,7 +101,7 @@ public function testLexerForTab() $lexer->moveNext(); $lexer->skipUntil(EmailLexer::S_HTAB); $lexer->moveNext(); - $this->assertEquals(EmailLexer::S_HTAB, $lexer->token['type']); + $this->assertEquals(EmailLexer::S_HTAB, $lexer->current->type); } public function testLexerForUTF8() @@ -110,9 +110,9 @@ public function testLexerForUTF8() $lexer->setInput("áÇ@bar.com"); $lexer->moveNext(); $lexer->moveNext(); - $this->assertEquals(EmailLexer::GENERIC, $lexer->token['type']); + $this->assertEquals(EmailLexer::GENERIC, $lexer->current->type); $lexer->moveNext(); - $this->assertEquals(EmailLexer::GENERIC, $lexer->token['type']); + $this->assertEquals(EmailLexer::GENERIC, $lexer->current->type); } public function testLexerSearchToken()