File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -774,6 +774,9 @@ public function getArraySize(): Type
774774
775775 public function getIterableKeyType (): Type
776776 {
777+ if ($ this ->isCallable ()->yes () && $ this ->isArray ()->yes ()) {
778+ return new UnionType ([new ConstantIntegerType (0 ), new ConstantIntegerType (1 )]);
779+ }
777780 return $ this ->intersectTypes (static fn (Type $ type ): Type => $ type ->getIterableKeyType ());
778781 }
779782
@@ -789,6 +792,9 @@ public function getLastIterableKeyType(): Type
789792
790793 public function getIterableValueType (): Type
791794 {
795+ if ($ this ->isCallable ()->yes () && $ this ->isArray ()->yes ()) {
796+ return new UnionType ([new ObjectWithoutClassType (), new StringType ()]);
797+ }
792798 return $ this ->intersectTypes (static fn (Type $ type ): Type => $ type ->getIterableValueType ());
793799 }
794800
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