Skip to content
Permalink
Browse files

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

Fixes #2392
Refs #2278
  • Loading branch information
weirdan authored and muglug committed Nov 29, 2019
1 parent 4052e6d commit 33142e76376d4725680fb554b5ef1d52f470b9d9
Showing with 13 additions and 5 deletions.
  1. +6 −5 src/Psalm/Internal/Analyzer/ClassAnalyzer.php
  2. +7 −0 tests/ClassTest.php
@@ -1380,7 +1380,8 @@ private function analyzeTraitUse(
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 @@ private function analyzeTraitUse(
}
}
$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
);
@@ -449,6 +449,13 @@ class_alias("A", "A_A");
echo A_A::class;'
],
'classAliasTrait' => [
'<?php
trait FeatureV1 {}
class_alias(FeatureV1::class, Feature::class);
class App { use Feature; }
'
]
];
}

0 comments on commit 33142e7

Please sign in to comment.
You can’t perform that action at this time.