Skip to content

Commit f61bbac

Browse files
herndlmondrejmirtes
authored andcommitted
Improve isList
1 parent 4bd0967 commit f61bbac

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/Type/WebMozartAssert/AssertTypeSpecifyingExtension.php

+12-3
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,18 @@ private static function getExpressionResolvers(): array
307307
);
308308
},
309309
'isList' => static function (Scope $scope, Arg $expr): Expr {
310-
return new FuncCall(
311-
new Name('is_array'),
312-
[$expr]
310+
return new BooleanAnd(
311+
new FuncCall(
312+
new Name('is_array'),
313+
[$expr]
314+
),
315+
new Identical(
316+
$expr->value,
317+
new FuncCall(
318+
new Name('array_values'),
319+
[$expr]
320+
)
321+
)
313322
);
314323
},
315324
'isCountable' => static function (Scope $scope, Arg $expr): Expr {

tests/Type/WebMozartAssert/data/array.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ public function countBetween(array $a, array $b, array $c, array $d): void
100100
public function isList($a, $b): void
101101
{
102102
Assert::isList($a);
103-
\PHPStan\Testing\assertType('array', $a);
103+
\PHPStan\Testing\assertType('array<int, mixed>', $a);
104104

105105
Assert::nullOrIsList($b);
106-
\PHPStan\Testing\assertType('array|null', $b);
106+
\PHPStan\Testing\assertType('array<int, mixed>|null', $b);
107107
}
108108

109109
}

0 commit comments

Comments
 (0)