Skip to content

Commit 8759bef

Browse files
committed
fix regression
1 parent 5963972 commit 8759bef

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
@@ -1397,6 +1397,17 @@ private function findGenericTypeAlias(string $name, NameScope $nameScope): ?Type
13971397
return null;
13981398
}
13991399

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

0 commit comments

Comments
 (0)