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:
commit
38d7d435c8
@ -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,
|
||||||
|
@ -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];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user