mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Allow typedef imports from any classlike type
All we really need is for the source to be autoloadable, and it includes all classlikes (interfaces, classes, enums and traits at the time of writing).
This commit is contained in:
parent
9ec556bb14
commit
6140f6881c
@ -237,7 +237,7 @@ class FileAnalyzer extends SourceAnalyzer
|
||||
$this->suppressed_issues,
|
||||
new ClassLikeNameOptions(
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
|
@ -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];
|
||||
}
|
||||
|
||||
|
@ -884,6 +884,21 @@ class TypeAnnotationTest extends TestCase
|
||||
'ignored_issues' => [],
|
||||
'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' => [
|
||||
'code' => <<<'PHP'
|
||||
<?php
|
||||
|
Loading…
Reference in New Issue
Block a user