File tree Expand file tree Collapse file tree
tests/PHPStan/Rules/Methods/data Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55use function PHPStan \Testing \assertType ;
66
7- class MondayMorning
7+ class Foo
88{
99 /**
1010 * @param callable-array $task
1111 */
12- public function call (array $ task ): void
12+ public function doFoo (array $ task ): void
1313 {
1414 foreach ($ task as $ k => $ v ) {
1515 assertType ('0|1 ' , $ k );
@@ -18,6 +18,22 @@ public function call(array $task): void
1818 assertType ('class-string|object ' , $ task [0 ]);
1919 assertType ('string ' , $ task [1 ]);
2020 }
21+
22+ /**
23+ * @param non-empty-list<string> $list
24+ */
25+ public function doBar (array $ list ): void
26+ {
27+ if ($ list [0 ] !== '' ) {
28+ assertType ('non-empty-list<string>&hasOffsetValue(0, non-empty-string) ' , $ list );
29+
30+ if (is_callable ($ list )) {
31+ assertType ('non-empty-list<string>&callable(): mixed&hasOffsetValue(0, non-empty-string) ' , $ list );
32+ assertType ('non-empty-string ' , $ list [0 ]);
33+ assertType ('string ' , $ list [1 ]);
34+ }
35+ }
36+ }
2137}
2238
2339
You can’t perform that action at this time.
0 commit comments