From 931870bbfab20d392164e1c4c62351492de66b10 Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Fri, 19 Jun 2020 21:50:41 +0200 Subject: [PATCH] Allow BetterReflection 4 --- composer.json | 2 +- composer.lock | 152 +++++++++--------- .../LocateDependenciesViaComposer.php | 3 +- test/unit/StringReflectorFactory.php | 6 +- 4 files changed, 85 insertions(+), 78 deletions(-) diff --git a/composer.json b/composer.json index 62e8b3911..39b8b515b 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "composer/composer": "^1.10.5", "nikolaposa/version": "^4.0.0", "ocramius/package-versions": "^1.5.1", - "roave/better-reflection": "^3.5.0", + "roave/better-reflection": "^3.5.0 || ^4.0.0", "symfony/console": "^4.4.8", "symfony/process": "^5.1.0", "thecodingmachine/safe": "^1.1" diff --git a/composer.lock b/composer.lock index 6e80e23d8..f3ae7c94c 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": "7fb7e8b631a76af58ce6f7d8f3564e84", + "content-hash": "8606f9f4e181fa805f4be6eb8dfb534b", "packages": [ { "name": "beberlei/assert", @@ -371,25 +371,30 @@ }, { "name": "jetbrains/phpstorm-stubs", - "version": "v2019.1", + "version": "v2019.3", "source": { "type": "git", "url": "https://github.com/JetBrains/phpstorm-stubs.git", - "reference": "9e309771f362e979ecfb429303ad7a402c657234" + "reference": "883b6facd78e01c0743b554af86fa590c2573f40" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/JetBrains/phpstorm-stubs/zipball/9e309771f362e979ecfb429303ad7a402c657234", - "reference": "9e309771f362e979ecfb429303ad7a402c657234", + "url": "https://api.github.com/repos/JetBrains/phpstorm-stubs/zipball/883b6facd78e01c0743b554af86fa590c2573f40", + "reference": "883b6facd78e01c0743b554af86fa590c2573f40", "shasum": "" }, "require-dev": { - "nikic/php-parser": "v4.0.1", + "nikic/php-parser": "^4", "php": "^7.1", "phpdocumentor/reflection-docblock": "^4.3", - "phpunit/phpunit": "7.1.4" + "phpunit/phpunit": "^7" }, "type": "library", + "autoload": { + "files": [ + "PhpStormStubsMap.php" + ] + }, "notification-url": "https://packagist.org/downloads/", "license": [ "Apache-2.0" @@ -406,7 +411,7 @@ "stubs", "type" ], - "time": "2019-03-25T16:59:23+00:00" + "time": "2019-12-05T16:56:26+00:00" }, { "name": "justinrainbow/json-schema", @@ -476,16 +481,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.4.0", + "version": "v4.5.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "bd43ec7152eaaab3bd8c6d0aa95ceeb1df8ee120" + "reference": "53c2753d756f5adb586dca79c2ec0e2654dd9463" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/bd43ec7152eaaab3bd8c6d0aa95ceeb1df8ee120", - "reference": "bd43ec7152eaaab3bd8c6d0aa95ceeb1df8ee120", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/53c2753d756f5adb586dca79c2ec0e2654dd9463", + "reference": "53c2753d756f5adb586dca79c2ec0e2654dd9463", "shasum": "" }, "require": { @@ -524,7 +529,7 @@ "parser", "php" ], - "time": "2020-04-10T16:34:50+00:00" + "time": "2020-06-03T07:24:19+00:00" }, { "name": "nikolaposa/version", @@ -633,35 +638,30 @@ }, { "name": "phpdocumentor/reflection-common", - "version": "1.0.1", + "version": "2.1.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" + "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/6568f4687e5b41b054365f9ae03fcb1ed5f2069b", + "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b", "shasum": "" }, "require": { - "php": ">=5.5" - }, - "require-dev": { - "phpunit/phpunit": "^4.6" + "php": ">=7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src" - ] + "phpDocumentor\\Reflection\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -683,45 +683,42 @@ "reflection", "static analysis" ], - "time": "2017-09-11T18:02:19+00:00" + "time": "2020-04-27T09:25:28+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/", @@ -732,44 +729,46 @@ { "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": "0.4.0", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" + "reference": "7462d5f123dfc080dfdf26897032a6513644fc95" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/7462d5f123dfc080dfdf26897032a6513644fc95", + "reference": "7462d5f123dfc080dfdf26897032a6513644fc95", "shasum": "" }, "require": { - "php": "^5.5 || ^7.0", - "phpdocumentor/reflection-common": "^1.0" + "php": "^7.2", + "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^5.2||^4.8.24" + "ext-tokenizer": "^7.2", + "mockery/mockery": "~1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] + "phpDocumentor\\Reflection\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -782,7 +781,8 @@ "email": "me@mikevanriel.com" } ], - "time": "2017-07-14T14:27:02+00:00" + "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "time": "2020-02-18T18:59:58+00:00" }, { "name": "psr/container", @@ -882,30 +882,33 @@ }, { "name": "roave/better-reflection", - "version": "3.5.0", + "version": "4.6.1", "source": { "type": "git", "url": "https://github.com/Roave/BetterReflection.git", - "reference": "a93d26f6f08add54943d752dad1da64c464c2e69" + "reference": "c6797a2e6a44aff887e6fd78229025b37f771b85" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/BetterReflection/zipball/a93d26f6f08add54943d752dad1da64c464c2e69", - "reference": "a93d26f6f08add54943d752dad1da64c464c2e69", + "url": "https://api.github.com/repos/Roave/BetterReflection/zipball/c6797a2e6a44aff887e6fd78229025b37f771b85", + "reference": "c6797a2e6a44aff887e6fd78229025b37f771b85", "shasum": "" }, "require": { "ext-json": "*", - "jetbrains/phpstorm-stubs": "2019.1", - "nikic/php-parser": "^4.2.1", - "php": ">=7.2.0,<7.5.0", - "phpdocumentor/reflection-docblock": "^4.1.1", - "phpdocumentor/type-resolver": "^0.4.0", + "jetbrains/phpstorm-stubs": "2019.3", + "nikic/php-parser": "^4.4.0", + "php": ">=7.4.1,<7.5.0", + "phpdocumentor/reflection-docblock": "^5.1.0", + "phpdocumentor/type-resolver": "^1.1.0", "roave/signature": "^1.0" }, "require-dev": { - "doctrine/coding-standard": "^6.0", - "phpunit/phpunit": "^8.1.0" + "doctrine/coding-standard": "^7.0.2", + "infection/infection": "^0.16.3", + "phpstan/phpstan": "^0.12.25", + "phpunit/phpunit": "^9.1.5", + "vimeo/psalm": "3.11.2" }, "suggest": { "composer/composer": "Required to use the ComposerSourceLocator" @@ -931,6 +934,11 @@ "email": "james@asgrim.com", "homepage": "https://github.com/asgrim" }, + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "https://ocramius.github.io/" + }, { "name": "Gary Hockin", "email": "gary@roave.com", @@ -940,15 +948,10 @@ "name": "Jaroslav HanslĂ­k", "email": "kukulich@kukulich.cz", "homepage": "https://github.com/kukulich" - }, - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "https://ocramius.github.io/" } ], "description": "Better Reflection - an improved code reflection API", - "time": "2019-05-28T00:00:03+00:00" + "time": "2020-06-12T11:11:23+00:00" }, { "name": "roave/signature", @@ -5337,5 +5340,6 @@ "php": "^7.3", "ext-json": "*" }, - "platform-dev": [] + "platform-dev": [], + "plugin-api-version": "1.1.0" } diff --git a/src/LocateDependencies/LocateDependenciesViaComposer.php b/src/LocateDependencies/LocateDependenciesViaComposer.php index 3ff71418d..5486484a5 100644 --- a/src/LocateDependencies/LocateDependenciesViaComposer.php +++ b/src/LocateDependencies/LocateDependenciesViaComposer.php @@ -7,6 +7,7 @@ use Assert\Assert; use Composer\Installer; use Roave\BetterReflection\SourceLocator\Ast\Locator; +use Roave\BetterReflection\SourceLocator\SourceStubber\ReflectionSourceStubber; use Roave\BetterReflection\SourceLocator\Type\AggregateSourceLocator; use Roave\BetterReflection\SourceLocator\Type\Composer\Factory\MakeLocatorForInstalledJson; use Roave\BetterReflection\SourceLocator\Type\PhpInternalSourceLocator; @@ -55,7 +56,7 @@ public function __invoke(string $installationPath) : SourceLocator return new AggregateSourceLocator([ (new MakeLocatorForInstalledJson())->__invoke($installationPath, $this->astLocator), - new PhpInternalSourceLocator($this->astLocator), + new PhpInternalSourceLocator($this->astLocator, new ReflectionSourceStubber()), ]); } diff --git a/test/unit/StringReflectorFactory.php b/test/unit/StringReflectorFactory.php index e6ba1b80a..a11292d70 100644 --- a/test/unit/StringReflectorFactory.php +++ b/test/unit/StringReflectorFactory.php @@ -7,6 +7,7 @@ use Roave\BetterReflection\BetterReflection; use Roave\BetterReflection\Reflector\ClassReflector; use Roave\BetterReflection\SourceLocator\Exception\EmptyPhpSourceCode; +use Roave\BetterReflection\SourceLocator\SourceStubber\ReflectionSourceStubber; use Roave\BetterReflection\SourceLocator\Type\AggregateSourceLocator; use Roave\BetterReflection\SourceLocator\Type\EvaledCodeSourceLocator; use Roave\BetterReflection\SourceLocator\Type\PhpInternalSourceLocator; @@ -20,11 +21,12 @@ final class StringReflectorFactory public function __invoke(string $sourceCode) : ClassReflector { $astLocator = (new BetterReflection())->astLocator(); + $stubber = new ReflectionSourceStubber(); return new ClassReflector( new AggregateSourceLocator([ - new PhpInternalSourceLocator($astLocator), - new EvaledCodeSourceLocator($astLocator), + new PhpInternalSourceLocator($astLocator, $stubber), + new EvaledCodeSourceLocator($astLocator, $stubber), new StringSourceLocator($sourceCode, $astLocator), ]) );