Skip to content

Commit 09f0beb

Browse files
committed
Native method reflection - look in stubs first, then into native runtime PHP reflection
1 parent 43ee94a commit 09f0beb

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

src/Reflection/Php/PhpClassReflectionExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,13 +415,13 @@ private function createMethod(
415415
$stubPhpDocString = null;
416416
$variants = [];
417417
$reflectionMethod = null;
418-
if (class_exists($classReflection->getName(), false)) {
418+
if ($classReflection->getNativeReflection()->hasMethod($methodReflection->getName())) {
419+
$reflectionMethod = $classReflection->getNativeReflection()->getMethod($methodReflection->getName());
420+
} elseif (class_exists($classReflection->getName(), false)) {
419421
$reflectionClass = new \ReflectionClass($classReflection->getName());
420422
if ($reflectionClass->hasMethod($methodReflection->getName())) {
421423
$reflectionMethod = $reflectionClass->getMethod($methodReflection->getName());
422424
}
423-
} else {
424-
$reflectionMethod = $classReflection->getNativeReflection()->getMethod($methodReflection->getName());
425425
}
426426
foreach ($variantNames as $innerVariantName) {
427427
$methodSignature = $this->signatureMapProvider->getFunctionSignature($innerVariantName, $declaringClassName);

tests/PHPStan/Rules/Methods/OverridingMethodRuleTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,4 +336,10 @@ public function testBug3443(): void
336336
$this->analyse([__DIR__ . '/data/bug-3443.php'], []);
337337
}
338338

339+
public function testBug3478(): void
340+
{
341+
$this->phpVersionId = PHP_VERSION_ID;
342+
$this->analyse([__DIR__ . '/data/bug-3478.php'], []);
343+
}
344+
339345
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace Bug3478;
4+
5+
class ExtendedDocument extends \DOMDocument
6+
{
7+
public function saveHTML(\DOMNode $node = null)
8+
{
9+
return parent::saveHTML($node);
10+
}
11+
}

0 commit comments

Comments
 (0)