Skip to content

Commit fac7a75

Browse files
author
Matthieu Renard
committed
Fix bug #9630 (?)
1 parent 1846ffd commit fac7a75

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

src/Type/FileTypeMapper.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,35 @@ public function getResolvedPhpDoc(
109109
return $this->createResolvedPhpDocBlock($phpDocKey, $nameScopeMap[$nameScopeKey], $docComment, $fileName);
110110
}
111111

112+
$keyFileName = $fileName;
112113
if (!isset($this->inProcess[$fileName][$nameScopeKey])) { // wrong $fileName due to traits
114+
if (!is_null($className)) {
115+
$reflectionProvider = $this->reflectionProviderProvider->getReflectionProvider();
116+
if ($reflectionProvider->hasClass($className)) {
117+
$classFileName = $reflectionProvider->getClass($className)->getFileName();
118+
$nameScopeKeyCandidate = $this->getNameScopeKey($classFileName, $className, $traitName, $functionName);
119+
if (isset($this->inProcess[$classFileName][$nameScopeKeyCandidate])) {
120+
$keyFileName = $classFileName;
121+
$nameScopeKey = $nameScopeKeyCandidate;
122+
}
123+
}
124+
}
125+
}
126+
if (!isset($this->inProcess[$keyFileName][$nameScopeKey])) {
113127
return ResolvedPhpDocBlock::createEmpty();
114128
}
115129

116-
if ($this->inProcess[$fileName][$nameScopeKey] === true) { // PHPDoc has cyclic dependency
130+
if ($this->inProcess[$keyFileName][$nameScopeKey] === true) { // PHPDoc has cyclic dependency
117131
return ResolvedPhpDocBlock::createEmpty();
118132
}
119133

120-
if (is_callable($this->inProcess[$fileName][$nameScopeKey])) {
121-
$resolveCallback = $this->inProcess[$fileName][$nameScopeKey];
122-
$this->inProcess[$fileName][$nameScopeKey] = true;
123-
$this->inProcess[$fileName][$nameScopeKey] = $resolveCallback();
134+
if (is_callable($this->inProcess[$keyFileName][$nameScopeKey])) {
135+
$resolveCallback = $this->inProcess[$keyFileName][$nameScopeKey];
136+
$this->inProcess[$keyFileName][$nameScopeKey] = true;
137+
$this->inProcess[$keyFileName][$nameScopeKey] = $resolveCallback();
124138
}
125139

126-
return $this->createResolvedPhpDocBlock($phpDocKey, $this->inProcess[$fileName][$nameScopeKey], $docComment, $fileName);
140+
return $this->createResolvedPhpDocBlock($phpDocKey, $this->inProcess[$keyFileName][$nameScopeKey], $docComment, $fileName);
127141
}
128142

129143
private function createResolvedPhpDocBlock(string $phpDocKey, NameScope $nameScope, string $phpDocString, ?string $fileName): ResolvedPhpDocBlock

0 commit comments

Comments
 (0)