Skip to content

Commit 7c1d51f

Browse files
committed
fix regression
1 parent 2d0ee50 commit 7c1d51f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/PhpDoc/TypeNodeResolver.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,6 +1432,17 @@ private function findGenericTypeAlias(string $name, NameScope $nameScope): ?Type
14321432
return null;
14331433
}
14341434

1435+
// Fast path: if the name isn't registered as a type alias in this scope, skip the
1436+
// more expensive ClassReflection::getTypeAliases() call. This also prevents a circular
1437+
// NameScope-building issue: getTypeAliases() can trigger FileTypeMapper::getResolvedPhpDoc()
1438+
// which calls getNameScope() — if we are already inside getNameScope() for this class,
1439+
// that throws NameScopeAlreadyBeingCreatedException, causing the class's ResolvedPhpDocBlock
1440+
// to be poisoned with an empty block and all its type aliases to be lost.
1441+
// UsefulTypeAliasResolver uses the same guard.
1442+
if (!$nameScope->hasTypeAlias($name)) {
1443+
return null;
1444+
}
1445+
14351446
$className = $nameScope->getClassNameForTypeAlias();
14361447
if ($className === null || !$this->getReflectionProvider()->hasClass($className)) {
14371448
return null;

0 commit comments

Comments
 (0)