1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-02 09:37:59 +01:00

Merge pull request #10625 from weirdan/allow-typedef-imports-from-any-kind-of-classlike

This commit is contained in:
Bruce Weirdan 2024-02-01 13:05:07 -04:00 committed by GitHub
commit 38d7d435c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 2 deletions

View File

@ -237,7 +237,7 @@ class FileAnalyzer extends SourceAnalyzer
$this->suppressed_issues, $this->suppressed_issues,
new ClassLikeNameOptions( new ClassLikeNameOptions(
true, true,
false, true,
true, true,
true, true,
true, true,

View File

@ -283,7 +283,9 @@ final class TypeExpander
$declaring_fq_classlike_name = $self_class; $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]; return [$return_type];
} }

View File

@ -884,6 +884,21 @@ class TypeAnnotationTest extends TestCase
'ignored_issues' => [], 'ignored_issues' => [],
'php_version' => '8.1', 'php_version' => '8.1',
], ],
'importFromTrait' => [
'code' => <<<'PHP'
<?php
/** @psalm-type _Foo = array{foo: string} */
trait T {}
/** @psalm-import-type _Foo from T */
class C {
/** @param _Foo $foo */
public function f(array $foo): void {
echo $foo['foo'];
}
}
PHP,
],
'inlineComments' => [ 'inlineComments' => [
'code' => <<<'PHP' 'code' => <<<'PHP'
<?php <?php