diff --git a/src/Psalm/Internal/Analyzer/FileAnalyzer.php b/src/Psalm/Internal/Analyzer/FileAnalyzer.php index d98795589..80db22ed9 100644 --- a/src/Psalm/Internal/Analyzer/FileAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FileAnalyzer.php @@ -237,7 +237,7 @@ class FileAnalyzer extends SourceAnalyzer $this->suppressed_issues, new ClassLikeNameOptions( true, - false, + true, true, true, true, diff --git a/src/Psalm/Internal/Type/TypeExpander.php b/src/Psalm/Internal/Type/TypeExpander.php index 61af64106..0855a1ab7 100644 --- a/src/Psalm/Internal/Type/TypeExpander.php +++ b/src/Psalm/Internal/Type/TypeExpander.php @@ -283,7 +283,9 @@ final class TypeExpander $declaring_fq_classlike_name = $self_class; } - if (!($evaluate_class_constants && $codebase->classOrInterfaceOrEnumExists($declaring_fq_classlike_name))) { + if (!($evaluate_class_constants + && $codebase->classlikes->doesClassLikeExist(strtolower($declaring_fq_classlike_name)) + )) { return [$return_type]; } diff --git a/tests/TypeAnnotationTest.php b/tests/TypeAnnotationTest.php index ea4d4be65..0e101137c 100644 --- a/tests/TypeAnnotationTest.php +++ b/tests/TypeAnnotationTest.php @@ -884,6 +884,21 @@ class TypeAnnotationTest extends TestCase 'ignored_issues' => [], 'php_version' => '8.1', ], + 'importFromTrait' => [ + 'code' => <<<'PHP' + [ 'code' => <<<'PHP'