1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Use unalised trait name when importing aliased trait (#2393)

Fixes vimeo/psalm#2392
Refs vimeo/psalm#2278
This commit is contained in:
Bruce Weirdan 2019-11-29 08:21:00 +02:00 committed by Matthew Brown
parent 4052e6dfac
commit 33142e7637
2 changed files with 13 additions and 5 deletions

View File

@ -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
);

View File

@ -449,6 +449,13 @@ class ClassTest extends TestCase
echo A_A::class;'
],
'classAliasTrait' => [
'<?php
trait FeatureV1 {}
class_alias(FeatureV1::class, Feature::class);
class App { use Feature; }
'
]
];
}