diff --git a/composer.json b/composer.json index faa2375245..4dc091b928 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "nette/utils": "^3.1.3", "nikic/php-parser": "4.10.4", "ondram/ci-detector": "^3.4.0", - "ondrejmirtes/better-reflection": "4.3.52", + "ondrejmirtes/better-reflection": "4.3.53", "phpdocumentor/reflection-docblock": "4.3.4", "phpstan/php-8-stubs": "^0.1.13", "phpstan/phpdoc-parser": "^0.4.9", diff --git a/composer.lock b/composer.lock index 919f59694e..828bdfbfb8 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": "f42fe49e4769379d175c33c0d7cce4dd", + "content-hash": "35ab6f1e16ad329d3e8e9037c80077fe", "packages": [ { "name": "clue/block-react", @@ -2072,16 +2072,16 @@ }, { "name": "ondrejmirtes/better-reflection", - "version": "4.3.52", + "version": "4.3.53", "source": { "type": "git", "url": "https://github.com/ondrejmirtes/BetterReflection.git", - "reference": "a41da9f783e2f452421ffd16dc7b96bae3a14157" + "reference": "408c0588e28204de40e6ffa30af3d545021ac764" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ondrejmirtes/BetterReflection/zipball/a41da9f783e2f452421ffd16dc7b96bae3a14157", - "reference": "a41da9f783e2f452421ffd16dc7b96bae3a14157", + "url": "https://api.github.com/repos/ondrejmirtes/BetterReflection/zipball/408c0588e28204de40e6ffa30af3d545021ac764", + "reference": "408c0588e28204de40e6ffa30af3d545021ac764", "shasum": "" }, "require": { @@ -2140,9 +2140,9 @@ ], "description": "Better Reflection - an improved code reflection API", "support": { - "source": "https://github.com/ondrejmirtes/BetterReflection/tree/4.3.52" + "source": "https://github.com/ondrejmirtes/BetterReflection/tree/4.3.53" }, - "time": "2021-03-17T14:45:49+00:00" + "time": "2021-03-17T15:39:23+00:00" }, { "name": "phpdocumentor/reflection-common", diff --git a/tests/PHPStan/Analyser/AnalyserIntegrationTest.php b/tests/PHPStan/Analyser/AnalyserIntegrationTest.php index c1fd49d004..5c6174b73d 100644 --- a/tests/PHPStan/Analyser/AnalyserIntegrationTest.php +++ b/tests/PHPStan/Analyser/AnalyserIntegrationTest.php @@ -2,11 +2,13 @@ namespace PHPStan\Analyser; +use Bug4288\MyClass; use Bug4713\Service; use PHPStan\Broker\Broker; use PHPStan\File\FileHelper; use PHPStan\Reflection\ParametersAcceptorSelector; use PHPStan\Reflection\SignatureMap\SignatureMapProvider; +use PHPStan\Type\Constant\ConstantIntegerType; use PHPStan\Type\Constant\ConstantStringType; use const PHP_VERSION_ID; use function array_reverse; @@ -352,6 +354,26 @@ public function testBug4713(): void $this->assertSame(Service::class, $defaultValue->getValue()); } + public function testBug4288(): void + { + $errors = $this->runAnalyse(__DIR__ . '/data/bug-4288.php'); + $this->assertCount(0, $errors); + + $reflectionProvider = $this->createBroker(); + $class = $reflectionProvider->getClass(MyClass::class); + $parameter = ParametersAcceptorSelector::selectSingle($class->getNativeMethod('paginate')->getVariants())->getParameters()[0]; + $defaultValue = $parameter->getDefaultValue(); + $this->assertInstanceOf(ConstantIntegerType::class, $defaultValue); + $this->assertSame(10, $defaultValue->getValue()); + + $nativeProperty = $class->getNativeReflection()->getProperty('test'); + if (!method_exists($nativeProperty, 'getDefaultValue')) { + return; + } + + $this->assertSame(10, $nativeProperty->getDefaultValue()); + } + /** * @param string $file * @return \PHPStan\Analyser\Error[] diff --git a/tests/PHPStan/Analyser/data/bug-4288.php b/tests/PHPStan/Analyser/data/bug-4288.php new file mode 100644 index 0000000000..10c2318731 --- /dev/null +++ b/tests/PHPStan/Analyser/data/bug-4288.php @@ -0,0 +1,28 @@ +paginate(); + } +} +