diff --git a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php index c752a631a..854f9e84a 100644 --- a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php @@ -1380,7 +1380,8 @@ class ClassAnalyzer extends ClassLikeAnalyzer continue; } - $trait_storage = $codebase->classlike_storage_provider->get($fq_trait_name); + $fq_trait_name_resolved = $codebase->classlikes->getUnAliasedName($fq_trait_name); + $trait_storage = $codebase->classlike_storage_provider->get($fq_trait_name_resolved); if ($trait_storage->deprecated) { if (IssueBuffer::accepts( @@ -1394,13 +1395,13 @@ class ClassAnalyzer extends ClassLikeAnalyzer } } - $trait_file_analyzer = $project_analyzer->getFileAnalyzerForClassLike($fq_trait_name); - $trait_node = $codebase->classlikes->getTraitNode($fq_trait_name); - $trait_aliases = $codebase->classlikes->getTraitAliases($fq_trait_name); + $trait_file_analyzer = $project_analyzer->getFileAnalyzerForClassLike($fq_trait_name_resolved); + $trait_node = $codebase->classlikes->getTraitNode($fq_trait_name_resolved); + $trait_aliases = $codebase->classlikes->getTraitAliases($fq_trait_name_resolved); $trait_analyzer = new TraitAnalyzer( $trait_node, $trait_file_analyzer, - $fq_trait_name, + $fq_trait_name_resolved, $trait_aliases ); diff --git a/tests/ClassTest.php b/tests/ClassTest.php index e4fb7d433..43169e0dc 100644 --- a/tests/ClassTest.php +++ b/tests/ClassTest.php @@ -449,6 +449,13 @@ class ClassTest extends TestCase echo A_A::class;' ], + 'classAliasTrait' => [ + '