Skip to content

Commit 3ef5f1b

Browse files
committed
fix regression
1 parent 53e48f6 commit 3ef5f1b

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/PhpDoc/TypeNodeResolver.php

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

1401+
// Fast path: if the name isn't registered as a type alias in this scope, skip the
1402+
// more expensive ClassReflection::getTypeAliases() call. This also prevents a circular
1403+
// NameScope-building issue: getTypeAliases() can trigger FileTypeMapper::getResolvedPhpDoc()
1404+
// which calls getNameScope() — if we are already inside getNameScope() for this class,
1405+
// that throws NameScopeAlreadyBeingCreatedException, causing the class's ResolvedPhpDocBlock
1406+
// to be poisoned with an empty block and all its type aliases to be lost.
1407+
// UsefulTypeAliasResolver uses the same guard.
1408+
if (!$nameScope->hasTypeAlias($name)) {
1409+
return null;
1410+
}
1411+
14011412
$className = $nameScope->getClassNameForTypeAlias();
14021413
if ($className === null || !$this->getReflectionProvider()->hasClass($className)) {
14031414
return null;

0 commit comments

Comments
 (0)