Skip to content

Commit dcb3839

Browse files
committed
Fix all* methods for partially iterable types
1 parent 5119d01 commit dcb3839

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/Type/WebMozartAssert/AssertTypeSpecifyingExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ private function arrayOrIterable(
441441
\Closure $typeCallback
442442
): SpecifiedTypes
443443
{
444-
$currentType = $scope->getType($expr);
444+
$currentType = TypeCombinator::intersect($scope->getType($expr), new IterableType(new MixedType(), new MixedType()));
445445
$arrayTypes = TypeUtils::getArrays($currentType);
446446
if (count($arrayTypes) > 0) {
447447
$newArrayTypes = [];

tests/Type/WebMozartAssert/AssertTypeSpecifyingExtensionTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ public function testExtension(): void
172172
'Variable $ag is: class-string',
173173
134,
174174
],
175+
[
176+
'Variable $ah is: array<stdClass>',
177+
141,
178+
],
175179
]);
176180
}
177181

tests/Type/WebMozartAssert/data/data.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class Foo
88
{
99

10-
public function doFoo($a, $b, array $c, iterable $d, $e, $f, $g, $h, $i, $j, $k, $l, $m, $n, $o, $p, $r, $s, ?int $t, ?int $u, $x, $aa, array $ab, $ac, $ad, $ae, $af, $ag)
10+
public function doFoo($a, $b, array $c, iterable $d, $e, $f, $g, $h, $i, $j, $k, $l, $m, $n, $o, $p, $r, $s, ?int $t, ?int $u, $x, $aa, array $ab, $ac, $ad, $ae, $af, $ag, array $ah)
1111
{
1212
$a;
1313

@@ -132,6 +132,13 @@ public function doFoo($a, $b, array $c, iterable $d, $e, $f, $g, $h, $i, $j, $k,
132132

133133
Assert::classExists($ag);
134134
$ag;
135+
136+
if (rand(0, 1)) {
137+
$ah = false;
138+
}
139+
140+
Assert::allIsInstanceOf($ah, \stdClass::class);
141+
$ah;
135142
}
136143

137144
}

0 commit comments

Comments
 (0)