From c1077dc6da8dbcad9158e559c0636c1d409f4138 Mon Sep 17 00:00:00 2001 From: peter279k Date: Fri, 3 Jul 2020 19:11:06 +0800 Subject: [PATCH 1/4] Upgrade cached dependencies and PHP version Original source: https://github.com/TysonAndre/tolerant-php-parser-to-php-ast/pull/16/files --- .travis.yml | 2 +- composer.json | 4 +- composer.lock | 710 ++++++++++++++++++++++++++++++-------------------- 3 files changed, 424 insertions(+), 292 deletions(-) diff --git a/.travis.yml b/.travis.yml index cdd5b22..b066dd5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ php: - 7.1 - 7.2 - 7.3 - - 7.4snapshot + - 7.4 dist: xenial diff --git a/composer.json b/composer.json index acd56ba..1d9cd3a 100644 --- a/composer.json +++ b/composer.json @@ -17,11 +17,11 @@ } }, "require": { - "php": ">=7.0", + "php": ">=7.1", "microsoft/tolerant-php-parser": "0.0.18" }, "require-dev": { - "phpunit/phpunit": "^6.4", + "phpunit/phpunit": "^7.5", "phan/phan": "^2.3.0" }, "suggest": { diff --git a/composer.lock b/composer.lock index 205988c..ff0dd3e 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": "b73b7b9b0fc7897e204151a06d4ccde2", + "content-hash": "19c08422ce0965a299029e77dbc94bb5", "packages": [ { "name": "microsoft/tolerant-php-parser", @@ -51,24 +51,23 @@ "packages-dev": [ { "name": "composer/semver", - "version": "1.5.0", + "version": "1.5.1", "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "46d9139568ccb8d9e7cdd4539cab7347568a5e2e" + "reference": "c6bea70230ef4dd483e6bbcab6005f682ed3a8de" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/46d9139568ccb8d9e7cdd4539cab7347568a5e2e", - "reference": "46d9139568ccb8d9e7cdd4539cab7347568a5e2e", + "url": "https://api.github.com/repos/composer/semver/zipball/c6bea70230ef4dd483e6bbcab6005f682ed3a8de", + "reference": "c6bea70230ef4dd483e6bbcab6005f682ed3a8de", "shasum": "" }, "require": { "php": "^5.3.2 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "^4.5 || ^5.0.5", - "phpunit/phpunit-mock-objects": "2.3.0 || ^3.0" + "phpunit/phpunit": "^4.5 || ^5.0.5" }, "type": "library", "extra": { @@ -109,28 +108,28 @@ "validation", "versioning" ], - "time": "2019-03-19T17:25:45+00:00" + "time": "2020-01-13T12:06:48+00:00" }, { "name": "composer/xdebug-handler", - "version": "1.3.3", + "version": "1.4.2", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "46867cbf8ca9fb8d60c506895449eb799db1184f" + "reference": "fa2aaf99e2087f013a14f7432c1cd2dd7d8f1f51" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/46867cbf8ca9fb8d60c506895449eb799db1184f", - "reference": "46867cbf8ca9fb8d60c506895449eb799db1184f", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/fa2aaf99e2087f013a14f7432c1cd2dd7d8f1f51", + "reference": "fa2aaf99e2087f013a14f7432c1cd2dd7d8f1f51", "shasum": "" }, "require": { - "php": "^5.3.2 || ^7.0", + "php": "^5.3.2 || ^7.0 || ^8.0", "psr/log": "^1.0" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" + "phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8" }, "type": "library", "autoload": { @@ -148,29 +147,43 @@ "email": "john-stevenson@blueyonder.co.uk" } ], - "description": "Restarts a process without xdebug.", + "description": "Restarts a process without Xdebug.", "keywords": [ "Xdebug", "performance" ], - "time": "2019-05-27T17:52:04+00:00" + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2020-06-04T11:16:35+00:00" }, { "name": "doctrine/instantiator", - "version": "1.2.0", + "version": "1.3.1", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "a2c590166b2133a4633738648b6b064edae0814a" + "reference": "f350df0268e904597e3bd9c4685c53e0e333feea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/a2c590166b2133a4633738648b6b064edae0814a", - "reference": "a2c590166b2133a4633738648b6b064edae0814a", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f350df0268e904597e3bd9c4685c53e0e333feea", + "reference": "f350df0268e904597e3bd9c4685c53e0e333feea", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.1 || ^8.0" }, "require-dev": { "doctrine/coding-standard": "^6.0", @@ -209,26 +222,40 @@ "constructor", "instantiate" ], - "time": "2019-03-17T17:37:11+00:00" + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "type": "tidelift" + } + ], + "time": "2020-05-29T17:27:14+00:00" }, { "name": "felixfbecker/advanced-json-rpc", - "version": "v3.0.4", + "version": "v3.1.1", "source": { "type": "git", "url": "https://github.com/felixfbecker/php-advanced-json-rpc.git", - "reference": "23366dd0cab0a0f3fd3016bf3c0b36dec74348e7" + "reference": "0ed363f8de17d284d479ec813c9ad3f6834b5c40" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/felixfbecker/php-advanced-json-rpc/zipball/23366dd0cab0a0f3fd3016bf3c0b36dec74348e7", - "reference": "23366dd0cab0a0f3fd3016bf3c0b36dec74348e7", + "url": "https://api.github.com/repos/felixfbecker/php-advanced-json-rpc/zipball/0ed363f8de17d284d479ec813c9ad3f6834b5c40", + "reference": "0ed363f8de17d284d479ec813c9ad3f6834b5c40", "shasum": "" }, "require": { - "netresearch/jsonmapper": "^1.0", + "netresearch/jsonmapper": "^1.0 || ^2.0", "php": ">=7.0", - "phpdocumentor/reflection-docblock": "^4.0.0" + "phpdocumentor/reflection-docblock": "^4.0.0 || ^5.0.0" }, "require-dev": { "phpunit/phpunit": "^6.0.0" @@ -250,24 +277,24 @@ } ], "description": "A more advanced JSONRPC implementation", - "time": "2019-09-12T22:41:08+00:00" + "time": "2020-03-11T15:21:41+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.9.3", + "version": "1.10.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "007c053ae6f31bba39dfa19a7726f56e9763bbea" + "reference": "969b211f9a51aa1f6c01d1d2aef56d3bd91598e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/007c053ae6f31bba39dfa19a7726f56e9763bbea", - "reference": "007c053ae6f31bba39dfa19a7726f56e9763bbea", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/969b211f9a51aa1f6c01d1d2aef56d3bd91598e5", + "reference": "969b211f9a51aa1f6c01d1d2aef56d3bd91598e5", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.1 || ^8.0" }, "replace": { "myclabs/deep-copy": "self.version" @@ -298,7 +325,13 @@ "object", "object graph" ], - "time": "2019-08-09T12:45:53+00:00" + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2020-06-29T13:22:24+00:00" }, { "name": "netresearch/jsonmapper", @@ -348,16 +381,16 @@ }, { "name": "phan/phan", - "version": "2.3.0", + "version": "2.5.0", "source": { "type": "git", "url": "https://github.com/phan/phan.git", - "reference": "cd72de4bde30606a8da3aaec7dd1b1ba365e8627" + "reference": "d458d8197b5b25bdca4c442be9a50321f0f8a15b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phan/phan/zipball/cd72de4bde30606a8da3aaec7dd1b1ba365e8627", - "reference": "cd72de4bde30606a8da3aaec7dd1b1ba365e8627", + "url": "https://api.github.com/repos/phan/phan/zipball/d458d8197b5b25bdca4c442be9a50321f0f8a15b", + "reference": "d458d8197b5b25bdca4c442be9a50321f0f8a15b", "shasum": "" }, "require": { @@ -368,13 +401,14 @@ "ext-tokenizer": "*", "felixfbecker/advanced-json-rpc": "^3.0.4", "microsoft/tolerant-php-parser": "0.0.18", + "netresearch/jsonmapper": "^1.6.0", "php": "^7.1.0", "sabre/event": "^5.0", - "symfony/console": "^2.3|^3.0|~4.0", + "symfony/console": "^2.3|^3.0|^4.0|^5.0", "symfony/polyfill-mbstring": "^1.11.0" }, "require-dev": { - "brianium/paratest": "^2.2.0", + "brianium/paratest": "^4.0.0", "phpunit/phpunit": "^7.5.0" }, "suggest": { @@ -416,26 +450,26 @@ "php", "static" ], - "time": "2019-10-14T02:32:36+00:00" + "time": "2020-02-20T14:53:46+00:00" }, { "name": "phar-io/manifest", - "version": "1.0.1", + "version": "1.0.3", "source": { "type": "git", "url": "https://github.com/phar-io/manifest.git", - "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0" + "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/2df402786ab5368a0169091f61a7c1e0eb6852d0", - "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", + "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", "shasum": "" }, "require": { "ext-dom": "*", "ext-phar": "*", - "phar-io/version": "^1.0.1", + "phar-io/version": "^2.0", "php": "^5.6 || ^7.0" }, "type": "library", @@ -471,20 +505,20 @@ } ], "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", - "time": "2017-03-05T18:14:27+00:00" + "time": "2018-07-08T19:23:20+00:00" }, { "name": "phar-io/version", - "version": "1.0.1", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/phar-io/version.git", - "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df" + "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/version/zipball/a70c0ced4be299a63d32fa96d9281d03e94041df", - "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df", + "url": "https://api.github.com/repos/phar-io/version/zipball/45a2ec53a73c70ce41d55cedef9063630abaf1b6", + "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6", "shasum": "" }, "require": { @@ -518,28 +552,25 @@ } ], "description": "Library for handling version information and constraints", - "time": "2017-03-05T17:38:23+00:00" + "time": "2018-07-08T19:19:57+00:00" }, { "name": "phpdocumentor/reflection-common", - "version": "2.0.0", + "version": "2.1.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a" + "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/63a995caa1ca9e5590304cd845c15ad6d482a62a", - "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/6568f4687e5b41b054365f9ae03fcb1ed5f2069b", + "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b", "shasum": "" }, "require": { "php": ">=7.1" }, - "require-dev": { - "phpunit/phpunit": "~6" - }, "type": "library", "extra": { "branch-alias": { @@ -570,20 +601,20 @@ "reflection", "static analysis" ], - "time": "2018-08-07T13:53:10+00:00" + "time": "2020-04-27T09:25:28+00:00" }, { "name": "phpdocumentor/reflection-docblock", - "version": "4.3.2", + "version": "4.3.4", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e" + "reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/b83ff7cfcfee7827e1e78b637a5904fe6a96698e", - "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/da3fd972d6bafd628114f7e7e036f45944b62e9c", + "reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c", "shasum": "" }, "require": { @@ -595,6 +626,7 @@ "require-dev": { "doctrine/instantiator": "^1.0.5", "mockery/mockery": "^1.0", + "phpdocumentor/type-resolver": "0.4.*", "phpunit/phpunit": "^6.4" }, "type": "library", @@ -621,7 +653,7 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2019-09-12T14:27:41+00:00" + "time": "2019-12-28T18:55:12+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -672,33 +704,33 @@ }, { "name": "phpspec/prophecy", - "version": "1.9.0", + "version": "v1.10.3", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203" + "reference": "451c3cd1418cf640de218914901e51b064abb093" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/f6811d96d97bdf400077a0cc100ae56aa32b9203", - "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093", + "reference": "451c3cd1418cf640de218914901e51b064abb093", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", - "sebastian/comparator": "^1.1|^2.0|^3.0", - "sebastian/recursion-context": "^1.0|^2.0|^3.0" + "sebastian/comparator": "^1.2.3|^2.0|^3.0|^4.0", + "sebastian/recursion-context": "^1.0|^2.0|^3.0|^4.0" }, "require-dev": { - "phpspec/phpspec": "^2.5|^3.2", + "phpspec/phpspec": "^2.5 || ^3.2", "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.8.x-dev" + "dev-master": "1.10.x-dev" } }, "autoload": { @@ -731,44 +763,44 @@ "spy", "stub" ], - "time": "2019-10-03T11:07:50+00:00" + "time": "2020-03-05T15:02:03+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "5.3.2", + "version": "6.1.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "c89677919c5dd6d3b3852f230a663118762218ac" + "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/c89677919c5dd6d3b3852f230a663118762218ac", - "reference": "c89677919c5dd6d3b3852f230a663118762218ac", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/807e6013b00af69b6c5d9ceb4282d0393dbb9d8d", + "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d", "shasum": "" }, "require": { "ext-dom": "*", "ext-xmlwriter": "*", - "php": "^7.0", - "phpunit/php-file-iterator": "^1.4.2", + "php": "^7.1", + "phpunit/php-file-iterator": "^2.0", "phpunit/php-text-template": "^1.2.1", - "phpunit/php-token-stream": "^2.0.1", + "phpunit/php-token-stream": "^3.0", "sebastian/code-unit-reverse-lookup": "^1.0.1", - "sebastian/environment": "^3.0", + "sebastian/environment": "^3.1 || ^4.0", "sebastian/version": "^2.0.1", "theseer/tokenizer": "^1.1" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^7.0" }, "suggest": { - "ext-xdebug": "^2.5.5" + "ext-xdebug": "^2.6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.3.x-dev" + "dev-master": "6.1-dev" } }, "autoload": { @@ -794,29 +826,32 @@ "testing", "xunit" ], - "time": "2018-04-06T15:36:58+00:00" + "time": "2018-10-31T16:06:48+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "1.4.5", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" + "reference": "050bedf145a257b1ff02746c31894800e5122946" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", - "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/050bedf145a257b1ff02746c31894800e5122946", + "reference": "050bedf145a257b1ff02746c31894800e5122946", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -831,7 +866,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -841,7 +876,7 @@ "filesystem", "iterator" ], - "time": "2017-11-27T13:52:08+00:00" + "time": "2018-09-13T20:33:42+00:00" }, { "name": "phpunit/php-text-template", @@ -886,28 +921,28 @@ }, { "name": "phpunit/php-timer", - "version": "1.0.9", + "version": "2.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" + "reference": "1038454804406b0b5f5f520358e78c1c2f71501e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/1038454804406b0b5f5f520358e78c1c2f71501e", + "reference": "1038454804406b0b5f5f520358e78c1c2f71501e", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "2.1-dev" } }, "autoload": { @@ -922,7 +957,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -931,33 +966,33 @@ "keywords": [ "timer" ], - "time": "2017-02-26T11:10:40+00:00" + "time": "2019-06-07T04:22:29+00:00" }, { "name": "phpunit/php-token-stream", - "version": "2.0.2", + "version": "3.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "791198a2c6254db10131eecfe8c06670700904db" + "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/791198a2c6254db10131eecfe8c06670700904db", - "reference": "791198a2c6254db10131eecfe8c06670700904db", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/995192df77f63a59e47f025390d2d1fdf8f425ff", + "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": "^7.0" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^6.2.4" + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -980,57 +1015,57 @@ "keywords": [ "tokenizer" ], - "time": "2017-11-27T05:48:46+00:00" + "time": "2019-09-17T06:23:10+00:00" }, { "name": "phpunit/phpunit", - "version": "6.5.14", + "version": "7.5.20", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "bac23fe7ff13dbdb461481f706f0e9fe746334b7" + "reference": "9467db479d1b0487c99733bb1e7944d32deded2c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/bac23fe7ff13dbdb461481f706f0e9fe746334b7", - "reference": "bac23fe7ff13dbdb461481f706f0e9fe746334b7", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9467db479d1b0487c99733bb1e7944d32deded2c", + "reference": "9467db479d1b0487c99733bb1e7944d32deded2c", "shasum": "" }, "require": { + "doctrine/instantiator": "^1.1", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", - "myclabs/deep-copy": "^1.6.1", - "phar-io/manifest": "^1.0.1", - "phar-io/version": "^1.0", - "php": "^7.0", + "myclabs/deep-copy": "^1.7", + "phar-io/manifest": "^1.0.2", + "phar-io/version": "^2.0", + "php": "^7.1", "phpspec/prophecy": "^1.7", - "phpunit/php-code-coverage": "^5.3", - "phpunit/php-file-iterator": "^1.4.3", + "phpunit/php-code-coverage": "^6.0.7", + "phpunit/php-file-iterator": "^2.0.1", "phpunit/php-text-template": "^1.2.1", - "phpunit/php-timer": "^1.0.9", - "phpunit/phpunit-mock-objects": "^5.0.9", - "sebastian/comparator": "^2.1", - "sebastian/diff": "^2.0", - "sebastian/environment": "^3.1", + "phpunit/php-timer": "^2.1", + "sebastian/comparator": "^3.0", + "sebastian/diff": "^3.0", + "sebastian/environment": "^4.0", "sebastian/exporter": "^3.1", "sebastian/global-state": "^2.0", "sebastian/object-enumerator": "^3.0.3", - "sebastian/resource-operations": "^1.0", + "sebastian/resource-operations": "^2.0", "sebastian/version": "^2.0.1" }, "conflict": { - "phpdocumentor/reflection-docblock": "3.0.2", - "phpunit/dbunit": "<3.0" + "phpunit/phpunit-mock-objects": "*" }, "require-dev": { "ext-pdo": "*" }, "suggest": { + "ext-soap": "*", "ext-xdebug": "*", - "phpunit/php-invoker": "^1.1" + "phpunit/php-invoker": "^2.0" }, "bin": [ "phpunit" @@ -1038,7 +1073,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "6.5.x-dev" + "dev-master": "7.5-dev" } }, "autoload": { @@ -1064,67 +1099,7 @@ "testing", "xunit" ], - "time": "2019-02-01T05:22:47+00:00" - }, - { - "name": "phpunit/phpunit-mock-objects", - "version": "5.0.10", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "cd1cf05c553ecfec36b170070573e540b67d3f1f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/cd1cf05c553ecfec36b170070573e540b67d3f1f", - "reference": "cd1cf05c553ecfec36b170070573e540b67d3f1f", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.5", - "php": "^7.0", - "phpunit/php-text-template": "^1.2.1", - "sebastian/exporter": "^3.1" - }, - "conflict": { - "phpunit/phpunit": "<6.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.5.11" - }, - "suggest": { - "ext-soap": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", - "keywords": [ - "mock", - "xunit" - ], - "abandoned": true, - "time": "2018-08-09T05:50:03+00:00" + "time": "2020-01-08T08:45:45+00:00" }, { "name": "psr/container", @@ -1177,16 +1152,16 @@ }, { "name": "psr/log", - "version": "1.1.0", + "version": "1.1.3", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd" + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", - "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", + "url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc", + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc", "shasum": "" }, "require": { @@ -1195,7 +1170,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.1.x-dev" } }, "autoload": { @@ -1220,28 +1195,28 @@ "psr", "psr-3" ], - "time": "2018-11-20T15:27:04+00:00" + "time": "2020-03-23T09:12:05+00:00" }, { "name": "sabre/event", - "version": "5.0.3", + "version": "5.1.0", "source": { "type": "git", "url": "https://github.com/sabre-io/event.git", - "reference": "f5cf802d240df1257866d8813282b98aee3bc548" + "reference": "d00a17507af0e7544cfe17096372f5d733e3b276" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sabre-io/event/zipball/f5cf802d240df1257866d8813282b98aee3bc548", - "reference": "f5cf802d240df1257866d8813282b98aee3bc548", + "url": "https://api.github.com/repos/sabre-io/event/zipball/d00a17507af0e7544cfe17096372f5d733e3b276", + "reference": "d00a17507af0e7544cfe17096372f5d733e3b276", "shasum": "" }, "require": { - "php": ">=7.0" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": ">=6", - "sabre/cs": "~1.0.0" + "friendsofphp/php-cs-fixer": "~2.16.1", + "phpunit/phpunit": "^7 || ^8" }, "type": "library", "autoload": { @@ -1280,7 +1255,7 @@ "reactor", "signal" ], - "time": "2018-03-05T13:55:47+00:00" + "time": "2020-01-31T18:52:29+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -1329,30 +1304,30 @@ }, { "name": "sebastian/comparator", - "version": "2.1.3", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9" + "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/34369daee48eafb2651bea869b4b15d75ccc35f9", - "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5de4fc177adf9bce8df98d8d141a7559d7ccf6da", + "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da", "shasum": "" }, "require": { - "php": "^7.0", - "sebastian/diff": "^2.0 || ^3.0", + "php": "^7.1", + "sebastian/diff": "^3.0", "sebastian/exporter": "^3.1" }, "require-dev": { - "phpunit/phpunit": "^6.4" + "phpunit/phpunit": "^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1.x-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -1389,32 +1364,33 @@ "compare", "equality" ], - "time": "2018-02-01T13:46:46+00:00" + "time": "2018-07-12T15:12:46+00:00" }, { "name": "sebastian/diff", - "version": "2.0.1", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "347c1d8b49c5c3ee30c7040ea6fc446790e6bddd" + "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/347c1d8b49c5c3ee30c7040ea6fc446790e6bddd", - "reference": "347c1d8b49c5c3ee30c7040ea6fc446790e6bddd", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/720fcc7e9b5cf384ea68d9d930d480907a0c1a29", + "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29", "shasum": "" }, "require": { - "php": "^7.0" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^6.2" + "phpunit/phpunit": "^7.5 || ^8.0", + "symfony/process": "^2 || ^3.3 || ^4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -1439,34 +1415,40 @@ "description": "Diff implementation", "homepage": "https://github.com/sebastianbergmann/diff", "keywords": [ - "diff" + "diff", + "udiff", + "unidiff", + "unified diff" ], - "time": "2017-08-03T08:09:46+00:00" + "time": "2019-02-04T06:01:07+00:00" }, { "name": "sebastian/environment", - "version": "3.1.0", + "version": "4.2.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5" + "reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/cd0871b3975fb7fc44d11314fd1ee20925fce4f5", - "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/464c90d7bdf5ad4e8a6aea15c091fec0603d4368", + "reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368", "shasum": "" }, "require": { - "php": "^7.0" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^6.1" + "phpunit/phpunit": "^7.5" + }, + "suggest": { + "ext-posix": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1.x-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -1491,7 +1473,7 @@ "environment", "hhvm" ], - "time": "2017-07-01T08:51:00+00:00" + "time": "2019-11-20T08:46:58+00:00" }, { "name": "sebastian/exporter", @@ -1758,25 +1740,25 @@ }, { "name": "sebastian/resource-operations", - "version": "1.0.0", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" + "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/4d7a795d35b889bf80a0cc04e08d77cedfa917a9", + "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9", "shasum": "" }, "require": { - "php": ">=5.6.0" + "php": "^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -1796,7 +1778,7 @@ ], "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "time": "2015-07-28T20:34:47+00:00" + "time": "2018-10-04T04:07:39+00:00" }, { "name": "sebastian/version", @@ -1843,27 +1825,29 @@ }, { "name": "symfony/console", - "version": "v4.3.5", + "version": "v4.4.10", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "929ddf360d401b958f611d44e726094ab46a7369" + "reference": "326b064d804043005526f5a0494cfb49edb59bb0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/929ddf360d401b958f611d44e726094ab46a7369", - "reference": "929ddf360d401b958f611d44e726094ab46a7369", + "url": "https://api.github.com/repos/symfony/console/zipball/326b064d804043005526f5a0494cfb49edb59bb0", + "reference": "326b064d804043005526f5a0494cfb49edb59bb0", "shasum": "" }, "require": { - "php": "^7.1.3", + "php": ">=7.1.3", "symfony/polyfill-mbstring": "~1.0", "symfony/polyfill-php73": "^1.8", - "symfony/service-contracts": "^1.1" + "symfony/polyfill-php80": "^1.15", + "symfony/service-contracts": "^1.1|^2" }, "conflict": { "symfony/dependency-injection": "<3.4", - "symfony/event-dispatcher": "<4.3", + "symfony/event-dispatcher": "<4.3|>=5", + "symfony/lock": "<4.4", "symfony/process": "<3.3" }, "provide": { @@ -1871,12 +1855,12 @@ }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~3.4|~4.0", - "symfony/dependency-injection": "~3.4|~4.0", + "symfony/config": "^3.4|^4.0|^5.0", + "symfony/dependency-injection": "^3.4|^4.0|^5.0", "symfony/event-dispatcher": "^4.3", - "symfony/lock": "~3.4|~4.0", - "symfony/process": "~3.4|~4.0", - "symfony/var-dumper": "^4.3" + "symfony/lock": "^4.4|^5.0", + "symfony/process": "^3.4|^4.0|^5.0", + "symfony/var-dumper": "^4.3|^5.0" }, "suggest": { "psr/log": "For using the console logger", @@ -1887,7 +1871,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -1914,20 +1898,34 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2019-10-07T12:36:49+00:00" + "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": "2020-05-30T20:06:45+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.12.0", + "version": "v1.17.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "550ebaac289296ce228a706d0867afc34687e3f4" + "reference": "2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/550ebaac289296ce228a706d0867afc34687e3f4", - "reference": "550ebaac289296ce228a706d0867afc34687e3f4", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d", + "reference": "2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d", "shasum": "" }, "require": { @@ -1939,7 +1937,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.12-dev" + "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -1972,20 +1974,34 @@ "polyfill", "portable" ], - "time": "2019-08-06T08:03:45+00:00" + "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": "2020-06-06T08:46:27+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.12.0", + "version": "v1.17.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17" + "reference": "7110338d81ce1cbc3e273136e4574663627037a7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/b42a2f66e8f1b15ccf25652c3424265923eb4f17", - "reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7110338d81ce1cbc3e273136e4574663627037a7", + "reference": "7110338d81ce1cbc3e273136e4574663627037a7", "shasum": "" }, "require": { @@ -1997,7 +2013,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.12-dev" + "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -2031,20 +2051,34 @@ "portable", "shim" ], - "time": "2019-08-06T08:03:45+00:00" + "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": "2020-06-06T08:46:27+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.12.0", + "version": "v1.17.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "2ceb49eaccb9352bff54d22570276bb75ba4a188" + "reference": "fa0837fe02d617d31fbb25f990655861bb27bd1a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/2ceb49eaccb9352bff54d22570276bb75ba4a188", - "reference": "2ceb49eaccb9352bff54d22570276bb75ba4a188", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fa0837fe02d617d31fbb25f990655861bb27bd1a", + "reference": "fa0837fe02d617d31fbb25f990655861bb27bd1a", "shasum": "" }, "require": { @@ -2053,7 +2087,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.12-dev" + "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -2089,20 +2127,114 @@ "portable", "shim" ], - "time": "2019-08-06T08:03:45+00:00" + "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": "2020-06-06T08:46:27+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.17.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "4a5b6bba3259902e386eb80dd1956181ee90b5b2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/4a5b6bba3259902e386eb80dd1956181ee90b5b2", + "reference": "4a5b6bba3259902e386eb80dd1956181ee90b5b2", + "shasum": "" + }, + "require": { + "php": ">=7.0.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "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": "2020-06-06T08:46:27+00:00" }, { "name": "symfony/service-contracts", - "version": "v1.1.7", + "version": "v1.1.8", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "ffcde9615dc5bb4825b9f6aed07716f1f57faae0" + "reference": "ffc7f5692092df31515df2a5ecf3b7302b3ddacf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/ffcde9615dc5bb4825b9f6aed07716f1f57faae0", - "reference": "ffcde9615dc5bb4825b9f6aed07716f1f57faae0", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/ffc7f5692092df31515df2a5ecf3b7302b3ddacf", + "reference": "ffc7f5692092df31515df2a5ecf3b7302b3ddacf", "shasum": "" }, "require": { @@ -2147,7 +2279,7 @@ "interoperability", "standards" ], - "time": "2019-09-17T11:12:18+00:00" + "time": "2019-10-14T12:27:06+00:00" }, { "name": "theseer/tokenizer", @@ -2191,31 +2323,30 @@ }, { "name": "webmozart/assert", - "version": "1.5.0", + "version": "1.9.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "88e6d84706d09a236046d686bbea96f07b3a34f4" + "reference": "9dc4f203e36f2b486149058bade43c851dd97451" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/88e6d84706d09a236046d686bbea96f07b3a34f4", - "reference": "88e6d84706d09a236046d686bbea96f07b3a34f4", + "url": "https://api.github.com/repos/webmozart/assert/zipball/9dc4f203e36f2b486149058bade43c851dd97451", + "reference": "9dc4f203e36f2b486149058bade43c851dd97451", "shasum": "" }, "require": { "php": "^5.3.3 || ^7.0", "symfony/polyfill-ctype": "^1.8" }, + "conflict": { + "phpstan/phpstan": "<0.12.20", + "vimeo/psalm": "<3.9.1" + }, "require-dev": { "phpunit/phpunit": "^4.8.36 || ^7.5.13" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, "autoload": { "psr-4": { "Webmozart\\Assert\\": "src/" @@ -2237,7 +2368,7 @@ "check", "validate" ], - "time": "2019-08-24T08:43:50+00:00" + "time": "2020-06-16T10:16:42+00:00" } ], "aliases": [], @@ -2246,10 +2377,11 @@ "prefer-stable": true, "prefer-lowest": false, "platform": { - "php": ">=7.0" + "php": ">=7.1" }, "platform-dev": [], "platform-overrides": { "php": "7.1.28" - } + }, + "plugin-api-version": "1.1.0" } From ece35ccb1374180d5d70822788a8b070f50385b1 Mon Sep 17 00:00:00 2001 From: Tyson Andre Date: Fri, 3 Jul 2020 13:06:44 -0400 Subject: [PATCH 2/4] Update composer.lock again, use php 7.2+, phan 3.0.4+ --- composer.json | 10 +- composer.lock | 458 ++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 371 insertions(+), 97 deletions(-) diff --git a/composer.json b/composer.json index 1d9cd3a..c6719f6 100644 --- a/composer.json +++ b/composer.json @@ -13,19 +13,19 @@ "config": { "sort-packages": true, "platform": { - "php": "7.1.28" + "php": "7.2.22" } }, "require": { - "php": ">=7.1", - "microsoft/tolerant-php-parser": "0.0.18" + "php": ">=7.2", + "microsoft/tolerant-php-parser": "0.0.20" }, "require-dev": { "phpunit/phpunit": "^7.5", - "phan/phan": "^2.3.0" + "phan/phan": "^3.0.4" }, "suggest": { - "ext-ast": "~1.0.1" + "ext-ast": "^1.0.6" }, "autoload": { "psr-4": {"TolerantASTConverter\\": "src/TolerantASTConverter"} diff --git a/composer.lock b/composer.lock index ff0dd3e..e3be42a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "19c08422ce0965a299029e77dbc94bb5", + "content-hash": "4f544a98b0c6b62bc359ceaca755d225", "packages": [ { "name": "microsoft/tolerant-php-parser", - "version": "v0.0.18", + "version": "v0.0.20", "source": { "type": "git", "url": "https://github.com/microsoft/tolerant-php-parser.git", - "reference": "e255aa978b45729094da2a1a6f9954044a244ff2" + "reference": "c5e2bf5d8c9f4f27eef1370bd39ea2d1f374eeb4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/microsoft/tolerant-php-parser/zipball/e255aa978b45729094da2a1a6f9954044a244ff2", - "reference": "e255aa978b45729094da2a1a6f9954044a244ff2", + "url": "https://api.github.com/repos/microsoft/tolerant-php-parser/zipball/c5e2bf5d8c9f4f27eef1370bd39ea2d1f374eeb4", + "reference": "c5e2bf5d8c9f4f27eef1370bd39ea2d1f374eeb4", "shasum": "" }, "require": { @@ -45,34 +45,35 @@ } ], "description": "Tolerant PHP-to-AST parser designed for IDE usage scenarios", - "time": "2019-07-01T02:21:00+00:00" + "time": "2020-02-18T02:57:19+00:00" } ], "packages-dev": [ { "name": "composer/semver", - "version": "1.5.1", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "c6bea70230ef4dd483e6bbcab6005f682ed3a8de" + "reference": "3426bd5efa8a12d230824536c42a8a4ad30b7940" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/c6bea70230ef4dd483e6bbcab6005f682ed3a8de", - "reference": "c6bea70230ef4dd483e6bbcab6005f682ed3a8de", + "url": "https://api.github.com/repos/composer/semver/zipball/3426bd5efa8a12d230824536c42a8a4ad30b7940", + "reference": "3426bd5efa8a12d230824536c42a8a4ad30b7940", "shasum": "" }, "require": { - "php": "^5.3.2 || ^7.0" + "php": "^5.3.2 || ^7.0 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^4.5 || ^5.0.5" + "phpstan/phpstan": "^0.12.19", + "symfony/phpunit-bridge": "^4.2 || ^5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.x-dev" + "dev-master": "3.x-dev" } }, "autoload": { @@ -108,7 +109,21 @@ "validation", "versioning" ], - "time": "2020-01-13T12:06:48+00:00" + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2020-05-26T18:22:04+00:00" }, { "name": "composer/xdebug-handler", @@ -335,16 +350,16 @@ }, { "name": "netresearch/jsonmapper", - "version": "v1.6.0", + "version": "v2.1.0", "source": { "type": "git", "url": "https://github.com/cweiske/jsonmapper.git", - "reference": "0d4d1b48d682a93b6bfedf60b88c7750e9cb0b06" + "reference": "e0f1e33a71587aca81be5cffbb9746510e1fe04e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/0d4d1b48d682a93b6bfedf60b88c7750e9cb0b06", - "reference": "0d4d1b48d682a93b6bfedf60b88c7750e9cb0b06", + "url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/e0f1e33a71587aca81be5cffbb9746510e1fe04e", + "reference": "e0f1e33a71587aca81be5cffbb9746510e1fe04e", "shasum": "" }, "require": { @@ -355,8 +370,8 @@ "php": ">=5.6" }, "require-dev": { - "phpunit/phpunit": "~4.8.35 || ~5.7 || ~6.4", - "squizlabs/php_codesniffer": "~1.5" + "phpunit/phpunit": "~4.8.35 || ~5.7 || ~6.4 || ~7.0", + "squizlabs/php_codesniffer": "~3.5" }, "type": "library", "autoload": { @@ -377,46 +392,46 @@ } ], "description": "Map nested JSON structures onto PHP classes", - "time": "2019-08-15T19:41:25+00:00" + "time": "2020-04-16T18:48:43+00:00" }, { "name": "phan/phan", - "version": "2.5.0", + "version": "3.0.4", "source": { "type": "git", "url": "https://github.com/phan/phan.git", - "reference": "d458d8197b5b25bdca4c442be9a50321f0f8a15b" + "reference": "ba01d4a56fcb2019d79dc7ce63dc0151d1cc41f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phan/phan/zipball/d458d8197b5b25bdca4c442be9a50321f0f8a15b", - "reference": "d458d8197b5b25bdca4c442be9a50321f0f8a15b", + "url": "https://api.github.com/repos/phan/phan/zipball/ba01d4a56fcb2019d79dc7ce63dc0151d1cc41f7", + "reference": "ba01d4a56fcb2019d79dc7ce63dc0151d1cc41f7", "shasum": "" }, "require": { - "composer/semver": "^1.4", + "composer/semver": "^1.4|^2.0|^3.0", "composer/xdebug-handler": "^1.3.2", "ext-filter": "*", "ext-json": "*", "ext-tokenizer": "*", "felixfbecker/advanced-json-rpc": "^3.0.4", - "microsoft/tolerant-php-parser": "0.0.18", - "netresearch/jsonmapper": "^1.6.0", - "php": "^7.1.0", + "microsoft/tolerant-php-parser": "0.0.20", + "netresearch/jsonmapper": "^1.6.0|^2.0", + "php": "^7.2.0", "sabre/event": "^5.0", "symfony/console": "^2.3|^3.0|^4.0|^5.0", "symfony/polyfill-mbstring": "^1.11.0" }, "require-dev": { "brianium/paratest": "^4.0.0", - "phpunit/phpunit": "^7.5.0" + "phpunit/phpunit": "^8.5.0" }, "suggest": { - "ext-ast": "Needed for parsing ASTs (unless --use-fallback-parser is used). 1.0.1+ is needed.", + "ext-ast": "Needed for parsing ASTs (unless --use-fallback-parser is used). 1.0.1+ is needed, 1.0.6+ is recommended.", "ext-iconv": "Either iconv or mbstring is needed to ensure issue messages are valid utf-8", "ext-igbinary": "Improves performance of polyfill when ext-ast is unavailable", "ext-mbstring": "Either iconv or mbstring is needed to ensure issue messages are valid utf-8", - "ext-tokenizer": "Needed for non-AST support and file/line-based suppressions." + "ext-tokenizer": "Needed for fallback/polyfill parser support and file/line-based suppressions." }, "bin": [ "phan", @@ -450,7 +465,7 @@ "php", "static" ], - "time": "2020-02-20T14:53:46+00:00" + "time": "2020-07-01T18:04:58+00:00" }, { "name": "phar-io/manifest", @@ -556,25 +571,25 @@ }, { "name": "phpdocumentor/reflection-common", - "version": "2.1.0", + "version": "2.2.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b" + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/6568f4687e5b41b054365f9ae03fcb1ed5f2069b", - "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", "shasum": "" }, "require": { - "php": ">=7.1" + "php": "^7.2 || ^8.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.x-dev" + "dev-2.x": "2.x-dev" } }, "autoload": { @@ -601,45 +616,42 @@ "reflection", "static analysis" ], - "time": "2020-04-27T09:25:28+00:00" + "time": "2020-06-27T09:03:43+00:00" }, { "name": "phpdocumentor/reflection-docblock", - "version": "4.3.4", + "version": "5.1.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c" + "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/da3fd972d6bafd628114f7e7e036f45944b62e9c", - "reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e", + "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e", "shasum": "" }, "require": { - "php": "^7.0", - "phpdocumentor/reflection-common": "^1.0.0 || ^2.0.0", - "phpdocumentor/type-resolver": "~0.4 || ^1.0.0", - "webmozart/assert": "^1.0" + "ext-filter": "^7.1", + "php": "^7.2", + "phpdocumentor/reflection-common": "^2.0", + "phpdocumentor/type-resolver": "^1.0", + "webmozart/assert": "^1" }, "require-dev": { - "doctrine/instantiator": "^1.0.5", - "mockery/mockery": "^1.0", - "phpdocumentor/type-resolver": "0.4.*", - "phpunit/phpunit": "^6.4" + "doctrine/instantiator": "^1", + "mockery/mockery": "^1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.x-dev" + "dev-master": "5.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] + "phpDocumentor\\Reflection\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -650,38 +662,40 @@ { "name": "Mike van Riel", "email": "me@mikevanriel.com" + }, + { + "name": "Jaap van Otterdijk", + "email": "account@ijaap.nl" } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2019-12-28T18:55:12+00:00" + "time": "2020-02-22T12:28:44+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "1.0.1", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9" + "reference": "e878a14a65245fbe78f8080eba03b47c3b705651" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", - "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e878a14a65245fbe78f8080eba03b47c3b705651", + "reference": "e878a14a65245fbe78f8080eba03b47c3b705651", "shasum": "" }, "require": { - "php": "^7.1", + "php": "^7.2 || ^8.0", "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { - "ext-tokenizer": "^7.1", - "mockery/mockery": "~1", - "phpunit/phpunit": "^7.0" + "ext-tokenizer": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.x-dev" + "dev-1.x": "1.x-dev" } }, "autoload": { @@ -700,7 +714,7 @@ } ], "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "time": "2019-08-22T18:11:29+00:00" + "time": "2020-06-27T10:12:23+00:00" }, { "name": "phpspec/prophecy", @@ -1825,42 +1839,44 @@ }, { "name": "symfony/console", - "version": "v4.4.10", + "version": "v5.1.2", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "326b064d804043005526f5a0494cfb49edb59bb0" + "reference": "34ac555a3627e324b660e318daa07572e1140123" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/326b064d804043005526f5a0494cfb49edb59bb0", - "reference": "326b064d804043005526f5a0494cfb49edb59bb0", + "url": "https://api.github.com/repos/symfony/console/zipball/34ac555a3627e324b660e318daa07572e1140123", + "reference": "34ac555a3627e324b660e318daa07572e1140123", "shasum": "" }, "require": { - "php": ">=7.1.3", + "php": ">=7.2.5", "symfony/polyfill-mbstring": "~1.0", "symfony/polyfill-php73": "^1.8", "symfony/polyfill-php80": "^1.15", - "symfony/service-contracts": "^1.1|^2" + "symfony/service-contracts": "^1.1|^2", + "symfony/string": "^5.1" }, "conflict": { - "symfony/dependency-injection": "<3.4", - "symfony/event-dispatcher": "<4.3|>=5", + "symfony/dependency-injection": "<4.4", + "symfony/dotenv": "<5.1", + "symfony/event-dispatcher": "<4.4", "symfony/lock": "<4.4", - "symfony/process": "<3.3" + "symfony/process": "<4.4" }, "provide": { "psr/log-implementation": "1.0" }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "^3.4|^4.0|^5.0", - "symfony/dependency-injection": "^3.4|^4.0|^5.0", - "symfony/event-dispatcher": "^4.3", + "symfony/config": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/event-dispatcher": "^4.4|^5.0", "symfony/lock": "^4.4|^5.0", - "symfony/process": "^3.4|^4.0|^5.0", - "symfony/var-dumper": "^4.3|^5.0" + "symfony/process": "^4.4|^5.0", + "symfony/var-dumper": "^4.4|^5.0" }, "suggest": { "psr/log": "For using the console logger", @@ -1871,7 +1887,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.1-dev" } }, "autoload": { @@ -1912,7 +1928,7 @@ "type": "tidelift" } ], - "time": "2020-05-30T20:06:45+00:00" + "time": "2020-06-15T12:59:21+00:00" }, { "name": "symfony/polyfill-ctype", @@ -1990,6 +2006,165 @@ ], "time": "2020-06-06T08:46:27+00:00" }, + { + "name": "symfony/polyfill-intl-grapheme", + "version": "v1.17.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-grapheme.git", + "reference": "6e4dbcf5e81eba86e36731f94fe56b1726835846" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/6e4dbcf5e81eba86e36731f94fe56b1726835846", + "reference": "6e4dbcf5e81eba86e36731f94fe56b1726835846", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Intl\\Grapheme\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "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 for intl's grapheme_* functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "grapheme", + "intl", + "polyfill", + "portable", + "shim" + ], + "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": "2020-06-06T08:46:27+00:00" + }, + { + "name": "symfony/polyfill-intl-normalizer", + "version": "v1.17.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-normalizer.git", + "reference": "40309d1700e8f72447bb9e7b54af756eeea35620" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/40309d1700e8f72447bb9e7b54af756eeea35620", + "reference": "40309d1700e8f72447bb9e7b54af756eeea35620", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Intl\\Normalizer\\": "" + }, + "files": [ + "bootstrap.php" + ], + "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 for intl's Normalizer class and related functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "intl", + "normalizer", + "polyfill", + "portable", + "shim" + ], + "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": "2020-06-14T14:40:37+00:00" + }, { "name": "symfony/polyfill-mbstring", "version": "v1.17.1", @@ -2225,20 +2400,20 @@ }, { "name": "symfony/service-contracts", - "version": "v1.1.8", + "version": "v2.1.2", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "ffc7f5692092df31515df2a5ecf3b7302b3ddacf" + "reference": "66a8f0957a3ca54e4f724e49028ab19d75a8918b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/ffc7f5692092df31515df2a5ecf3b7302b3ddacf", - "reference": "ffc7f5692092df31515df2a5ecf3b7302b3ddacf", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/66a8f0957a3ca54e4f724e49028ab19d75a8918b", + "reference": "66a8f0957a3ca54e4f724e49028ab19d75a8918b", "shasum": "" }, "require": { - "php": "^7.1.3", + "php": ">=7.2.5", "psr/container": "^1.0" }, "suggest": { @@ -2247,7 +2422,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-master": "2.1-dev" } }, "autoload": { @@ -2279,7 +2454,106 @@ "interoperability", "standards" ], - "time": "2019-10-14T12:27:06+00:00" + "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": "2020-05-20T17:43:50+00:00" + }, + { + "name": "symfony/string", + "version": "v5.1.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/string.git", + "reference": "ac70459db781108db7c6d8981dd31ce0e29e3298" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/string/zipball/ac70459db781108db7c6d8981dd31ce0e29e3298", + "reference": "ac70459db781108db7c6d8981dd31ce0e29e3298", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "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" + }, + "require-dev": { + "symfony/error-handler": "^4.4|^5.0", + "symfony/http-client": "^4.4|^5.0", + "symfony/translation-contracts": "^1.1|^2", + "symfony/var-exporter": "^4.4|^5.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\String\\": "" + }, + "files": [ + "Resources/functions.php" + ], + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "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 String component", + "homepage": "https://symfony.com", + "keywords": [ + "grapheme", + "i18n", + "string", + "unicode", + "utf-8", + "utf8" + ], + "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": "2020-06-11T12:16:36+00:00" }, { "name": "theseer/tokenizer", @@ -2377,11 +2651,11 @@ "prefer-stable": true, "prefer-lowest": false, "platform": { - "php": ">=7.1" + "php": ">=7.2" }, "platform-dev": [], "platform-overrides": { - "php": "7.1.28" + "php": "7.2.22" }, "plugin-api-version": "1.1.0" } From 25e9c930d06f7123ec30b944d9805d195ed3a861 Mon Sep 17 00:00:00 2001 From: Tyson Andre Date: Fri, 3 Jul 2020 13:07:01 -0400 Subject: [PATCH 3/4] Run phpcbf, sync changes with phan And update tests --- src/TolerantASTConverter/Bootstrap.php | 4 +- src/TolerantASTConverter/Cache.php | 6 +- .../InvalidNodeException.php | 4 +- src/TolerantASTConverter/NodeDumper.php | 18 +- src/TolerantASTConverter/ParseResult.php | 4 +- src/TolerantASTConverter/StringUtil.php | 16 +- .../TolerantASTConverter.php | 434 +++++++++++------- .../TolerantASTConverterWithNodeMapping.php | 44 +- src/ast_shim.php | 155 ++++--- src/echo.php | 3 - src/shim_loader.php | 44 ++ src/util.php | 12 +- test_files/src/switch.php | 6 + tests/TolerantASTConverter/ConversionTest.php | 27 +- .../TolerantASTConverterTest.php | 20 + 15 files changed, 488 insertions(+), 309 deletions(-) delete mode 100644 src/echo.php create mode 100644 src/shim_loader.php create mode 100644 tests/TolerantASTConverter/TolerantASTConverterTest.php diff --git a/src/TolerantASTConverter/Bootstrap.php b/src/TolerantASTConverter/Bootstrap.php index 2a3723f..0b76999 100644 --- a/src/TolerantASTConverter/Bootstrap.php +++ b/src/TolerantASTConverter/Bootstrap.php @@ -1,4 +1,6 @@ -include_offset = $include_offset; } @@ -68,7 +70,7 @@ public function setIncludeOffset(bool $include_offset) : void /** * Should this include the token kind (default is just the text of the token) */ - public function setIncludeTokenKind(bool $include_token_kind) : void + public function setIncludeTokenKind(bool $include_token_kind): void { $this->include_token_kind = $include_token_kind; } @@ -77,7 +79,7 @@ public function setIncludeTokenKind(bool $include_token_kind) : void * Sets the text used for indentation (e.g. 4 spaces) * @suppress PhanUnreferencedPublicMethod */ - public function setIndent(string $indent) : void + public function setIndent(string $indent): void { $this->indent = $indent; } @@ -86,7 +88,7 @@ public function setIndent(string $indent) : void * Converts the class name of $ast_node to a short string describing that class name. * Removes the common `Microsoft\\PhpParser\\` prefix */ - public static function dumpClassName(Node $ast_node) : string + public static function dumpClassName(Node $ast_node): string { $name = get_class($ast_node); if (\stripos($name, 'Microsoft\\PhpParser\\') === 0) { @@ -100,7 +102,7 @@ public static function dumpClassName(Node $ast_node) : string * Converts the class name of $token to a short string describing that class name. * Removes the common `Microsoft\\PhpParser\\` prefix */ - public static function dumpTokenClassName(Token $token) : string + public static function dumpTokenClassName(Token $token): string { $name = get_class($token); if (\stripos($name, 'Microsoft\\PhpParser\\') === 0) { @@ -115,7 +117,7 @@ public static function dumpTokenClassName(Token $token) : string * @param string $padding (to be echoed before the current node * @throws Exception for invalid $ast_node values */ - public function dumpTreeAsString($ast_node, string $key = '', string $padding = '') : string + public function dumpTreeAsString($ast_node, string $key = '', string $padding = ''): string { if ($ast_node instanceof Node) { $first_part = \sprintf( @@ -156,7 +158,7 @@ public function dumpTreeAsString($ast_node, string $key = '', string $padding = * @throws Exception for invalid $ast_node values * @suppress PhanUnreferencedPublicMethod */ - public function dumpTree($ast_node, string $key = '', string $padding = '') : void + public function dumpTree($ast_node, string $key = '', string $padding = ''): void { echo $this->dumpTreeAsString($ast_node, $key, $padding); } diff --git a/src/TolerantASTConverter/ParseResult.php b/src/TolerantASTConverter/ParseResult.php index 65aeab1..8f28ab1 100644 --- a/src/TolerantASTConverter/ParseResult.php +++ b/src/TolerantASTConverter/ParseResult.php @@ -1,4 +1,6 @@ - $matches */ - static function (array $matches) : string { + static function (array $matches): string { $str = $matches[1]; if (isset(self::REPLACEMENTS[$str])) { @@ -179,7 +181,7 @@ static function (array $matches) : string { * * @throws InvalidNodeException for invalid code points */ - private static function codePointToUtf8(int $num) : string + private static function codePointToUtf8(int $num): string { if ($num <= 0x7F) { return chr($num); @@ -202,7 +204,7 @@ private static function codePointToUtf8(int $num) : string * @param string|int|float|bool|null|array|object $value * Source: Phan\Library\StringUtil */ - public static function jsonEncode($value) : string + public static function jsonEncode($value): string { $result = \json_encode($value, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE | \JSON_PARTIAL_OUTPUT_ON_ERROR); return \is_string($result) ? $result : '(invalid data)'; diff --git a/src/TolerantASTConverter/TolerantASTConverter.php b/src/TolerantASTConverter/TolerantASTConverter.php index 5d2de0b..36787ad 100644 --- a/src/TolerantASTConverter/TolerantASTConverter.php +++ b/src/TolerantASTConverter/TolerantASTConverter.php @@ -1,4 +1,6 @@ -getText() provide optional file contents, Token->getText provide mandatory file contents -if (!class_exists('\ast\Node')) { - require_once __DIR__ . '/../ast_shim.php'; -} +require_once dirname(__DIR__) . '/shim_loader.php'; /** * Source: https://github.com/TysonAndre/tolerant-php-parser-to-php-ast @@ -105,13 +109,12 @@ class TolerantASTConverter { // The latest stable version of php-ast. // For something != 70, update the library's release. - const AST_VERSION = 70; + public const AST_VERSION = 70; // The versions that this supports - // TODO: Also enable support for version 60 once there is a stable 1.0.0 release. (Issue #2038) - const SUPPORTED_AST_VERSIONS = [self::AST_VERSION]; + public const SUPPORTED_AST_VERSIONS = [self::AST_VERSION]; - const _IGNORED_STRING_TOKEN_KIND_SET = [ + private const _IGNORED_STRING_TOKEN_KIND_SET = [ TokenKind::OpenBraceDollarToken => true, TokenKind::OpenBraceToken => true, TokenKind::DollarOpenBraceToken => true, @@ -120,11 +123,11 @@ class TolerantASTConverter // If this environment variable is set, this will throw. // (For debugging, may be removed in the future) - const ENV_AST_THROW_INVALID = 'AST_THROW_INVALID'; + public const ENV_AST_THROW_INVALID = 'AST_THROW_INVALID'; - const INCOMPLETE_CLASS_CONST = '__INCOMPLETE_CLASS_CONST__'; - const INCOMPLETE_PROPERTY = '__INCOMPLETE_PROPERTY__'; - const INCOMPLETE_VARIABLE = '__INCOMPLETE_VARIABLE__'; + public const INCOMPLETE_CLASS_CONST = '__INCOMPLETE_CLASS_CONST__'; + public const INCOMPLETE_PROPERTY = '__INCOMPLETE_PROPERTY__'; + public const INCOMPLETE_VARIABLE = '__INCOMPLETE_VARIABLE__'; /** * @var int - A version in SUPPORTED_AST_VERSIONS @@ -163,7 +166,7 @@ public function __construct() * Controls whether this should add placeholders for nodes that couldn't be parsed * (enabled for code completion) */ - public function setShouldAddPlaceholders(bool $value) : void + public function setShouldAddPlaceholders(bool $value): void { $this->instance_should_add_placeholders = $value; } @@ -172,7 +175,7 @@ public function setShouldAddPlaceholders(bool $value) : void * Records the PHP major+minor version id (70100, 70200, etc.) * that this polyfill should emulate the behavior of php-ast for. */ - public function setPHPVersionId(int $value) : void + public function setPHPVersionId(int $value): void { $this->instance_php_version_id_parsing = $value; } @@ -184,7 +187,7 @@ public function setPHPVersionId(int $value) : void * @param ?Cache $cache * @throws InvalidArgumentException if the requested AST version is invalid. */ - public function parseCodeAsPHPAST(string $file_contents, int $version, array &$errors = [], Cache $cache = null) : \ast\Node + public function parseCodeAsPHPAST(string $file_contents, int $version, array &$errors = [], Cache $cache = null): \ast\Node { if (!\in_array($version, self::SUPPORTED_AST_VERSIONS, true)) { throw new \InvalidArgumentException(sprintf("Unexpected version: want %s, got %d", \implode(', ', self::SUPPORTED_AST_VERSIONS), $version)); @@ -212,17 +215,39 @@ public function parseCodeAsPHPAST(string $file_contents, int $version, array &$e * @param Diagnostic[] &$errors @phan-output-reference * @throws InvalidArgumentException if the requested AST version is invalid. */ - public function parseCodeAsPHPASTUncached(string $file_contents, int $version, array &$errors = []) : \ast\Node + public function parseCodeAsPHPASTUncached(string $file_contents, int $version, array &$errors = []): \ast\Node { - // Aside: this can be implemented as a stub. $parser_node = static::phpParserParse($file_contents, $errors); - return $this->phpParserToPhpast($parser_node, $version, $file_contents); + try { + return $this->phpParserToPhpast($parser_node, $version, $file_contents); + } finally { + // Remove object reference cycles manually to free memory - automatic cyclic garbage collection is disabled for performance in older php 7 versions. + self::unlinkDescendantNodes($parser_node); + } + } + + /** + * Unlink the nodes manually to free memory (or to exclude them from var_export()) + * + * Automatic cyclic garbage collection is disabled for performance in older php 7 versions. + */ + public static function unlinkDescendantNodes(SourceFileNode $root): void + { + // Avoid creating cyclic data structures. + // Node->getRoot() requires a valid parent node path to a SourceFileNode because it needs getDocCommentText() to work. + $placeholder_root = new SourceFileNode(); + $placeholder_root->fileContents = $root->fileContents; + + foreach ($root->getDescendantNodes() as $descendant) { + $descendant->parent = $placeholder_root; + } + $root->parent = null; } /** * @param Diagnostic[] &$errors @phan-output-reference (TODO: param-out) */ - public static function phpParserParse(string $file_contents, array &$errors = []) : PhpParser\Node + public static function phpParserParse(string $file_contents, array &$errors = []): PhpParser\Node\SourceFileNode { $parser = new Parser(); // TODO: In php 7.3, we might need to provide a version, due to small changes in lexing? $result = $parser->parseSourceFile($file_contents); @@ -238,7 +263,7 @@ public static function phpParserParse(string $file_contents, array &$errors = [] * @param string $file_contents * @throws InvalidArgumentException if the provided AST version isn't valid */ - public function phpParserToPhpast(PhpParser\Node $parser_node, int $ast_version, string $file_contents) : \ast\Node + public function phpParserToPhpast(PhpParser\Node $parser_node, int $ast_version, string $file_contents): \ast\Node { if (!\in_array($ast_version, self::SUPPORTED_AST_VERSIONS, true)) { throw new \InvalidArgumentException(sprintf("Unexpected version: want %s, got %d", implode(', ', self::SUPPORTED_AST_VERSIONS), $ast_version)); @@ -249,7 +274,7 @@ public function phpParserToPhpast(PhpParser\Node $parser_node, int $ast_version, return $stmts; } - protected function startParsing(string $file_contents) : void + protected function startParsing(string $file_contents): void { self::$decl_id = 0; self::$should_add_placeholders = $this->instance_should_add_placeholders; @@ -264,7 +289,7 @@ protected function startParsing(string $file_contents) : void * @param null|bool|int|string|PhpParser\Node|Token|(PhpParser\Node|Token)[] $n * @throws Exception if node is invalid */ - protected static function debugDumpNodeOrToken($n) : string + protected static function debugDumpNodeOrToken($n): string { if (\is_scalar($n)) { return var_export($n, true); @@ -290,7 +315,7 @@ protected static function debugDumpNodeOrToken($n) : string * Throws RuntimeException|Exception if the statement list is invalid * @suppress PhanThrowTypeAbsentForCall|PhanThrowTypeMismatchForCall */ - private static function phpParserStmtlistToAstNode($parser_nodes, ?int $lineno, bool $return_null_on_empty = false) : ?\ast\Node + private static function phpParserStmtlistToAstNode($parser_nodes, ?int $lineno, bool $return_null_on_empty = false): ?\ast\Node { if ($parser_nodes instanceof PhpParser\Node\Statement\CompoundStatementNode) { $parser_nodes = $parser_nodes->statements; @@ -320,7 +345,6 @@ private static function phpParserStmtlistToAstNode($parser_nodes, ?int $lineno, $children = []; foreach ($parser_nodes as $parser_node) { try { - // @phan-suppress-next-line PhanPossiblyNullTypeArgument $child_node = static::phpParserNodeToAstNode($parser_node); } catch (InvalidNodeException $_) { continue; @@ -346,7 +370,7 @@ private static function phpParserStmtlistToAstNode($parser_nodes, ?int $lineno, return new ast\Node(ast\AST_STMT_LIST, 0, $children, $lineno ?? 0); } - private static function phpParserExprListToExprList(PhpParser\Node\DelimitedList\ExpressionList $expressions_list, int $lineno) : ast\Node + private static function phpParserExprListToExprList(PhpParser\Node\DelimitedList\ExpressionList $expressions_list, int $lineno): ast\Node { $children = []; $expressions_children = $expressions_list->children; @@ -397,7 +421,7 @@ protected static function phpParserNonValueNodeToAstNode($n) * @throws InvalidArgumentException for invalid node classes * @throws Error if the environment variable AST_THROW_INVALID is set (for debugging) */ - $fallback_closure = static function ($n, int $unused_start_line) : \ast\Node { + $fallback_closure = static function ($n, int $unused_start_line): \ast\Node { if (!($n instanceof PhpParser\Node) && !($n instanceof Token)) { // @phan-suppress-next-line PhanThrowTypeMismatchForCall debugDumpNodeOrToken can throw throw new \InvalidArgumentException("Invalid type for node: " . (\is_object($n) ? \get_class($n) : \gettype($n)) . ": " . static::debugDumpNodeOrToken($n)); @@ -444,7 +468,7 @@ protected static function phpParserNodeToAstNode($n) * @throws InvalidArgumentException|Exception for invalid node classes * @throws Error if the environment variable AST_THROW_INVALID is set to debug. */ - $fallback_closure = static function ($n, int $unused_start_line) : \ast\Node { + $fallback_closure = static function ($n, int $unused_start_line): \ast\Node { if (!($n instanceof PhpParser\Node) && !($n instanceof Token)) { throw new \InvalidArgumentException("Invalid type for node: " . (\is_object($n) ? \get_class($n) : \gettype($n)) . ": " . static::debugDumpNodeOrToken($n)); } @@ -465,7 +489,7 @@ protected static function phpParserNodeToAstNode($n) * @param PhpParser\Node|Token $n * @throws InvalidNodeException if this was called on an unexpected type */ - final protected static function getStartLine($n) : int + final protected static function getStartLine($n): int { if (\is_object($n)) { return self::$file_position_map->getStartLine($n); @@ -477,7 +501,7 @@ final protected static function getStartLine($n) : int * @param ?PhpParser\Node|?Token $n * @throws InvalidNodeException if this was called on an unexpected type */ - final protected static function getEndLine($n) : int + final protected static function getEndLine($n): int { if (!\is_object($n)) { if (\is_null($n)) { @@ -498,11 +522,11 @@ final protected static function getEndLine($n) : int * * @return array */ - protected static function initHandleMap() : array + protected static function initHandleMap(): array { $closures = [ /** @return ?ast\Node */ - 'Microsoft\PhpParser\Node\SourceFileNode' => static function (PhpParser\Node\SourceFileNode $n, int $start_line) : ?\ast\Node { + 'Microsoft\PhpParser\Node\SourceFileNode' => static function (PhpParser\Node\SourceFileNode $n, int $start_line): ?\ast\Node { return static::phpParserStmtlistToAstNode($n->statementList, $start_line, false); }, /** @return mixed */ @@ -534,7 +558,7 @@ protected static function initHandleMap() : array } }, /** @return ?ast\Node */ - 'Microsoft\PhpParser\Node\Expression\AssignmentExpression' => static function (PhpParser\Node\Expression\AssignmentExpression $n, int $start_line) : ?\ast\Node { + 'Microsoft\PhpParser\Node\Expression\AssignmentExpression' => static function (PhpParser\Node\Expression\AssignmentExpression $n, int $start_line): ?\ast\Node { try { $var_node = static::phpParserNodeToAstNode($n->leftOperand); } catch (InvalidNodeException $_) { @@ -600,6 +624,7 @@ protected static function initHandleMap() : array TokenKind::SlashEqualsToken => flags\BINARY_DIV, TokenKind::GreaterThanGreaterThanEqualsToken => flags\BINARY_SHIFT_RIGHT, TokenKind::LessThanLessThanEqualsToken => flags\BINARY_SHIFT_LEFT, + TokenKind::QuestionQuestionEqualsToken => flags\BINARY_COALESCE, ]; $kind = $n->operator->kind; if ($kind === TokenKind::InstanceOfKeyword) { @@ -618,7 +643,7 @@ protected static function initHandleMap() : array } return static::astNodeBinaryop($ast_kind, $n, $start_line); }, - 'Microsoft\PhpParser\Node\Expression\UnaryOpExpression' => static function (PhpParser\Node\Expression\UnaryOpExpression $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Expression\UnaryOpExpression' => static function (PhpParser\Node\Expression\UnaryOpExpression $n, int $start_line): ast\Node { static $lookup = [ TokenKind::TildeToken => flags\UNARY_BITWISE_NOT, TokenKind::MinusToken => flags\UNARY_MINUS, @@ -637,7 +662,7 @@ protected static function initHandleMap() : array $start_line ); }, - 'Microsoft\PhpParser\Node\Expression\CastExpression' => static function (PhpParser\Node\Expression\CastExpression $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Expression\CastExpression' => static function (PhpParser\Node\Expression\CastExpression $n, int $start_line): ast\Node { static $lookup = [ // From Parser->parseCastExpression() TokenKind::ArrayCastToken => flags\TYPE_ARRAY, @@ -662,6 +687,7 @@ protected static function initHandleMap() : array TokenKind::RealReservedWord => flags\TYPE_DOUBLE, TokenKind::StringReservedWord => flags\TYPE_STRING, TokenKind::UnsetKeyword => flags\TYPE_NULL, + TokenKind::StaticKeyword => flags\TYPE_STATIC, ]; $kind = $n->castType->kind; $ast_kind = $lookup[$kind] ?? null; @@ -678,8 +704,8 @@ protected static function initHandleMap() : array 'Microsoft\PhpParser\Node\Expression\AnonymousFunctionCreationExpression' => static function ( PhpParser\Node\Expression\AnonymousFunctionCreationExpression $n, int $start_line - ) : ast\Node { - $ast_return_type = static::phpParserTypeToAstNode($n->returnType, static::getEndLine($n->returnType) ?: $start_line); + ): ast\Node { + $ast_return_type = static::phpParserUnionTypeToAstNode($n->returnType, $n->otherReturnTypes, static::getEndLine($n->returnType) ?: $start_line); if (($ast_return_type->children['name'] ?? null) === '') { $ast_return_type = null; } @@ -702,8 +728,8 @@ protected static function initHandleMap() : array 'Microsoft\PhpParser\Node\Expression\ArrowFunctionCreationExpression' => static function ( PhpParser\Node\Expression\ArrowFunctionCreationExpression $n, int $start_line - ) : ast\Node { - $ast_return_type = static::phpParserTypeToAstNode($n->returnType, static::getEndLine($n->returnType) ?: $start_line); + ): ast\Node { + $ast_return_type = static::phpParserUnionTypeToAstNode($n->returnType, $n->otherReturnTypes, static::getEndLine($n->returnType) ?: $start_line); if (($ast_return_type->children['name'] ?? null) === '') { $ast_return_type = null; } @@ -734,7 +760,7 @@ protected static function initHandleMap() : array /** * @throws InvalidNodeException if the resulting AST would not be analyzable by Phan */ - 'Microsoft\PhpParser\Node\Expression\ScopedPropertyAccessExpression' => static function (PhpParser\Node\Expression\ScopedPropertyAccessExpression $n, int $start_line) : ?\ast\Node { + 'Microsoft\PhpParser\Node\Expression\ScopedPropertyAccessExpression' => static function (PhpParser\Node\Expression\ScopedPropertyAccessExpression $n, int $start_line): ?\ast\Node { $member_name = $n->memberName; if ($member_name instanceof PhpParser\Node\Expression\Variable) { try { @@ -770,13 +796,13 @@ protected static function initHandleMap() : array // E.g. Node\Expression\BracedExpression throw new InvalidNodeException(); } - return static::phpParserClassconstfetchToAstClassconstfetch($n->scopeResolutionQualifier, $member_name, $start_line); + return static::phpParserClassConstFetchToAstClassConstFetch($n->scopeResolutionQualifier, $member_name, $start_line); } }, - 'Microsoft\PhpParser\Node\Expression\CloneExpression' => static function (PhpParser\Node\Expression\CloneExpression $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Expression\CloneExpression' => static function (PhpParser\Node\Expression\CloneExpression $n, int $start_line): ast\Node { return new ast\Node(ast\AST_CLONE, 0, ['expr' => static::phpParserNodeToAstNode($n->expression)], $start_line); }, - 'Microsoft\PhpParser\Node\Expression\ErrorControlExpression' => static function (PhpParser\Node\Expression\ErrorControlExpression $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Expression\ErrorControlExpression' => static function (PhpParser\Node\Expression\ErrorControlExpression $n, int $start_line): ast\Node { return new ast\Node( ast\AST_UNARY_OP, flags\UNARY_SILENCE, @@ -784,10 +810,10 @@ protected static function initHandleMap() : array $start_line ); }, - 'Microsoft\PhpParser\Node\Expression\EmptyIntrinsicExpression' => static function (PhpParser\Node\Expression\EmptyIntrinsicExpression $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Expression\EmptyIntrinsicExpression' => static function (PhpParser\Node\Expression\EmptyIntrinsicExpression $n, int $start_line): ast\Node { return new ast\Node(ast\AST_EMPTY, 0, ['expr' => static::phpParserNodeToAstNode($n->expression)], $start_line); }, - 'Microsoft\PhpParser\Node\Expression\EvalIntrinsicExpression' => static function (PhpParser\Node\Expression\EvalIntrinsicExpression $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Expression\EvalIntrinsicExpression' => static function (PhpParser\Node\Expression\EvalIntrinsicExpression $n, int $start_line): ast\Node { return new ast\Node( ast\AST_INCLUDE_OR_EVAL, flags\EXEC_EVAL, @@ -807,21 +833,21 @@ protected static function initHandleMap() : array /** * @throws InvalidNodeException */ - 'Microsoft\PhpParser\MissingToken' => static function (PhpParser\MissingToken $unused_node, int $_) : void { + 'Microsoft\PhpParser\MissingToken' => static function (PhpParser\MissingToken $unused_node, int $_): void { throw new InvalidNodeException(); }, /** * @throws InvalidNodeException */ - 'Microsoft\PhpParser\SkippedToken' => static function (PhpParser\SkippedToken $unused_node, int $_) : void { + 'Microsoft\PhpParser\SkippedToken' => static function (PhpParser\SkippedToken $unused_node, int $_): void { throw new InvalidNodeException(); }, - 'Microsoft\PhpParser\Node\Expression\ExitIntrinsicExpression' => static function (PhpParser\Node\Expression\ExitIntrinsicExpression $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Expression\ExitIntrinsicExpression' => static function (PhpParser\Node\Expression\ExitIntrinsicExpression $n, int $start_line): ast\Node { $expression = $n->expression; $expr_node = $expression !== null ? static::phpParserNodeToAstNode($expression) : null; return new ast\Node(ast\AST_EXIT, 0, ['expr' => $expr_node], $start_line); }, - 'Microsoft\PhpParser\Node\Expression\CallExpression' => static function (PhpParser\Node\Expression\CallExpression $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Expression\CallExpression' => static function (PhpParser\Node\Expression\CallExpression $n, int $start_line): ast\Node { $callable_expression = $n->callableExpression; $arg_list = static::phpParserArgListToAstArgList($n->argumentExpressionList, $start_line); if ($callable_expression instanceof PhpParser\Node\Expression\MemberAccessExpression) { // $a->f() @@ -846,7 +872,7 @@ protected static function initHandleMap() : array ); } }, - 'Microsoft\PhpParser\Node\Expression\ScriptInclusionExpression' => static function (PhpParser\Node\Expression\ScriptInclusionExpression $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Expression\ScriptInclusionExpression' => static function (PhpParser\Node\Expression\ScriptInclusionExpression $n, int $start_line): ast\Node { // @phan-suppress-next-line PhanThrowTypeAbsentForCall should not happen $flags = static::phpParserIncludeTokenToAstIncludeFlags($n->requireOrIncludeKeyword); return new ast\Node( @@ -859,7 +885,7 @@ protected static function initHandleMap() : array /** * @return ?ast\Node */ - 'Microsoft\PhpParser\Node\Expression\IssetIntrinsicExpression' => static function (PhpParser\Node\Expression\IssetIntrinsicExpression $n, int $start_line) : ?\ast\Node { + 'Microsoft\PhpParser\Node\Expression\IssetIntrinsicExpression' => static function (PhpParser\Node\Expression\IssetIntrinsicExpression $n, int $start_line): ?\ast\Node { $ast_issets = []; foreach ($n->expressions->children ?? [] as $var) { if ($var instanceof Token) { @@ -889,13 +915,13 @@ protected static function initHandleMap() : array } return $e; }, - 'Microsoft\PhpParser\Node\Expression\ArrayCreationExpression' => static function (PhpParser\Node\Expression\ArrayCreationExpression $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Expression\ArrayCreationExpression' => static function (PhpParser\Node\Expression\ArrayCreationExpression $n, int $start_line): ast\Node { return static::phpParserArrayToAstArray($n, $start_line); }, - 'Microsoft\PhpParser\Node\Expression\ListIntrinsicExpression' => static function (PhpParser\Node\Expression\ListIntrinsicExpression $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Expression\ListIntrinsicExpression' => static function (PhpParser\Node\Expression\ListIntrinsicExpression $n, int $start_line): ast\Node { return static::phpParserListToAstList($n, $start_line); }, - 'Microsoft\PhpParser\Node\Expression\ObjectCreationExpression' => static function (PhpParser\Node\Expression\ObjectCreationExpression $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Expression\ObjectCreationExpression' => static function (PhpParser\Node\Expression\ObjectCreationExpression $n, int $start_line): ast\Node { $end_line = static::getEndLine($n); $class_type_designator = $n->classTypeDesignator; if ($class_type_designator instanceof Token && $class_type_designator->kind === TokenKind::ClassKeyword) { @@ -923,17 +949,17 @@ protected static function initHandleMap() : array 'Microsoft\PhpParser\Node\Expression\ParenthesizedExpression' => static function (PhpParser\Node\Expression\ParenthesizedExpression $n, int $_) { return static::phpParserNodeToAstNode($n->expression); }, - 'Microsoft\PhpParser\Node\Expression\PrefixUpdateExpression' => static function (PhpParser\Node\Expression\PrefixUpdateExpression $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Expression\PrefixUpdateExpression' => static function (PhpParser\Node\Expression\PrefixUpdateExpression $n, int $start_line): ast\Node { $type = $n->incrementOrDecrementOperator->kind === TokenKind::PlusPlusToken ? ast\AST_PRE_INC : ast\AST_PRE_DEC; return new ast\Node($type, 0, ['var' => static::phpParserNodeToAstNode($n->operand)], $start_line); }, - 'Microsoft\PhpParser\Node\Expression\PostfixUpdateExpression' => static function (PhpParser\Node\Expression\PostfixUpdateExpression $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Expression\PostfixUpdateExpression' => static function (PhpParser\Node\Expression\PostfixUpdateExpression $n, int $start_line): ast\Node { $type = $n->incrementOrDecrementOperator->kind === TokenKind::PlusPlusToken ? ast\AST_POST_INC : ast\AST_POST_DEC; return new ast\Node($type, 0, ['var' => static::phpParserNodeToAstNode($n->operand)], $start_line); }, - 'Microsoft\PhpParser\Node\Expression\PrintIntrinsicExpression' => static function (PhpParser\Node\Expression\PrintIntrinsicExpression $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Expression\PrintIntrinsicExpression' => static function (PhpParser\Node\Expression\PrintIntrinsicExpression $n, int $start_line): ast\Node { return new ast\Node( ast\AST_PRINT, 0, @@ -942,10 +968,10 @@ protected static function initHandleMap() : array ); }, /** @return ?ast\Node */ - 'Microsoft\PhpParser\Node\Expression\MemberAccessExpression' => static function (PhpParser\Node\Expression\MemberAccessExpression $n, int $start_line) : ?\ast\Node { + 'Microsoft\PhpParser\Node\Expression\MemberAccessExpression' => static function (PhpParser\Node\Expression\MemberAccessExpression $n, int $start_line): ?\ast\Node { return static::phpParserMemberAccessExpressionToAstProp($n, $start_line); }, - 'Microsoft\PhpParser\Node\Expression\TernaryExpression' => static function (TernaryExpression $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Expression\TernaryExpression' => static function (TernaryExpression $n, int $start_line): ast\Node { $n = self::normalizeTernaryExpression($n); $is_parenthesized = $n->parent instanceof PhpParser\Node\Expression\ParenthesizedExpression; $result = new ast\Node( @@ -966,11 +992,10 @@ protected static function initHandleMap() : array return $result; }, /** - * @return ?ast\Node * @throws InvalidNodeException if the variable would be unanalyzable * TODO: Consider ${''} as a placeholder instead? */ - 'Microsoft\PhpParser\Node\Expression\Variable' => static function (PhpParser\Node\Expression\Variable $n, int $start_line) : ?\ast\Node { + 'Microsoft\PhpParser\Node\Expression\Variable' => static function (PhpParser\Node\Expression\Variable $n, int $start_line): \ast\Node { $name_node = $n->name; // Note: there are 2 different ways to handle an Error. 1. Add a placeholder. 2. remove all of the statements in that tree. if ($name_node instanceof PhpParser\Node) { @@ -998,7 +1023,7 @@ protected static function initHandleMap() : array 'Microsoft\PhpParser\Node\Expression\BracedExpression' => static function (PhpParser\Node\Expression\BracedExpression $n, int $_) { return static::phpParserNodeToAstNode($n->expression); }, - 'Microsoft\PhpParser\Node\Expression\YieldExpression' => static function (PhpParser\Node\Expression\YieldExpression $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Expression\YieldExpression' => static function (PhpParser\Node\Expression\YieldExpression $n, int $start_line): ast\Node { $kind = $n->yieldOrYieldFromKeyword->kind === TokenKind::YieldFromKeyword ? ast\AST_YIELD_FROM : ast\AST_YIELD; $array_element = $n->arrayElement; @@ -1024,7 +1049,7 @@ protected static function initHandleMap() : array $start_line ); }, - 'Microsoft\PhpParser\Node\ReservedWord' => static function (PhpParser\Node\ReservedWord $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\ReservedWord' => static function (PhpParser\Node\ReservedWord $n, int $start_line): ast\Node { return new ast\Node( ast\AST_NAME, flags\NAME_NOT_FQ, @@ -1032,17 +1057,17 @@ protected static function initHandleMap() : array $start_line ); }, - 'Microsoft\PhpParser\Node\QualifiedName' => static function (PhpParser\Node\QualifiedName $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\QualifiedName' => static function (PhpParser\Node\QualifiedName $n, int $start_line): ast\Node { $name_parts = $n->nameParts; if (\count($name_parts) === 1) { $part = $name_parts[0]; '@phan-var Token $part'; $imploded_parts = static::tokenToString($part); if ($part->kind === TokenKind::Name) { - if (\preg_match('@^__(LINE|FILE|DIR|FUNCTION|CLASS|TRAIT|METHOD|NAMESPACE)__$@i', $imploded_parts) > 0) { + if (\preg_match('@^__(LINE|FILE|DIR|FUNCTION|CLASS|TRAIT|METHOD|NAMESPACE)__$@iD', $imploded_parts) > 0) { return new ast\Node( ast\AST_MAGIC_CONST, - self::_MAGIC_CONST_LOOKUP[\strtoupper($imploded_parts)], + self::MAGIC_CONST_LOOKUP[\strtoupper($imploded_parts)], [], self::getStartLine($part) ); @@ -1060,7 +1085,7 @@ protected static function initHandleMap() : array } return new ast\Node(ast\AST_NAME, $ast_kind, ['name' => $imploded_parts], $start_line); }, - 'Microsoft\PhpParser\Node\Parameter' => static function (PhpParser\Node\Parameter $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Parameter' => static function (PhpParser\Node\Parameter $n, int $start_line): ast\Node { $type_line = static::getEndLine($n->typeDeclaration) ?: $start_line; $default = $n->default; $default_node = $default !== null ? static::phpParserNodeToAstNode($default) : null; @@ -1068,7 +1093,7 @@ protected static function initHandleMap() : array $n->questionToken !== null, $n->byRefToken !== null, $n->dotDotDotToken !== null, - static::phpParserTypeToAstNode($n->typeDeclaration, $type_line), + static::phpParserUnionTypeToAstNode($n->typeDeclaration, $n->otherTypeDeclarations, $type_line), static::variableTokenToString($n->variableName), $default_node, $start_line @@ -1077,10 +1102,27 @@ protected static function initHandleMap() : array /** @return int|float */ 'Microsoft\PhpParser\Node\NumericLiteral' => static function (PhpParser\Node\NumericLiteral $n, int $_) { // Support php 7.4 numeric literal separators. Ignore `_`. - $text = \str_replace('_', '', static::tokenToString($n->children)); + $n = $n->children; + $text = \str_replace('_', '', static::tokenToString($n)); + if (($n->kind ?? null) === TokenKind::IntegerLiteralToken) { $as_int = \filter_var($text, FILTER_VALIDATE_INT, FILTER_FLAG_ALLOW_OCTAL | FILTER_FLAG_ALLOW_HEX); if ($as_int !== false) { return $as_int; + } + if (\preg_match('/^0[0-7]+$/D', $text)) { + // this is octal - FILTER_VALIDATE_FLOAT would treat it like decimal + return \intval($text, 8); + } + } + if ($text[0] === '0' && !\preg_match('/[.eE]/', $text)) { + $c = $text[1]; + if ($c === 'b' || $c === 'B') { + return \bindec($text); + } + if ($c === 'x' || $c === 'X') { + return \hexdec($text); + } + return \octdec(substr($text, 0, \strcspn($text, '89'))); } return (float)$text; }, @@ -1105,11 +1147,10 @@ protected static function initHandleMap() : array } return $inner_node; }, - /** @return mixed - Can return a node or a scalar, depending on the settings */ + /** @return list - Can return a node or a scalar, depending on the settings */ 'Microsoft\PhpParser\Node\Statement\CompoundStatementNode' => static function (PhpParser\Node\Statement\CompoundStatementNode $n, int $_) { $children = []; foreach ($n->statements as $parser_node) { - // @phan-suppress-next-line PhanPossiblyNullTypeArgument $child_node = static::phpParserNodeToAstNode($parser_node); if (\is_array($child_node)) { // EchoExpression returns multiple children. @@ -1136,7 +1177,7 @@ protected static function initHandleMap() : array } return static::phpParserNodeToAstNode($n->expression); }, - 'Microsoft\PhpParser\Node\Statement\BreakOrContinueStatement' => static function (PhpParser\Node\Statement\BreakOrContinueStatement $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Statement\BreakOrContinueStatement' => static function (PhpParser\Node\Statement\BreakOrContinueStatement $n, int $start_line): ast\Node { $kind = $n->breakOrContinueKeyword->kind === TokenKind::ContinueKeyword ? ast\AST_CONTINUE : ast\AST_BREAK; $breakout_level = $n->breakoutLevel; if ($breakout_level !== null) { @@ -1147,7 +1188,7 @@ protected static function initHandleMap() : array } return new ast\Node($kind, 0, ['depth' => $breakout_level], $start_line); }, - 'Microsoft\PhpParser\Node\CatchClause' => static function (PhpParser\Node\CatchClause $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\CatchClause' => static function (PhpParser\Node\CatchClause $n, int $start_line): ast\Node { $qualified_name = $n->qualifiedName; $catch_inner_list = []; // Handle `catch()` syntax error @@ -1170,7 +1211,7 @@ protected static function initHandleMap() : array $start_line ); }, - 'Microsoft\PhpParser\Node\Statement\InterfaceDeclaration' => static function (PhpParser\Node\Statement\InterfaceDeclaration $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Statement\InterfaceDeclaration' => static function (PhpParser\Node\Statement\InterfaceDeclaration $n, int $start_line): ast\Node { $end_line = static::getEndLine($n) ?: $start_line; return static::astStmtClass( flags\CLASS_INTERFACE, @@ -1183,7 +1224,7 @@ protected static function initHandleMap() : array $n->getDocCommentText() ); }, - 'Microsoft\PhpParser\Node\Statement\ClassDeclaration' => static function (PhpParser\Node\Statement\ClassDeclaration $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Statement\ClassDeclaration' => static function (PhpParser\Node\Statement\ClassDeclaration $n, int $start_line): ast\Node { $end_line = static::getEndLine($n); $base_class = $n->classBaseClause->baseClass ?? null; return static::astStmtClass( @@ -1197,7 +1238,7 @@ protected static function initHandleMap() : array $n->getDocCommentText() ); }, - 'Microsoft\PhpParser\Node\Statement\TraitDeclaration' => static function (PhpParser\Node\Statement\TraitDeclaration $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Statement\TraitDeclaration' => static function (PhpParser\Node\Statement\TraitDeclaration $n, int $start_line): ast\Node { $end_line = static::getEndLine($n) ?: $start_line; return static::astStmtClass( flags\CLASS_TRAIT, @@ -1210,7 +1251,7 @@ protected static function initHandleMap() : array $n->getDocCommentText() ); }, - 'Microsoft\PhpParser\Node\ClassConstDeclaration' => static function (PhpParser\Node\ClassConstDeclaration $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\ClassConstDeclaration' => static function (PhpParser\Node\ClassConstDeclaration $n, int $start_line): ast\Node { return static::phpParserClassConstToAstNode($n, $start_line); }, /** @return null - A stub that will be removed by the caller. */ @@ -1221,9 +1262,9 @@ protected static function initHandleMap() : array /** * @throws InvalidNodeException */ - 'Microsoft\PhpParser\Node\MethodDeclaration' => static function (PhpParser\Node\MethodDeclaration $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\MethodDeclaration' => static function (PhpParser\Node\MethodDeclaration $n, int $start_line): ast\Node { $statements = $n->compoundStatementOrSemicolon; - $ast_return_type = static::phpParserTypeToAstNode($n->returnType, static::getEndLine($n->returnType) ?: $start_line); + $ast_return_type = static::phpParserUnionTypeToAstNode($n->returnType, $n->otherReturnTypes, static::getEndLine($n->returnType) ?: $start_line); if (($ast_return_type->children['name'] ?? null) === '') { $ast_return_type = null; } @@ -1255,10 +1296,10 @@ protected static function initHandleMap() : array self::nextDeclId() ); }, - 'Microsoft\PhpParser\Node\Statement\ConstDeclaration' => static function (PhpParser\Node\Statement\ConstDeclaration $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Statement\ConstDeclaration' => static function (PhpParser\Node\Statement\ConstDeclaration $n, int $start_line): ast\Node { return static::phpParserConstToAstNode($n, $start_line); }, - 'Microsoft\PhpParser\Node\Statement\DeclareStatement' => static function (PhpParser\Node\Statement\DeclareStatement $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Statement\DeclareStatement' => static function (PhpParser\Node\Statement\DeclareStatement $n, int $start_line): ast\Node { $doc_comment = $n->getDocCommentText(); $directive = $n->declareDirective; if (!($directive instanceof PhpParser\Node\DeclareDirective)) { @@ -1270,7 +1311,7 @@ protected static function initHandleMap() : array $start_line ); }, - 'Microsoft\PhpParser\Node\Statement\DoStatement' => static function (PhpParser\Node\Statement\DoStatement $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Statement\DoStatement' => static function (PhpParser\Node\Statement\DoStatement $n, int $start_line): ast\Node { return new ast\Node( ast\AST_DO_WHILE, 0, @@ -1302,14 +1343,14 @@ protected static function initHandleMap() : array /** * @return ?ast\Node */ - 'Microsoft\PhpParser\Node\ForeachKey' => static function (PhpParser\Node\ForeachKey $n, int $_) : ?\ast\Node { + 'Microsoft\PhpParser\Node\ForeachKey' => static function (PhpParser\Node\ForeachKey $n, int $_): ?\ast\Node { $result = static::phpParserNodeToAstNode($n->expression); if (!$result instanceof ast\Node) { return null; } return $result; }, - 'Microsoft\PhpParser\Node\Statement\ForeachStatement' => static function (PhpParser\Node\Statement\ForeachStatement $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Statement\ForeachStatement' => static function (PhpParser\Node\Statement\ForeachStatement $n, int $start_line): ast\Node { $foreach_value = $n->foreachValue; $value = static::phpParserNodeToAstNode($foreach_value->expression); if ($foreach_value->ampersand) { @@ -1334,16 +1375,16 @@ protected static function initHandleMap() : array ); //return static::phpParserStmtlistToAstNode($n->statements, $start_line); }, - 'Microsoft\PhpParser\Node\FinallyClause' => static function (PhpParser\Node\FinallyClause $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\FinallyClause' => static function (PhpParser\Node\FinallyClause $n, int $start_line): ast\Node { // @phan-suppress-next-line PhanTypeMismatchReturnNullable return_null_on_empty is false. return static::phpParserStmtlistToAstNode($n->compoundStatement, $start_line, false); }, /** * @throws InvalidNodeException */ - 'Microsoft\PhpParser\Node\Statement\FunctionDeclaration' => static function (PhpParser\Node\Statement\FunctionDeclaration $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Statement\FunctionDeclaration' => static function (PhpParser\Node\Statement\FunctionDeclaration $n, int $start_line): ast\Node { $end_line = static::getEndLine($n) ?: $start_line; - $ast_return_type = static::phpParserTypeToAstNode($n->returnType, static::getEndLine($n->returnType) ?: $start_line); + $ast_return_type = static::phpParserUnionTypeToAstNode($n->returnType, $n->otherReturnTypes, static::getEndLine($n->returnType) ?: $start_line); if (($ast_return_type->children['name'] ?? null) === '') { $ast_return_type = null; } @@ -1377,7 +1418,7 @@ protected static function initHandleMap() : array } return \count($global_nodes) === 1 ? $global_nodes[0] : $global_nodes; }, - 'Microsoft\PhpParser\Node\Statement\IfStatementNode' => static function (PhpParser\Node\Statement\IfStatementNode $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Statement\IfStatementNode' => static function (PhpParser\Node\Statement\IfStatementNode $n, int $start_line): ast\Node { return static::phpParserIfStmtToAstIfStmt($n, $start_line); }, /** @return ast\Node|ast\Node[] */ @@ -1394,7 +1435,7 @@ protected static function initHandleMap() : array ); }, /** @suppress PhanTypeMismatchArgument TODO: Make ForStatement have more accurate docs? */ - 'Microsoft\PhpParser\Node\Statement\ForStatement' => static function (PhpParser\Node\Statement\ForStatement $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Statement\ForStatement' => static function (PhpParser\Node\Statement\ForStatement $n, int $start_line): ast\Node { return new ast\Node( ast\AST_FOR, 0, @@ -1408,7 +1449,7 @@ protected static function initHandleMap() : array ); }, /** @return ast\Node[] */ - 'Microsoft\PhpParser\Node\Statement\NamespaceUseDeclaration' => static function (PhpParser\Node\Statement\NamespaceUseDeclaration $n, int $start_line) : array { + 'Microsoft\PhpParser\Node\Statement\NamespaceUseDeclaration' => static function (PhpParser\Node\Statement\NamespaceUseDeclaration $n, int $start_line): array { $use_clauses = $n->useClauses; $results = []; $parser_use_kind = $n->functionOrConst->kind ?? null; @@ -1420,7 +1461,7 @@ protected static function initHandleMap() : array } return $results; }, - 'Microsoft\PhpParser\Node\Statement\NamespaceDefinition' => static function (PhpParser\Node\Statement\NamespaceDefinition $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Statement\NamespaceDefinition' => static function (PhpParser\Node\Statement\NamespaceDefinition $n, int $start_line): ast\Node { $stmt = $n->compoundStatementOrSemicolon; $name_node = $n->name; if ($stmt instanceof PhpParser\Node) { @@ -1441,14 +1482,14 @@ protected static function initHandleMap() : array ); }, /** @return array{} */ - 'Microsoft\PhpParser\Node\Statement\EmptyStatement' => static function (PhpParser\Node\Statement\EmptyStatement $unused_node, int $unused_start_line) : array { + 'Microsoft\PhpParser\Node\Statement\EmptyStatement' => static function (PhpParser\Node\Statement\EmptyStatement $unused_node, int $unused_start_line): array { // `;;` return []; }, - 'Microsoft\PhpParser\Node\PropertyDeclaration' => static function (PhpParser\Node\PropertyDeclaration $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\PropertyDeclaration' => static function (PhpParser\Node\PropertyDeclaration $n, int $start_line): ast\Node { return static::phpParserPropertyToAstNode($n, $start_line); }, - 'Microsoft\PhpParser\Node\Statement\ReturnStatement' => static function (PhpParser\Node\Statement\ReturnStatement $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Statement\ReturnStatement' => static function (PhpParser\Node\Statement\ReturnStatement $n, int $start_line): ast\Node { $e = $n->expression; $expr_node = $e !== null ? static::phpParserNodeToAstNode($e) : null; return new ast\Node(ast\AST_RETURN, 0, ['expr' => $expr_node], $start_line); @@ -1473,10 +1514,10 @@ protected static function initHandleMap() : array } return \count($static_nodes) === 1 ? $static_nodes[0] : $static_nodes; }, - 'Microsoft\PhpParser\Node\Statement\SwitchStatementNode' => static function (PhpParser\Node\Statement\SwitchStatementNode $n, int $_) : ast\Node { + 'Microsoft\PhpParser\Node\Statement\SwitchStatementNode' => static function (PhpParser\Node\Statement\SwitchStatementNode $n, int $_): ast\Node { return static::phpParserSwitchListToAstSwitch($n); }, - 'Microsoft\PhpParser\Node\Statement\ThrowStatement' => static function (PhpParser\Node\Statement\ThrowStatement $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Statement\ThrowStatement' => static function (PhpParser\Node\Statement\ThrowStatement $n, int $start_line): ast\Node { return new ast\Node( ast\AST_THROW, 0, @@ -1485,7 +1526,7 @@ protected static function initHandleMap() : array ); }, - 'Microsoft\PhpParser\Node\TraitUseClause' => static function (PhpParser\Node\TraitUseClause $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\TraitUseClause' => static function (PhpParser\Node\TraitUseClause $n, int $start_line): ast\Node { $clauses_list_node = $n->traitSelectAndAliasClauses; if ($clauses_list_node instanceof PhpParser\Node\DelimitedList\TraitSelectOrAliasClauseList) { $adaptations_inner = []; @@ -1519,7 +1560,7 @@ protected static function initHandleMap() : array /** * @return ?ast\Node */ - 'Microsoft\PhpParser\Node\TraitSelectOrAliasClause' => static function (PhpParser\Node\TraitSelectOrAliasClause $n, int $start_line) : ?\ast\Node { + 'Microsoft\PhpParser\Node\TraitSelectOrAliasClause' => static function (PhpParser\Node\TraitSelectOrAliasClause $n, int $start_line): ?\ast\Node { // FIXME targetName phpdoc is wrong. $name = $n->name; if ($n->asOrInsteadOfKeyword->kind === TokenKind::InsteadOfKeyword) { @@ -1574,7 +1615,7 @@ protected static function initHandleMap() : array return new ast\Node(ast\AST_TRAIT_ALIAS, $flags, $children, $start_line); } }, - 'Microsoft\PhpParser\Node\Statement\TryStatement' => static function (PhpParser\Node\Statement\TryStatement $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Statement\TryStatement' => static function (PhpParser\Node\Statement\TryStatement $n, int $start_line): ast\Node { $finally_clause = $n->finallyClause; return static::astNodeTry( // @phan-suppress-next-line PhanTypeMismatchArgumentNullable return_null_on_empty is false. @@ -1596,7 +1637,7 @@ protected static function initHandleMap() : array } return \count($stmts) === 1 ? $stmts[0] : $stmts; }, - 'Microsoft\PhpParser\Node\Statement\WhileStatement' => static function (PhpParser\Node\Statement\WhileStatement $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Statement\WhileStatement' => static function (PhpParser\Node\Statement\WhileStatement $n, int $start_line): ast\Node { return static::astNodeWhile( static::phpParserNodeToAstNode($n->expression), // @phan-suppress-next-line PhanTypeMismatchArgumentNullable return_null_on_empty is false. @@ -1604,11 +1645,11 @@ protected static function initHandleMap() : array $start_line ); }, - 'Microsoft\PhpParser\Node\Statement\GotoStatement' => static function (PhpParser\Node\Statement\GotoStatement $n, int $start_line) : ast\Node { + 'Microsoft\PhpParser\Node\Statement\GotoStatement' => static function (PhpParser\Node\Statement\GotoStatement $n, int $start_line): ast\Node { return new ast\Node(ast\AST_GOTO, 0, ['label' => static::tokenToString($n->name)], $start_line); }, /** @return ast\Node[] */ - 'Microsoft\PhpParser\Node\Statement\NamedLabelStatement' => static function (PhpParser\Node\Statement\NamedLabelStatement $n, int $start_line) : array { + 'Microsoft\PhpParser\Node\Statement\NamedLabelStatement' => static function (PhpParser\Node\Statement\NamedLabelStatement $n, int $start_line): array { $label = new ast\Node(ast\AST_LABEL, 0, ['name' => static::tokenToString($n->name)], $start_line); $statement = static::phpParserNodeToAstNode($n->statement); return [$label, $statement]; @@ -1631,7 +1672,7 @@ protected static function initHandleMap() : array * @param int $start_line * @throws InvalidNodeException */ - protected static function astStmtUseOrGroupUseFromUseClause(PhpParser\Node\NamespaceUseClause $use_clause, ?int $parser_use_kind, int $start_line) : ast\Node + protected static function astStmtUseOrGroupUseFromUseClause(PhpParser\Node\NamespaceUseClause $use_clause, ?int $parser_use_kind, int $start_line): ast\Node { $namespace_name_node = $use_clause->namespaceName; if ($namespace_name_node instanceof PhpParser\Node\QualifiedName) { @@ -1658,7 +1699,7 @@ private static function astNodeTry( ?\ast\Node $catches_node, ?\ast\Node $finally_node, int $start_line - ) : ast\Node { + ): ast\Node { // Return fields of $node->children in the same order as php-ast $children = [ 'try' => $try_node, @@ -1670,7 +1711,7 @@ private static function astNodeTry( return new ast\Node(ast\AST_TRY, 0, $children, $start_line); } - private static function astStmtCatch(ast\Node $types, string $var, \ast\Node $stmts, int $lineno) : ast\Node + private static function astStmtCatch(ast\Node $types, string $var, \ast\Node $stmts, int $lineno): ast\Node { return new ast\Node( ast\AST_CATCH, @@ -1687,7 +1728,7 @@ private static function astStmtCatch(ast\Node $types, string $var, \ast\Node $st /** * @param PhpParser\Node\CatchClause[] $catches */ - private static function phpParserCatchlistToAstCatchlist(array $catches, int $lineno) : ast\Node + private static function phpParserCatchlistToAstCatchlist(array $catches, int $lineno): ast\Node { $children = []; foreach ($catches as $parser_catch) { @@ -1699,7 +1740,7 @@ private static function phpParserCatchlistToAstCatchlist(array $catches, int $li /** * @param list $types */ - private static function phpParserNameListToAstNameList(array $types, int $line) : ast\Node + private static function phpParserNameListToAstNameList(array $types, int $line): ast\Node { $ast_types = []; foreach ($types as $type) { @@ -1714,7 +1755,7 @@ private static function phpParserNameListToAstNameList(array $types, int $line) /** * @param ast\Node|string|int|float $cond */ - private static function astNodeWhile($cond, ast\Node $stmts, int $start_line) : ast\Node + private static function astNodeWhile($cond, ast\Node $stmts, int $start_line): ast\Node { return new ast\Node( ast\AST_WHILE, @@ -1731,7 +1772,7 @@ private static function astNodeWhile($cond, ast\Node $stmts, int $start_line) : * @param ast\Node|string|int|float $var * @param ast\Node|string|int|float $expr */ - private static function astNodeAssign($var, $expr, int $line, bool $ref) : ast\Node + private static function astNodeAssign($var, $expr, int $line, bool $ref): ast\Node { return new ast\Node( $ref ? ast\AST_ASSIGN_REF : ast\AST_ASSIGN, @@ -1747,7 +1788,7 @@ private static function astNodeAssign($var, $expr, int $line, bool $ref) : ast\N /** * @throws Error if the kind could not be found */ - private static function phpParserIncludeTokenToAstIncludeFlags(Token $type) : int + private static function phpParserIncludeTokenToAstIncludeFlags(Token $type): int { switch ($type->kind) { case TokenKind::IncludeKeyword: @@ -1766,7 +1807,39 @@ private static function phpParserIncludeTokenToAstIncludeFlags(Token $type) : in /** * @param PhpParser\Node\QualifiedName|Token|null $type */ - protected static function phpParserTypeToAstNode($type, int $line) : ?\ast\Node + protected static function phpParserUnionTypeToAstNode($type, ?PhpParser\Node\DelimitedList\QualifiedNameList $other_types, int $line): ?\ast\Node + { + $types = []; + if (!\is_null($type)) { + $result = static::phpParserTypeToAstNode($type, $line); + if ($result) { + $types[] = $result; + } + } + if ($other_types instanceof PhpParser\Node\DelimitedList\QualifiedNameList) { + foreach ($other_types->children as $child) { + if ($child instanceof Token && $child->kind === TokenKind::BarToken) { + continue; + } + $result = static::phpParserTypeToAstNode($child, static::getEndLine($child) ?: $line); + if ($result) { + $types[] = $result; + } + } + } + $n = \count($types); + if ($n === 0) { + return null; + } elseif ($n === 1) { + return $types[0]; + } + return new ast\Node(ast\AST_TYPE_UNION, 0, $types, $types[0]->lineno); + } + + /** + * @param PhpParser\Node\QualifiedName|Token|null $type + */ + protected static function phpParserTypeToAstNode($type, int $line): ?ast\Node { if (\is_null($type)) { return null; @@ -1809,6 +1882,12 @@ protected static function phpParserTypeToAstNode($type, int $line) : ?\ast\Node case 'iterable': $flags = flags\TYPE_ITERABLE; break; + case 'false': + $flags = flags\TYPE_FALSE; + break; + case 'static': + $flags = flags\TYPE_STATIC; + break; default: // TODO: Refactor this into a function accepting a QualifiedName if ($original_type instanceof PhpParser\Node\QualifiedName) { @@ -1840,7 +1919,7 @@ protected static function phpParserTypeToAstNode($type, int $line) : ?\ast\Node * @param string $name * @param ?ast\Node|?int|?string|?float $default */ - private static function astNodeParam(bool $is_nullable, bool $by_ref, bool $variadic, ?\ast\Node $type, string $name, $default, int $line) : ast\Node + private static function astNodeParam(bool $is_nullable, bool $by_ref, bool $variadic, ?\ast\Node $type, string $name, $default, int $line): ast\Node { if ($is_nullable) { $type = new ast\Node( @@ -1862,7 +1941,7 @@ private static function astNodeParam(bool $is_nullable, bool $by_ref, bool $vari ); } - private static function phpParserParamsToAstParams(?\Microsoft\PhpParser\node\delimitedlist\parameterdeclarationlist $parser_params, int $line) : ast\Node + private static function phpParserParamsToAstParams(?\Microsoft\PhpParser\node\delimitedlist\parameterdeclarationlist $parser_params, int $line): ast\Node { $new_params = []; foreach ($parser_params->children ?? [] as $parser_node) { @@ -1883,7 +1962,7 @@ private static function phpParserParamsToAstParams(?\Microsoft\PhpParser\node\de * @param PhpParser\Node|PhpParser\Token $parser_node * @suppress UnusedSuppression, TypeMismatchProperty */ - protected static function astStub($parser_node) : ast\Node + protected static function astStub($parser_node): ast\Node { // Debugging code. if (\getenv(self::ENV_AST_THROW_INVALID)) { @@ -1902,7 +1981,7 @@ protected static function astStub($parser_node) : ast\Node private static function phpParserClosureUsesToAstClosureUses( ?\Microsoft\PhpParser\Node\DelimitedList\UseVariableNameList $uses, int $line - ) : ?\ast\Node { + ): ?\ast\Node { $children = $uses->children ?? []; if (count($children) === 0) { return null; @@ -1915,12 +1994,12 @@ private static function phpParserClosureUsesToAstClosureUses( if (!($use instanceof PhpParser\Node\UseVariableName)) { throw new AssertionError("Expected UseVariableName"); } - $ast_uses[] = new ast\Node(ast\AST_CLOSURE_VAR, $use->byRef ? 1 : 0, ['name' => static::tokenToString($use->variableName)], self::getStartLine($use)); + $ast_uses[] = new ast\Node(ast\AST_CLOSURE_VAR, $use->byRef ? ast\flags\CLOSURE_USE_REF : 0, ['name' => static::tokenToString($use->variableName)], self::getStartLine($use)); } return new ast\Node(ast\AST_CLOSURE_USES, 0, $ast_uses, $ast_uses[0]->lineno ?? $line); } - private static function resolveDocCommentForClosure(PhpParser\Node\Expression $node) : ?string + private static function resolveDocCommentForClosure(PhpParser\Node\Expression $node): ?string { $doc_comment = $node->getDocCommentText(); if ($doc_comment) { @@ -1950,7 +2029,7 @@ private static function resolveDocCommentForClosure(PhpParser\Node\Expression $n return null; } $doc_comment = $node->getDocCommentText(); - if ($doc_comment) { + if (is_string($doc_comment)) { return $doc_comment; } continue; @@ -1958,7 +2037,7 @@ private static function resolveDocCommentForClosure(PhpParser\Node\Expression $n if ($node instanceof PhpParser\Node\Expression\CallExpression) { if ($prev_node === $node->callableExpression) { $doc_comment = $node->getDocCommentText(); - if ($doc_comment) { + if (is_string($doc_comment)) { return $doc_comment; } continue; @@ -1975,7 +2054,7 @@ private static function resolveDocCommentForClosure(PhpParser\Node\Expression $n if ($expression === $prev_node) { $found = true; $doc_comment = $node->getDocCommentText(); - if ($doc_comment) { + if (is_string($doc_comment)) { return $doc_comment; } break; @@ -2008,7 +2087,7 @@ private static function astDeclClosure( int $start_line, int $end_line, ?string $doc_comment - ) : ast\Node { + ): ast\Node { return static::newAstDecl( ast\AST_CLOSURE, ($by_ref ? flags\FUNC_RETURNS_REF : 0) | ($static ? flags\MODIFIER_STATIC : 0), @@ -2040,7 +2119,7 @@ private static function astDeclFunction( int $line, int $end_line, ?string $doc_comment - ) : ast\Node { + ): ast\Node { return static::newAstDecl( ast\AST_FUNC_DECL, $by_ref ? flags\FUNC_RETURNS_REF : 0, @@ -2061,7 +2140,7 @@ private static function astDeclFunction( * @param ?Token $flags * @throws InvalidArgumentException if the class flags were unexpected */ - private static function phpParserClassModifierToAstClassFlags(?Token $flags) : int + private static function phpParserClassModifierToAstClassFlags(?Token $flags): int { if ($flags === null) { return 0; @@ -2076,7 +2155,7 @@ private static function phpParserClassModifierToAstClassFlags(?Token $flags) : i } } - private static function interfaceBaseClauseToNode(?\Microsoft\PhpParser\Node\InterfaceBaseClause $node) : ?\ast\Node + private static function interfaceBaseClauseToNode(?\Microsoft\PhpParser\Node\InterfaceBaseClause $node): ?\ast\Node { if (!$node instanceof PhpParser\Node\InterfaceBaseClause) { // TODO: real placeholder? @@ -2109,12 +2188,12 @@ private static function astStmtClass( int $line, int $end_line, ?string $doc_comment - ) : ast\Node { + ): ast\Node { // NOTE: `null` would be an anonymous class. - // the empty string or '0' is a missing string we pretend is an anonymous class + // the empty string is a missing string we pretend is an anonymous class // so that Phan won't throw an UnanalyzableException during the analysis phase - if ($name === null || !$name) { + if ($name === null || $name === '') { $flags |= flags\CLASS_ANONYMOUS; } @@ -2165,7 +2244,7 @@ private static function astStmtClass( ); } - private static function phpParserArgListToAstArgList(?\Microsoft\PhpParser\node\delimitedlist\argumentexpressionlist $args, int $line) : ast\Node + private static function phpParserArgListToAstArgList(?\Microsoft\PhpParser\node\delimitedlist\argumentexpressionlist $args, int $line): ast\Node { $ast_args = []; foreach ($args->children ?? [] as $arg) { @@ -2181,7 +2260,7 @@ private static function phpParserArgListToAstArgList(?\Microsoft\PhpParser\node\ * @param ?int $kind * @throws InvalidArgumentException if the token kind was somehow invalid */ - private static function phpParserNamespaceUseKindToASTUseFlags(?int $kind) : int + private static function phpParserNamespaceUseKindToASTUseFlags(?int $kind): int { switch ($kind ?? 0) { case TokenKind::FunctionKeyword: @@ -2199,7 +2278,7 @@ private static function phpParserNamespaceUseKindToASTUseFlags(?int $kind) : int * @param Token[]|PhpParser\Node\NamespaceUseGroupClause[]|PhpParser\Node[] $uses * @return ast\Node[] */ - private static function phpParserNamespaceUseListToAstUseList(array $uses) : array + private static function phpParserNamespaceUseListToAstUseList(array $uses): array { $ast_uses = []; foreach ($uses as $use_clause) { @@ -2230,7 +2309,7 @@ private static function phpParserNamespaceUseListToAstUseList(array $uses) : arr return $ast_uses; } - private static function astStmtUse(?int $type, string $name, ?string $alias, int $line) : ast\Node + private static function astStmtUse(?int $type, string $name, ?string $alias, int $line): ast\Node { $use_inner = new ast\Node(ast\AST_USE_ELEM, 0, ['name' => $name, 'alias' => $alias], $line); return new ast\Node( @@ -2247,7 +2326,7 @@ private static function astStmtUse(?int $type, string $name, ?string $alias, int * @param list $uses * @suppress PhanPossiblyUndeclaredProperty $use should always be a node */ - private static function astStmtGroupUse(?int $type, ?string $prefix, array $uses, int $line) : ast\Node + private static function astStmtGroupUse(?int $type, ?string $prefix, array $uses, int $line): ast\Node { $flags = static::phpParserNamespaceUseKindToASTUseFlags($type); $uses = new ast\Node(ast\AST_USE, 0, $uses, $line); @@ -2282,12 +2361,12 @@ private static function astStmtGroupUse(?int $type, ?string $prefix, array $uses * @param ast\Node $stmts * @param int $line */ - private static function astIfElem($cond, \ast\Node $stmts, int $line) : ast\Node + private static function astIfElem($cond, \ast\Node $stmts, int $line): ast\Node { return new ast\Node(ast\AST_IF_ELEM, 0, ['cond' => $cond, 'stmts' => $stmts], $line); } - private static function phpParserSwitchListToAstSwitch(PhpParser\Node\Statement\SwitchStatementNode $node) : ast\Node + private static function phpParserSwitchListToAstSwitch(PhpParser\Node\Statement\SwitchStatementNode $node): ast\Node { $stmts = []; $node_line = static::getStartLine($node); @@ -2295,7 +2374,7 @@ private static function phpParserSwitchListToAstSwitch(PhpParser\Node\Statement\ if (!($case instanceof PhpParser\Node\CaseStatementNode)) { continue; } - $case_line = static::getEndLine($case); + $case_line = static::getStartLine($case); $stmts[] = new ast\Node( ast\AST_SWITCH_CASE, 0, @@ -2315,7 +2394,7 @@ private static function phpParserSwitchListToAstSwitch(PhpParser\Node\Statement\ /** * @param PhpParser\Node[]|PhpParser\Node|Token $stmts */ - private static function getStartLineOfStatementOrStatements($stmts) : int + private static function getStartLineOfStatementOrStatements($stmts): int { if (is_array($stmts)) { return isset($stmts[0]) ? self::getStartLine($stmts[0]) : 0; @@ -2323,7 +2402,7 @@ private static function getStartLineOfStatementOrStatements($stmts) : int return self::getStartLine($stmts); } - private static function phpParserIfStmtToAstIfStmt(PhpParser\Node\Statement\IfStatementNode $node, int $start_line) : ast\Node + private static function phpParserIfStmtToAstIfStmt(PhpParser\Node\Statement\IfStatementNode $node, int $start_line): ast\Node { $if_elem = static::astIfElem( static::phpParserNodeToAstNode($node->expression), @@ -2435,7 +2514,7 @@ private static function astNodeAssignop(int $flags, PhpParser\Node\Expression\Bi * @throws InvalidNodeException if the type can't be converted to a valid AST * @throws InvalidArgumentException if the passed in class is completely unexpected */ - private static function phpParserPropelemToAstPropelem($n, ?string $doc_comment) : ast\Node + private static function phpParserPropelemToAstPropelem($n, ?string $doc_comment): ast\Node { if ($n instanceof PhpParser\Node\Expression\AssignmentExpression) { $name_node = $n->leftOperand; @@ -2466,7 +2545,7 @@ private static function phpParserPropelemToAstPropelem($n, ?string $doc_comment) return new ast\Node(ast\AST_PROP_ELEM, 0, $children, $start_line); } - private static function phpParserConstelemToAstConstelem(PhpParser\Node\ConstElement $n, ?string $doc_comment) : ast\Node + private static function phpParserConstelemToAstConstelem(PhpParser\Node\ConstElement $n, ?string $doc_comment): ast\Node { $start_line = self::getStartLine($n); $children = [ @@ -2482,7 +2561,7 @@ private static function phpParserConstelemToAstConstelem(PhpParser\Node\ConstEle * @param Token[] $visibility * @throws RuntimeException if a visibility token was unexpected */ - private static function phpParserVisibilityToAstVisibility(array $visibility, bool $automatically_add_public = true) : int + private static function phpParserVisibilityToAstVisibility(array $visibility, bool $automatically_add_public = true): int { $ast_visibility = 0; foreach ($visibility as $token) { @@ -2518,7 +2597,7 @@ private static function phpParserVisibilityToAstVisibility(array $visibility, bo return $ast_visibility; } - private static function phpParserPropertyToAstNode(PhpParser\Node\PropertyDeclaration $n, int $start_line) : ast\Node + private static function phpParserPropertyToAstNode(PhpParser\Node\PropertyDeclaration $n, int $start_line): ast\Node { $prop_elems = []; $doc_comment = $n->getDocCommentText(); @@ -2536,12 +2615,12 @@ private static function phpParserPropertyToAstNode(PhpParser\Node\PropertyDeclar $prop_decl = new ast\Node(ast\AST_PROP_DECL, 0, $prop_elems, $line); $type_line = static::getEndLine($n->typeDeclaration) ?: $start_line; return new ast\Node(ast\AST_PROP_GROUP, $flags, [ - 'type' => static::phpParserTypeToAstNode($n->typeDeclaration, $type_line), + 'type' => static::phpParserUnionTypeToAstNode($n->typeDeclaration, $n->otherTypeDeclarations, $type_line), 'props' => $prop_decl, ], $line); } - private static function phpParserClassConstToAstNode(PhpParser\Node\ClassConstDeclaration $n, int $start_line) : ast\Node + private static function phpParserClassConstToAstNode(PhpParser\Node\ClassConstDeclaration $n, int $start_line): ast\Node { $const_elems = []; $doc_comment = $n->getDocCommentText(); @@ -2560,7 +2639,7 @@ private static function phpParserClassConstToAstNode(PhpParser\Node\ClassConstDe /** * @throws InvalidNodeException */ - private static function phpParserConstToAstNode(PhpParser\Node\Statement\ConstDeclaration $n, int $start_line) : ast\Node + private static function phpParserConstToAstNode(PhpParser\Node\Statement\ConstDeclaration $n, int $start_line): ast\Node { $const_elems = []; $doc_comment = $n->getDocCommentText(); @@ -2577,7 +2656,7 @@ private static function phpParserConstToAstNode(PhpParser\Node\Statement\ConstDe return new ast\Node(ast\AST_CONST_DECL, 0, $const_elems, $const_elems[0]->lineno ?? $start_line); } - private static function phpParserDeclareListToAstDeclares(PhpParser\Node\DeclareDirective $declare, int $start_line, ?string $first_doc_comment) : ast\Node + private static function phpParserDeclareListToAstDeclares(PhpParser\Node\DeclareDirective $declare, int $start_line, ?string $first_doc_comment): ast\Node { $ast_declare_elements = []; if ($declare->name->length > 0 && $declare->literal->length > 0) { @@ -2595,7 +2674,7 @@ private static function phpParserDeclareListToAstDeclares(PhpParser\Node\Declare return new ast\Node(ast\AST_CONST_DECL, 0, $ast_declare_elements, $start_line); } - private static function astStmtDeclare(ast\Node $declares, ?\ast\Node $stmts, int $start_line) : ast\Node + private static function astStmtDeclare(ast\Node $declares, ?\ast\Node $stmts, int $start_line): ast\Node { $children = [ 'declares' => $declares, @@ -2608,7 +2687,7 @@ private static function astStmtDeclare(ast\Node $declares, ?\ast\Node $stmts, in * @param string|ast\Node $expr * @param ast\Node $args */ - private static function astNodeCall($expr, \ast\Node $args, int $start_line) : ast\Node + private static function astNodeCall($expr, \ast\Node $args, int $start_line): ast\Node { if (\is_string($expr)) { if (substr($expr, 0, 1) === '\\') { @@ -2623,7 +2702,7 @@ private static function astNodeCall($expr, \ast\Node $args, int $start_line) : a * @param ast\Node|string $expr (can parse non-nodes, but they'd cause runtime errors) * @param ast\Node|string $method */ - private static function astNodeMethodCall($expr, $method, ast\Node $args, int $start_line) : ast\Node + private static function astNodeMethodCall($expr, $method, ast\Node $args, int $start_line): ast\Node { return new ast\Node(ast\AST_METHOD_CALL, 0, ['expr' => $expr, 'method' => $method, 'args' => $args], $start_line); } @@ -2632,7 +2711,7 @@ private static function astNodeMethodCall($expr, $method, ast\Node $args, int $s * @param ast\Node|string $class * @param ast\Node|string $method */ - private static function astNodeStaticCall($class, $method, ast\Node $args, int $start_line) : ast\Node + private static function astNodeStaticCall($class, $method, ast\Node $args, int $start_line): ast\Node { // TODO: is this applicable? if (\is_string($class)) { @@ -2649,7 +2728,7 @@ private static function astNodeStaticCall($class, $method, ast\Node $args, int $ * @param string|PhpParser\Node|null|array $comments * @return ?string the doc comment, or null */ - private static function extractPhpdocComment($comments) : ?string + private static function extractPhpdocComment($comments): ?string { if (\is_string($comments)) { return $comments; @@ -2673,7 +2752,7 @@ private static function extractPhpdocComment($comments) : ?string */ } - private static function phpParserListToAstList(PhpParser\Node\Expression\ListIntrinsicExpression $n, int $start_line) : ast\Node + private static function phpParserListToAstList(PhpParser\Node\Expression\ListIntrinsicExpression $n, int $start_line): ast\Node { $ast_items = []; $prev_was_element = false; @@ -2703,7 +2782,7 @@ private static function phpParserListToAstList(PhpParser\Node\Expression\ListInt return new ast\Node(ast\AST_ARRAY, flags\ARRAY_SYNTAX_LIST, $ast_items, $start_line); } - private static function phpParserArrayToAstArray(PhpParser\Node\Expression\ArrayCreationExpression $n, int $start_line) : ast\Node + private static function phpParserArrayToAstArray(PhpParser\Node\Expression\ArrayCreationExpression $n, int $start_line): ast\Node { $ast_items = []; $prev_was_element = false; @@ -2727,7 +2806,7 @@ private static function phpParserArrayToAstArray(PhpParser\Node\Expression\Array ], self::getStartLine($item)); continue; } - $flags = $item->byRef ? flags\PARAM_REF : 0; + $flags = $item->byRef ? flags\ARRAY_ELEM_REF : 0; $element_key = $item->elementKey; $ast_items[] = new ast\Node(ast\AST_ARRAY_ELEM, $flags, [ 'value' => static::phpParserNodeToAstNode($item->elementValue), @@ -2749,12 +2828,11 @@ private static function phpParserArrayToAstArray(PhpParser\Node\Expression\Array } /** - * @return ?ast\Node * @throws InvalidNodeException if the member name could not be converted * * (and various other exceptions) */ - private static function phpParserMemberAccessExpressionToAstProp(PhpParser\Node\Expression\MemberAccessExpression $n, int $start_line) : ?\ast\Node + private static function phpParserMemberAccessExpressionToAstProp(PhpParser\Node\Expression\MemberAccessExpression $n, int $start_line): \ast\Node { // TODO: Check for incomplete tokens? $member_name = $n->memberName; @@ -2794,7 +2872,7 @@ private static function tokenToScalar(Token $n) /** * @throws Exception if node is invalid */ - private static function parseQuotedString(PhpParser\Node\StringLiteral $n) : string + private static function parseQuotedString(PhpParser\Node\StringLiteral $n): string { $start = $n->getStart(); $text = (string)substr(self::$file_contents, $start, $n->getEndPosition() - $start); @@ -2804,7 +2882,7 @@ private static function parseQuotedString(PhpParser\Node\StringLiteral $n) : str /** * @suppress PhanPartialTypeMismatchArgumentInternal hopefully in range */ - private static function variableTokenToString(Token $n) : string + private static function variableTokenToString(Token $n): string { return \ltrim(\trim($n->getText(self::$file_contents)), '$'); } @@ -2812,13 +2890,13 @@ private static function variableTokenToString(Token $n) : string /** * @suppress PhanPartialTypeMismatchReturn this is in bounds and $file_contents is a string */ - private static function tokenToRawString(Token $n) : string + private static function tokenToRawString(Token $n): string { return $n->getText(self::$file_contents); } /** @internal */ - const _MAGIC_CONST_LOOKUP = [ + private const MAGIC_CONST_LOOKUP = [ '__LINE__' => flags\MAGIC_LINE, '__FILE__' => flags\MAGIC_FILE, '__DIR__' => flags\MAGIC_DIR, @@ -2833,7 +2911,7 @@ private static function tokenToRawString(Token $n) : string /** * @phan-suppress PhanPartialTypeMismatchArgumentInternal hopefully in range */ - private static function tokenToString(Token $n) : string + private static function tokenToString(Token $n): string { $result = \trim($n->getText(self::$file_contents)); $kind = $n->kind; @@ -2846,11 +2924,16 @@ private static function tokenToString(Token $n) : string /** * @param PhpParser\Node\Expression|PhpParser\Node\QualifiedName|Token $scope_resolution_qualifier */ - private static function phpParserClassconstfetchToAstClassconstfetch($scope_resolution_qualifier, string $name, int $start_line) : ast\Node + private static function phpParserClassConstFetchToAstClassConstFetch($scope_resolution_qualifier, string $name, int $start_line): ast\Node { if (\strcasecmp($name, 'class') === 0) { + $class_node = static::phpParserNonValueNodeToAstNode($scope_resolution_qualifier); + if (!$class_node instanceof ast\Node) { + // e.g. (0)::class + $class_node = new ast\Node(ast\AST_NAME, ast\flags\NAME_FQ, ['name' => $class_node], $start_line); + } return new ast\Node(ast\AST_CLASS_NAME, 0, [ - 'class' => static::phpParserNonValueNodeToAstNode($scope_resolution_qualifier), + 'class' => $class_node, ], $start_line); } return new ast\Node(ast\AST_CLASS_CONST, 0, [ @@ -2862,13 +2945,12 @@ private static function phpParserClassconstfetchToAstClassconstfetch($scope_reso /** * @throws InvalidNodeException if the qualified type name could not be converted to a valid php-ast type name */ - private static function phpParserNameToString(PhpParser\Node\QualifiedName $name) : string + private static function phpParserNameToString(PhpParser\Node\QualifiedName $name): string { $name_parts = $name->nameParts; // TODO: Handle error case (can there be missing parts?) $result = ''; foreach ($name_parts as $part) { - // @phan-suppress-next-line PhanPossiblyNullTypeArgument $part_as_string = static::tokenToString($part); if ($part_as_string !== '') { $result .= \trim($part_as_string); @@ -2885,7 +2967,7 @@ private static function phpParserNameToString(PhpParser\Node\QualifiedName $name /** * @param array $children */ - private static function newAstDecl(int $kind, int $flags, array $children, int $lineno, string $doc_comment = null, string $name = null, int $end_lineno = 0, int $decl_id = -1) : ast\Node + private static function newAstDecl(int $kind, int $flags, array $children, int $lineno, string $doc_comment = null, string $name = null, int $end_lineno = 0, int $decl_id = -1): ast\Node { $decl_children = []; $decl_children['name'] = $name; @@ -2899,13 +2981,13 @@ private static function newAstDecl(int $kind, int $flags, array $children, int $ return $node; } - private static function nextDeclId() : int + private static function nextDeclId(): int { return self::$decl_id++; } /** @param PhpParser\Node|Token $n the node or token to convert to a placeholder */ - private static function newPlaceholderExpression($n) : ast\Node + private static function newPlaceholderExpression($n): ast\Node { $start_line = self::getStartLine($n); $name_node = new ast\Node(ast\AST_NAME, flags\NAME_FQ, ['name' => '__INCOMPLETE_EXPR__'], $start_line); @@ -2915,7 +2997,7 @@ private static function newPlaceholderExpression($n) : ast\Node /** * @param PhpParser\Node[]|PhpParser\Token[] $children $children */ - private static function parseMultiPartString(PhpParser\Node\StringLiteral $n, array $children) : ast\Node + private static function parseMultiPartString(PhpParser\Node\StringLiteral $n, array $children): ast\Node { if ($n->startQuote->length >= 3) { return self::parseMultiPartHeredoc($n, $children); @@ -2926,7 +3008,7 @@ private static function parseMultiPartString(PhpParser\Node\StringLiteral $n, ar /** * @param PhpParser\Node[]|PhpParser\Token[] $children $children */ - private static function parseMultiPartRegularString(PhpParser\Node\StringLiteral $n, array $children) : ast\Node + private static function parseMultiPartRegularString(PhpParser\Node\StringLiteral $n, array $children): ast\Node { $inner_node_parts = []; $start_quote_text = static::tokenToString($n->startQuote); @@ -2959,7 +3041,7 @@ private static function parseMultiPartRegularString(PhpParser\Node\StringLiteral /** * @param PhpParser\Node[]|PhpParser\Token[] $children $children */ - private static function parseMultiPartHeredoc(PhpParser\Node\StringLiteral $n, array $children) : ast\Node + private static function parseMultiPartHeredoc(PhpParser\Node\StringLiteral $n, array $children): ast\Node { $inner_node_parts = []; $end_of_start_quote = self::$file_contents[$n->startQuote->start + $n->startQuote->length - 1]; @@ -3006,7 +3088,7 @@ private static function parseMultiPartHeredoc(PhpParser\Node\StringLiteral $n, a /** * Gets a string based on environment details that could affect parsing */ - private static function getEnvironmentDetails() : string + private static function getEnvironmentDetails(): string { static $details = null; if ($details === null) { @@ -3016,7 +3098,7 @@ private static function getEnvironmentDetails() : string self::getDevelopmentBuildDate(), \phpversion('ast'), \ini_get('short_open_tag'), - '2.3.1-dev-standalone' + \sha1((string)\file_get_contents(dirname(__DIR__) . '/ast_shim.php')), ], true)); } return $details; @@ -3024,11 +3106,11 @@ private static function getEnvironmentDetails() : string /** * For development PHP versions such as 8.0.0-dev, use the build date as part of the cache key to invalidate cached ASTs when this gets rebuilt. - * @suppress PhanImpossibleTypeComparison, PhanRedundantCondition, PhanImpossibleCondition, PhanSuspiciousValueComparison + * @suppress PhanImpossibleTypeComparison, PhanRedundantCondition, PhanImpossibleCondition, PhanSuspiciousValueComparison Phan evaluates the strpos to a constant, so this is either impossible or redundant */ - private static function getDevelopmentBuildDate() : ?string + private static function getDevelopmentBuildDate(): ?string { - if (\stripos(\PHP_VERSION, '-dev') === false) { + if (\strpos(\PHP_VERSION, '-dev') === false) { return null; } \ob_start(); @@ -3041,7 +3123,7 @@ private static function getDevelopmentBuildDate() : ?string /** * @return ?string - null if this should not be cached */ - public function generateCacheKey(string $file_contents, int $version) : ?string + public function generateCacheKey(string $file_contents, int $version): ?string { $details = var_export([ \sha1($file_contents), @@ -3052,7 +3134,7 @@ public function generateCacheKey(string $file_contents, int $version) : ?string return \sha1($details); } - private static function normalizeTernaryExpression(TernaryExpression $n) : TernaryExpression + private static function normalizeTernaryExpression(TernaryExpression $n): TernaryExpression { $else = $n->elseExpression; if (!($else instanceof TernaryExpression)) { diff --git a/src/TolerantASTConverter/TolerantASTConverterWithNodeMapping.php b/src/TolerantASTConverter/TolerantASTConverterWithNodeMapping.php index b1d3ec5..4c7cc06 100644 --- a/src/TolerantASTConverter/TolerantASTConverterWithNodeMapping.php +++ b/src/TolerantASTConverter/TolerantASTConverterWithNodeMapping.php @@ -1,4 +1,6 @@ -instance_desired_byte_offset)); @@ -128,7 +132,7 @@ public function parseCodeAsPHPAST(string $file_contents, int $version, array &$e /** * @return ?string - null if this should not be cached */ - public function generateCacheKey(string $unused_file_contents, int $unused_version) : ?string + public function generateCacheKey(string $unused_file_contents, int $unused_version): ?string { return null; } @@ -138,7 +142,7 @@ public function generateCacheKey(string $unused_file_contents, int $unused_versi * Heuristics are used to ensure that this can map to an ast\Node. * TODO: Finish implementing */ - private static function findNodeAtOffset(PhpParser\Node $parser_node, int $offset) : void + private static function findNodeAtOffset(PhpParser\Node $parser_node, int $offset): void { self::$closest_node_or_token = null; self::$closest_node_or_token_symbol = null; @@ -149,10 +153,8 @@ private static function findNodeAtOffset(PhpParser\Node $parser_node, int $offse /** * We use a blacklist because there are more many more tokens we want to use the parent for. * For example, when navigating to class names in comments, the comment can be prior to pretty much any token (e.g. AmpersandToken, PublicKeyword, etc.) - * - * @internal */ - const KINDS_TO_NOT_RETURN_PARENT = [ + private const KINDS_TO_NOT_RETURN_PARENT = [ TokenKind::QualifiedName => true, ]; @@ -205,16 +207,17 @@ private static function findNodeAtOffsetRecursive(\Microsoft\PhpParser\Node $par // End this early if this token ends before the cursor even starts continue; } + // Either the node, or true if a the node was found as a descendant, or false. $state = self::findNodeAtOffsetRecursive($node_or_token, $offset); - if ($state) { + if (\is_object($state)) { // fwrite(STDERR, "Found parent node for $key: " . get_class($parser_node) . "\n"); // fwrite(STDERR, "Found parent node for $key: " . json_encode($parser_node) . "\n"); - if ($state instanceof PhpParser\Node) { + // $state is either a Node or a Token if (!is_string($key)) { throw new AssertionError("Expected key to be a string"); } return self::adjustClosestNodeOrToken($parser_node, $key); - } + } elseif ($state) { return true; } } @@ -267,7 +270,7 @@ protected static function phpParserNodeToAstNodeOrPlaceholderExpr($n) * @param PhpParser\Node|Token $n @phan-unused-param the tolerant-php-parser node that generated the $ast_node * @param mixed $ast_node the node that was selected because it was under the cursor */ - private static function markNodeAsSelected($n, $ast_node) : void + private static function markNodeAsSelected($n, $ast_node): void { // fwrite(STDERR, "Marking corresponding node as flagged: " . json_encode($n) . "\n" . \Phan\Debug::nodeToString($ast_node) . "\n"); // fflush(STDERR); @@ -297,10 +300,7 @@ private static function markNodeAsSelected($n, $ast_node) : void } } - /** - * @internal - */ - const VALID_FRAGMENT_CHARACTER_REGEX = '/[\\\\a-z0-9_\x7f-\xff]/i'; + private const VALID_FRAGMENT_CHARACTER_REGEX = '/[\\\\a-z0-9_\x7f-\xff]/i'; /** * @return ?string A fragment that is a potentially valid class or function identifier (e.g. 'MyNs\MyClass', '\MyClass') @@ -310,7 +310,7 @@ private static function markNodeAsSelected($n, $ast_node) : void * TODO: Support variables? * TODO: Implement support for going to function definitions if no class could be found */ - private static function extractFragmentFromCommentLike() : ?string + private static function extractFragmentFromCommentLike(): ?string { $offset = self::$desired_byte_offset; $contents = self::$file_contents; @@ -354,7 +354,7 @@ protected static function phpParserNodeToAstNode($n) * @throws InvalidArgumentException for invalid token classes * @suppress PhanThrowTypeMismatchForCall can throw if debugDumpNodeOrToken fails */ - $fallback_closure = static function ($n, int $unused_start_line) : ast\Node { + $fallback_closure = static function ($n, int $unused_start_line): ast\Node { if (!($n instanceof PhpParser\Node) && !($n instanceof Token)) { throw new InvalidArgumentException("Invalid type for node: " . (\is_object($n) ? \get_class($n) : \gettype($n)) . ": " . static::debugDumpNodeOrToken($n)); } @@ -393,7 +393,7 @@ protected static function phpParserNonValueNodeToAstNode($n) * @param PhpParser\Node|Token $n * @throws InvalidArgumentException for invalid token classes */ - $fallback_closure = static function ($n, int $unused_start_line) : ast\Node { + $fallback_closure = static function ($n, int $unused_start_line): ast\Node { if (!($n instanceof PhpParser\Node) && !($n instanceof Token)) { // @phan-suppress-next-line PhanThrowTypeMismatchForCall debugDumpNodeOrToken can throw throw new InvalidArgumentException("Invalid type for node: " . (\is_object($n) ? \get_class($n) : \gettype($n)) . ": " . static::debugDumpNodeOrToken($n)); @@ -416,7 +416,7 @@ protected static function astStmtUseOrGroupUseFromUseClause( PhpParser\Node\NamespaceUseClause $use_clause, ?int $parser_use_kind, int $start_line - ) : ast\Node { + ): ast\Node { // fwrite(STDERR, "Calling astStmtUseOrGroupUseFromUseClause for " . json_encode($use_clause) . "\n"); $ast_node = parent::astStmtUseOrGroupUseFromUseClause($use_clause, $parser_use_kind, $start_line); if ($use_clause === self::$closest_node_or_token) { @@ -432,7 +432,7 @@ protected static function astStmtUseOrGroupUseFromUseClause( * @param PhpParser\Node\QualifiedName|Token|null $type * @override */ - protected static function phpParserTypeToAstNode($type, int $line) : ?\ast\Node + protected static function phpParserTypeToAstNode($type, int $line): ?\ast\Node { $ast_node = parent::phpParserTypeToAstNode($type, $line); if ($type === self::$closest_node_or_token && $type !== null) { diff --git a/src/ast_shim.php b/src/ast_shim.php index 2bed1f3..9bbfda5 100644 --- a/src/ast_shim.php +++ b/src/ast_shim.php @@ -1,5 +1,7 @@ getText() provide optional file contents, Token->getText provide mandatory file contents +if (!class_exists('\ast\Node')) { + require_once __DIR__ . '/ast_shim.php'; +} +// Define node kinds that may be absent +if (!\defined('ast\AST_PROP_GROUP')) { + \define('ast\AST_PROP_GROUP', 545); +} +if (!\defined('ast\AST_CLASS_NAME')) { + \define('ast\AST_CLASS_NAME', 287); +} +if (!\defined('ast\AST_ARROW_FUNC')) { + \define('ast\AST_ARROW_FUNC', 71); +} +if (!\defined('ast\AST_TYPE_UNION')) { + \define('ast\AST_TYPE_UNION', 254); +} +if (!\defined('ast\AST_ATTRIBUTE_LIST')) { + // @phan-suppress-next-line PhanUnreferencedConstant TODO support attributes + \define('ast\AST_ATTRIBUTE_LIST', 253); +} +if (!\defined('ast\AST_ATTRIBUTE')) { + // @phan-suppress-next-line PhanUnreferencedConstant TODO support attributes + \define('ast\AST_ATTRIBUTE', 0x2fb); +} +// Define flags +if (!\defined('ast\flags\DIM_ALTERNATIVE_SYNTAX')) { + \define('ast\flags\DIM_ALTERNATIVE_SYNTAX', 1 << 1); +} +if (!\defined('ast\flags\PARENTHESIZED_CONDITIONAL')) { + \define('ast\flags\PARENTHESIZED_CONDITIONAL', 1); +} +if (!\defined('ast\flags\TYPE_FALSE')) { + \define('ast\flags\TYPE_FALSE', 2); +} +if (!\defined('ast\flags\TYPE_STATIC')) { + \define('ast\flags\TYPE_STATIC', \PHP_MAJOR_VERSION >= 80000 ? 15 : 20); +} diff --git a/src/util.php b/src/util.php index 144d736..c9194d4 100644 --- a/src/util.php +++ b/src/util.php @@ -1,4 +1,6 @@ ->,1:associative-array>} * Returns [string[][] $exclusive, string[][] $combinable]. */ -function get_flag_info() : array +function get_flag_info(): array { // TODO: Use AST's built in flag info if available. static $exclusive, $combinable; @@ -39,6 +41,7 @@ function get_flag_info() : array ]; $types = [ flags\TYPE_NULL => 'TYPE_NULL', + flags\TYPE_FALSE => 'TYPE_FALSE', flags\TYPE_BOOL => 'TYPE_BOOL', flags\TYPE_LONG => 'TYPE_LONG', flags\TYPE_DOUBLE => 'TYPE_DOUBLE', @@ -48,6 +51,7 @@ function get_flag_info() : array flags\TYPE_CALLABLE => 'TYPE_CALLABLE', flags\TYPE_VOID => 'TYPE_VOID', flags\TYPE_ITERABLE => 'TYPE_ITERABLE', + flags\TYPE_STATIC => 'TYPE_STATIC', ]; $use_types = [ flags\USE_NORMAL => 'USE_NORMAL', @@ -172,7 +176,7 @@ function get_flag_info() : array * Computes a string representation of AST node flags such as * 'ASSIGN_DIV|TYPE_ARRAY' */ -function format_flags(int $kind, int $flags) : string +function format_flags(int $kind, int $flags): string { [$exclusive, $combinable] = get_flag_info(); $flag_names = []; @@ -199,7 +203,7 @@ function format_flags(int $kind, int $flags) : string * @param Node|string|int|float|null $ast * @param int $options (AST_DUMP_*) */ -function ast_dump($ast, int $options = 0) : string +function ast_dump($ast, int $options = 0): string { if ($ast instanceof Node) { // $kind can be invalid for placeholder nodes or unexpected tolerant-php-parser classes diff --git a/test_files/src/switch.php b/test_files/src/switch.php index 940234c..f274b0f 100644 --- a/test_files/src/switch.php +++ b/test_files/src/switch.php @@ -2,3 +2,9 @@ switch($x) {} switch($x) {case 2: default:} switch($x) {case 2: $y = 3;} +switch($x) { + case 2: + $y = 3; + default: + echo "test"; +} diff --git a/tests/TolerantASTConverter/ConversionTest.php b/tests/TolerantASTConverter/ConversionTest.php index cd89b2d..e9852f6 100644 --- a/tests/TolerantASTConverter/ConversionTest.php +++ b/tests/TolerantASTConverter/ConversionTest.php @@ -18,6 +18,7 @@ use function is_string; require_once __DIR__ . '/../../src/util.php'; +require_once __DIR__ . '/../../src/shim_loader.php'; /** * Tests that the polyfill works with valid ASTs @@ -26,8 +27,9 @@ class ConversionTest extends \PHPUnit\Framework\TestCase { /** * @return list + * @suppress PhanPluginUnknownObjectMethodCall */ - protected function scanSourceDirForPHP(string $source_dir) : array + protected function scanSourceDirForPHP(string $source_dir): array { $files = []; foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source_dir)) as $file_path => $file_info) { @@ -36,7 +38,7 @@ protected function scanSourceDirForPHP(string $source_dir) : array !in_array($filename, ['.', '..'], true) && \substr($filename, 0, 1) !== '.' && \strpos($filename, '.') !== false && - \pathinfo($filename)['extension'] === 'php') { + (\pathinfo($filename)['extension'] ?? '') === 'php') { $files[] = $file_path; } } @@ -49,7 +51,7 @@ protected function scanSourceDirForPHP(string $source_dir) : array /** * @return bool does php-ast support $ast_version */ - public static function hasNativeASTSupport(int $ast_version) : bool + public static function hasNativeASTSupport(int $ast_version): bool { try { ast\parse_code('', $ast_version); @@ -64,7 +66,7 @@ public static function hasNativeASTSupport(int $ast_version) : bool * (i.e. simplest ASTs) appear first. * @param string[] $files */ - private static function sortByTokenCount(array &$files) : void + private static function sortByTokenCount(array &$files): void { $token_counts = []; foreach ($files as $file) { @@ -74,7 +76,7 @@ private static function sortByTokenCount(array &$files) : void } $token_counts[$file] = count(\token_get_all($contents)); } - \usort($files, static function (string $path1, string $path2) use ($token_counts) : int { + \usort($files, static function (string $path1, string $path2) use ($token_counts): int { return $token_counts[$path1] <=> $token_counts[$path2]; }); } @@ -84,11 +86,11 @@ private static function sortByTokenCount(array &$files) : void * * @return array{0:string,1:int}[] array of [string $file_path, int $ast_version] */ - public function astValidFileExampleProvider() : array + public function astValidFileExampleProvider(): array { $tests = []; // @phan-suppress-next-line PhanPossiblyFalseTypeArgumentInternal - $source_dir = \dirname(\realpath(__DIR__), 2) . '/test_files/src'; + $source_dir = \dirname(\realpath(__DIR__), 3) . '/misc/fallback_ast_src'; $paths = $this->scanSourceDirForPHP($source_dir); self::sortByTokenCount($paths); @@ -105,7 +107,7 @@ public function astValidFileExampleProvider() : array /** * @param ast\Node|int|string|float|null $node */ - private static function normalizeOriginalAST($node) : void + private static function normalizeOriginalAST($node): void { if ($node instanceof ast\Node) { $kind = $node->kind; @@ -130,7 +132,7 @@ private static function normalizeOriginalAST($node) : void * Set all of the line numbers to constants, * so that minor differences in line numbers won't cause tests to fail. */ - public static function normalizeLineNumbers(ast\Node $node) : ast\Node + public static function normalizeLineNumbers(ast\Node $node): ast\Node { $node = clone($node); if (is_array($node->children)) { @@ -157,7 +159,7 @@ public static function normalizeLineNumbers(ast\Node $node) : ast\Node * Phan does not use these flags because they are not natively provided in all PHP versions. * TODO: Shouldn't they be available in PHP 7.1+ */ - public static function normalizeYieldFlags(ast\Node $node) : void + public static function normalizeYieldFlags(ast\Node $node): void { if (\in_array($node->kind, self::FUNCTION_DECLARATION_KINDS, true)) { // Alternately, could make Phan do this. @@ -174,7 +176,7 @@ public static function normalizeYieldFlags(ast\Node $node) : void } /** @dataProvider astValidFileExampleProvider */ - public function testFallbackFromParser(string $file_name, int $ast_version) : void + public function testFallbackFromParser(string $file_name, int $ast_version): void { $test_folder_name = \basename(\dirname($file_name)); if (\PHP_VERSION_ID < 70300 && $test_folder_name === 'php73_or_newer') { @@ -183,6 +185,9 @@ public function testFallbackFromParser(string $file_name, int $ast_version) : vo if (\PHP_VERSION_ID < 70400 && $test_folder_name === 'php74_or_newer') { $this->markTestIncomplete('php-ast cannot parse php7.4 syntax when running in php7.3 or older'); } + if (\PHP_VERSION_ID < 80000 && $test_folder_name === 'php80_or_newer') { + $this->markTestIncomplete('php-ast cannot parse php8.0 syntax when running in php7.4 or older'); + } $contents = \file_get_contents($file_name); if ($contents === false) { $this->fail("Failed to read $file_name"); diff --git a/tests/TolerantASTConverter/TolerantASTConverterTest.php b/tests/TolerantASTConverter/TolerantASTConverterTest.php new file mode 100644 index 0000000..7acc414 --- /dev/null +++ b/tests/TolerantASTConverter/TolerantASTConverterTest.php @@ -0,0 +1,20 @@ +assertSame( + (new TolerantASTConverter())->generateCacheKey('Some file contents', 70), + (new TolerantASTConverter())->generateCacheKey('Some file contents', 70), + 'generateCacheKey should be idempotent' + ); + } +} From 205c8146d6681b8755b20bb3a7682db9c2a7673c Mon Sep 17 00:00:00 2001 From: Tyson Andre Date: Fri, 3 Jul 2020 13:27:10 -0400 Subject: [PATCH 4/4] Run phpcbf on tests --- tests/TolerantASTConverter/ConversionTest.php | 4 +- .../ErrorTolerantConversionTest.php | 44 ++++++++++--------- .../TolerantASTConverterTest.php | 4 +- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/tests/TolerantASTConverter/ConversionTest.php b/tests/TolerantASTConverter/ConversionTest.php index e9852f6..04c2b82 100644 --- a/tests/TolerantASTConverter/ConversionTest.php +++ b/tests/TolerantASTConverter/ConversionTest.php @@ -1,4 +1,6 @@ -runTestFallbackFromParser($incomplete_contents, $valid_contents); } - public function testIncompleteVarWithPlaceholderShort() : void + public function testIncompleteVarWithPlaceholderShort(): void { $incomplete_contents = <<<'EOT' runTestFallbackFromParser($incomplete_contents, $valid_contents, true); } - public function testIncompleteVarWithPlaceholder() : void + public function testIncompleteVarWithPlaceholder(): void { $incomplete_contents = <<<'EOT' runTestFallbackFromParser($incomplete_contents, $valid_contents, true); } - public function testIncompleteProperty() : void + public function testIncompleteProperty(): void { $incomplete_contents = <<<'EOT' runTestFallbackFromParser($incomplete_contents, $valid_contents); } - public function testIncompletePropertyWithPlaceholder() : void + public function testIncompletePropertyWithPlaceholder(): void { $incomplete_contents = <<<'EOT' runTestFallbackFromParser($incomplete_contents, $valid_contents, true); } - public function testIncompleteMethod() : void + public function testIncompleteMethod(): void { $incomplete_contents = <<<'EOT' runTestFallbackFromParser($incomplete_contents, $valid_contents); } - public function testIncompleteMethodWithPlaceholder() : void + public function testIncompleteMethodWithPlaceholder(): void { $incomplete_contents = <<<'EOT' runTestFallbackFromParser($incomplete_contents, $valid_contents, true); } - public function testMiscNoise() : void + public function testMiscNoise(): void { $incomplete_contents = <<<'EOT' runTestFallbackFromParser($incomplete_contents, $valid_contents); } - public function testMiscNoiseWithPlaceholders() : void + public function testMiscNoiseWithPlaceholders(): void { $incomplete_contents = <<<'EOT' runTestFallbackFromParser($incomplete_contents, $valid_contents, true); } - public function testIncompleteArithmeticWithPlaceholders() : void + public function testIncompleteArithmeticWithPlaceholders(): void { $incomplete_contents = <<<'EOT' runTestFallbackFromParser($incomplete_contents, $valid_contents, true); } - public function testIncompleteArithmeticWithoutPlaceholders() : void + public function testIncompleteArithmeticWithoutPlaceholders(): void { $incomplete_contents = <<<'EOT' runTestFallbackFromParser($incomplete_contents, $valid_contents, false); } - public function testMissingMember() : void + public function testMissingMember(): void { // in 0.0.17, this starts trying to parse a typed property declaration // and discards all of it because it's invalid. @@ -230,7 +232,7 @@ function aFunction() {} $this->runTestFallbackFromParser($incomplete_contents, $valid_contents, false); } - public function testIncompleteTypedProperty() : void + public function testIncompleteTypedProperty(): void { $incomplete_contents = <<<'EOT' runTestFallbackFromParser($incomplete_contents, $valid_contents, false); } - public function testEmptyConstList() : void + public function testEmptyConstList(): void { $incomplete_contents = <<<'EOT' runTestFallbackFromParser($incomplete_contents, $valid_contents, false); } - public function testMissingSemicolon() : void + public function testMissingSemicolon(): void { $incomplete_contents = <<<'EOT' runTestFallbackFromParser($incomplete_contents, $valid_contents); } - public function testIncompleteMethodCallBeforeIfWithPlaceholders() : void + public function testIncompleteMethodCallBeforeIfWithPlaceholders(): void { $incomplete_contents = <<<'EOT' runTestFallbackFromParser($incomplete_contents, $valid_contents, true); } - public function testIncompleteMethodCallBeforeIfWithoutPlaceholders() : void + public function testIncompleteMethodCallBeforeIfWithoutPlaceholders(): void { $incomplete_contents = <<<'EOT' kind) { case ast\AST_DIM: @@ -377,7 +379,7 @@ private static function normalizePolyfillAST(ast\Node $ast) : void } } - private function runTestFallbackFromParser(string $incomplete_contents, string $valid_contents, bool $should_add_placeholders = false) : void + private function runTestFallbackFromParser(string $incomplete_contents, string $valid_contents, bool $should_add_placeholders = false): void { $supports70 = ConversionTest::hasNativeASTSupport(70); if (!$supports70) { @@ -386,7 +388,7 @@ private function runTestFallbackFromParser(string $incomplete_contents, string $ $this->runTestFallbackFromParserForASTVersion($incomplete_contents, $valid_contents, 70, $should_add_placeholders); } - private function runTestFallbackFromParserForASTVersion(string $incomplete_contents, string $valid_contents, int $ast_version, bool $should_add_placeholders) : void + private function runTestFallbackFromParserForASTVersion(string $incomplete_contents, string $valid_contents, int $ast_version, bool $should_add_placeholders): void { $ast = \ast\parse_code($valid_contents, $ast_version); $this->assertInstanceOf('\ast\Node', $ast, 'Examples(for validContents) must be syntactically valid PHP parsable by php-ast'); diff --git a/tests/TolerantASTConverter/TolerantASTConverterTest.php b/tests/TolerantASTConverter/TolerantASTConverterTest.php index 7acc414..9339bf8 100644 --- a/tests/TolerantASTConverter/TolerantASTConverterTest.php +++ b/tests/TolerantASTConverter/TolerantASTConverterTest.php @@ -1,4 +1,6 @@ -