diff --git a/src/Reflection/Runtime/RuntimeReflectionProvider.php b/src/Reflection/Runtime/RuntimeReflectionProvider.php index f7e3eca7ef..7221bae4c3 100644 --- a/src/Reflection/Runtime/RuntimeReflectionProvider.php +++ b/src/Reflection/Runtime/RuntimeReflectionProvider.php @@ -302,7 +302,7 @@ private function getCustomFunction(\PhpParser\Node\Name $nameNode, ?Scope $scope public function resolveFunctionName(\PhpParser\Node\Name $nameNode, ?Scope $scope): ?string { return $this->resolveName($nameNode, function (string $name): bool { - $exists = function_exists($name); + $exists = function_exists($name) || $this->nativeFunctionReflectionProvider->findFunctionReflection($name) !== null; if ($exists) { if ($this->phpStormStubsSourceStubber->isPresentFunction($name) === false) { return false; diff --git a/tests/PHPStan/Analyser/AnalyserIntegrationTest.php b/tests/PHPStan/Analyser/AnalyserIntegrationTest.php index 5c6174b73d..d610d6d798 100644 --- a/tests/PHPStan/Analyser/AnalyserIntegrationTest.php +++ b/tests/PHPStan/Analyser/AnalyserIntegrationTest.php @@ -374,6 +374,12 @@ public function testBug4288(): void $this->assertSame(10, $nativeProperty->getDefaultValue()); } + public function testBug4702(): void + { + $errors = $this->runAnalyse(__DIR__ . '/data/bug-4702.php'); + $this->assertCount(0, $errors); + } + /** * @param string $file * @return \PHPStan\Analyser\Error[] diff --git a/tests/PHPStan/Analyser/data/bug-4702.php b/tests/PHPStan/Analyser/data/bug-4702.php new file mode 100644 index 0000000000..6b7b2c474f --- /dev/null +++ b/tests/PHPStan/Analyser/data/bug-4702.php @@ -0,0 +1,6 @@ +