Skip to content

Commit e44e476

Browse files
uekannuekann
authored andcommitted
Add new test case for array_all
1 parent c265a6a commit e44e476

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/PHPStan/Analyser/nsrt/array-all.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace ArrayAll;
44

5+
use DateTime;
6+
use DateTimeImmutable;
7+
58
use function PHPStan\Testing\assertType;
69

710
class Foo {
@@ -58,4 +61,22 @@ public function test6($array) {
5861
assertType("array<mixed>", $array);
5962
}
6063
}
64+
65+
/**
66+
* @param array<mixed> $array
67+
*/
68+
public function test7($array) {
69+
if (array_all($array, fn ($value) => $value instanceof DateTime)) {
70+
assertType("array<DateTime>", $array);
71+
}
72+
}
73+
74+
/**
75+
* @param array<mixed> $array
76+
*/
77+
public function test8($array) {
78+
if (array_all($array, fn ($value) => $value instanceof DateTime || $value instanceof DateTimeImmutable)) {
79+
assertType("array<DateTime|DateTimeImmutable>", $array);
80+
}
81+
}
6182
}

0 commit comments

Comments
 (0)