File tree Expand file tree Collapse file tree 3 files changed +52
-6
lines changed
tests/PHPStan/Rules/PhpDoc Expand file tree Collapse file tree 3 files changed +52
-6
lines changed Original file line number Diff line number Diff line change @@ -1373,13 +1373,10 @@ public function getTypeAliases(): array
13731373
13741374 $ typeAliasImportTags = $ resolvedPhpDoc ->getTypeAliasImportTags ();
13751375 $ typeAliasTags = $ resolvedPhpDoc ->getTypeAliasTags ();
1376+ $ localAliases = array_map (static fn (TypeAliasTag $ typeAliasTag ): TypeAlias => $ typeAliasTag ->getTypeAlias (), $ typeAliasTags );
13761377
13771378 // prevent circular imports
13781379 if (array_key_exists ($ this ->getName (), self ::$ resolvingTypeAliasImports )) {
1379- // Return only local type aliases to break the cycle.
1380- // Imported aliases are not available yet, but local ones
1381- // don't depend on other classes and can be returned safely.
1382- $ localAliases = array_map (static fn (TypeAliasTag $ typeAliasTag ): TypeAlias => $ typeAliasTag ->getTypeAlias (), $ typeAliasTags );
13831380 if ($ localAliases !== []) {
13841381 return $ this ->typeAliases = $ localAliases ;
13851382 }
@@ -1413,8 +1410,6 @@ public function getTypeAliases(): array
14131410
14141411 unset(self ::$ resolvingTypeAliasImports [$ this ->getName ()]);
14151412
1416- $ localAliases = array_map (static fn (TypeAliasTag $ typeAliasTag ): TypeAlias => $ typeAliasTag ->getTypeAlias (), $ typeAliasTags );
1417-
14181413 $ this ->typeAliases = array_filter (
14191414 array_merge ($ importedAliases , $ localAliases ),
14201415 static fn (?TypeAlias $ typeAlias ): bool => $ typeAlias !== null ,
Original file line number Diff line number Diff line change @@ -492,4 +492,9 @@ public function testBug11463(): void
492492 $ this ->analyse ([__DIR__ . '/data/bug-11463.php ' ], []);
493493 }
494494
495+ public function testBug11463b (): void
496+ {
497+ $ this ->analyse ([__DIR__ . '/data/bug-11463b.php ' ], []);
498+ }
499+
495500}
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 );
2+
3+ namespace Bug11463b ;
4+
5+ /**
6+ * @phpstan-type Foo 'foo'
7+ *
8+ * @phpstan-import-type Bar from BarType
9+ * @phpstan-import-type Baz from BazType
10+ */
11+ class FooType
12+ {
13+ /**
14+ * @param Bar $bar
15+ */
16+ public function foo (string $ bar ): void {}
17+
18+ /**
19+ * @param Baz $bar
20+ */
21+ public function baz (string $ bar ): void {}
22+ }
23+
24+ /**
25+ * @phpstan-import-type Foo from FooType
26+ *
27+ * @phpstan-type Bar 'bar'
28+ * @phpstan-import-type Baz from BazType
29+ */
30+ class BarType {
31+ /**
32+ * @param Foo $foo
33+ */
34+ public function bar ($ foo ): string { return $ foo ; }
35+
36+ /**
37+ * @param Baz $bar
38+ */
39+ public function baz (string $ bar ): void {}
40+ }
41+
42+ /**
43+ * @phpstan-type Baz 'baz'
44+ */
45+ class BazType {
46+ }
You can’t perform that action at this time.
0 commit comments