From 86933da4bba996baf245dd520f625048a925b953 Mon Sep 17 00:00:00 2001 From: Bastien Wermeille Date: Wed, 14 Dec 2022 14:12:31 +0100 Subject: [PATCH 01/10] Migrate to doctrine/lexer v2.0 --- composer.json | 2 +- composer.lock | 586 +++++++++---------- src/EmailLexer.php | 66 +-- src/EmailParser.php | 18 +- src/MessageIDParser.php | 18 +- src/Parser.php | 18 +- src/Parser/Comment.php | 31 +- src/Parser/CommentStrategy/DomainComment.php | 8 +- src/Parser/CommentStrategy/LocalComment.php | 6 +- src/Parser/DomainLiteral.php | 39 +- src/Parser/DomainPart.php | 124 ++-- src/Parser/DoubleQuote.php | 36 +- src/Parser/FoldingWhiteSpace.php | 31 +- src/Parser/IDLeftPart.php | 2 +- src/Parser/IDRightPart.php | 8 +- src/Parser/LocalPart.php | 53 +- src/Parser/PartParser.php | 17 +- src/Validation/DNSCheckValidation.php | 18 +- tests/EmailValidator/EmailLexerTest.php | 20 +- 19 files changed, 544 insertions(+), 557 deletions(-) diff --git a/composer.json b/composer.json index d598d1b..d55f740 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ }, "require": { "php": ">=7.2", - "doctrine/lexer": "^1.2", + "doctrine/lexer": "^2.0", "symfony/polyfill-intl-idn": "^1.15" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 15d9667..c5ad426 100644 --- a/composer.lock +++ b/composer.lock @@ -4,35 +4,80 @@ "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": "fa788fd0799305dbc0cb247a6f981084", "packages": [ { - "name": "doctrine/lexer", - "version": "1.2.3", + "name": "doctrine/deprecations", + "version": "v1.0.0", "source": { "type": "git", - "url": "https://github.com/doctrine/lexer.git", - "reference": "c268e882d4dbdd85e36e4ad69e02dc284f89d229" + "url": "https://github.com/doctrine/deprecations.git", + "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/lexer/zipball/c268e882d4dbdd85e36e4ad69e02dc284f89d229", - "reference": "c268e882d4dbdd85e36e4ad69e02dc284f89d229", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de", + "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de", "shasum": "" }, "require": { - "php": "^7.1 || ^8.0" + "php": "^7.1|^8.0" }, "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": "^9", + "phpunit/phpunit": "^7.5|^8.5|^9.5", + "psr/log": "^1|^2|^3" + }, + "suggest": { + "psr/log": "Allows logging deprecations via PSR-3 logger implementation" }, "type": "library", "autoload": { "psr-4": { - "Doctrine\\Common\\Lexer\\": "lib/Doctrine/Common/Lexer" + "Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.", + "homepage": "https://www.doctrine-project.org/", + "support": { + "issues": "https://github.com/doctrine/deprecations/issues", + "source": "https://github.com/doctrine/deprecations/tree/v1.0.0" + }, + "time": "2022-05-02T15:47:09+00:00" + }, + { + "name": "doctrine/lexer", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/lexer.git", + "reference": "3cf140b81e55d5d640f73367d829db7e3023ef69" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/3cf140b81e55d5d640f73367d829db7e3023ef69", + "reference": "3cf140b81e55d5d640f73367d829db7e3023ef69", + "shasum": "" + }, + "require": { + "doctrine/deprecations": "^1.0", + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^9 || ^10", + "phpstan/phpstan": "^1.3", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "psalm/plugin-phpunit": "^0.18.3", + "vimeo/psalm": "^4.11 || ^5.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Common\\Lexer\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -64,7 +109,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/2.0.0" }, "funding": [ { @@ -80,20 +125,20 @@ "type": "tidelift" } ], - "time": "2022-02-28T11:07:21+00:00" + "time": "2022-12-11T10:51:23+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 +152,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -151,7 +196,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 +212,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 +237,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -235,7 +280,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 +296,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 +318,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -311,7 +356,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 +372,7 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2022-11-03T14:55:06+00:00" } ], "packages-dev": [ @@ -572,20 +617,20 @@ }, { "name": "composer/pcre", - "version": "3.0.0", + "version": "2.1.0", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "e300eb6c535192decd27a85bc72a9290f0d6b3bd" + "reference": "3fdb2807b31a78a40ad89570e30ec77466c98717" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/e300eb6c535192decd27a85bc72a9290f0d6b3bd", - "reference": "e300eb6c535192decd27a85bc72a9290f0d6b3bd", + "url": "https://api.github.com/repos/composer/pcre/zipball/3fdb2807b31a78a40ad89570e30ec77466c98717", + "reference": "3fdb2807b31a78a40ad89570e30ec77466c98717", "shasum": "" }, "require": { - "php": "^7.4 || ^8.0" + "php": "^7.2 || ^8.0" }, "require-dev": { "phpstan/phpstan": "^1.3", @@ -595,7 +640,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "3.x-dev" + "dev-main": "2.x-dev" } }, "autoload": { @@ -623,7 +668,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/2.1.0" }, "funding": [ { @@ -639,7 +684,7 @@ "type": "tidelift" } ], - "time": "2022-02-25T20:21:48+00:00" + "time": "2022-11-16T18:32:04+00:00" }, { "name": "composer/semver", @@ -998,16 +1043,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 +1067,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 +1080,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 +1151,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 +1167,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 +1235,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 +1251,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 +1278,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 +1354,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 +1370,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 +1433,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 +1478,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 +1534,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 +1704,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 +1728,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 +1781,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", @@ -1892,92 +1945,25 @@ }, "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" - }, { "name": "phpunit/php-code-coverage", - "version": "9.2.15", + "version": "9.2.20", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f" + "reference": "af7463c955007de36db0c5e26d03e2f933c2e980" }, "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/af7463c955007de36db0c5e26d03e2f933c2e980", + "reference": "af7463c955007de36db0c5e26d03e2f933c2e980", "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 +2012,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.20" }, "funding": [ { @@ -2034,7 +2020,7 @@ "type": "github" } ], - "time": "2022-03-07T09:28:20+00:00" + "time": "2022-12-13T07:49:28+00:00" }, { "name": "phpunit/php-file-iterator", @@ -2279,16 +2265,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 +2289,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 +2296,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 +2347,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,26 +2357,30 @@ { "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": "1.1.1", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" + "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf" }, "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/8622567409010282b7aeebe4bb841fe98b58dcaf", + "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf", "shasum": "" }, "require": { - "php": ">=7.4.0" + "php": ">=7.2.0" }, "type": "library", "autoload": { @@ -2424,9 +2409,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/1.1.1" }, - "time": "2021-11-05T16:50:12+00:00" + "time": "2021-03-05T17:36:06+00:00" }, { "name": "psr/http-client", @@ -2851,16 +2836,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 +2898,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 +2906,7 @@ "type": "github" } ], - "time": "2020-10-26T15:49:45+00:00" + "time": "2022-09-14T12:41:17+00:00" }, { "name": "sebastian/complexity", @@ -3111,16 +3096,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 +3161,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 +3169,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 +3524,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 +3545,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.2-dev" } }, "autoload": { @@ -3583,7 +3568,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 +3576,7 @@ "type": "github" } ], - "time": "2022-03-15T09:54:48+00:00" + "time": "2022-09-12T14:47:03+00:00" }, { "name": "sebastian/version", @@ -3648,16 +3633,16 @@ }, { "name": "symfony/config", - "version": "v5.4.9", + "version": "v5.4.11", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "8f551fe22672ac7ab2c95fe46d899f960ed4d979" + "reference": "ec79e03125c1d2477e43dde8528535d90cc78379" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/8f551fe22672ac7ab2c95fe46d899f960ed4d979", - "reference": "8f551fe22672ac7ab2c95fe46d899f960ed4d979", + "url": "https://api.github.com/repos/symfony/config/zipball/ec79e03125c1d2477e43dde8528535d90cc78379", + "reference": "ec79e03125c1d2477e43dde8528535d90cc78379", "shasum": "" }, "require": { @@ -3707,7 +3692,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/v5.4.11" }, "funding": [ { @@ -3723,20 +3708,20 @@ "type": "tidelift" } ], - "time": "2022-05-17T10:39:36+00:00" + "time": "2022-07-20T13:00:38+00:00" }, { "name": "symfony/console", - "version": "v5.4.9", + "version": "v5.4.16", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "829d5d1bf60b2efeb0887b7436873becc71a45eb" + "reference": "8e9b9c8dfb33af6057c94e1b44846bee700dc5ef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/829d5d1bf60b2efeb0887b7436873becc71a45eb", - "reference": "829d5d1bf60b2efeb0887b7436873becc71a45eb", + "url": "https://api.github.com/repos/symfony/console/zipball/8e9b9c8dfb33af6057c94e1b44846bee700dc5ef", + "reference": "8e9b9c8dfb33af6057c94e1b44846bee700dc5ef", "shasum": "" }, "require": { @@ -3806,7 +3791,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.9" + "source": "https://github.com/symfony/console/tree/v5.4.16" }, "funding": [ { @@ -3822,11 +3807,11 @@ "type": "tidelift" } ], - "time": "2022-05-18T06:17:34+00:00" + "time": "2022-11-25T14:09:27+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v2.5.1", + "version": "v2.5.2", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", @@ -3873,7 +3858,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/v2.5.2" }, "funding": [ { @@ -3893,16 +3878,16 @@ }, { "name": "symfony/filesystem", - "version": "v5.4.9", + "version": "v5.4.13", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "36a017fa4cce1eff1b8e8129ff53513abcef05ba" + "reference": "ac09569844a9109a5966b9438fc29113ce77cf51" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/36a017fa4cce1eff1b8e8129ff53513abcef05ba", - "reference": "36a017fa4cce1eff1b8e8129ff53513abcef05ba", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/ac09569844a9109a5966b9438fc29113ce77cf51", + "reference": "ac09569844a9109a5966b9438fc29113ce77cf51", "shasum": "" }, "require": { @@ -3937,7 +3922,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/v5.4.13" }, "funding": [ { @@ -3953,20 +3938,20 @@ "type": "tidelift" } ], - "time": "2022-05-20T13:55:35+00:00" + "time": "2022-09-21T19:53:16+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 +3966,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4019,7 +4004,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 +4020,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 +4045,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4100,7 +4085,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 +4101,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 +4129,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4183,7 +4168,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0" }, "funding": [ { @@ -4199,20 +4184,20 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.25.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5" + "reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/cc5db0e22b3cb4111010e48785a97f670b350ca5", - "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/9e8ecb5f92152187c4799efd3c96b78ccab18ff9", + "reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9", "shasum": "" }, "require": { @@ -4221,7 +4206,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4262,7 +4247,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.25.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.27.0" }, "funding": [ { @@ -4278,20 +4263,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 +4285,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4345,7 +4330,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.25.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.27.0" }, "funding": [ { @@ -4361,20 +4346,20 @@ "type": "tidelift" } ], - "time": "2022-03-04T08:16:47+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/polyfill-php81", - "version": "v1.25.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php81.git", - "reference": "5de4ba2d41b15f9bd0e19b2ab9674135813ec98f" + "reference": "707403074c8ea6e2edaf8794b0157a0bfa52157a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/5de4ba2d41b15f9bd0e19b2ab9674135813ec98f", - "reference": "5de4ba2d41b15f9bd0e19b2ab9674135813ec98f", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/707403074c8ea6e2edaf8794b0157a0bfa52157a", + "reference": "707403074c8ea6e2edaf8794b0157a0bfa52157a", "shasum": "" }, "require": { @@ -4383,7 +4368,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4424,7 +4409,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php81/tree/v1.25.0" + "source": "https://github.com/symfony/polyfill-php81/tree/v1.27.0" }, "funding": [ { @@ -4440,20 +4425,20 @@ "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": "v2.5.2", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "24d9dc654b83e91aa59f9d167b131bc3b5bea24c" + "reference": "4b426aac47d6427cc1a1d0f7e2ac724627f5966c" }, "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/4b426aac47d6427cc1a1d0f7e2ac724627f5966c", + "reference": "4b426aac47d6427cc1a1d0f7e2ac724627f5966c", "shasum": "" }, "require": { @@ -4507,7 +4492,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v2.5.1" + "source": "https://github.com/symfony/service-contracts/tree/v2.5.2" }, "funding": [ { @@ -4523,20 +4508,20 @@ "type": "tidelift" } ], - "time": "2022-03-13T20:07:29+00:00" + "time": "2022-05-30T19:17:29+00:00" }, { "name": "symfony/stopwatch", - "version": "v5.4.5", + "version": "v5.4.13", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "4d04b5c24f3c9a1a168a131f6cbe297155bc0d30" + "reference": "6df7a3effde34d81717bbef4591e5ffe32226d69" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/4d04b5c24f3c9a1a168a131f6cbe297155bc0d30", - "reference": "4d04b5c24f3c9a1a168a131f6cbe297155bc0d30", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/6df7a3effde34d81717bbef4591e5ffe32226d69", + "reference": "6df7a3effde34d81717bbef4591e5ffe32226d69", "shasum": "" }, "require": { @@ -4569,7 +4554,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/v5.4.13" }, "funding": [ { @@ -4585,20 +4570,20 @@ "type": "tidelift" } ], - "time": "2022-02-18T16:06:09+00:00" + "time": "2022-09-28T13:19:49+00:00" }, { "name": "symfony/string", - "version": "v5.4.9", + "version": "v5.4.15", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "985e6a9703ef5ce32ba617c9c7d97873bb7b2a99" + "reference": "571334ce9f687e3e6af72db4d3b2a9431e4fd9ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/985e6a9703ef5ce32ba617c9c7d97873bb7b2a99", - "reference": "985e6a9703ef5ce32ba617c9c7d97873bb7b2a99", + "url": "https://api.github.com/repos/symfony/string/zipball/571334ce9f687e3e6af72db4d3b2a9431e4fd9ed", + "reference": "571334ce9f687e3e6af72db4d3b2a9431e4fd9ed", "shasum": "" }, "require": { @@ -4655,7 +4640,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.4.9" + "source": "https://github.com/symfony/string/tree/v5.4.15" }, "funding": [ { @@ -4671,20 +4656,20 @@ "type": "tidelift" } ], - "time": "2022-04-19T10:40:37+00:00" + "time": "2022-10-05T15:16:54+00:00" }, { "name": "symfony/yaml", - "version": "v5.4.3", + "version": "v5.4.16", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "e80f87d2c9495966768310fc531b487ce64237a2" + "reference": "ebd37c71f62d5ec5f6e27de3e06fee492d4c6298" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/e80f87d2c9495966768310fc531b487ce64237a2", - "reference": "e80f87d2c9495966768310fc531b487ce64237a2", + "url": "https://api.github.com/repos/symfony/yaml/zipball/ebd37c71f62d5ec5f6e27de3e06fee492d4c6298", + "reference": "ebd37c71f62d5ec5f6e27de3e06fee492d4c6298", "shasum": "" }, "require": { @@ -4730,7 +4715,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/v5.4.16" }, "funding": [ { @@ -4746,7 +4731,7 @@ "type": "tidelift" } ], - "time": "2022-01-26T16:32:32+00:00" + "time": "2022-11-25T16:04:03+00:00" }, { "name": "theseer/tokenizer", @@ -4800,16 +4785,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 +4833,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 +4887,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 +4945,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", diff --git a/src/EmailLexer.php b/src/EmailLexer.php index 0bfe86f..4d5d5d8 100644 --- a/src/EmailLexer.php +++ b/src/EmailLexer.php @@ -3,6 +3,7 @@ namespace Egulias\EmailValidator; use Doctrine\Common\Lexer\AbstractLexer; +use Doctrine\Common\Lexer\Token; class EmailLexer extends AbstractLexer { @@ -46,7 +47,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,16 +132,16 @@ class EmailLexer extends AbstractLexer protected $hasInvalidTokens = false; /** - * @var array + * @var Token * * @psalm-var array{value:string, type:null|int, position:int}|array */ - protected $previous = []; + protected $previous = null; /** * The last matched/seen token. * - * @var array + * @var object * * @psalm-suppress NonInvariantDocblockPropertyType * @psalm-var array{value:string, type:null|int, position:int} @@ -156,11 +157,7 @@ class EmailLexer extends AbstractLexer public $lookahead; /** @psalm-var array{value:'', type:null, position:0} */ - private static $nullToken = [ - 'value' => '', - 'type' => null, - 'position' => 0, - ]; + private $nullToken = null; /** @var string */ private $accumulator = ''; @@ -170,15 +167,16 @@ class EmailLexer extends AbstractLexer public function __construct() { - $this->previous = $this->token = self::$nullToken; + $this->nullToken = new Token('', null, 0); + $this->previous = $this->token = $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->previous = $this->token = $this->nullToken; } /** @@ -188,7 +186,7 @@ class EmailLexer extends AbstractLexer * * @psalm-suppress InvalidScalarArgument */ - public function find($type) : bool + public function find($type): bool { $search = clone $this; $search->skipUntil($type); @@ -204,22 +202,22 @@ class EmailLexer extends AbstractLexer * * @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->token->value; } $this->previous = $this->token; - - if($this->lookahead === null) { - $this->lookahead = self::$nullToken; + + if ($this->lookahead === null) { + $this->lookahead = $this->nullToken; } $hasNext = parent::moveNext(); if ($this->hasToRecord) { - $this->accumulator .= $this->token['value']; + $this->accumulator .= $this->token->value; } return $hasNext; @@ -257,27 +255,27 @@ class EmailLexer extends AbstractLexer 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 @@ class EmailLexer extends AbstractLexer /** * getPrevious * - * @return array + * @return object */ - public function getPrevious() : array + public function getPrevious(): object { return $this->previous; } @@ -297,7 +295,7 @@ class EmailLexer extends AbstractLexer * * @return string[] */ - protected function getCatchablePatterns() : array + protected function getCatchablePatterns(): array { return self::CATCHABLE_PATTERNS; } @@ -307,32 +305,32 @@ class EmailLexer extends AbstractLexer * * @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..b72a731 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 @@ class EmailParser extends Parser 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->token->value); } return new ValidEmail(); } @@ -51,7 +51,7 @@ class EmailParser extends Parser return $this->processDomainPart(); } - private function processLocalPart() : Result + private function processLocalPart(): Result { $localPartParser = new LocalPart($this->lexer); $localPartResult = $localPartParser->parse(); @@ -61,27 +61,27 @@ class EmailParser extends Parser 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..4cf580b 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 @@ class MessageIDParser extends Parser 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->value); } return new ValidEmail(); } @@ -52,7 +52,7 @@ class MessageIDParser extends Parser return $this->processIDRight(); } - private function processIDLeft() : Result + private function processIDLeft(): Result { $localPartParser = new IDLeftPart($this->lexer); $localPartResult = $localPartParser->parse(); @@ -62,27 +62,27 @@ class MessageIDParser extends Parser 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..181644b 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -22,17 +22,17 @@ 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); @@ -51,7 +51,7 @@ abstract class Parser return $localPartResult; } - $domainPartResult = $this->parseRightFromAt(); + $domainPartResult = $this->parseRightFromAt(); if ($domainPartResult->isInvalid()) { return $domainPartResult; @@ -63,16 +63,16 @@ abstract class Parser /** * @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->token->isA(EmailLexer::S_AT); } } diff --git a/src/Parser/Comment.php b/src/Parser/Comment.php index d6f3032..1f66577 100644 --- a/src/Parser/Comment.php +++ b/src/Parser/Comment.php @@ -29,39 +29,39 @@ class Comment extends PartParser $this->commentStrategy = $commentStrategy; } - public function parse() : Result + public function parse(): Result { - if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) { + if ($this->lexer->token->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->token->value); } } - if ($this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS) { - return new InvalidEmail(new UnOpenedComment(), $this->lexer->token['value']); + if ($this->lexer->token->isA(EmailLexer::S_CLOSEPARENTHESIS)) { + return new InvalidEmail(new UnOpenedComment(), $this->lexer->token->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->token->value); } if ($this->openedParenthesis < 0) { - return new InvalidEmail(new UnOpenedComment(), $this->lexer->token['value']); + return new InvalidEmail(new UnOpenedComment(), $this->lexer->token->value); } $finalValidations = $this->commentStrategy->endOfLoopValidations($this->lexer); @@ -75,10 +75,10 @@ class Comment extends PartParser /** * @return bool */ - private function warnEscaping() : bool + private function warnEscaping(): bool { //Backslash found - if ($this->lexer->token['type'] !== EmailLexer::S_BACKSLASH) { + if (!$this->lexer->token->isA(EmailLexer::S_BACKSLASH)) { return false; } @@ -87,12 +87,11 @@ class Comment extends PartParser } $this->warnings[QuotedPart::CODE] = - new QuotedPart($this->lexer->getPrevious()['type'], $this->lexer->token['type']); + new QuotedPart($this->lexer->getPrevious()->type, $this->lexer->token->type); return true; - } - private function noClosingParenthesis() : bool + private function noClosingParenthesis(): bool { try { $this->lexer->find(EmailLexer::S_CLOSEPARENTHESIS); diff --git a/src/Parser/CommentStrategy/DomainComment.php b/src/Parser/CommentStrategy/DomainComment.php index cbbe3f2..339f06b 100644 --- a/src/Parser/CommentStrategy/DomainComment.php +++ b/src/Parser/CommentStrategy/DomainComment.php @@ -10,20 +10,20 @@ use Egulias\EmailValidator\Result\Reason\ExpectingATEXT; 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->token->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..75cfa68 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->token->value); } $this->warnings[CFWSNearAt::CODE] = new CFWSNearAt(); return new ValidEmail(); diff --git a/src/Parser/DomainLiteral.php b/src/Parser/DomainLiteral.php index e6d66d0..962b9fd 100644 --- a/src/Parser/DomainLiteral.php +++ b/src/Parser/DomainLiteral.php @@ -1,4 +1,5 @@ addTagWarnings(); @@ -39,14 +40,14 @@ class DomainLiteral extends PartParser $addressLiteral = ''; do { - if ($this->lexer->token['type'] === EmailLexer::C_NUL) { - return new InvalidEmail(new ExpectingDTEXT(), $this->lexer->token['value']); + if ($this->lexer->token->isA(EmailLexer::C_NUL)) { + return new InvalidEmail(new ExpectingDTEXT(), $this->lexer->token->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->token->value); } if ($this->lexer->isNextTokenAny( @@ -57,22 +58,21 @@ class DomainLiteral extends PartParser } if ($this->lexer->isNextToken(EmailLexer::S_CR)) { - return new InvalidEmail(new CRNoLF(), $this->lexer->token['value']); + return new InvalidEmail(new CRNoLF(), $this->lexer->token->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->token->isA(EmailLexer::S_BACKSLASH)) { + return new InvalidEmail(new UnusualElements($this->lexer->token->value), $this->lexer->token->value); } - if ($this->lexer->token['type'] === EmailLexer::S_IPV6TAG) { + if ($this->lexer->token->isA(EmailLexer::S_IPV6TAG)) { $IPv6TAG = true; } - if ($this->lexer->token['type'] === EmailLexer::S_CLOSEBRACKET) { + if ($this->lexer->token->isA(EmailLexer::S_CLOSEBRACKET)) { break; } - $addressLiteral .= $this->lexer->token['value']; - + $addressLiteral .= $this->lexer->token->value; } while ($this->lexer->moveNext()); @@ -102,10 +102,10 @@ class DomainLiteral extends PartParser * @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 @@ class DomainLiteral extends PartParser $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 @@ class DomainLiteral extends PartParser * * @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 @@ class DomainLiteral extends PartParser 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->token->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 @@ class DomainLiteral extends PartParser } } } - } diff --git a/src/Parser/DomainPart.php b/src/Parser/DomainPart.php index a57f4ba..ccfa7bd 100644 --- a/src/Parser/DomainPart.php +++ b/src/Parser/DomainPart.php @@ -37,7 +37,7 @@ class DomainPart extends PartParser */ protected $label = ''; - public function parse() : Result + public function parse(): Result { $this->lexer->clearRecorded(); $this->lexer->startRecording(); @@ -49,8 +49,8 @@ class DomainPart extends PartParser return $domainChecks; } - if ($this->lexer->token['type'] === EmailLexer::S_AT) { - return new InvalidEmail(new ConsecutiveAt(), $this->lexer->token['value']); + if ($this->lexer->token->isA(EmailLexer::S_AT)) { + return new InvalidEmail(new ConsecutiveAt(), $this->lexer->token->value); } $result = $this->doParseDomainPart(); @@ -68,67 +68,66 @@ class DomainPart extends PartParser $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->token->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->token->value); } - if ($prev['type'] === EmailLexer::S_HYPHEN) { + 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) { + if ($this->lexer->token->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->token->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->token->isA(EmailLexer::S_EMPTY) || + ($this->lexer->token->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->token->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->token->isA(EmailLexer::S_DOT)) { + return new InvalidEmail(new DotAtStart(), $this->lexer->token->value); } - if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN) { - return new InvalidEmail(new DomainHyphened('After AT'), $this->lexer->token['value']); + if ($this->lexer->token->isA(EmailLexer::S_HYPHEN)) { + return new InvalidEmail(new DomainHyphened('After AT'), $this->lexer->token->value); } return new ValidEmail(); } @@ -142,7 +141,7 @@ class DomainPart extends PartParser return $result; } - protected function doParseDomainPart() : Result + protected function doParseDomainPart(): Result { $tldMissing = true; $hasComments = false; @@ -155,13 +154,15 @@ class DomainPart extends PartParser return $notAllowedChars; } - if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS || - $this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS ) { + if ( + $this->lexer->token->isA(EmailLexer::S_OPENPARENTHESIS) || + $this->lexer->token->isA(EmailLexer::S_CLOSEPARENTHESIS) + ) { $hasComments = true; $commentsResult = $this->parseComments(); //Invalid comment parsing - if($commentsResult->isInvalid()) { + if ($commentsResult->isInvalid()) { return $commentsResult; } } @@ -171,26 +172,26 @@ class DomainPart extends PartParser return $dotsResult; } - if ($this->lexer->token['type'] === EmailLexer::S_OPENBRACKET) { + if ($this->lexer->token->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->token->value; - if ($this->lexer->token['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::GENERIC)) { + if ($this->lexer->token->isA(EmailLexer::S_DOT) && $this->lexer->isNextToken(EmailLexer::GENERIC)) { $tldMissing = false; } @@ -199,8 +200,7 @@ class DomainPart extends PartParser return $exceptionsResult; } $this->lexer->moveNext(); - - } while (null !== $this->lexer->token['type']); + } while (null !== $this->lexer->token->type); $labelCheck = $this->checkLabelLength(true); if ($labelCheck->isInvalid()) { @@ -212,11 +212,11 @@ class DomainPart extends PartParser return new ValidEmail(); } - private function checkNotAllowedChars(array $token) : Result + private function checkNotAllowedChars(object $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 +224,12 @@ class DomainPart extends PartParser /** * @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->token->value); } $domainLiteralParser = new DomainLiteralParser($this->lexer); @@ -238,25 +238,27 @@ class DomainPart extends PartParser return $result; } - protected function checkDomainPartExceptions(array $prev, bool $hasComments) : Result + protected function checkDomainPartExceptions(object $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->token->isA(EmailLexer::S_OPENBRACKET) && $prev->type !== EmailLexer::S_AT) { + return new InvalidEmail(new ExpectingATEXT('OPENBRACKET not after AT'), $this->lexer->token->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->token->isA(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->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->token->isA(EmailLexer::S_BACKSLASH) + && $this->lexer->isNextToken(EmailLexer::GENERIC) + ) { + return new InvalidEmail(new ExpectingATEXT('Escaping following "ATOM"'), $this->lexer->token->value); } return $this->validateTokens($hasComments); } - protected function validateTokens(bool $hasComments) : Result + protected function validateTokens(bool $hasComments): Result { $validDomainTokens = array( EmailLexer::GENERIC => true, @@ -269,27 +271,27 @@ class DomainPart extends PartParser $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->token->type])) { + return new InvalidEmail(new ExpectingATEXT('Invalid token in domain: ' . $this->lexer->token->value), $this->lexer->token->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->token->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->token->value); } $this->label = ''; } - $this->label .= $this->lexer->token['value']; + $this->label .= $this->lexer->token->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 +300,14 @@ class DomainPart extends PartParser 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..6fcbc39 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 @@ class DoubleQuote extends PartParser 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->token->isA(EmailLexer::S_DQUOTE) && null !== $this->lexer->token->type) { + if (isset($special[$this->lexer->token->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->token->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->token->type])) { + return new InvalidEmail(new ExpectingATEXT("Expecting ATEXT between DQUOTE"), $this->lexer->token->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->token->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->token->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->token->value); } - $this->warnings[QuotedString::CODE] = new QuotedString($previous['value'], $this->lexer->token['value']); + $this->warnings[QuotedString::CODE] = new QuotedString($previous->value, $this->lexer->token->value); return new ValidEmail(); } - } diff --git a/src/Parser/FoldingWhiteSpace.php b/src/Parser/FoldingWhiteSpace.php index fff6ec3..b6ded56 100644 --- a/src/Parser/FoldingWhiteSpace.php +++ b/src/Parser/FoldingWhiteSpace.php @@ -1,4 +1,5 @@ isFWS()) { return new ValidEmail(); @@ -36,19 +37,19 @@ class FoldingWhiteSpace extends PartParser return $resultCRLF; } - if ($this->lexer->token['type'] === EmailLexer::S_CR) { - return new InvalidEmail(new CRNoLF(), $this->lexer->token['value']); + if ($this->lexer->token->isA(EmailLexer::S_CR)) { + return new InvalidEmail(new CRNoLF(), $this->lexer->token->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->token->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->token->isA(EmailLexer::S_LF) || $this->lexer->token->isA(EmailLexer::C_NUL)) { + return new InvalidEmail(new ExpectingCTEXT(), $this->lexer->token->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 @@ class FoldingWhiteSpace extends PartParser return new ValidEmail(); } - protected function checkCRLFInFWS() : Result + protected function checkCRLFInFWS(): Result { - if ($this->lexer->token['type'] !== EmailLexer::CRLF) { + if (!$this->lexer->token->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->token->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->token->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->token->type, self::FWS_TYPES); } } diff --git a/src/Parser/IDLeftPart.php b/src/Parser/IDLeftPart.php index 5fd9cdf..20707cf 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->token->value); } } diff --git a/src/Parser/IDRightPart.php b/src/Parser/IDRightPart.php index 1a1268f..47e5284 100644 --- a/src/Parser/IDRightPart.php +++ b/src/Parser/IDRightPart.php @@ -10,7 +10,7 @@ use Egulias\EmailValidator\Result\Reason\ExpectingATEXT; 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 @@ class IDRightPart extends DomainPart 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->token->type])) { + return new InvalidEmail(new ExpectingATEXT('Invalid token in domain: ' . $this->lexer->token->value), $this->lexer->token->value); } return new ValidEmail(); } diff --git a/src/Parser/LocalPart.php b/src/Parser/LocalPart.php index 154521b..a16e188 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->token->isA(EmailLexer::S_AT) && null !== $this->lexer->token->type) { if ($this->hasDotAtStart()) { - return new InvalidEmail(new DotAtStart(), $this->lexer->token['value']); + return new InvalidEmail(new DotAtStart(), $this->lexer->token->value); } - if ($this->lexer->token['type'] === EmailLexer::S_DQUOTE) { + if ($this->lexer->token->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->token->isA(EmailLexer::S_OPENPARENTHESIS) || + $this->lexer->token->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->token->isA(EmailLexer::S_DOT) && $this->lexer->isNextToken(EmailLexer::S_DOT)) { + return new InvalidEmail(new ConsecutiveDot(), $this->lexer->token->value); } - if ($this->lexer->token['type'] === EmailLexer::S_DOT && + if ( + $this->lexer->token->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->token->value); } $resultEscaping = $this->validateEscaping(); @@ -81,7 +84,7 @@ class LocalPart extends PartParser } $resultFWS = $this->parseLocalFWS(); - if($resultFWS->isInvalid()) { + if ($resultFWS->isInvalid()) { return $resultFWS; } @@ -97,20 +100,20 @@ class LocalPart extends PartParser 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->token->type])) { + return new InvalidEmail(new ExpectingATEXT('Invalid token found'), $this->lexer->token->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 @@ class LocalPart extends PartParser 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->token->isA(EmailLexer::S_DOT) && null === $this->lexer->getPrevious()->type; } - private function parseDoubleQuote() : Result + private function parseDoubleQuote(): Result { $dquoteParser = new DoubleQuote($this->lexer); $parseAgain = $dquoteParser->parse(); @@ -139,21 +142,21 @@ class LocalPart extends PartParser $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->token->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->token->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..3c01766 100644 --- a/src/Parser/PartParser.php +++ b/src/Parser/PartParser.php @@ -25,7 +25,7 @@ abstract class PartParser $this->lexer = $lexer; } - abstract public function parse() : Result; + abstract public function parse(): Result; /** * @return \Egulias\EmailValidator\Warning\Warning[] @@ -35,7 +35,7 @@ abstract class PartParser return $this->warnings; } - protected function parseFWS() : Result + protected function parseFWS(): Result { $foldingWS = new FoldingWhiteSpace($this->lexer); $resultFWS = $foldingWS->parse(); @@ -43,21 +43,20 @@ abstract class PartParser 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->token->isA(EmailLexer::S_DOT) && $this->lexer->isNextToken(EmailLexer::S_DOT)) { + return new InvalidEmail(new ConsecutiveDot(), $this->lexer->token->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 && $previous->isA(EmailLexer::S_BACKSLASH) + && !$this->lexer->token->isA(EmailLexer::GENERIC); } } diff --git a/src/Validation/DNSCheckValidation.php b/src/Validation/DNSCheckValidation.php index 4882b80..f620642 100644 --- a/src/Validation/DNSCheckValidation.php +++ b/src/Validation/DNSCheckValidation.php @@ -39,7 +39,7 @@ class DNSCheckValidation implements EmailValidation 'home', 'lan', ]; - + /** * @var array */ @@ -73,7 +73,7 @@ class DNSCheckValidation implements EmailValidation $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 +98,12 @@ class DNSCheckValidation implements EmailValidation return $this->checkDns($host); } - public function getError() : ?InvalidEmail + public function getError(): ?InvalidEmail { return $this->error; } - public function getWarnings() : array + public function getWarnings(): array { return $this->warnings; } @@ -130,7 +130,7 @@ class DNSCheckValidation implements EmailValidation * * @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); @@ -163,18 +163,18 @@ class DNSCheckValidation implements EmailValidation /** * Validate an MX record * - * @param array $dnsRecord Given DNS record. + * @param object $dnsRecord Given DNS record. * * @return bool True if valid. */ - private function validateMxRecord($dnsRecord) : bool + private function validateMxRecord($dnsRecord): bool { - if (!isset($dnsRecord['type'])) { + if (!isset($dnsRecord->type)) { $this->error = new InvalidEmail(new ReasonNoDNSRecord(), ''); return false; } - if ($dnsRecord['type'] !== 'MX') { + if ($dnsRecord->type !== 'MX') { return true; } diff --git a/tests/EmailValidator/EmailLexerTest.php b/tests/EmailValidator/EmailLexerTest.php index a09ebe2..ad0b07c 100644 --- a/tests/EmailValidator/EmailLexerTest.php +++ b/tests/EmailValidator/EmailLexerTest.php @@ -24,7 +24,7 @@ class EmailLexerTest extends TestCase $lexer->setInput($str); $lexer->moveNext(); $lexer->moveNext(); - $this->assertEquals($token, $lexer->token['type']); + $this->assertEquals($token, $lexer->token->type); } public function testLexerParsesMultipleSpaces() @@ -33,9 +33,9 @@ class EmailLexerTest extends TestCase $lexer->setInput(' '); $lexer->moveNext(); $lexer->moveNext(); - $this->assertEquals(EmailLexer::S_SP, $lexer->token['type']); + $this->assertEquals(EmailLexer::S_SP, $lexer->token->type); $lexer->moveNext(); - $this->assertEquals(EmailLexer::S_SP, $lexer->token['type']); + $this->assertEquals(EmailLexer::S_SP, $lexer->token->type); } /** @@ -48,7 +48,7 @@ class EmailLexerTest extends TestCase $lexer->moveNext(); $lexer->moveNext(); - $this->assertEquals(EmailLexer::INVALID, $lexer->token['type']); + $this->assertEquals(EmailLexer::INVALID, $lexer->token->type); } public function invalidUTF8CharsProvider() @@ -77,18 +77,18 @@ class EmailLexerTest extends TestCase } 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 @@ class EmailLexerTest extends TestCase $lexer->moveNext(); $lexer->skipUntil(EmailLexer::S_HTAB); $lexer->moveNext(); - $this->assertEquals(EmailLexer::S_HTAB, $lexer->token['type']); + $this->assertEquals(EmailLexer::S_HTAB, $lexer->token->type); } public function testLexerForUTF8() @@ -110,9 +110,9 @@ class EmailLexerTest extends TestCase $lexer->setInput("áÇ@bar.com"); $lexer->moveNext(); $lexer->moveNext(); - $this->assertEquals(EmailLexer::GENERIC, $lexer->token['type']); + $this->assertEquals(EmailLexer::GENERIC, $lexer->token->type); $lexer->moveNext(); - $this->assertEquals(EmailLexer::GENERIC, $lexer->token['type']); + $this->assertEquals(EmailLexer::GENERIC, $lexer->token->type); } public function testLexerSearchToken() From d80748070a79514b691de9eb0c2c7e0152683d9f Mon Sep 17 00:00:00 2001 From: Bastien Wermeille Date: Wed, 14 Dec 2022 20:29:41 +0100 Subject: [PATCH 02/10] Apply feedbacks --- src/EmailLexer.php | 15 ++++----------- src/MessageIDParser.php | 2 +- src/Parser.php | 2 +- src/Parser/DomainPart.php | 9 +++++---- src/Validation/DNSCheckValidation.php | 2 +- 5 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/EmailLexer.php b/src/EmailLexer.php index 4d5d5d8..912745b 100644 --- a/src/EmailLexer.php +++ b/src/EmailLexer.php @@ -133,30 +133,23 @@ class EmailLexer extends AbstractLexer /** * @var Token - * - * @psalm-var array{value:string, type:null|int, position:int}|array */ protected $previous = null; /** * The last matched/seen token. * - * @var object - * - * @psalm-suppress NonInvariantDocblockPropertyType - * @psalm-var array{value:string, type:null|int, position:int} - * @psalm-suppress NonInvariantDocblockPropertyType + * @var Token */ public $token; /** * The next token in the input. * - * @var array{position: int, type: int|null|string, value: int|string}|null + * @var Token|null */ public $lookahead; - /** @psalm-var array{value:'', type:null, position:0} */ private $nullToken = null; /** @var string */ @@ -283,9 +276,9 @@ class EmailLexer extends AbstractLexer /** * getPrevious * - * @return object + * @return Token */ - public function getPrevious(): object + public function getPrevious(): Token { return $this->previous; } diff --git a/src/MessageIDParser.php b/src/MessageIDParser.php index 4cf580b..a80b01a 100644 --- a/src/MessageIDParser.php +++ b/src/MessageIDParser.php @@ -37,7 +37,7 @@ class MessageIDParser extends Parser protected function preLeftParsing(): Result { if (!$this->hasAtToken()) { - return new InvalidEmail(new NoLocalPart(), $this->lexer->value); + return new InvalidEmail(new NoLocalPart(), $this->lexer->token->value); } return new ValidEmail(); } diff --git a/src/Parser.php b/src/Parser.php index 181644b..c007c49 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -37,7 +37,7 @@ abstract class Parser $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->token->value); } $preParsingResult = $this->preLeftParsing(); diff --git a/src/Parser/DomainPart.php b/src/Parser/DomainPart.php index ccfa7bd..14e6814 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; @@ -81,11 +82,11 @@ class DomainPart extends PartParser return new InvalidEmail(new DotAtEnd(), $this->lexer->token->value); } if ($prev->isA(EmailLexer::S_HYPHEN)) { - return new InvalidEmail(new DomainHyphened('Hypen found at the end of the domain'), $prev['value']); + return new InvalidEmail(new DomainHyphened('Hypen found at the end of the domain'), $prev->value); } if ($this->lexer->token->isA(EmailLexer::S_SP)) { - return new InvalidEmail(new CRLFAtTheEnd(), $prev['value']); + return new InvalidEmail(new CRLFAtTheEnd(), $prev->value); } return new ValidEmail(); } @@ -212,7 +213,7 @@ class DomainPart extends PartParser return new ValidEmail(); } - private function checkNotAllowedChars(object $token): Result + private function checkNotAllowedChars(Token $token): Result { $notAllowed = [EmailLexer::S_BACKSLASH => true, EmailLexer::S_SLASH => true]; if (isset($notAllowed[$token->type])) { @@ -238,7 +239,7 @@ class DomainPart extends PartParser return $result; } - protected function checkDomainPartExceptions(object $prev, bool $hasComments): Result + protected function checkDomainPartExceptions(Token $prev, bool $hasComments): Result { if ($this->lexer->token->isA(EmailLexer::S_OPENBRACKET) && $prev->type !== EmailLexer::S_AT) { return new InvalidEmail(new ExpectingATEXT('OPENBRACKET not after AT'), $this->lexer->token->value); diff --git a/src/Validation/DNSCheckValidation.php b/src/Validation/DNSCheckValidation.php index f620642..cd48b7b 100644 --- a/src/Validation/DNSCheckValidation.php +++ b/src/Validation/DNSCheckValidation.php @@ -179,7 +179,7 @@ class DNSCheckValidation implements EmailValidation } // "Null MX" record indicates the domain accepts no mail (https://tools.ietf.org/html/rfc7505) - if (empty($dnsRecord['target']) || $dnsRecord['target'] === '.') { + if (empty($dnsRecord->target) || $dnsRecord->target === '.') { $this->error = new InvalidEmail(new DomainAcceptsNoMail(), ""); return false; } From 3d254921232ef4fc15f1c90a80ff0fd847327da6 Mon Sep 17 00:00:00 2001 From: Bastien Wermeille Date: Thu, 15 Dec 2022 00:04:10 +0100 Subject: [PATCH 03/10] Fix Tests + Psalm issues --- composer.json | 2 +- composer.lock | 26 +++++++++---------- src/EmailLexer.php | 27 +++++++++++++------- src/Parser/DomainPart.php | 13 +++++++++- src/Parser/DoubleQuote.php | 2 +- src/Parser/LocalPart.php | 4 +-- src/Parser/PartParser.php | 2 +- src/Validation/DNSCheckValidation.php | 8 +++--- src/Validation/MultipleValidationWithAnd.php | 12 ++++----- src/Warning/QuotedPart.php | 4 +-- 10 files changed, 60 insertions(+), 40 deletions(-) diff --git a/composer.json b/composer.json index d55f740..0545a0e 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ }, "require": { "php": ">=7.2", - "doctrine/lexer": "^2.0", + "doctrine/lexer": "^2.1", "symfony/polyfill-intl-idn": "^1.15" }, "require-dev": { diff --git a/composer.lock b/composer.lock index c5ad426..e0e261c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "fa788fd0799305dbc0cb247a6f981084", + "content-hash": "e4db7645a86d3dd51c48de4de7474017", "packages": [ { "name": "doctrine/deprecations", @@ -51,16 +51,16 @@ }, { "name": "doctrine/lexer", - "version": "2.0.0", + "version": "2.1.0", "source": { "type": "git", "url": "https://github.com/doctrine/lexer.git", - "reference": "3cf140b81e55d5d640f73367d829db7e3023ef69" + "reference": "39ab8fcf5a51ce4b85ca97c7a7d033eb12831124" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/lexer/zipball/3cf140b81e55d5d640f73367d829db7e3023ef69", - "reference": "3cf140b81e55d5d640f73367d829db7e3023ef69", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/39ab8fcf5a51ce4b85ca97c7a7d033eb12831124", + "reference": "39ab8fcf5a51ce4b85ca97c7a7d033eb12831124", "shasum": "" }, "require": { @@ -109,7 +109,7 @@ ], "support": { "issues": "https://github.com/doctrine/lexer/issues", - "source": "https://github.com/doctrine/lexer/tree/2.0.0" + "source": "https://github.com/doctrine/lexer/tree/2.1.0" }, "funding": [ { @@ -125,7 +125,7 @@ "type": "tidelift" } ], - "time": "2022-12-11T10:51:23+00:00" + "time": "2022-12-14T08:49:07+00:00" }, { "name": "symfony/polyfill-intl-idn", @@ -1947,16 +1947,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.20", + "version": "9.2.21", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "af7463c955007de36db0c5e26d03e2f933c2e980" + "reference": "3f893e19712bb0c8bc86665d1562e9fd509c4ef0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/af7463c955007de36db0c5e26d03e2f933c2e980", - "reference": "af7463c955007de36db0c5e26d03e2f933c2e980", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/3f893e19712bb0c8bc86665d1562e9fd509c4ef0", + "reference": "3f893e19712bb0c8bc86665d1562e9fd509c4ef0", "shasum": "" }, "require": { @@ -2012,7 +2012,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.20" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.21" }, "funding": [ { @@ -2020,7 +2020,7 @@ "type": "github" } ], - "time": "2022-12-13T07:49:28+00:00" + "time": "2022-12-14T13:26:54+00:00" }, { "name": "phpunit/php-file-iterator", diff --git a/src/EmailLexer.php b/src/EmailLexer.php index 912745b..a0fab3f 100644 --- a/src/EmailLexer.php +++ b/src/EmailLexer.php @@ -5,10 +5,11 @@ 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; @@ -132,25 +133,30 @@ class EmailLexer extends AbstractLexer protected $hasInvalidTokens = false; /** - * @var Token + * @var Token */ - protected $previous = null; + protected $previous; /** * The last matched/seen token. * - * @var Token + * @var Token + * + * @psalm-suppress NonInvariantDocblockPropertyType */ public $token; /** * The next token in the input. * - * @var Token|null + * @var Token|null */ public $lookahead; - private $nullToken = null; + /** + * @var Token + */ + private $nullToken; /** @var string */ private $accumulator = ''; @@ -160,7 +166,10 @@ class EmailLexer extends AbstractLexer public function __construct() { - $this->nullToken = new Token('', null, 0); + /** @var Token $nullToken */ + $nullToken = new Token('', self::S_EMPTY, 0); + $this->nullToken = $nullToken; + $this->previous = $this->token = $this->nullToken; $this->lookahead = null; } @@ -223,7 +232,7 @@ class EmailLexer extends AbstractLexer * @throws \InvalidArgumentException * @return integer */ - protected function getType(&$value) + protected function getType(&$value): int { $encoded = $value; @@ -276,7 +285,7 @@ class EmailLexer extends AbstractLexer /** * getPrevious * - * @return Token + * @return Token */ public function getPrevious(): Token { diff --git a/src/Parser/DomainPart.php b/src/Parser/DomainPart.php index 14e6814..ac6fd35 100644 --- a/src/Parser/DomainPart.php +++ b/src/Parser/DomainPart.php @@ -201,7 +201,7 @@ class DomainPart extends PartParser return $exceptionsResult; } $this->lexer->moveNext(); - } while (null !== $this->lexer->token->type); + } while (!$this->lexer->token->isA(EmailLexer::S_EMPTY)); $labelCheck = $this->checkLabelLength(true); if ($labelCheck->isInvalid()) { @@ -213,6 +213,11 @@ class DomainPart extends PartParser return new ValidEmail(); } + /** + * @param Token $token + * + * @return Result + */ private function checkNotAllowedChars(Token $token): Result { $notAllowed = [EmailLexer::S_BACKSLASH => true, EmailLexer::S_SLASH => true]; @@ -239,6 +244,12 @@ class DomainPart extends PartParser return $result; } + /** + * @param Token $prev + * @param bool $hasComments + * + * @return Result + */ protected function checkDomainPartExceptions(Token $prev, bool $hasComments): Result { if ($this->lexer->token->isA(EmailLexer::S_OPENBRACKET) && $prev->type !== EmailLexer::S_AT) { diff --git a/src/Parser/DoubleQuote.php b/src/Parser/DoubleQuote.php index 6fcbc39..9295066 100644 --- a/src/Parser/DoubleQuote.php +++ b/src/Parser/DoubleQuote.php @@ -36,7 +36,7 @@ class DoubleQuote extends PartParser $this->lexer->moveNext(); - while (!$this->lexer->token->isA(EmailLexer::S_DQUOTE) && null !== $this->lexer->token->type) { + while (!$this->lexer->token->isA(EmailLexer::S_DQUOTE) && !$this->lexer->token->isA(EmailLexer::S_EMPTY)) { if (isset($special[$this->lexer->token->type]) && $setSpecialsWarning) { $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS(); $setSpecialsWarning = false; diff --git a/src/Parser/LocalPart.php b/src/Parser/LocalPart.php index a16e188..d42873f 100644 --- a/src/Parser/LocalPart.php +++ b/src/Parser/LocalPart.php @@ -36,7 +36,7 @@ class LocalPart extends PartParser { $this->lexer->startRecording(); - while (!$this->lexer->token->isA(EmailLexer::S_AT) && null !== $this->lexer->token->type) { + while (!$this->lexer->token->isA(EmailLexer::S_AT) && !$this->lexer->token->isA(EmailLexer::S_EMPTY)) { if ($this->hasDotAtStart()) { return new InvalidEmail(new DotAtStart(), $this->lexer->token->value); } @@ -125,7 +125,7 @@ class LocalPart extends PartParser private function hasDotAtStart(): bool { - return $this->lexer->token->isA(EmailLexer::S_DOT) && null === $this->lexer->getPrevious()->type; + return $this->lexer->token->isA(EmailLexer::S_DOT) && $this->lexer->getPrevious()->isA(EmailLexer::S_EMPTY); } private function parseDoubleQuote(): Result diff --git a/src/Parser/PartParser.php b/src/Parser/PartParser.php index 3c01766..35418de 100644 --- a/src/Parser/PartParser.php +++ b/src/Parser/PartParser.php @@ -56,7 +56,7 @@ abstract class PartParser { $previous = $this->lexer->getPrevious(); - return $previous && $previous->isA(EmailLexer::S_BACKSLASH) + return $previous->isA(EmailLexer::S_BACKSLASH) && !$this->lexer->token->isA(EmailLexer::GENERIC); } } diff --git a/src/Validation/DNSCheckValidation.php b/src/Validation/DNSCheckValidation.php index cd48b7b..8350cc5 100644 --- a/src/Validation/DNSCheckValidation.php +++ b/src/Validation/DNSCheckValidation.php @@ -163,23 +163,23 @@ class DNSCheckValidation implements EmailValidation /** * Validate an MX record * - * @param object $dnsRecord Given DNS record. + * @param array $dnsRecord Given DNS record. * * @return bool True if valid. */ private function validateMxRecord($dnsRecord): bool { - if (!isset($dnsRecord->type)) { + if (!isset($dnsRecord['type'])) { $this->error = new InvalidEmail(new ReasonNoDNSRecord(), ''); return false; } - if ($dnsRecord->type !== 'MX') { + if ($dnsRecord['type'] !== 'MX') { return true; } // "Null MX" record indicates the domain accepts no mail (https://tools.ietf.org/html/rfc7505) - if (empty($dnsRecord->target) || $dnsRecord->target === '.') { + if (empty($dnsRecord['target']) || $dnsRecord['target'] === '.') { $this->error = new InvalidEmail(new DomainAcceptsNoMail(), ""); return false; } diff --git a/src/Validation/MultipleValidationWithAnd.php b/src/Validation/MultipleValidationWithAnd.php index abafe75..7feb7c0 100644 --- a/src/Validation/MultipleValidationWithAnd.php +++ b/src/Validation/MultipleValidationWithAnd.php @@ -58,7 +58,7 @@ class MultipleValidationWithAnd implements EmailValidation /** * {@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 +78,14 @@ class MultipleValidationWithAnd implements EmailValidation 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 +94,7 @@ class MultipleValidationWithAnd implements EmailValidation } } - private function shouldStop(bool $result) : bool + private function shouldStop(bool $result): bool { return !$result && $this->mode === self::STOP_ON_ERROR; } @@ -102,7 +102,7 @@ class MultipleValidationWithAnd implements EmailValidation /** * Returns the validation errors. */ - public function getError() : ?InvalidEmail + public function getError(): ?InvalidEmail { return $this->error; } @@ -110,7 +110,7 @@ class MultipleValidationWithAnd implements EmailValidation /** * {@inheritdoc} */ - public function getWarnings() : array + 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) { From 0841364b8d59b89b7bd0db1858ea78b7385bef01 Mon Sep 17 00:00:00 2001 From: Bastien Wermeille Date: Sun, 18 Dec 2022 21:51:37 +0100 Subject: [PATCH 04/10] Upgrade to doctrine/lexer 3.x --- .scrutinizer.yml | 21 +- .travis.yml | 10 +- README.md | 13 +- composer.json | 26 ++- composer.lock | 507 ++++++++++++++------------------------------- src/EmailLexer.php | 6 +- 6 files changed, 195 insertions(+), 388 deletions(-) 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..36e7296 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,16 +2,12 @@ language: php matrix: include: - - php: 7.4 - dist: bionic - env: - - psalm=yes - - php: 8.0 + - php: 8.1 env: - psalm=yes dist: bionic -#ppc64le support code - - php: 7.4 + #ppc64le support code + - php: 8.1 arch: ppc64le env: - psalm=yes diff --git a/README.md b/README.md index 0bd8503..8801dab 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 | 2022/12/20 | - | X | X | +| v3.x | 2020/12/29 | - | X | X | +| v2.1.x | 2016/05/16 | 01/2022 | 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 0545a0e..1f7dbe7 100644 --- a/composer.json +++ b/composer.json @@ -1,20 +1,28 @@ { - "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"} + { + "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": "^2.1", + "php": ">=8.1", + "doctrine/lexer": "^3.0", "symfony/polyfill-intl-idn": "^1.15" }, "require-dev": { diff --git a/composer.lock b/composer.lock index e0e261c..e3afa9d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,75 +4,31 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e4db7645a86d3dd51c48de4de7474017", + "content-hash": "3ddee5f72f898d23c46200c3b12c5a1d", "packages": [ - { - "name": "doctrine/deprecations", - "version": "v1.0.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/deprecations.git", - "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de", - "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de", - "shasum": "" - }, - "require": { - "php": "^7.1|^8.0" - }, - "require-dev": { - "doctrine/coding-standard": "^9", - "phpunit/phpunit": "^7.5|^8.5|^9.5", - "psr/log": "^1|^2|^3" - }, - "suggest": { - "psr/log": "Allows logging deprecations via PSR-3 logger implementation" - }, - "type": "library", - "autoload": { - "psr-4": { - "Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.", - "homepage": "https://www.doctrine-project.org/", - "support": { - "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/v1.0.0" - }, - "time": "2022-05-02T15:47:09+00:00" - }, { "name": "doctrine/lexer", - "version": "2.1.0", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/doctrine/lexer.git", - "reference": "39ab8fcf5a51ce4b85ca97c7a7d033eb12831124" + "reference": "84a527db05647743d50373e0ec53a152f2cde568" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/lexer/zipball/39ab8fcf5a51ce4b85ca97c7a7d033eb12831124", - "reference": "39ab8fcf5a51ce4b85ca97c7a7d033eb12831124", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/84a527db05647743d50373e0ec53a152f2cde568", + "reference": "84a527db05647743d50373e0ec53a152f2cde568", "shasum": "" }, "require": { - "doctrine/deprecations": "^1.0", - "php": "^7.1 || ^8.0" + "php": "^8.1" }, "require-dev": { - "doctrine/coding-standard": "^9 || ^10", - "phpstan/phpstan": "^1.3", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "doctrine/coding-standard": "^10", + "phpstan/phpstan": "^1.9", + "phpunit/phpunit": "^9.5", "psalm/plugin-phpunit": "^0.18.3", - "vimeo/psalm": "^4.11 || ^5.0" + "vimeo/psalm": "^5.0" }, "type": "library", "autoload": { @@ -109,7 +65,7 @@ ], "support": { "issues": "https://github.com/doctrine/lexer/issues", - "source": "https://github.com/doctrine/lexer/tree/2.1.0" + "source": "https://github.com/doctrine/lexer/tree/3.0.0" }, "funding": [ { @@ -125,7 +81,7 @@ "type": "tidelift" } ], - "time": "2022-12-14T08:49:07+00:00" + "time": "2022-12-15T16:57:16+00:00" }, { "name": "symfony/polyfill-intl-idn", @@ -617,20 +573,20 @@ }, { "name": "composer/pcre", - "version": "2.1.0", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "3fdb2807b31a78a40ad89570e30ec77466c98717" + "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/3fdb2807b31a78a40ad89570e30ec77466c98717", - "reference": "3fdb2807b31a78a40ad89570e30ec77466c98717", + "url": "https://api.github.com/repos/composer/pcre/zipball/4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", + "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0" + "php": "^7.4 || ^8.0" }, "require-dev": { "phpstan/phpstan": "^1.3", @@ -640,7 +596,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "2.x-dev" + "dev-main": "3.x-dev" } }, "autoload": { @@ -668,7 +624,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/2.1.0" + "source": "https://github.com/composer/pcre/tree/3.1.0" }, "funding": [ { @@ -684,7 +640,7 @@ "type": "tidelift" } ], - "time": "2022-11-16T18:32:04+00:00" + "time": "2022-11-17T09:50:14+00:00" }, { "name": "composer/semver", @@ -1897,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": { @@ -1941,22 +1902,22 @@ "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" + "time": "2022-10-14T12:47:21+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.21", + "version": "9.2.22", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "3f893e19712bb0c8bc86665d1562e9fd509c4ef0" + "reference": "e4bf60d2220b4baaa0572986b5d69870226b06df" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/3f893e19712bb0c8bc86665d1562e9fd509c4ef0", - "reference": "3f893e19712bb0c8bc86665d1562e9fd509c4ef0", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/e4bf60d2220b4baaa0572986b5d69870226b06df", + "reference": "e4bf60d2220b4baaa0572986b5d69870226b06df", "shasum": "" }, "require": { @@ -2012,7 +1973,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.21" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.22" }, "funding": [ { @@ -2020,7 +1981,7 @@ "type": "github" } ], - "time": "2022-12-14T13:26:54+00:00" + "time": "2022-12-18T16:40:55+00:00" }, { "name": "phpunit/php-file-iterator", @@ -2367,22 +2328,27 @@ }, { "name": "psr/container", - "version": "1.1.1", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf" + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf", - "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", "shasum": "" }, "require": { - "php": ">=7.2.0" + "php": ">=7.4.0" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, "autoload": { "psr-4": { "Psr\\Container\\": "src/" @@ -2409,9 +2375,9 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/1.1.1" + "source": "https://github.com/php-fig/container/tree/2.0.2" }, - "time": "2021-03-05T17:36:06+00:00" + "time": "2021-11-05T16:47:00+00:00" }, { "name": "psr/http-client", @@ -2575,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/", @@ -2619,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", @@ -3633,35 +3599,33 @@ }, { "name": "symfony/config", - "version": "v5.4.11", + "version": "v6.2.0", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "ec79e03125c1d2477e43dde8528535d90cc78379" + "reference": "ebf27792246165a2a0b6b69ec9c620cac8c5a2f0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/ec79e03125c1d2477e43dde8528535d90cc78379", - "reference": "ec79e03125c1d2477e43dde8528535d90cc78379", + "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" @@ -3692,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.11" + "source": "https://github.com/symfony/config/tree/v6.2.0" }, "funding": [ { @@ -3708,50 +3672,47 @@ "type": "tidelift" } ], - "time": "2022-07-20T13:00:38+00:00" + "time": "2022-11-02T09:08:04+00:00" }, { "name": "symfony/console", - "version": "v5.4.16", + "version": "v6.2.2", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "8e9b9c8dfb33af6057c94e1b44846bee700dc5ef" + "reference": "5a9bd5c543f00157c55face973c149957467db31" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/8e9b9c8dfb33af6057c94e1b44846bee700dc5ef", - "reference": "8e9b9c8dfb33af6057c94e1b44846bee700dc5ef", + "url": "https://api.github.com/repos/symfony/console/zipball/5a9bd5c543f00157c55face973c149957467db31", + "reference": "5a9bd5c543f00157c55face973c149957467db31", "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", @@ -3791,7 +3752,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.16" + "source": "https://github.com/symfony/console/tree/v6.2.2" }, "funding": [ { @@ -3807,29 +3768,29 @@ "type": "tidelift" } ], - "time": "2022-11-25T14:09:27+00:00" + "time": "2022-12-16T15:08:36+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v2.5.2", + "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", @@ -3858,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.2" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.2.0" }, "funding": [ { @@ -3874,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.13", + "version": "v6.2.0", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "ac09569844a9109a5966b9438fc29113ce77cf51" + "reference": "50b2523c874605cf3d4acf7a9e2b30b6a440a016" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/ac09569844a9109a5966b9438fc29113ce77cf51", - "reference": "ac09569844a9109a5966b9438fc29113ce77cf51", + "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": { @@ -3922,7 +3882,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v5.4.13" + "source": "https://github.com/symfony/filesystem/tree/v6.2.0" }, "funding": [ { @@ -3938,7 +3898,7 @@ "type": "tidelift" } ], - "time": "2022-09-21T19:53:16+00:00" + "time": "2022-11-20T13:01:27+00:00" }, { "name": "symfony/polyfill-ctype", @@ -4186,85 +4146,6 @@ ], "time": "2022-11-03T14:55:06+00:00" }, - { - "name": "symfony/polyfill-php73", - "version": "v1.27.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/9e8ecb5f92152187c4799efd3c96b78ccab18ff9", - "reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.27-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.27.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-11-03T14:55:06+00:00" - }, { "name": "symfony/polyfill-php80", "version": "v1.27.0", @@ -4348,103 +4229,23 @@ ], "time": "2022-11-03T14:55:06+00:00" }, - { - "name": "symfony/polyfill-php81", - "version": "v1.27.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php81.git", - "reference": "707403074c8ea6e2edaf8794b0157a0bfa52157a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/707403074c8ea6e2edaf8794b0157a0bfa52157a", - "reference": "707403074c8ea6e2edaf8794b0157a0bfa52157a", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.27-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.27.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-11-03T14:55:06+00:00" - }, { "name": "symfony/service-contracts", - "version": "v2.5.2", + "version": "v3.2.0", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "4b426aac47d6427cc1a1d0f7e2ac724627f5966c" + "reference": "aac98028c69df04ee77eb69b96b86ee51fbf4b75" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/4b426aac47d6427cc1a1d0f7e2ac724627f5966c", - "reference": "4b426aac47d6427cc1a1d0f7e2ac724627f5966c", + "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" @@ -4455,7 +4256,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "2.5-dev" + "dev-main": "3.3-dev" }, "thanks": { "name": "symfony/contracts", @@ -4465,7 +4266,10 @@ "autoload": { "psr-4": { "Symfony\\Contracts\\Service\\": "" - } + }, + "exclude-from-classmap": [ + "/Test/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -4492,7 +4296,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v2.5.2" + "source": "https://github.com/symfony/service-contracts/tree/v3.2.0" }, "funding": [ { @@ -4508,24 +4312,24 @@ "type": "tidelift" } ], - "time": "2022-05-30T19:17:29+00:00" + "time": "2022-11-25T10:21:52+00:00" }, { "name": "symfony/stopwatch", - "version": "v5.4.13", + "version": "v6.2.0", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "6df7a3effde34d81717bbef4591e5ffe32226d69" + "reference": "266636bb8f3fbdccc302491df7b3a1b9a8c238a7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/6df7a3effde34d81717bbef4591e5ffe32226d69", - "reference": "6df7a3effde34d81717bbef4591e5ffe32226d69", + "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", @@ -4554,7 +4358,7 @@ "description": "Provides a way to profile code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/stopwatch/tree/v5.4.13" + "source": "https://github.com/symfony/stopwatch/tree/v6.2.0" }, "funding": [ { @@ -4570,38 +4374,38 @@ "type": "tidelift" } ], - "time": "2022-09-28T13:19:49+00:00" + "time": "2022-09-28T16:00:52+00:00" }, { "name": "symfony/string", - "version": "v5.4.15", + "version": "v6.2.2", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "571334ce9f687e3e6af72db4d3b2a9431e4fd9ed" + "reference": "863219fd713fa41cbcd285a79723f94672faff4d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/571334ce9f687e3e6af72db4d3b2a9431e4fd9ed", - "reference": "571334ce9f687e3e6af72db4d3b2a9431e4fd9ed", + "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": { @@ -4640,7 +4444,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.4.15" + "source": "https://github.com/symfony/string/tree/v6.2.2" }, "funding": [ { @@ -4656,32 +4460,31 @@ "type": "tidelift" } ], - "time": "2022-10-05T15:16:54+00:00" + "time": "2022-12-14T16:11:27+00:00" }, { "name": "symfony/yaml", - "version": "v5.4.16", + "version": "v6.2.2", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "ebd37c71f62d5ec5f6e27de3e06fee492d4c6298" + "reference": "6ed8243aa5f2cb5a57009f826b5e7fb3c4200cf3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/ebd37c71f62d5ec5f6e27de3e06fee492d4c6298", - "reference": "ebd37c71f62d5ec5f6e27de3e06fee492d4c6298", + "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" @@ -4715,7 +4518,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v5.4.16" + "source": "https://github.com/symfony/yaml/tree/v6.2.2" }, "funding": [ { @@ -4731,7 +4534,7 @@ "type": "tidelift" } ], - "time": "2022-11-25T16:04:03+00:00" + "time": "2022-12-14T16:11:27+00:00" }, { "name": "theseer/tokenizer", @@ -5007,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 a0fab3f..28d631f 100644 --- a/src/EmailLexer.php +++ b/src/EmailLexer.php @@ -144,19 +144,19 @@ class EmailLexer extends AbstractLexer * * @psalm-suppress NonInvariantDocblockPropertyType */ - public $token; + public Token|null $token; /** * The next token in the input. * * @var Token|null */ - public $lookahead; + public Token|null $lookahead; /** * @var Token */ - private $nullToken; + private Token|null $nullToken; /** @var string */ private $accumulator = ''; From f9e4bc583539fac2b4abbb41edca617503e4fd81 Mon Sep 17 00:00:00 2001 From: Bastien Wermeille Date: Sun, 18 Dec 2022 22:04:37 +0100 Subject: [PATCH 05/10] Use php nullsafe operator to fix type issues --- src/EmailLexer.php | 4 +- src/EmailParser.php | 2 +- src/MessageIDParser.php | 2 +- src/Parser.php | 4 +- src/Parser/Comment.php | 16 ++--- src/Parser/CommentStrategy/DomainComment.php | 2 +- src/Parser/CommentStrategy/LocalComment.php | 2 +- src/Parser/DomainLiteral.php | 20 +++---- src/Parser/DomainPart.php | 62 ++++++++++---------- src/Parser/DoubleQuote.php | 18 +++--- src/Parser/FoldingWhiteSpace.php | 18 +++--- src/Parser/IDLeftPart.php | 2 +- src/Parser/IDRightPart.php | 4 +- src/Parser/LocalPart.php | 28 ++++----- src/Parser/PartParser.php | 6 +- tests/EmailValidator/EmailLexerTest.php | 14 ++--- 16 files changed, 101 insertions(+), 103 deletions(-) diff --git a/src/EmailLexer.php b/src/EmailLexer.php index 28d631f..0db4d06 100644 --- a/src/EmailLexer.php +++ b/src/EmailLexer.php @@ -140,9 +140,7 @@ class EmailLexer extends AbstractLexer /** * The last matched/seen token. * - * @var Token - * - * @psalm-suppress NonInvariantDocblockPropertyType + * @var Token|null */ public Token|null $token; diff --git a/src/EmailParser.php b/src/EmailParser.php index b72a731..acb4d90 100644 --- a/src/EmailParser.php +++ b/src/EmailParser.php @@ -36,7 +36,7 @@ class EmailParser extends Parser protected function preLeftParsing(): Result { if (!$this->hasAtToken()) { - return new InvalidEmail(new NoLocalPart(), $this->lexer->token->value); + return new InvalidEmail(new NoLocalPart(), $this->lexer->token?->value); } return new ValidEmail(); } diff --git a/src/MessageIDParser.php b/src/MessageIDParser.php index a80b01a..761667d 100644 --- a/src/MessageIDParser.php +++ b/src/MessageIDParser.php @@ -37,7 +37,7 @@ class MessageIDParser extends Parser protected function preLeftParsing(): Result { if (!$this->hasAtToken()) { - return new InvalidEmail(new NoLocalPart(), $this->lexer->token->value); + return new InvalidEmail(new NoLocalPart(), $this->lexer->token?->value); } return new ValidEmail(); } diff --git a/src/Parser.php b/src/Parser.php index c007c49..993ac3f 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -37,7 +37,7 @@ abstract class Parser $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->token?->value); } $preParsingResult = $this->preLeftParsing(); @@ -73,6 +73,6 @@ abstract class Parser $this->lexer->moveNext(); $this->lexer->moveNext(); - return !$this->lexer->token->isA(EmailLexer::S_AT); + return !$this->lexer->token?->isA(EmailLexer::S_AT); } } diff --git a/src/Parser/Comment.php b/src/Parser/Comment.php index 1f66577..1032ac3 100644 --- a/src/Parser/Comment.php +++ b/src/Parser/Comment.php @@ -31,15 +31,15 @@ class Comment extends PartParser public function parse(): Result { - if ($this->lexer->token->isA(EmailLexer::S_OPENPARENTHESIS)) { + if ($this->lexer->token?->isA(EmailLexer::S_OPENPARENTHESIS)) { $this->openedParenthesis++; if ($this->noClosingParenthesis()) { - return new InvalidEmail(new UnclosedComment(), $this->lexer->token->value); + return new InvalidEmail(new UnclosedComment(), $this->lexer->token?->value); } } - if ($this->lexer->token->isA(EmailLexer::S_CLOSEPARENTHESIS)) { - return new InvalidEmail(new UnOpenedComment(), $this->lexer->token->value); + if ($this->lexer->token?->isA(EmailLexer::S_CLOSEPARENTHESIS)) { + return new InvalidEmail(new UnOpenedComment(), $this->lexer->token?->value); } $this->warnings[WarningComment::CODE] = new WarningComment(); @@ -58,10 +58,10 @@ class Comment extends PartParser } if ($this->openedParenthesis >= 1) { - return new InvalidEmail(new UnclosedComment(), $this->lexer->token->value); + return new InvalidEmail(new UnclosedComment(), $this->lexer->token?->value); } if ($this->openedParenthesis < 0) { - return new InvalidEmail(new UnOpenedComment(), $this->lexer->token->value); + return new InvalidEmail(new UnOpenedComment(), $this->lexer->token?->value); } $finalValidations = $this->commentStrategy->endOfLoopValidations($this->lexer); @@ -78,7 +78,7 @@ class Comment extends PartParser private function warnEscaping(): bool { //Backslash found - if (!$this->lexer->token->isA(EmailLexer::S_BACKSLASH)) { + if (!$this->lexer->token?->isA(EmailLexer::S_BACKSLASH)) { return false; } @@ -87,7 +87,7 @@ class Comment extends PartParser } $this->warnings[QuotedPart::CODE] = - new QuotedPart($this->lexer->getPrevious()->type, $this->lexer->token->type); + new QuotedPart($this->lexer->getPrevious()->type, $this->lexer->token?->type); return true; } diff --git a/src/Parser/CommentStrategy/DomainComment.php b/src/Parser/CommentStrategy/DomainComment.php index 339f06b..edbadec 100644 --- a/src/Parser/CommentStrategy/DomainComment.php +++ b/src/Parser/CommentStrategy/DomainComment.php @@ -23,7 +23,7 @@ class DomainComment implements CommentStrategy { //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->token?->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 75cfa68..6efc337 100644 --- a/src/Parser/CommentStrategy/LocalComment.php +++ b/src/Parser/CommentStrategy/LocalComment.php @@ -24,7 +24,7 @@ class LocalComment implements CommentStrategy 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->token?->value); } $this->warnings[CFWSNearAt::CODE] = new CFWSNearAt(); return new ValidEmail(); diff --git a/src/Parser/DomainLiteral.php b/src/Parser/DomainLiteral.php index 962b9fd..58fed93 100644 --- a/src/Parser/DomainLiteral.php +++ b/src/Parser/DomainLiteral.php @@ -40,14 +40,14 @@ class DomainLiteral extends PartParser $addressLiteral = ''; do { - if ($this->lexer->token->isA(EmailLexer::C_NUL)) { - return new InvalidEmail(new ExpectingDTEXT(), $this->lexer->token->value); + if ($this->lexer->token?->isA(EmailLexer::C_NUL)) { + return new InvalidEmail(new ExpectingDTEXT(), $this->lexer->token?->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->token?->value); } if ($this->lexer->isNextTokenAny( @@ -58,21 +58,21 @@ class DomainLiteral extends PartParser } if ($this->lexer->isNextToken(EmailLexer::S_CR)) { - return new InvalidEmail(new CRNoLF(), $this->lexer->token->value); + return new InvalidEmail(new CRNoLF(), $this->lexer->token?->value); } - if ($this->lexer->token->isA(EmailLexer::S_BACKSLASH)) { - return new InvalidEmail(new UnusualElements($this->lexer->token->value), $this->lexer->token->value); + if ($this->lexer->token?->isA(EmailLexer::S_BACKSLASH)) { + return new InvalidEmail(new UnusualElements($this->lexer->token?->value), $this->lexer->token?->value); } - if ($this->lexer->token->isA(EmailLexer::S_IPV6TAG)) { + if ($this->lexer->token?->isA(EmailLexer::S_IPV6TAG)) { $IPv6TAG = true; } - if ($this->lexer->token->isA(EmailLexer::S_CLOSEBRACKET)) { + if ($this->lexer->token?->isA(EmailLexer::S_CLOSEBRACKET)) { break; } - $addressLiteral .= $this->lexer->token->value; + $addressLiteral .= $this->lexer->token?->value; } while ($this->lexer->moveNext()); @@ -189,7 +189,7 @@ class DomainLiteral extends PartParser private function addObsoleteWarnings(): void { - if (in_array($this->lexer->token->type, self::OBSOLETE_WARNINGS)) { + if (in_array($this->lexer->token?->type, self::OBSOLETE_WARNINGS)) { $this->warnings[ObsoleteDTEXT::CODE] = new ObsoleteDTEXT(); } } diff --git a/src/Parser/DomainPart.php b/src/Parser/DomainPart.php index ac6fd35..e7d45d9 100644 --- a/src/Parser/DomainPart.php +++ b/src/Parser/DomainPart.php @@ -50,8 +50,8 @@ class DomainPart extends PartParser return $domainChecks; } - if ($this->lexer->token->isA(EmailLexer::S_AT)) { - return new InvalidEmail(new ConsecutiveAt(), $this->lexer->token->value); + if ($this->lexer->token?->isA(EmailLexer::S_AT)) { + return new InvalidEmail(new ConsecutiveAt(), $this->lexer->token?->value); } $result = $this->doParseDomainPart(); @@ -69,7 +69,7 @@ class DomainPart extends PartParser $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->token?->value); } return new ValidEmail(); @@ -79,13 +79,13 @@ class DomainPart extends PartParser { $prev = $this->lexer->getPrevious(); if ($prev->isA(EmailLexer::S_DOT)) { - return new InvalidEmail(new DotAtEnd(), $this->lexer->token->value); + return new InvalidEmail(new DotAtEnd(), $this->lexer->token?->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->isA(EmailLexer::S_SP)) { + if ($this->lexer->token?->isA(EmailLexer::S_SP)) { return new InvalidEmail(new CRLFAtTheEnd(), $prev->value); } return new ValidEmail(); @@ -103,7 +103,7 @@ class DomainPart extends PartParser return $missingDomain; } - if ($this->lexer->token->isA(EmailLexer::S_OPENPARENTHESIS)) { + if ($this->lexer->token?->isA(EmailLexer::S_OPENPARENTHESIS)) { $this->warnings[DeprecatedComment::CODE] = new DeprecatedComment(); } return new ValidEmail(); @@ -111,12 +111,12 @@ class DomainPart extends PartParser private function checkEmptyDomain(): Result { - $thereIsNoDomain = $this->lexer->token->isA(EmailLexer::S_EMPTY) || - ($this->lexer->token->isA(EmailLexer::S_SP) && + $thereIsNoDomain = $this->lexer->token?->isA(EmailLexer::S_EMPTY) || + ($this->lexer->token?->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->token?->value); } return new ValidEmail(); @@ -124,11 +124,11 @@ class DomainPart extends PartParser private function checkInvalidTokensAfterAT(): Result { - if ($this->lexer->token->isA(EmailLexer::S_DOT)) { - return new InvalidEmail(new DotAtStart(), $this->lexer->token->value); + if ($this->lexer->token?->isA(EmailLexer::S_DOT)) { + return new InvalidEmail(new DotAtStart(), $this->lexer->token?->value); } - if ($this->lexer->token->isA(EmailLexer::S_HYPHEN)) { - return new InvalidEmail(new DomainHyphened('After AT'), $this->lexer->token->value); + if ($this->lexer->token?->isA(EmailLexer::S_HYPHEN)) { + return new InvalidEmail(new DomainHyphened('After AT'), $this->lexer->token?->value); } return new ValidEmail(); } @@ -156,8 +156,8 @@ class DomainPart extends PartParser } if ( - $this->lexer->token->isA(EmailLexer::S_OPENPARENTHESIS) || - $this->lexer->token->isA(EmailLexer::S_CLOSEPARENTHESIS) + $this->lexer->token?->isA(EmailLexer::S_OPENPARENTHESIS) || + $this->lexer->token?->isA(EmailLexer::S_CLOSEPARENTHESIS) ) { $hasComments = true; $commentsResult = $this->parseComments(); @@ -173,7 +173,7 @@ class DomainPart extends PartParser return $dotsResult; } - if ($this->lexer->token->isA(EmailLexer::S_OPENBRACKET)) { + if ($this->lexer->token?->isA(EmailLexer::S_OPENBRACKET)) { $literalResult = $this->parseDomainLiteral(); $this->addTLDWarnings($tldMissing); @@ -190,9 +190,9 @@ class DomainPart extends PartParser return $FwsResult; } - $domain .= $this->lexer->token->value; + $domain .= $this->lexer->token?->value; - if ($this->lexer->token->isA(EmailLexer::S_DOT) && $this->lexer->isNextToken(EmailLexer::GENERIC)) { + if ($this->lexer->token?->isA(EmailLexer::S_DOT) && $this->lexer->isNextToken(EmailLexer::GENERIC)) { $tldMissing = false; } @@ -201,7 +201,7 @@ class DomainPart extends PartParser return $exceptionsResult; } $this->lexer->moveNext(); - } while (!$this->lexer->token->isA(EmailLexer::S_EMPTY)); + } while (!$this->lexer->token?->isA(EmailLexer::S_EMPTY)); $labelCheck = $this->checkLabelLength(true); if ($labelCheck->isInvalid()) { @@ -235,7 +235,7 @@ class DomainPart extends PartParser 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->token?->value); } $domainLiteralParser = new DomainLiteralParser($this->lexer); @@ -252,19 +252,19 @@ class DomainPart extends PartParser */ protected function checkDomainPartExceptions(Token $prev, bool $hasComments): Result { - if ($this->lexer->token->isA(EmailLexer::S_OPENBRACKET) && $prev->type !== EmailLexer::S_AT) { - return new InvalidEmail(new ExpectingATEXT('OPENBRACKET not after AT'), $this->lexer->token->value); + if ($this->lexer->token?->isA(EmailLexer::S_OPENBRACKET) && $prev->type !== EmailLexer::S_AT) { + return new InvalidEmail(new ExpectingATEXT('OPENBRACKET not after AT'), $this->lexer->token?->value); } - if ($this->lexer->token->isA(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->token?->isA(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->token->isA(EmailLexer::S_BACKSLASH) + $this->lexer->token?->isA(EmailLexer::S_BACKSLASH) && $this->lexer->isNextToken(EmailLexer::GENERIC) ) { - return new InvalidEmail(new ExpectingATEXT('Escaping following "ATOM"'), $this->lexer->token->value); + return new InvalidEmail(new ExpectingATEXT('Escaping following "ATOM"'), $this->lexer->token?->value); } return $this->validateTokens($hasComments); @@ -283,8 +283,8 @@ class DomainPart extends PartParser $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->token?->type])) { + return new InvalidEmail(new ExpectingATEXT('Invalid token in domain: ' . $this->lexer->token?->value), $this->lexer->token?->value); } return new ValidEmail(); @@ -292,13 +292,13 @@ class DomainPart extends PartParser private function checkLabelLength(bool $isEndOfDomain = false): Result { - if ($this->lexer->token->isA(EmailLexer::S_DOT) || $isEndOfDomain) { + if ($this->lexer->token?->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->token?->value); } $this->label = ''; } - $this->label .= $this->lexer->token->value; + $this->label .= $this->lexer->token?->value; return new ValidEmail(); } diff --git a/src/Parser/DoubleQuote.php b/src/Parser/DoubleQuote.php index 9295066..c78978c 100644 --- a/src/Parser/DoubleQuote.php +++ b/src/Parser/DoubleQuote.php @@ -36,19 +36,19 @@ class DoubleQuote extends PartParser $this->lexer->moveNext(); - while (!$this->lexer->token->isA(EmailLexer::S_DQUOTE) && !$this->lexer->token->isA(EmailLexer::S_EMPTY)) { - if (isset($special[$this->lexer->token->type]) && $setSpecialsWarning) { + while (!$this->lexer->token?->isA(EmailLexer::S_DQUOTE) && !$this->lexer->token?->isA(EmailLexer::S_EMPTY)) { + if (isset($special[$this->lexer->token?->type]) && $setSpecialsWarning) { $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS(); $setSpecialsWarning = false; } - if ($this->lexer->token->isA(EmailLexer::S_BACKSLASH) && $this->lexer->isNextToken(EmailLexer::S_DQUOTE)) { + if ($this->lexer->token?->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->token?->type])) { + return new InvalidEmail(new ExpectingATEXT("Expecting ATEXT between DQUOTE"), $this->lexer->token?->value); } } @@ -60,7 +60,7 @@ class DoubleQuote extends PartParser } if (!$this->lexer->isNextToken(EmailLexer::S_AT) && !$prev->isA(EmailLexer::S_BACKSLASH)) { - return new InvalidEmail(new ExpectingATEXT("Expecting ATEXT between DQUOTE"), $this->lexer->token->value); + return new InvalidEmail(new ExpectingATEXT("Expecting ATEXT between DQUOTE"), $this->lexer->token?->value); } return new ValidEmail(); @@ -72,15 +72,15 @@ class DoubleQuote extends PartParser 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->token?->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->token?->value); } - $this->warnings[QuotedString::CODE] = new QuotedString($previous->value, $this->lexer->token->value); + $this->warnings[QuotedString::CODE] = new QuotedString($previous->value, $this->lexer->token?->value); return new ValidEmail(); } diff --git a/src/Parser/FoldingWhiteSpace.php b/src/Parser/FoldingWhiteSpace.php index b6ded56..df51b8e 100644 --- a/src/Parser/FoldingWhiteSpace.php +++ b/src/Parser/FoldingWhiteSpace.php @@ -37,16 +37,16 @@ class FoldingWhiteSpace extends PartParser return $resultCRLF; } - if ($this->lexer->token->isA(EmailLexer::S_CR)) { - return new InvalidEmail(new CRNoLF(), $this->lexer->token->value); + if ($this->lexer->token?->isA(EmailLexer::S_CR)) { + return new InvalidEmail(new CRNoLF(), $this->lexer->token?->value); } if ($this->lexer->isNextToken(EmailLexer::GENERIC) && !$previous->isA(EmailLexer::S_AT)) { - return new InvalidEmail(new AtextAfterCFWS(), $this->lexer->token->value); + return new InvalidEmail(new AtextAfterCFWS(), $this->lexer->token?->value); } - if ($this->lexer->token->isA(EmailLexer::S_LF) || $this->lexer->token->isA(EmailLexer::C_NUL)) { - return new InvalidEmail(new ExpectingCTEXT(), $this->lexer->token->value); + if ($this->lexer->token?->isA(EmailLexer::S_LF) || $this->lexer->token?->isA(EmailLexer::C_NUL)) { + return new InvalidEmail(new ExpectingCTEXT(), $this->lexer->token?->value); } if ($this->lexer->isNextToken(EmailLexer::S_AT) || $previous->isA(EmailLexer::S_AT)) { @@ -60,17 +60,17 @@ class FoldingWhiteSpace extends PartParser protected function checkCRLFInFWS(): Result { - if (!$this->lexer->token->isA(EmailLexer::CRLF)) { + if (!$this->lexer->token?->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->token?->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->token?->value); } return new ValidEmail(); @@ -82,6 +82,6 @@ class FoldingWhiteSpace extends PartParser return false; } - return in_array($this->lexer->token->type, self::FWS_TYPES); + return in_array($this->lexer->token?->type, self::FWS_TYPES); } } diff --git a/src/Parser/IDLeftPart.php b/src/Parser/IDLeftPart.php index 20707cf..03c1e0d 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->token?->value); } } diff --git a/src/Parser/IDRightPart.php b/src/Parser/IDRightPart.php index 47e5284..6f41c68 100644 --- a/src/Parser/IDRightPart.php +++ b/src/Parser/IDRightPart.php @@ -21,8 +21,8 @@ class IDRightPart extends DomainPart 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->token?->type])) { + return new InvalidEmail(new ExpectingATEXT('Invalid token in domain: ' . $this->lexer->token?->value), $this->lexer->token?->value); } return new ValidEmail(); } diff --git a/src/Parser/LocalPart.php b/src/Parser/LocalPart.php index d42873f..2cb54d9 100644 --- a/src/Parser/LocalPart.php +++ b/src/Parser/LocalPart.php @@ -36,12 +36,12 @@ class LocalPart extends PartParser { $this->lexer->startRecording(); - while (!$this->lexer->token->isA(EmailLexer::S_AT) && !$this->lexer->token->isA(EmailLexer::S_EMPTY)) { + while (!$this->lexer->token?->isA(EmailLexer::S_AT) && !$this->lexer->token?->isA(EmailLexer::S_EMPTY)) { if ($this->hasDotAtStart()) { - return new InvalidEmail(new DotAtStart(), $this->lexer->token->value); + return new InvalidEmail(new DotAtStart(), $this->lexer->token?->value); } - if ($this->lexer->token->isA(EmailLexer::S_DQUOTE)) { + if ($this->lexer->token?->isA(EmailLexer::S_DQUOTE)) { $dquoteParsingResult = $this->parseDoubleQuote(); //Invalid double quote parsing @@ -51,8 +51,8 @@ class LocalPart extends PartParser } if ( - $this->lexer->token->isA(EmailLexer::S_OPENPARENTHESIS) || - $this->lexer->token->isA(EmailLexer::S_CLOSEPARENTHESIS) + $this->lexer->token?->isA(EmailLexer::S_OPENPARENTHESIS) || + $this->lexer->token?->isA(EmailLexer::S_CLOSEPARENTHESIS) ) { $commentsResult = $this->parseComments(); @@ -62,15 +62,15 @@ class LocalPart extends PartParser } } - if ($this->lexer->token->isA(EmailLexer::S_DOT) && $this->lexer->isNextToken(EmailLexer::S_DOT)) { - return new InvalidEmail(new ConsecutiveDot(), $this->lexer->token->value); + if ($this->lexer->token?->isA(EmailLexer::S_DOT) && $this->lexer->isNextToken(EmailLexer::S_DOT)) { + return new InvalidEmail(new ConsecutiveDot(), $this->lexer->token?->value); } if ( - $this->lexer->token->isA(EmailLexer::S_DOT) && + $this->lexer->token?->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->token?->value); } $resultEscaping = $this->validateEscaping(); @@ -102,8 +102,8 @@ class LocalPart extends PartParser 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->token?->type])) { + return new InvalidEmail(new ExpectingATEXT('Invalid token found'), $this->lexer->token?->value); } return new ValidEmail(); } @@ -125,7 +125,7 @@ class LocalPart extends PartParser private function hasDotAtStart(): bool { - return $this->lexer->token->isA(EmailLexer::S_DOT) && $this->lexer->getPrevious()->isA(EmailLexer::S_EMPTY); + return $this->lexer->token?->isA(EmailLexer::S_DOT) && $this->lexer->getPrevious()->isA(EmailLexer::S_EMPTY); } private function parseDoubleQuote(): Result @@ -151,12 +151,12 @@ class LocalPart extends PartParser private function validateEscaping(): Result { //Backslash found - if (!$this->lexer->token->isA(EmailLexer::S_BACKSLASH)) { + if (!$this->lexer->token?->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->token?->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 35418de..e672ea5 100644 --- a/src/Parser/PartParser.php +++ b/src/Parser/PartParser.php @@ -45,8 +45,8 @@ abstract class PartParser protected function checkConsecutiveDots(): Result { - if ($this->lexer->token->isA(EmailLexer::S_DOT) && $this->lexer->isNextToken(EmailLexer::S_DOT)) { - return new InvalidEmail(new ConsecutiveDot(), $this->lexer->token->value); + if ($this->lexer->token?->isA(EmailLexer::S_DOT) && $this->lexer->isNextToken(EmailLexer::S_DOT)) { + return new InvalidEmail(new ConsecutiveDot(), $this->lexer->token?->value); } return new ValidEmail(); @@ -57,6 +57,6 @@ abstract class PartParser $previous = $this->lexer->getPrevious(); return $previous->isA(EmailLexer::S_BACKSLASH) - && !$this->lexer->token->isA(EmailLexer::GENERIC); + && !$this->lexer->token?->isA(EmailLexer::GENERIC); } } diff --git a/tests/EmailValidator/EmailLexerTest.php b/tests/EmailValidator/EmailLexerTest.php index ad0b07c..4af25e3 100644 --- a/tests/EmailValidator/EmailLexerTest.php +++ b/tests/EmailValidator/EmailLexerTest.php @@ -24,7 +24,7 @@ class EmailLexerTest extends TestCase $lexer->setInput($str); $lexer->moveNext(); $lexer->moveNext(); - $this->assertEquals($token, $lexer->token->type); + $this->assertEquals($token, $lexer->token?->type); } public function testLexerParsesMultipleSpaces() @@ -33,9 +33,9 @@ class EmailLexerTest extends TestCase $lexer->setInput(' '); $lexer->moveNext(); $lexer->moveNext(); - $this->assertEquals(EmailLexer::S_SP, $lexer->token->type); + $this->assertEquals(EmailLexer::S_SP, $lexer->token?->type); $lexer->moveNext(); - $this->assertEquals(EmailLexer::S_SP, $lexer->token->type); + $this->assertEquals(EmailLexer::S_SP, $lexer->token?->type); } /** @@ -48,7 +48,7 @@ class EmailLexerTest extends TestCase $lexer->moveNext(); $lexer->moveNext(); - $this->assertEquals(EmailLexer::INVALID, $lexer->token->type); + $this->assertEquals(EmailLexer::INVALID, $lexer->token?->type); } public function invalidUTF8CharsProvider() @@ -101,7 +101,7 @@ class EmailLexerTest extends TestCase $lexer->moveNext(); $lexer->skipUntil(EmailLexer::S_HTAB); $lexer->moveNext(); - $this->assertEquals(EmailLexer::S_HTAB, $lexer->token->type); + $this->assertEquals(EmailLexer::S_HTAB, $lexer->token?->type); } public function testLexerForUTF8() @@ -110,9 +110,9 @@ class EmailLexerTest extends TestCase $lexer->setInput("áÇ@bar.com"); $lexer->moveNext(); $lexer->moveNext(); - $this->assertEquals(EmailLexer::GENERIC, $lexer->token->type); + $this->assertEquals(EmailLexer::GENERIC, $lexer->token?->type); $lexer->moveNext(); - $this->assertEquals(EmailLexer::GENERIC, $lexer->token->type); + $this->assertEquals(EmailLexer::GENERIC, $lexer->token?->type); } public function testLexerSearchToken() From 7771e2bf2c004d76fddb565ec73e7f78689bb8ff Mon Sep 17 00:00:00 2001 From: Bastien Wermeille Date: Sun, 18 Dec 2022 22:43:52 +0100 Subject: [PATCH 06/10] Fix types issues --- src/EmailLexer.php | 19 +++--- src/EmailParser.php | 2 +- src/MessageIDParser.php | 2 +- src/Parser.php | 4 +- src/Parser/Comment.php | 16 ++--- src/Parser/CommentStrategy/DomainComment.php | 2 +- src/Parser/CommentStrategy/LocalComment.php | 2 +- src/Parser/DomainLiteral.php | 20 +++--- src/Parser/DomainPart.php | 64 ++++++++++---------- src/Parser/DoubleQuote.php | 18 +++--- src/Parser/FoldingWhiteSpace.php | 18 +++--- src/Parser/IDLeftPart.php | 2 +- src/Parser/IDRightPart.php | 4 +- src/Parser/LocalPart.php | 28 ++++----- src/Parser/PartParser.php | 6 +- src/Result/InvalidEmail.php | 3 +- src/Warning/Warning.php | 5 +- tests/EmailValidator/EmailLexerTest.php | 14 ++--- 18 files changed, 116 insertions(+), 113 deletions(-) diff --git a/src/EmailLexer.php b/src/EmailLexer.php index 0db4d06..a553f5b 100644 --- a/src/EmailLexer.php +++ b/src/EmailLexer.php @@ -135,14 +135,14 @@ class EmailLexer extends AbstractLexer /** * @var Token */ - protected $previous; + protected Token $previous; /** * The last matched/seen token. * - * @var Token|null + * @var Token */ - public Token|null $token; + public Token $current; /** * The next token in the input. @@ -154,7 +154,7 @@ class EmailLexer extends AbstractLexer /** * @var Token */ - private Token|null $nullToken; + private Token $nullToken; /** @var string */ private $accumulator = ''; @@ -168,7 +168,7 @@ class EmailLexer extends AbstractLexer $nullToken = new Token('', self::S_EMPTY, 0); $this->nullToken = $nullToken; - $this->previous = $this->token = $this->nullToken; + $this->current = $this->previous = $this->nullToken; $this->lookahead = null; } @@ -176,7 +176,7 @@ class EmailLexer extends AbstractLexer { $this->hasInvalidTokens = false; parent::reset(); - $this->previous = $this->token = $this->nullToken; + $this->current = $this->previous = $this->nullToken; } /** @@ -205,19 +205,20 @@ class EmailLexer extends AbstractLexer public function moveNext(): bool { if ($this->hasToRecord && $this->previous === $this->nullToken) { - $this->accumulator .= $this->token->value; + $this->accumulator .= $this->current->value; } - $this->previous = $this->token; + $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; diff --git a/src/EmailParser.php b/src/EmailParser.php index acb4d90..788d016 100644 --- a/src/EmailParser.php +++ b/src/EmailParser.php @@ -36,7 +36,7 @@ class EmailParser extends Parser 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(); } diff --git a/src/MessageIDParser.php b/src/MessageIDParser.php index 761667d..9df27db 100644 --- a/src/MessageIDParser.php +++ b/src/MessageIDParser.php @@ -37,7 +37,7 @@ class MessageIDParser extends Parser 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(); } diff --git a/src/Parser.php b/src/Parser.php index 993ac3f..d577e3e 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -37,7 +37,7 @@ abstract class Parser $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(); @@ -73,6 +73,6 @@ abstract class Parser $this->lexer->moveNext(); $this->lexer->moveNext(); - return !$this->lexer->token?->isA(EmailLexer::S_AT); + return !$this->lexer->current->isA(EmailLexer::S_AT); } } diff --git a/src/Parser/Comment.php b/src/Parser/Comment.php index 1032ac3..9e4ab21 100644 --- a/src/Parser/Comment.php +++ b/src/Parser/Comment.php @@ -31,15 +31,15 @@ class Comment extends PartParser public function parse(): Result { - if ($this->lexer->token?->isA(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); + return new InvalidEmail(new UnclosedComment(), $this->lexer->current->value); } } - if ($this->lexer->token?->isA(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(); @@ -58,10 +58,10 @@ class Comment extends PartParser } if ($this->openedParenthesis >= 1) { - return new InvalidEmail(new UnclosedComment(), $this->lexer->token?->value); + 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); @@ -78,7 +78,7 @@ class Comment extends PartParser private function warnEscaping(): bool { //Backslash found - if (!$this->lexer->token?->isA(EmailLexer::S_BACKSLASH)) { + if (!$this->lexer->current->isA(EmailLexer::S_BACKSLASH)) { return false; } @@ -87,7 +87,7 @@ class Comment extends PartParser } $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; } diff --git a/src/Parser/CommentStrategy/DomainComment.php b/src/Parser/CommentStrategy/DomainComment.php index edbadec..a197c27 100644 --- a/src/Parser/CommentStrategy/DomainComment.php +++ b/src/Parser/CommentStrategy/DomainComment.php @@ -23,7 +23,7 @@ class DomainComment implements CommentStrategy { //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 6efc337..5c18b44 100644 --- a/src/Parser/CommentStrategy/LocalComment.php +++ b/src/Parser/CommentStrategy/LocalComment.php @@ -24,7 +24,7 @@ class LocalComment implements CommentStrategy 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 58fed93..e99498d 100644 --- a/src/Parser/DomainLiteral.php +++ b/src/Parser/DomainLiteral.php @@ -40,14 +40,14 @@ class DomainLiteral extends PartParser $addressLiteral = ''; do { - if ($this->lexer->token?->isA(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( @@ -58,21 +58,21 @@ class DomainLiteral extends PartParser } 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?->isA(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?->isA(EmailLexer::S_IPV6TAG)) { + if ($this->lexer->current->isA(EmailLexer::S_IPV6TAG)) { $IPv6TAG = true; } - if ($this->lexer->token?->isA(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()); @@ -189,7 +189,7 @@ class DomainLiteral extends PartParser 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(); } } diff --git a/src/Parser/DomainPart.php b/src/Parser/DomainPart.php index e7d45d9..9947c42 100644 --- a/src/Parser/DomainPart.php +++ b/src/Parser/DomainPart.php @@ -50,8 +50,8 @@ class DomainPart extends PartParser return $domainChecks; } - if ($this->lexer->token?->isA(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(); @@ -69,7 +69,7 @@ class DomainPart extends PartParser $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(); @@ -79,13 +79,13 @@ class DomainPart extends PartParser { $prev = $this->lexer->getPrevious(); if ($prev->isA(EmailLexer::S_DOT)) { - return new InvalidEmail(new DotAtEnd(), $this->lexer->token?->value); + return new InvalidEmail(new DotAtEnd(), $this->lexer->current->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?->isA(EmailLexer::S_SP)) { + if ($this->lexer->current->isA(EmailLexer::S_SP)) { return new InvalidEmail(new CRLFAtTheEnd(), $prev->value); } return new ValidEmail(); @@ -103,7 +103,7 @@ class DomainPart extends PartParser return $missingDomain; } - if ($this->lexer->token?->isA(EmailLexer::S_OPENPARENTHESIS)) { + if ($this->lexer->current->isA(EmailLexer::S_OPENPARENTHESIS)) { $this->warnings[DeprecatedComment::CODE] = new DeprecatedComment(); } return new ValidEmail(); @@ -111,12 +111,12 @@ class DomainPart extends PartParser private function checkEmptyDomain(): Result { - $thereIsNoDomain = $this->lexer->token?->isA(EmailLexer::S_EMPTY) || - ($this->lexer->token?->isA(EmailLexer::S_SP) && + $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(); @@ -124,11 +124,11 @@ class DomainPart extends PartParser private function checkInvalidTokensAfterAT(): Result { - if ($this->lexer->token?->isA(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?->isA(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(); } @@ -150,14 +150,14 @@ class DomainPart extends PartParser 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?->isA(EmailLexer::S_OPENPARENTHESIS) || - $this->lexer->token?->isA(EmailLexer::S_CLOSEPARENTHESIS) + $this->lexer->current->isA(EmailLexer::S_OPENPARENTHESIS) || + $this->lexer->current->isA(EmailLexer::S_CLOSEPARENTHESIS) ) { $hasComments = true; $commentsResult = $this->parseComments(); @@ -173,7 +173,7 @@ class DomainPart extends PartParser return $dotsResult; } - if ($this->lexer->token?->isA(EmailLexer::S_OPENBRACKET)) { + if ($this->lexer->current->isA(EmailLexer::S_OPENBRACKET)) { $literalResult = $this->parseDomainLiteral(); $this->addTLDWarnings($tldMissing); @@ -190,9 +190,9 @@ class DomainPart extends PartParser return $FwsResult; } - $domain .= $this->lexer->token?->value; + $domain .= $this->lexer->current->value; - if ($this->lexer->token?->isA(EmailLexer::S_DOT) && $this->lexer->isNextToken(EmailLexer::GENERIC)) { + if ($this->lexer->current->isA(EmailLexer::S_DOT) && $this->lexer->isNextToken(EmailLexer::GENERIC)) { $tldMissing = false; } @@ -201,7 +201,7 @@ class DomainPart extends PartParser return $exceptionsResult; } $this->lexer->moveNext(); - } while (!$this->lexer->token?->isA(EmailLexer::S_EMPTY)); + } while (!$this->lexer->current->isA(EmailLexer::S_EMPTY)); $labelCheck = $this->checkLabelLength(true); if ($labelCheck->isInvalid()) { @@ -235,7 +235,7 @@ class DomainPart extends PartParser 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); @@ -252,19 +252,19 @@ class DomainPart extends PartParser */ protected function checkDomainPartExceptions(Token $prev, bool $hasComments): Result { - if ($this->lexer->token?->isA(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?->isA(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?->isA(EmailLexer::S_BACKSLASH) + $this->lexer->current->isA(EmailLexer::S_BACKSLASH) && $this->lexer->isNextToken(EmailLexer::GENERIC) ) { - return new InvalidEmail(new ExpectingATEXT('Escaping following "ATOM"'), $this->lexer->token?->value); + return new InvalidEmail(new ExpectingATEXT('Escaping following "ATOM"'), $this->lexer->current->value); } return $this->validateTokens($hasComments); @@ -283,8 +283,8 @@ class DomainPart extends PartParser $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(); @@ -292,13 +292,13 @@ class DomainPart extends PartParser private function checkLabelLength(bool $isEndOfDomain = false): Result { - if ($this->lexer->token?->isA(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(); } diff --git a/src/Parser/DoubleQuote.php b/src/Parser/DoubleQuote.php index c78978c..b96dba5 100644 --- a/src/Parser/DoubleQuote.php +++ b/src/Parser/DoubleQuote.php @@ -36,19 +36,19 @@ class DoubleQuote extends PartParser $this->lexer->moveNext(); - while (!$this->lexer->token?->isA(EmailLexer::S_DQUOTE) && !$this->lexer->token?->isA(EmailLexer::S_EMPTY)) { - 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?->isA(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); } } @@ -60,7 +60,7 @@ class DoubleQuote extends PartParser } if (!$this->lexer->isNextToken(EmailLexer::S_AT) && !$prev->isA(EmailLexer::S_BACKSLASH)) { - return new InvalidEmail(new ExpectingATEXT("Expecting ATEXT between DQUOTE"), $this->lexer->token?->value); + return new InvalidEmail(new ExpectingATEXT("Expecting ATEXT between DQUOTE"), $this->lexer->current->value); } return new ValidEmail(); @@ -72,15 +72,15 @@ class DoubleQuote extends PartParser 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 df51b8e..348a7af 100644 --- a/src/Parser/FoldingWhiteSpace.php +++ b/src/Parser/FoldingWhiteSpace.php @@ -37,16 +37,16 @@ class FoldingWhiteSpace extends PartParser return $resultCRLF; } - if ($this->lexer->token?->isA(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->isA(EmailLexer::S_AT)) { - return new InvalidEmail(new AtextAfterCFWS(), $this->lexer->token?->value); + return new InvalidEmail(new AtextAfterCFWS(), $this->lexer->current->value); } - if ($this->lexer->token?->isA(EmailLexer::S_LF) || $this->lexer->token?->isA(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->isA(EmailLexer::S_AT)) { @@ -60,17 +60,17 @@ class FoldingWhiteSpace extends PartParser protected function checkCRLFInFWS(): Result { - if (!$this->lexer->token?->isA(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(); @@ -82,6 +82,6 @@ class FoldingWhiteSpace extends PartParser 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 03c1e0d..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 6f41c68..d2fc1d7 100644 --- a/src/Parser/IDRightPart.php +++ b/src/Parser/IDRightPart.php @@ -21,8 +21,8 @@ class IDRightPart extends DomainPart 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 2cb54d9..a6087e6 100644 --- a/src/Parser/LocalPart.php +++ b/src/Parser/LocalPart.php @@ -36,12 +36,12 @@ class LocalPart extends PartParser { $this->lexer->startRecording(); - while (!$this->lexer->token?->isA(EmailLexer::S_AT) && !$this->lexer->token?->isA(EmailLexer::S_EMPTY)) { + 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?->isA(EmailLexer::S_DQUOTE)) { + if ($this->lexer->current->isA(EmailLexer::S_DQUOTE)) { $dquoteParsingResult = $this->parseDoubleQuote(); //Invalid double quote parsing @@ -51,8 +51,8 @@ class LocalPart extends PartParser } if ( - $this->lexer->token?->isA(EmailLexer::S_OPENPARENTHESIS) || - $this->lexer->token?->isA(EmailLexer::S_CLOSEPARENTHESIS) + $this->lexer->current->isA(EmailLexer::S_OPENPARENTHESIS) || + $this->lexer->current->isA(EmailLexer::S_CLOSEPARENTHESIS) ) { $commentsResult = $this->parseComments(); @@ -62,15 +62,15 @@ class LocalPart extends PartParser } } - if ($this->lexer->token?->isA(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?->isA(EmailLexer::S_DOT) && + $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(); @@ -102,8 +102,8 @@ class LocalPart extends PartParser 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(); } @@ -125,7 +125,7 @@ class LocalPart extends PartParser private function hasDotAtStart(): bool { - return $this->lexer->token?->isA(EmailLexer::S_DOT) && $this->lexer->getPrevious()->isA(EmailLexer::S_EMPTY); + return $this->lexer->current->isA(EmailLexer::S_DOT) && $this->lexer->getPrevious()->isA(EmailLexer::S_EMPTY); } private function parseDoubleQuote(): Result @@ -151,12 +151,12 @@ class LocalPart extends PartParser private function validateEscaping(): Result { //Backslash found - if (!$this->lexer->token?->isA(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 e672ea5..7034e0b 100644 --- a/src/Parser/PartParser.php +++ b/src/Parser/PartParser.php @@ -45,8 +45,8 @@ abstract class PartParser protected function checkConsecutiveDots(): Result { - if ($this->lexer->token?->isA(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(); @@ -57,6 +57,6 @@ abstract class PartParser $previous = $this->lexer->getPrevious(); return $previous->isA(EmailLexer::S_BACKSLASH) - && !$this->lexer->token?->isA(EmailLexer::GENERIC); + && !$this->lexer->current->isA(EmailLexer::GENERIC); } } diff --git a/src/Result/InvalidEmail.php b/src/Result/InvalidEmail.php index 180f4d8..4cc7a2e 100644 --- a/src/Result/InvalidEmail.php +++ b/src/Result/InvalidEmail.php @@ -38,9 +38,8 @@ class InvalidEmail implements Result return $this->reason->code(); } - public function reason() : Reason + public function reason(): Reason { return $this->reason; } - } diff --git a/src/Warning/Warning.php b/src/Warning/Warning.php index 8b39d64..c3f62f6 100644 --- a/src/Warning/Warning.php +++ b/src/Warning/Warning.php @@ -40,7 +40,10 @@ abstract class Warning return $this->rfcNumber; } - public function __toString() + /** + * @return string + */ + public function __toString(): string { return $this->message() . " rfc: " . $this->rfcNumber . "internal code: " . static::CODE; } diff --git a/tests/EmailValidator/EmailLexerTest.php b/tests/EmailValidator/EmailLexerTest.php index 4af25e3..c800e93 100644 --- a/tests/EmailValidator/EmailLexerTest.php +++ b/tests/EmailValidator/EmailLexerTest.php @@ -24,7 +24,7 @@ class EmailLexerTest extends TestCase $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 @@ class EmailLexerTest extends TestCase $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 @@ class EmailLexerTest extends TestCase $lexer->moveNext(); $lexer->moveNext(); - $this->assertEquals(EmailLexer::INVALID, $lexer->token?->type); + $this->assertEquals(EmailLexer::INVALID, $lexer->current->type); } public function invalidUTF8CharsProvider() @@ -101,7 +101,7 @@ class EmailLexerTest extends TestCase $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 @@ class EmailLexerTest extends TestCase $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() From 46654152504d025fcdde9b3f1ef1763382fe54a2 Mon Sep 17 00:00:00 2001 From: Bastien Wermeille Date: Sun, 18 Dec 2022 23:33:57 +0100 Subject: [PATCH 07/10] Fix psalm type issues info --- src/EmailLexer.php | 3 +-- src/Parser/CommentStrategy/CommentStrategy.php | 10 +++++++--- src/Parser/PartParser.php | 5 +++-- src/Result/InvalidEmail.php | 8 ++++++-- src/Validation/DNSCheckValidation.php | 8 +++++++- src/Validation/DNSGetRecordWrapper.php | 7 +++++-- src/Validation/DNSRecords.php | 15 ++++++++++----- src/Validation/MessageIDValidation.php | 6 +++++- src/Validation/MultipleValidationWithAnd.php | 5 +++-- src/Validation/RFCValidation.php | 14 +++++++++----- src/Warning/Warning.php | 5 ++++- 11 files changed, 60 insertions(+), 26 deletions(-) diff --git a/src/EmailLexer.php b/src/EmailLexer.php index a553f5b..5c3bf3a 100644 --- a/src/EmailLexer.php +++ b/src/EmailLexer.php @@ -252,8 +252,7 @@ class EmailLexer extends AbstractLexer return self::INVALID; } - - return self::GENERIC; + return self::GENERIC; } protected function isValid(string $value): bool 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 @@ namespace Egulias\EmailValidator\Parser\CommentStrategy; 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/PartParser.php b/src/Parser/PartParser.php index 7034e0b..d0ed5fd 100644 --- a/src/Parser/PartParser.php +++ b/src/Parser/PartParser.php @@ -7,11 +7,12 @@ use Egulias\EmailValidator\Result\InvalidEmail; 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 = []; @@ -28,7 +29,7 @@ abstract class PartParser abstract public function parse(): Result; /** - * @return \Egulias\EmailValidator\Warning\Warning[] + * @return Warning[] */ public function getWarnings() { diff --git a/src/Result/InvalidEmail.php b/src/Result/InvalidEmail.php index 4cc7a2e..82699ac 100644 --- a/src/Result/InvalidEmail.php +++ b/src/Result/InvalidEmail.php @@ -6,11 +6,15 @@ use Egulias\EmailValidator\Result\Reason\Reason; 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) { diff --git a/src/Validation/DNSCheckValidation.php b/src/Validation/DNSCheckValidation.php index 8350cc5..a17091f 100644 --- a/src/Validation/DNSCheckValidation.php +++ b/src/Validation/DNSCheckValidation.php @@ -9,6 +9,7 @@ use Egulias\EmailValidator\Result\Reason\LocalOrReservedDomain; 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 @@ -41,7 +44,7 @@ class DNSCheckValidation implements EmailValidation ]; /** - * @var array + * @var Warning[] */ private $warnings = []; @@ -103,6 +106,9 @@ class DNSCheckValidation implements EmailValidation return $this->error; } + /** + * @return Warning[] + */ public function getWarnings(): array { return $this->warnings; 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\EmailLexer; 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 @@ class MessageIDValidation implements EmailValidation return true; } + /** + * @return Warning[] + */ public function getWarnings(): array { return $this->warnings; diff --git a/src/Validation/MultipleValidationWithAnd.php b/src/Validation/MultipleValidationWithAnd.php index 7feb7c0..f23e84b 100644 --- a/src/Validation/MultipleValidationWithAnd.php +++ b/src/Validation/MultipleValidationWithAnd.php @@ -6,6 +6,7 @@ use Egulias\EmailValidator\EmailLexer; 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 = []; @@ -108,7 +109,7 @@ class MultipleValidationWithAnd implements EmailValidation } /** - * {@inheritdoc} + * @return Warning[] */ public function getWarnings(): array { 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\EmailLexer; 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 @@ class RFCValidation implements EmailValidation 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/Warning.php b/src/Warning/Warning.php index c3f62f6..e5b6ad8 100644 --- a/src/Warning/Warning.php +++ b/src/Warning/Warning.php @@ -4,6 +4,9 @@ namespace Egulias\EmailValidator\Warning; abstract class Warning { + /** + * @var int CODE + */ public const CODE = 0; /** @@ -45,6 +48,6 @@ abstract class Warning */ 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); } } From 4898bc2528dc77b097e3e5c03454b060b95ac477 Mon Sep 17 00:00:00 2001 From: Bastien Wermeille Date: Sun, 18 Dec 2022 23:38:43 +0100 Subject: [PATCH 08/10] Fix psalm type check --- src/Validation/DNSCheckValidation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Validation/DNSCheckValidation.php b/src/Validation/DNSCheckValidation.php index a17091f..d9ffaad 100644 --- a/src/Validation/DNSCheckValidation.php +++ b/src/Validation/DNSCheckValidation.php @@ -22,7 +22,7 @@ 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 + * @var string[] */ public const RESERVED_DNS_TOP_LEVEL_NAMES = [ // Reserved Top Level DNS Names From d25d60679bb0abf1c787cbe19394f4d603a35fa3 Mon Sep 17 00:00:00 2001 From: Bastien Wermeille Date: Wed, 28 Dec 2022 23:06:42 +0100 Subject: [PATCH 09/10] Fix readme + clean composer.json --- .travis.yml | 4 ++-- README.md | 12 ++++++------ composer.json | 20 ++++++-------------- composer.lock | 26 +++++++++++++------------- 4 files changed, 27 insertions(+), 35 deletions(-) diff --git a/.travis.yml b/.travis.yml index 36e7296..f688af3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,13 +5,13 @@ matrix: - php: 8.1 env: - psalm=yes - dist: bionic + 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 8801dab..be1647c 100644 --- a/README.md +++ b/README.md @@ -21,12 +21,12 @@ This library aims to support RFCs: **Current major version with full support is v3** -| Version | Released | EOL | Only critical bug fixes | Full | -| ------- | :--------: | :-----: | :---------------------: | :---: | -| v4.x | 2022/12/20 | - | X | X | -| 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 ## diff --git a/composer.json b/composer.json index 1f7dbe7..c41838c 100644 --- a/composer.json +++ b/composer.json @@ -1,19 +1,11 @@ { - "name": "egulias/email-validator", + "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", + "homepage": "https://github.com/egulias/EmailValidator", + "keywords": ["email", "validation", "validator", "emailvalidation", "emailvalidator"], + "license": "MIT", "authors": [ - { - "name": "Eduardo Gulias Davis" - } + {"name": "Eduardo Gulias Davis"} ], "extra": { "branch-alias": { @@ -23,7 +15,7 @@ "require": { "php": ">=8.1", "doctrine/lexer": "^3.0", - "symfony/polyfill-intl-idn": "^1.15" + "symfony/polyfill-intl-idn": "^1.26" }, "require-dev": { "php-coveralls/php-coveralls": "^2.2", diff --git a/composer.lock b/composer.lock index e3afa9d..9763ec9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3ddee5f72f898d23c46200c3b12c5a1d", + "content-hash": "e171c375692ca089d73dcdc1d451ca3a", "packages": [ { "name": "doctrine/lexer", @@ -1908,16 +1908,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.22", + "version": "9.2.23", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "e4bf60d2220b4baaa0572986b5d69870226b06df" + "reference": "9f1f0f9a2fbb680b26d1cf9b61b6eac43a6e4e9c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/e4bf60d2220b4baaa0572986b5d69870226b06df", - "reference": "e4bf60d2220b4baaa0572986b5d69870226b06df", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/9f1f0f9a2fbb680b26d1cf9b61b6eac43a6e4e9c", + "reference": "9f1f0f9a2fbb680b26d1cf9b61b6eac43a6e4e9c", "shasum": "" }, "require": { @@ -1973,7 +1973,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.22" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.23" }, "funding": [ { @@ -1981,7 +1981,7 @@ "type": "github" } ], - "time": "2022-12-18T16:40:55+00:00" + "time": "2022-12-28T12:41:10+00:00" }, { "name": "phpunit/php-file-iterator", @@ -3676,16 +3676,16 @@ }, { "name": "symfony/console", - "version": "v6.2.2", + "version": "v6.2.3", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "5a9bd5c543f00157c55face973c149957467db31" + "reference": "0f579613e771dba2dbb8211c382342a641f5da06" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/5a9bd5c543f00157c55face973c149957467db31", - "reference": "5a9bd5c543f00157c55face973c149957467db31", + "url": "https://api.github.com/repos/symfony/console/zipball/0f579613e771dba2dbb8211c382342a641f5da06", + "reference": "0f579613e771dba2dbb8211c382342a641f5da06", "shasum": "" }, "require": { @@ -3752,7 +3752,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.2.2" + "source": "https://github.com/symfony/console/tree/v6.2.3" }, "funding": [ { @@ -3768,7 +3768,7 @@ "type": "tidelift" } ], - "time": "2022-12-16T15:08:36+00:00" + "time": "2022-12-28T14:26:22+00:00" }, { "name": "symfony/deprecation-contracts", From b3a424f63d950e92609a8fba5ef31ca61c9d4e33 Mon Sep 17 00:00:00 2001 From: Bastien Wermeille Date: Thu, 29 Dec 2022 12:17:25 +0100 Subject: [PATCH 10/10] loosen constraint over lexer --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c41838c..4ead5b8 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ }, "require": { "php": ">=8.1", - "doctrine/lexer": "^3.0", + "doctrine/lexer": "^2.0 || ^3.0", "symfony/polyfill-intl-idn": "^1.26" }, "require-dev": {