File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -782,6 +782,9 @@ public function getArraySize(): Type
782782
783783 public function getIterableKeyType (): Type
784784 {
785+ if ($ this ->isCallable ()->yes () && $ this ->isArray ()->yes ()) {
786+ return new UnionType ([new ConstantIntegerType (0 ), new ConstantIntegerType (1 )]);
787+ }
785788 return $ this ->intersectTypes (static fn (Type $ type ): Type => $ type ->getIterableKeyType ());
786789 }
787790
@@ -797,6 +800,9 @@ public function getLastIterableKeyType(): Type
797800
798801 public function getIterableValueType (): Type
799802 {
803+ if ($ this ->isCallable ()->yes () && $ this ->isArray ()->yes ()) {
804+ return new UnionType ([new ObjectWithoutClassType (), new StringType ()]);
805+ }
800806 return $ this ->intersectTypes (static fn (Type $ type ): Type => $ type ->getIterableValueType ());
801807 }
802808
Original file line number Diff line number Diff line change @@ -174,6 +174,7 @@ private static function findTestFiles(): iterable
174174 yield __DIR__ . '/../Rules/Variables/data/bug-7417.php ' ;
175175 yield __DIR__ . '/../Rules/Arrays/data/bug-7469.php ' ;
176176 yield __DIR__ . '/../Rules/Variables/data/bug-3391.php ' ;
177+ yield __DIR__ . '/../Rules/Methods/data/bug-14549.php ' ;
177178
178179 yield __DIR__ . '/../Rules/Functions/data/bug-anonymous-function-method-constant.php ' ;
179180
Original file line number Diff line number Diff line change 22
33namespace Bug14549 ;
44
5+ use function PHPStan \Testing \assertType ;
6+
57class MondayMorning
68{
79 /**
810 * @param callable-array $task
911 */
1012 public function call (array $ task ): void
1113 {
14+ foreach ($ task as $ k => $ v ) {
15+ assertType ('0|1 ' , $ k );
16+ assertType ('object|string ' , $ v );
17+ }
18+ assertType ('class-string|object ' , $ task [0 ]);
19+ assertType ('string ' , $ task [1 ]);
1220 }
1321}
1422
You can’t perform that action at this time.
0 commit comments