Skip to content

Commit 8732aa9

Browse files
committed
Checking for side effects from ancestor metadata
1 parent 113c0cf commit 8732aa9

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Reflection/Php/PhpClassReflectionExtension.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,17 @@ public function createUserlandMethodReflection(ClassReflection $fileDeclaringCla
839839
}
840840
$isInternal = $resolvedPhpDoc->isInternal();
841841
$isFinal = $resolvedPhpDoc->isFinal();
842-
$isPure = $resolvedPhpDoc->isPure();
842+
$isPure = null;
843+
foreach ($actualDeclaringClass->getAncestors() as $className => $_) {
844+
if ($this->signatureMapProvider->hasMethodMetadata($className, $methodReflection->getName())) {
845+
$hasSideEffects = $this->signatureMapProvider->getMethodMetadata($className, $methodReflection->getName())['hasSideEffects'];
846+
$isPure = !$hasSideEffects;
847+
848+
break;
849+
}
850+
}
851+
852+
$isPure ??= $resolvedPhpDoc->isPure();
843853
$asserts = Assertions::createFromResolvedPhpDocBlock($resolvedPhpDoc);
844854
$acceptsNamedArguments = $resolvedPhpDoc->acceptsNamedArguments();
845855
$selfOutType = $resolvedPhpDoc->getSelfOutTag() !== null ? $resolvedPhpDoc->getSelfOutTag()->getType() : null;

0 commit comments

Comments
 (0)