Skip to content

Commit

Permalink
Fix result-cache with phpstan-types on New_ references
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Jan 30, 2024
1 parent e25e29e commit cd8e4d4
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Dependency/DependencyResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,19 @@ public function resolveDependencies(Node $node, Scope $scope): NodeDependencies
$node instanceof Node\Expr\New_
&& $node->class instanceof Node\Name
) {
$this->addClassToDependencies($scope->resolveName($node->class), $dependenciesReflections);
$className = $scope->resolveName($node->class);
$this->addClassToDependencies($className, $dependenciesReflections);

if ($this->reflectionProvider->hasClass($className)) {
$classReflection = $this->reflectionProvider->getClass($className);

$phpDoc = $classReflection->getResolvedPhpDoc();
if ($phpDoc !== null) {
foreach ($phpDoc->getTypeAliasImportTags() as $importTag) {
$this->addClassToDependencies($importTag->getImportedFrom(), $dependenciesReflections);
}
}
}
} elseif ($node instanceof Node\Stmt\Trait_ && $node->namespacedName !== null) {
try {
$classReflection = $this->reflectionProvider->getClass($node->namespacedName->toString());
Expand Down

0 comments on commit cd8e4d4

Please sign in to comment.