Skip to content

Commit 35e6eff

Browse files
authored
Merge pull request #10617 from weirdan/10416-import-typedefs-from-enums
2 parents baa8660 + 6d32d2f commit 35e6eff

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/Psalm/Internal/Type/TypeExpander.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ public static function expandAtomic(
283283
$declaring_fq_classlike_name = $self_class;
284284
}
285285

286-
if (!($evaluate_class_constants && $codebase->classOrInterfaceExists($declaring_fq_classlike_name))) {
286+
if (!($evaluate_class_constants && $codebase->classOrInterfaceOrEnumExists($declaring_fq_classlike_name))) {
287287
return [$return_type];
288288
}
289289

tests/TypeAnnotationTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,25 @@ public function doesNotWork($_doesNotWork): void {
865865
}
866866
}',
867867
],
868+
'importFromEnum' => [
869+
'code' => <<<'PHP'
870+
<?php
871+
/** @psalm-type _Foo = array{foo: string} */
872+
enum E {}
873+
/**
874+
* @psalm-import-type _Foo from E
875+
*/
876+
class C {
877+
/** @param _Foo $foo */
878+
public function f(array $foo): void {
879+
echo $foo['foo'];
880+
}
881+
}
882+
PHP,
883+
'assertions' => [],
884+
'ignored_issues' => [],
885+
'php_version' => '8.1',
886+
],
868887
];
869888
}
870889

0 commit comments

Comments
 (0)