File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
tests/PHPStan/Analyser/nsrt Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 22
33namespace ArrayAll ;
44
5+ use DateTime ;
6+ use DateTimeImmutable ;
7+
58use function PHPStan \Testing \assertType ;
69
710class 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}
You can’t perform that action at this time.
0 commit comments