Skip to content

Commit

Permalink
Fix result cache bug with imported type aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jul 13, 2023
1 parent 0fa6903 commit 553c4b1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Dependency/DependencyResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use PHPStan\File\FileHelper;
use PHPStan\Node\ClassPropertyNode;
use PHPStan\Node\InClassMethodNode;
use PHPStan\Node\InClassNode;
use PHPStan\Node\InFunctionNode;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\FunctionReflection;
Expand Down Expand Up @@ -44,6 +45,22 @@ public function resolveDependencies(Node $node, Scope $scope): NodeDependencies
{
$dependenciesReflections = [];

if ($node instanceof InClassNode) {
$docComment = $node->getDocComment();
if ($docComment !== null) {
$phpDoc = $this->fileTypeMapper->getResolvedPhpDoc(
$scope->getFile(),
$scope->isInClass() ? $scope->getClassReflection()->getName() : null,
$scope->isInTrait() ? $scope->getTraitReflection()->getName() : null,
null,
$docComment->getText(),
);
foreach ($phpDoc->getTypeAliasImportTags() as $importTag) {
$this->addClassToDependencies($importTag->getImportedFrom(), $dependenciesReflections);
}
}
}

if ($node instanceof Node\Stmt\Class_) {
if ($node->namespacedName !== null) {
$this->addClassToDependencies($node->namespacedName->toString(), $dependenciesReflections);
Expand Down

0 comments on commit 553c4b1

Please sign in to comment.