Skip to content

Commit 553c4b1

Browse files
committed
Fix result cache bug with imported type aliases
1 parent 0fa6903 commit 553c4b1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/Dependency/DependencyResolver.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPStan\File\FileHelper;
1515
use PHPStan\Node\ClassPropertyNode;
1616
use PHPStan\Node\InClassMethodNode;
17+
use PHPStan\Node\InClassNode;
1718
use PHPStan\Node\InFunctionNode;
1819
use PHPStan\Reflection\ClassReflection;
1920
use PHPStan\Reflection\FunctionReflection;
@@ -44,6 +45,22 @@ public function resolveDependencies(Node $node, Scope $scope): NodeDependencies
4445
{
4546
$dependenciesReflections = [];
4647

48+
if ($node instanceof InClassNode) {
49+
$docComment = $node->getDocComment();
50+
if ($docComment !== null) {
51+
$phpDoc = $this->fileTypeMapper->getResolvedPhpDoc(
52+
$scope->getFile(),
53+
$scope->isInClass() ? $scope->getClassReflection()->getName() : null,
54+
$scope->isInTrait() ? $scope->getTraitReflection()->getName() : null,
55+
null,
56+
$docComment->getText(),
57+
);
58+
foreach ($phpDoc->getTypeAliasImportTags() as $importTag) {
59+
$this->addClassToDependencies($importTag->getImportedFrom(), $dependenciesReflections);
60+
}
61+
}
62+
}
63+
4764
if ($node instanceof Node\Stmt\Class_) {
4865
if ($node->namespacedName !== null) {
4966
$this->addClassToDependencies($node->namespacedName->toString(), $dependenciesReflections);

0 commit comments

Comments
 (0)