Skip to content

Commit 30e27db

Browse files
committed
cleanup
1 parent 68e65e9 commit 30e27db

File tree

3 files changed

+33
-13
lines changed

3 files changed

+33
-13
lines changed

src/Rules/PHPUnit/DataProviderDataRule.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ public function processNode(Node $node, Scope $scope): array
5555
$constantArrays = [];
5656
$exprType = $scope->getType($node->expr);
5757
$exprConstArrays = $exprType->getConstantArrays();
58-
if ($exprConstArrays !== []) {
59-
foreach ($exprConstArrays as $constArray) {
60-
foreach ($constArray->getValueTypes() as $valueType) {
61-
foreach ($valueType->getConstantArrays() as $constValueArray) {
62-
$constantArrays[] = $constValueArray;
63-
}
58+
foreach ($exprConstArrays as $constArray) {
59+
foreach ($constArray->getValueTypes() as $valueType) {
60+
foreach ($valueType->getConstantArrays() as $constValueArray) {
61+
$constantArrays[] = $constValueArray;
6462
}
6563
}
66-
} else {
64+
}
65+
66+
if ($constantArrays === []) {
6767
$constantArrays = $exprType->getIterableValueType()->getConstantArrays();
6868
}
6969
} elseif ($node instanceof Node\Expr\Yield_) {

tests/Rules/PHPUnit/DataProviderDataRuleTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,24 +139,24 @@ public function testRule(): void
139139
355,
140140
],
141141
[
142-
'Unknown parameter $foo in call to method DataProviderDataTest\TestIterable::testBar().',
142+
'Unknown parameter $foo in call to method DataProviderDataTest\TestArrayShapeIterable::testBar().',
143143
371,
144144
],
145145
[
146-
'Missing parameter $si (int) in call to method DataProviderDataTest\TestIterable::testBar().',
146+
'Missing parameter $si (int) in call to method DataProviderDataTest\TestArrayShapeIterable::testBar().',
147147
371,
148148
],
149149
[
150150
'Parameter #1 $i of method DataProviderDataTest\TestArrayIterator::testBar() expects int, int|string given.',
151-
401,
151+
421,
152152
],
153153
[
154154
'Parameter #1 $i of method DataProviderDataTest\TestArrayIterator::testFoo() expects int, int|string given.',
155-
401,
155+
421,
156156
],
157157
[
158158
'Parameter #1 $s1 of method DataProviderDataTest\TestArrayIterator::testFooBar() expects string, int|string given.',
159-
401,
159+
421,
160160
],
161161
]);
162162
}

tests/Rules/PHPUnit/data/data-provider-data.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ public function aProvider(): iterable
359359
}
360360
}
361361

362-
class TestIterable extends TestCase
362+
class TestArrayShapeIterable extends TestCase
363363
{
364364
/** @dataProvider aProvider */
365365
public function testBar(int $si): void
@@ -379,6 +379,26 @@ public function data(): iterable
379379
}
380380
}
381381

382+
class TestTypedIterable extends TestCase
383+
{
384+
/** @dataProvider aProvider */
385+
public function testBar(int $si): void
386+
{
387+
}
388+
389+
public function aProvider(): iterable
390+
{
391+
return $this->data();
392+
}
393+
394+
/**
395+
* @return iterable<array<int>>
396+
*/
397+
public function data(): iterable
398+
{
399+
}
400+
}
401+
382402
class TestArrayIterator extends TestCase
383403
{
384404
/** @dataProvider aProvider */

0 commit comments

Comments
 (0)