From 4f54a9dd9fb85b191df683a88231533bff754eff Mon Sep 17 00:00:00 2001 From: Toon Verwerft Date: Fri, 9 Feb 2024 10:02:36 +0100 Subject: [PATCH] Upgrade to php-parser v5 --- composer.json | 2 +- composer.lock | 266 +++++++++--------- doc/tasks/phpparser.md | 12 +- spec/Parser/Php/Factory/ParserFactorySpec.php | 26 +- src/Parser/Php/Factory/ParserFactory.php | 13 +- .../ForbiddenStaticMethodCallsVisitor.php | 7 +- src/Task/PhpParser.php | 15 +- .../Php/Visitor/AbstractVisitorTest.php | 2 +- test/Unit/Task/PhpParserTest.php | 3 +- 9 files changed, 189 insertions(+), 157 deletions(-) diff --git a/composer.json b/composer.json index eb2ea7865..c1ab28756 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,7 @@ "require-dev": { "brianium/paratest": "^6.4", "composer/composer": "^2.2.6", - "nikic/php-parser": "^4.13", + "nikic/php-parser": "^5.0", "php-parallel-lint/php-parallel-lint": "^1.3", "phpspec/phpspec": "^7.2", "phpspec/prophecy-phpunit": "^2.0", diff --git a/composer.lock b/composer.lock index 3eac68aad..0d4c03787 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": "f66bba30f44224b3473fd0efb5b31b9b", + "content-hash": "9e17101685b10d7c1dcb88749d86eccf", "packages": [ { "name": "amphp/amp", @@ -229,16 +229,16 @@ }, { "name": "amphp/dns", - "version": "v2.1.0", + "version": "v2.1.1", "source": { "type": "git", "url": "https://github.com/amphp/dns.git", - "reference": "c3b518f321f26e786554480de580f06b9f34d1cd" + "reference": "3e3f413fbbaacd9632b1612941b363fa26a72e52" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/dns/zipball/c3b518f321f26e786554480de580f06b9f34d1cd", - "reference": "c3b518f321f26e786554480de580f06b9f34d1cd", + "url": "https://api.github.com/repos/amphp/dns/zipball/3e3f413fbbaacd9632b1612941b363fa26a72e52", + "reference": "3e3f413fbbaacd9632b1612941b363fa26a72e52", "shasum": "" }, "require": { @@ -246,7 +246,7 @@ "amphp/byte-stream": "^2", "amphp/cache": "^2", "amphp/parser": "^1", - "amphp/windows-registry": "^1", + "amphp/windows-registry": "^1.0.1", "daverandom/libdns": "^2.0.2", "ext-filter": "*", "php": ">=8.1", @@ -256,7 +256,7 @@ "amphp/php-cs-fixer-config": "^2", "amphp/phpunit-util": "^3", "phpunit/phpunit": "^9", - "psalm/phar": "^5.4" + "psalm/phar": "5.20" }, "type": "library", "autoload": { @@ -305,7 +305,7 @@ ], "support": { "issues": "https://github.com/amphp/dns/issues", - "source": "https://github.com/amphp/dns/tree/v2.1.0" + "source": "https://github.com/amphp/dns/tree/v2.1.1" }, "funding": [ { @@ -313,20 +313,20 @@ "type": "github" } ], - "time": "2023-11-18T15:49:57+00:00" + "time": "2024-01-30T23:25:30+00:00" }, { "name": "amphp/parallel", - "version": "v2.2.4", + "version": "v2.2.6", "source": { "type": "git", "url": "https://github.com/amphp/parallel.git", - "reference": "8b8f33a742c2ba63a8bfff664f5836c26f1996ed" + "reference": "5aeaad20297507cc754859236720501b54306eba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/parallel/zipball/8b8f33a742c2ba63a8bfff664f5836c26f1996ed", - "reference": "8b8f33a742c2ba63a8bfff664f5836c26f1996ed", + "url": "https://api.github.com/repos/amphp/parallel/zipball/5aeaad20297507cc754859236720501b54306eba", + "reference": "5aeaad20297507cc754859236720501b54306eba", "shasum": "" }, "require": { @@ -345,7 +345,7 @@ "amphp/php-cs-fixer-config": "^2", "amphp/phpunit-util": "^3", "phpunit/phpunit": "^9", - "psalm/phar": "^5.4" + "psalm/phar": "^5.18" }, "type": "library", "autoload": { @@ -388,7 +388,7 @@ ], "support": { "issues": "https://github.com/amphp/parallel/issues", - "source": "https://github.com/amphp/parallel/tree/v2.2.4" + "source": "https://github.com/amphp/parallel/tree/v2.2.6" }, "funding": [ { @@ -396,7 +396,7 @@ "type": "github" } ], - "time": "2023-11-29T04:21:30+00:00" + "time": "2024-01-07T18:12:13+00:00" }, { "name": "amphp/parser", @@ -462,28 +462,28 @@ }, { "name": "amphp/pipeline", - "version": "v1.0.0", + "version": "v1.1.0", "source": { "type": "git", "url": "https://github.com/amphp/pipeline.git", - "reference": "810dee498d2fd7d2c9247b32d95f38c92c13169e" + "reference": "8a0ecc281bb0932d6b4a786453aff18c55756e63" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/pipeline/zipball/810dee498d2fd7d2c9247b32d95f38c92c13169e", - "reference": "810dee498d2fd7d2c9247b32d95f38c92c13169e", + "url": "https://api.github.com/repos/amphp/pipeline/zipball/8a0ecc281bb0932d6b4a786453aff18c55756e63", + "reference": "8a0ecc281bb0932d6b4a786453aff18c55756e63", "shasum": "" }, "require": { "amphp/amp": "^3", "php": ">=8.1", - "revolt/event-loop": "^1 || ^0.2" + "revolt/event-loop": "^1" }, "require-dev": { "amphp/php-cs-fixer-config": "^2", "amphp/phpunit-util": "^3", "phpunit/phpunit": "^9", - "psalm/phar": "^4.12" + "psalm/phar": "^5.18" }, "type": "library", "autoload": { @@ -517,7 +517,7 @@ ], "support": { "issues": "https://github.com/amphp/pipeline/issues", - "source": "https://github.com/amphp/pipeline/tree/v1.0.0" + "source": "https://github.com/amphp/pipeline/tree/v1.1.0" }, "funding": [ { @@ -525,7 +525,7 @@ "type": "github" } ], - "time": "2022-12-22T02:13:01+00:00" + "time": "2023-12-23T04:34:28+00:00" }, { "name": "amphp/process", @@ -655,16 +655,16 @@ }, { "name": "amphp/socket", - "version": "v2.2.1", + "version": "v2.2.2", "source": { "type": "git", "url": "https://github.com/amphp/socket.git", - "reference": "88ca6d2cfec2f40b1c7beac7316a26cd916fd209" + "reference": "eb6c5e6baae5aebd9a209f50e81bff38c7efef97" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/socket/zipball/88ca6d2cfec2f40b1c7beac7316a26cd916fd209", - "reference": "88ca6d2cfec2f40b1c7beac7316a26cd916fd209", + "url": "https://api.github.com/repos/amphp/socket/zipball/eb6c5e6baae5aebd9a209f50e81bff38c7efef97", + "reference": "eb6c5e6baae5aebd9a209f50e81bff38c7efef97", "shasum": "" }, "require": { @@ -727,7 +727,7 @@ ], "support": { "issues": "https://github.com/amphp/socket/issues", - "source": "https://github.com/amphp/socket/tree/v2.2.1" + "source": "https://github.com/amphp/socket/tree/v2.2.2" }, "funding": [ { @@ -735,7 +735,7 @@ "type": "github" } ], - "time": "2023-12-16T00:08:33+00:00" + "time": "2023-12-31T18:12:01+00:00" }, { "name": "amphp/sync", @@ -814,16 +814,16 @@ }, { "name": "amphp/windows-registry", - "version": "v1.0.0", + "version": "v1.0.1", "source": { "type": "git", "url": "https://github.com/amphp/windows-registry.git", - "reference": "8248247a41af7f97b88e4716c0f8de39696ef111" + "reference": "0d569e8f256cca974e3842b6e78b4e434bf98306" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/windows-registry/zipball/8248247a41af7f97b88e4716c0f8de39696ef111", - "reference": "8248247a41af7f97b88e4716c0f8de39696ef111", + "url": "https://api.github.com/repos/amphp/windows-registry/zipball/0d569e8f256cca974e3842b6e78b4e434bf98306", + "reference": "0d569e8f256cca974e3842b6e78b4e434bf98306", "shasum": "" }, "require": { @@ -854,7 +854,7 @@ "description": "Windows Registry Reader.", "support": { "issues": "https://github.com/amphp/windows-registry/issues", - "source": "https://github.com/amphp/windows-registry/tree/v1.0.0" + "source": "https://github.com/amphp/windows-registry/tree/v1.0.1" }, "funding": [ { @@ -862,7 +862,7 @@ "type": "github" } ], - "time": "2023-01-09T22:29:20+00:00" + "time": "2024-01-30T23:01:51+00:00" }, { "name": "daverandom/libdns", @@ -996,16 +996,16 @@ }, { "name": "doctrine/deprecations", - "version": "1.1.2", + "version": "1.1.3", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931" + "reference": "dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/4f2d4f2836e7ec4e7a8625e75c6aa916004db931", - "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab", + "reference": "dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab", "shasum": "" }, "require": { @@ -1037,9 +1037,9 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/1.1.2" + "source": "https://github.com/doctrine/deprecations/tree/1.1.3" }, - "time": "2023-09-27T20:04:15+00:00" + "time": "2024-01-30T19:34:25+00:00" }, { "name": "gitonomy/gitlib", @@ -1982,16 +1982,16 @@ }, { "name": "symfony/config", - "version": "v6.4.0", + "version": "v6.4.3", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "5d33e0fb707d603330e0edfd4691803a1253572e" + "reference": "206482ff3ed450495b1d5b7bad1bc3a852def96f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/5d33e0fb707d603330e0edfd4691803a1253572e", - "reference": "5d33e0fb707d603330e0edfd4691803a1253572e", + "url": "https://api.github.com/repos/symfony/config/zipball/206482ff3ed450495b1d5b7bad1bc3a852def96f", + "reference": "206482ff3ed450495b1d5b7bad1bc3a852def96f", "shasum": "" }, "require": { @@ -2037,7 +2037,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/v6.4.0" + "source": "https://github.com/symfony/config/tree/v6.4.3" }, "funding": [ { @@ -2053,7 +2053,7 @@ "type": "tidelift" } ], - "time": "2023-11-09T08:28:32+00:00" + "time": "2024-01-29T13:26:27+00:00" }, { "name": "symfony/console", @@ -2151,16 +2151,16 @@ }, { "name": "symfony/dependency-injection", - "version": "v6.4.1", + "version": "v6.4.3", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "f88ff6428afbeb17cc648c8003bd608534750baf" + "reference": "6871811c5a5c5e180244ddb689746446db02c05b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/f88ff6428afbeb17cc648c8003bd608534750baf", - "reference": "f88ff6428afbeb17cc648c8003bd608534750baf", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/6871811c5a5c5e180244ddb689746446db02c05b", + "reference": "6871811c5a5c5e180244ddb689746446db02c05b", "shasum": "" }, "require": { @@ -2212,7 +2212,7 @@ "description": "Allows you to standardize and centralize the way objects are constructed in your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/dependency-injection/tree/v6.4.1" + "source": "https://github.com/symfony/dependency-injection/tree/v6.4.3" }, "funding": [ { @@ -2228,7 +2228,7 @@ "type": "tidelift" } ], - "time": "2023-12-01T14:56:37+00:00" + "time": "2024-01-30T08:32:12+00:00" }, { "name": "symfony/deprecation-contracts", @@ -2299,16 +2299,16 @@ }, { "name": "symfony/dotenv", - "version": "v6.4.0", + "version": "v6.4.3", "source": { "type": "git", "url": "https://github.com/symfony/dotenv.git", - "reference": "d0d584a91422ddaa2c94317200d4c4e5b935555f" + "reference": "3cb7ca997124760ed1389d5341806247670f4ef8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dotenv/zipball/d0d584a91422ddaa2c94317200d4c4e5b935555f", - "reference": "d0d584a91422ddaa2c94317200d4c4e5b935555f", + "url": "https://api.github.com/repos/symfony/dotenv/zipball/3cb7ca997124760ed1389d5341806247670f4ef8", + "reference": "3cb7ca997124760ed1389d5341806247670f4ef8", "shasum": "" }, "require": { @@ -2353,7 +2353,7 @@ "environment" ], "support": { - "source": "https://github.com/symfony/dotenv/tree/v6.4.0" + "source": "https://github.com/symfony/dotenv/tree/v6.4.3" }, "funding": [ { @@ -2369,20 +2369,20 @@ "type": "tidelift" } ], - "time": "2023-10-26T18:19:48+00:00" + "time": "2024-01-23T14:51:35+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v6.4.0", + "version": "v6.4.3", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "d76d2632cfc2206eecb5ad2b26cd5934082941b6" + "reference": "ae9d3a6f3003a6caf56acd7466d8d52378d44fef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/d76d2632cfc2206eecb5ad2b26cd5934082941b6", - "reference": "d76d2632cfc2206eecb5ad2b26cd5934082941b6", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/ae9d3a6f3003a6caf56acd7466d8d52378d44fef", + "reference": "ae9d3a6f3003a6caf56acd7466d8d52378d44fef", "shasum": "" }, "require": { @@ -2433,7 +2433,7 @@ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v6.4.0" + "source": "https://github.com/symfony/event-dispatcher/tree/v6.4.3" }, "funding": [ { @@ -2449,7 +2449,7 @@ "type": "tidelift" } ], - "time": "2023-07-27T06:52:43+00:00" + "time": "2024-01-23T14:51:35+00:00" }, { "name": "symfony/event-dispatcher-contracts", @@ -3270,16 +3270,16 @@ }, { "name": "symfony/var-exporter", - "version": "v6.4.1", + "version": "v6.4.3", "source": { "type": "git", "url": "https://github.com/symfony/var-exporter.git", - "reference": "2d08ca6b9cc704dce525615d1e6d1788734f36d9" + "reference": "a8c12b5448a5ac685347f5eeb2abf6a571ec16b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-exporter/zipball/2d08ca6b9cc704dce525615d1e6d1788734f36d9", - "reference": "2d08ca6b9cc704dce525615d1e6d1788734f36d9", + "url": "https://api.github.com/repos/symfony/var-exporter/zipball/a8c12b5448a5ac685347f5eeb2abf6a571ec16b8", + "reference": "a8c12b5448a5ac685347f5eeb2abf6a571ec16b8", "shasum": "" }, "require": { @@ -3325,7 +3325,7 @@ "serialize" ], "support": { - "source": "https://github.com/symfony/var-exporter/tree/v6.4.1" + "source": "https://github.com/symfony/var-exporter/tree/v6.4.3" }, "funding": [ { @@ -3341,20 +3341,20 @@ "type": "tidelift" } ], - "time": "2023-11-30T10:32:10+00:00" + "time": "2024-01-23T14:51:35+00:00" }, { "name": "symfony/yaml", - "version": "v6.4.0", + "version": "v6.4.3", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "4f9237a1bb42455d609e6687d2613dde5b41a587" + "reference": "d75715985f0f94f978e3a8fa42533e10db921b90" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/4f9237a1bb42455d609e6687d2613dde5b41a587", - "reference": "4f9237a1bb42455d609e6687d2613dde5b41a587", + "url": "https://api.github.com/repos/symfony/yaml/zipball/d75715985f0f94f978e3a8fa42533e10db921b90", + "reference": "d75715985f0f94f978e3a8fa42533e10db921b90", "shasum": "" }, "require": { @@ -3397,7 +3397,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v6.4.0" + "source": "https://github.com/symfony/yaml/tree/v6.4.3" }, "funding": [ { @@ -3413,7 +3413,7 @@ "type": "tidelift" } ], - "time": "2023-11-06T11:00:25+00:00" + "time": "2024-01-23T14:51:35+00:00" } ], "packages-dev": [ @@ -4211,16 +4211,16 @@ }, { "name": "fidry/cpu-core-counter", - "version": "1.0.0", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/theofidry/cpu-core-counter.git", - "reference": "85193c0b0cb5c47894b5eaec906e946f054e7077" + "reference": "f92996c4d5c1a696a6a970e20f7c4216200fcc42" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theofidry/cpu-core-counter/zipball/85193c0b0cb5c47894b5eaec906e946f054e7077", - "reference": "85193c0b0cb5c47894b5eaec906e946f054e7077", + "url": "https://api.github.com/repos/theofidry/cpu-core-counter/zipball/f92996c4d5c1a696a6a970e20f7c4216200fcc42", + "reference": "f92996c4d5c1a696a6a970e20f7c4216200fcc42", "shasum": "" }, "require": { @@ -4260,7 +4260,7 @@ ], "support": { "issues": "https://github.com/theofidry/cpu-core-counter/issues", - "source": "https://github.com/theofidry/cpu-core-counter/tree/1.0.0" + "source": "https://github.com/theofidry/cpu-core-counter/tree/1.1.0" }, "funding": [ { @@ -4268,7 +4268,7 @@ "type": "github" } ], - "time": "2023-09-17T21:38:23+00:00" + "time": "2024-02-07T09:43:46+00:00" }, { "name": "jean85/pretty-package-versions", @@ -4460,25 +4460,27 @@ }, { "name": "nikic/php-parser", - "version": "v4.18.0", + "version": "v5.0.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999" + "reference": "4a21235f7e56e713259a6f76bf4b5ea08502b9dc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1bcbb2179f97633e98bbbc87044ee2611c7d7999", - "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4a21235f7e56e713259a6f76bf4b5ea08502b9dc", + "reference": "4a21235f7e56e713259a6f76bf4b5ea08502b9dc", "shasum": "" }, "require": { + "ext-ctype": "*", + "ext-json": "*", "ext-tokenizer": "*", - "php": ">=7.0" + "php": ">=7.4" }, "require-dev": { "ircmaxell/php-yacc": "^0.0.7", - "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" }, "bin": [ "bin/php-parse" @@ -4486,7 +4488,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.9-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -4510,9 +4512,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.18.0" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.0.0" }, - "time": "2023-12-10T21:03:43+00:00" + "time": "2024-01-07T17:17:35+00:00" }, { "name": "phar-io/manifest", @@ -4794,16 +4796,16 @@ }, { "name": "phpdocumentor/type-resolver", - "version": "1.7.3", + "version": "1.8.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419" + "reference": "fad452781b3d774e3337b0c0b245dd8e5a4455fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419", - "reference": "3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/fad452781b3d774e3337b0c0b245dd8e5a4455fc", + "reference": "fad452781b3d774e3337b0c0b245dd8e5a4455fc", "shasum": "" }, "require": { @@ -4846,9 +4848,9 @@ "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.7.3" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.8.0" }, - "time": "2023-08-12T11:01:26+00:00" + "time": "2024-01-11T11:49:22+00:00" }, { "name": "phpspec/php-diff", @@ -4893,30 +4895,30 @@ }, { "name": "phpspec/phpspec", - "version": "7.4.0", + "version": "7.5.0", "source": { "type": "git", "url": "https://github.com/phpspec/phpspec.git", - "reference": "28faa87d1151a15848166226f33de61cb7107d0d" + "reference": "3613651cd36306b5eb04c0e90d197feb68d5f351" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/phpspec/zipball/28faa87d1151a15848166226f33de61cb7107d0d", - "reference": "28faa87d1151a15848166226f33de61cb7107d0d", + "url": "https://api.github.com/repos/phpspec/phpspec/zipball/3613651cd36306b5eb04c0e90d197feb68d5f351", + "reference": "3613651cd36306b5eb04c0e90d197feb68d5f351", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.5 || ^2", "ext-tokenizer": "*", - "php": "^7.3 || 8.0.* || 8.1.* || 8.2.*", + "php": "^7.3 || 8.0.* || 8.1.* || 8.2.* || 8.3.*", "phpspec/php-diff": "^1.0.0", "phpspec/prophecy": "^1.9", "sebastian/exporter": "^3.0 || ^4.0 || ^5.0", - "symfony/console": "^3.4 || ^4.4 || ^5.0 || ^6.0", - "symfony/event-dispatcher": "^3.4 || ^4.4 || ^5.0 || ^6.0", - "symfony/finder": "^3.4 || ^4.4 || ^5.0 || ^6.0", - "symfony/process": "^3.4 || ^4.4 || ^5.0 || ^6.0", - "symfony/yaml": "^3.4 || ^4.4 || ^5.0 || ^6.0" + "symfony/console": "^3.4 || ^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/event-dispatcher": "^3.4 || ^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/finder": "^3.4 || ^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/process": "^3.4 || ^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/yaml": "^3.4 || ^4.4 || ^5.0 || ^6.0 || ^7.0" }, "conflict": { "sebastian/comparator": "<1.2.4" @@ -4924,7 +4926,7 @@ "require-dev": { "behat/behat": "^3.3", "phpunit/phpunit": "^8.0 || ^9.0 || ^10.0", - "symfony/filesystem": "^3.4 || ^4.0 || ^5.0 || ^6.0", + "symfony/filesystem": "^3.4 || ^4.0 || ^5.0 || ^6.0 || ^7.0", "vimeo/psalm": "^4.3 || ^5.2" }, "suggest": { @@ -4936,7 +4938,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "7.4.x-dev" + "dev-main": "7.5.x-dev" } }, "autoload": { @@ -4976,9 +4978,9 @@ ], "support": { "issues": "https://github.com/phpspec/phpspec/issues", - "source": "https://github.com/phpspec/phpspec/tree/7.4.0" + "source": "https://github.com/phpspec/phpspec/tree/7.5.0" }, - "time": "2023-04-21T13:17:48+00:00" + "time": "2024-01-19T14:20:56+00:00" }, { "name": "phpspec/prophecy", @@ -5103,16 +5105,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.24.5", + "version": "1.25.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "fedf211ff14ec8381c9bf5714e33a7a552dd1acc" + "reference": "bd84b629c8de41aa2ae82c067c955e06f1b00240" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/fedf211ff14ec8381c9bf5714e33a7a552dd1acc", - "reference": "fedf211ff14ec8381c9bf5714e33a7a552dd1acc", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/bd84b629c8de41aa2ae82c067c955e06f1b00240", + "reference": "bd84b629c8de41aa2ae82c067c955e06f1b00240", "shasum": "" }, "require": { @@ -5144,29 +5146,29 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.5" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.25.0" }, - "time": "2023-12-16T09:33:33+00:00" + "time": "2024-01-04T17:06:16+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.29", + "version": "9.2.30", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76" + "reference": "ca2bd87d2f9215904682a9cb9bb37dda98e76089" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6a3a87ac2bbe33b25042753df8195ba4aa534c76", - "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ca2bd87d2f9215904682a9cb9bb37dda98e76089", + "reference": "ca2bd87d2f9215904682a9cb9bb37dda98e76089", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.15", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=7.3", "phpunit/php-file-iterator": "^3.0.3", "phpunit/php-text-template": "^2.0.2", @@ -5216,7 +5218,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.29" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.30" }, "funding": [ { @@ -5224,7 +5226,7 @@ "type": "github" } ], - "time": "2023-09-19T04:57:46+00:00" + "time": "2023-12-22T06:47:57+00:00" }, { "name": "phpunit/php-file-iterator", @@ -5469,16 +5471,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.15", + "version": "9.6.16", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "05017b80304e0eb3f31d90194a563fd53a6021f1" + "reference": "3767b2c56ce02d01e3491046f33466a1ae60a37f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/05017b80304e0eb3f31d90194a563fd53a6021f1", - "reference": "05017b80304e0eb3f31d90194a563fd53a6021f1", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3767b2c56ce02d01e3491046f33466a1ae60a37f", + "reference": "3767b2c56ce02d01e3491046f33466a1ae60a37f", "shasum": "" }, "require": { @@ -5552,7 +5554,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.15" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.16" }, "funding": [ { @@ -5568,7 +5570,7 @@ "type": "tidelift" } ], - "time": "2023-12-01T16:55:19+00:00" + "time": "2024-01-19T07:03:14+00:00" }, { "name": "react/promise", diff --git a/doc/tasks/phpparser.md b/doc/tasks/phpparser.md index 3d9fa2c01..6e37b6a4c 100644 --- a/doc/tasks/phpparser.md +++ b/doc/tasks/phpparser.md @@ -19,7 +19,7 @@ grumphp: tasks: phpparser: ignore_patterns: [] - kind: php7 + php_version: null visitors: {} triggered_by: [php] ``` @@ -31,13 +31,13 @@ grumphp: This is a list of patterns that will be ignored by the PHP Parser. With this option you can skip files like tests. Leave this option blank to run analysis for every php file. -**kind** +**php_version** -*Default: php7* +*Default: null* -Can be one of: php5, php7. -This option determines which Lexer the PHP_Parser uses to tokenize the PHP code. -By default, the PREFER_PHP7 is loaded. +Can be any PHP version specified as `major.minor`. For example: `8.2`. +There is a special placeholder `latest`, which will use the latest supported PHP version from php-parser. +If left empty, the system's PHP version will be picked. This is the default behaviour. **visitors** diff --git a/spec/Parser/Php/Factory/ParserFactorySpec.php b/spec/Parser/Php/Factory/ParserFactorySpec.php index 71c082fa4..2985abb32 100644 --- a/spec/Parser/Php/Factory/ParserFactorySpec.php +++ b/spec/Parser/Php/Factory/ParserFactorySpec.php @@ -16,7 +16,31 @@ function it_is_initializable() function it_can_create_a_parser_from_task_options() { - $options = ['kind' => PhpParser::KIND_PHP7]; + $options = ['php_version' => null]; $this->createFromOptions($options)->shouldBeAnInstanceOf(Parser::class); } + + function it_can_create_a_parser_from_empty_options() + { + $options = []; + $this->createFromOptions($options)->shouldBeAnInstanceOf(Parser::class); + } + + function it_can_create_a_parser_from_latest_php_version() + { + $options = ['php_version' => 'latest']; + $this->createFromOptions($options)->shouldBeAnInstanceOf(Parser::class); + } + + function it_can_create_a_parser_from_specific_latest_php_version() + { + $options = ['php_version' => '8.0']; + $this->createFromOptions($options)->shouldBeAnInstanceOf(Parser::class); + } + + function it_fails_on_invalid_version() + { + $options = ['php_version' => 'invalid']; + $this->shouldThrow(\LogicException::class)->duringCreateFromOptions($options); + } } diff --git a/src/Parser/Php/Factory/ParserFactory.php b/src/Parser/Php/Factory/ParserFactory.php index c904db568..7b8c91986 100644 --- a/src/Parser/Php/Factory/ParserFactory.php +++ b/src/Parser/Php/Factory/ParserFactory.php @@ -4,16 +4,21 @@ namespace GrumPHP\Parser\Php\Factory; -use GrumPHP\Task\PhpParser; use PhpParser\ParserFactory as PhpParserFactory; +use PhpParser\PhpVersion; class ParserFactory { public function createFromOptions(array $options): \PhpParser\Parser { - $kind = (PhpParser::KIND_PHP5 === $options['kind']) - ? PhpParserFactory::PREFER_PHP5 : PhpParserFactory::PREFER_PHP7; + $version = $options['php_version'] ?? null; - return (new PhpParserFactory())->create($kind); + return (new PhpParserFactory())->createForVersion( + match ($version) { + null => PhpVersion::getHostVersion(), + 'latest' => PhpVersion::getNewestSupported(), + default => PhpVersion::fromString($version) + } + ); } } diff --git a/src/Parser/Php/Visitor/ForbiddenStaticMethodCallsVisitor.php b/src/Parser/Php/Visitor/ForbiddenStaticMethodCallsVisitor.php index 7e4f7c50c..88b963e19 100644 --- a/src/Parser/Php/Visitor/ForbiddenStaticMethodCallsVisitor.php +++ b/src/Parser/Php/Visitor/ForbiddenStaticMethodCallsVisitor.php @@ -41,12 +41,7 @@ public function leaveNode(Node $node): void return; } - /** - * https://github.com/nikic/PHP-Parser/releases/tag/v4.16.0 - * @psalm-suppress DeprecatedProperty - */ - $class = implode('\\', $node->class->parts); - + $class = implode('\\', $node->class->getParts()); $method = $node->name; $normalized = sprintf('%s::%s', $class, $method); diff --git a/src/Task/PhpParser.php b/src/Task/PhpParser.php index e407d75ec..7fef195c6 100644 --- a/src/Task/PhpParser.php +++ b/src/Task/PhpParser.php @@ -10,16 +10,12 @@ use GrumPHP\Task\Context\RunContext; use GrumPHP\Runner\TaskResult; use GrumPHP\Runner\TaskResultInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; /** * @extends AbstractParserTask */ class PhpParser extends AbstractParserTask { - const KIND_PHP5 = 'php5'; - const KIND_PHP7 = 'php7'; - /** * @var \GrumPHP\Parser\Php\PhpParser */ @@ -30,10 +26,19 @@ public static function getConfigurableOptions(): ConfigOptionsResolver $resolver = self::sharedOptionsResolver(); $resolver->setDefaults([ 'triggered_by' => ['php'], - 'kind' => self::KIND_PHP7, + 'php_version' => null, + 'kind' => null, 'visitors' => [], ]); + $resolver->setAllowedTypes('php_version', ['string', 'null']); + $resolver->setDeprecated( + 'kind', + 'phpro/grumphp', + '2.5', + 'The option "%name%" is deprecated and replaced by the php_version option.' + ); + return ConfigOptionsResolver::fromOptionsResolver($resolver); } diff --git a/test/Unit/Parser/Php/Visitor/AbstractVisitorTest.php b/test/Unit/Parser/Php/Visitor/AbstractVisitorTest.php index 2c42fb262..b37678ab3 100644 --- a/test/Unit/Parser/Php/Visitor/AbstractVisitorTest.php +++ b/test/Unit/Parser/Php/Visitor/AbstractVisitorTest.php @@ -46,7 +46,7 @@ protected function visit($code): ParseErrorsCollection $visitor = $this->getVisitor(); $visitor->setContext($context); - $parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7); + $parser = (new ParserFactory())->createForHostVersion(); $traverser = new NodeTraverser(); $traverser->addVisitor(new NameResolver()); $traverser->addVisitor($visitor); diff --git a/test/Unit/Task/PhpParserTest.php b/test/Unit/Task/PhpParserTest.php index 55f0db0c8..95044b30c 100644 --- a/test/Unit/Task/PhpParserTest.php +++ b/test/Unit/Task/PhpParserTest.php @@ -36,10 +36,11 @@ public function provideConfigurableOptions(): iterable yield 'defaults' => [ [], [ - 'kind' => PhpParser::KIND_PHP7, 'visitors' => [], 'triggered_by' => ['php'], 'ignore_patterns' => [], + 'php_version' => null, + 'kind' => null, ] ]; }