Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rework
  • Loading branch information
VincentLanglet committed Nov 3, 2025
commit 61a0974111f26d5aba3233e78aceed831180bb89
23 changes: 19 additions & 4 deletions src/PhpDoc/ResolvedPhpDocBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,7 @@ public static function createEmpty(): self
*/
public function merge(array $parents, array $parentPhpDocBlocks): self
{
$className = $this->nameScope !== null ? $this->nameScope->getClassName() : null;
$classReflection = $className !== null && $this->reflectionProvider->hasClass($className)
? $this->reflectionProvider->getClass($className)
: null;
$classReflection = $this->getClassReflection();

// new property also needs to be added to createEmpty()
$result = new self();
Expand Down Expand Up @@ -461,6 +458,16 @@ public function getNullableNameScope(): ?NameScope
return $this->nameScope;
}

private function getClassReflection(): ?ClassReflection
{
$className = $this->nameScope?->getClassName();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The phpstan downgrade process does not support null-safe calls. You need regular if-null checks for php7 compat

if ($className === null || !$this->reflectionProvider->hasClass($className)) {
return null;
}

return $this->reflectionProvider->getClass($className);
}

/**
* @return array<(string|int), VarTag>
*/
Expand Down Expand Up @@ -827,6 +834,14 @@ public function isPure(): ?bool
return $this->isPure;
}

if ($this->nameScope !== null) {
$classReflection = $this->getClassReflection();
if ($classReflection !== null) {
$this->isPure = $classReflection->getDefaultMethodPurity();
return $this->isPure;
}
}

$this->isPure = null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Reflection/Php/PhpClassReflectionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ public function createUserlandMethodReflection(ClassReflection $fileDeclaringCla
}
}

$isPure ??= $resolvedPhpDoc->isPure() ?? $phpDocBlockClassReflection->getDefaultMethodPurity();
$isPure ??= $resolvedPhpDoc->isPure();
$asserts = Assertions::createFromResolvedPhpDocBlock($resolvedPhpDoc);
$acceptsNamedArguments = $resolvedPhpDoc->acceptsNamedArguments();
$selfOutType = $resolvedPhpDoc->getSelfOutTag() !== null ? $resolvedPhpDoc->getSelfOutTag()->getType() : null;
Expand Down