Skip to content

Commit 510a99d

Browse files
authored
[PHPUnit] Support list in YieldDataProviderRector (#418)
* [PHPUnit] Support list in YieldDataProviderRector * cs
1 parent 0014e22 commit 510a99d

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

rules-tests/CodeQuality/Rector/Class_/YieldDataProviderRector/Fixture/use_data_provider_with_phpdoc.php.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ final class UseDataProviderTestPhpdoc extends TestCase
2020
];
2121
}
2222

23+
/** @return list<array<string>> */
2324
public static function dataProvider()
2425
{
2526
return [
@@ -51,6 +52,7 @@ final class UseDataProviderTestPhpdoc extends TestCase
5152
yield ['<?php implode("", $foo, );', '<?php implode($foo, "", );'];
5253
}
5354

55+
/** @return \Iterator<int<0, max>, array<string>> */
5456
public static function dataProvider(): \Iterator
5557
{
5658
yield ['<?php implode(\'\', $foo, );', '<?php implode($foo, );'];

rules/CodeQuality/Rector/Class_/YieldDataProviderRector.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use PhpParser\Node\Stmt\ClassMethod;
1212
use PhpParser\Node\Stmt\Return_;
1313
use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode;
14-
use PHPStan\Type\ArrayType;
1514
use PHPStan\Type\Generic\GenericObjectType;
1615
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
1716
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger;
@@ -177,7 +176,7 @@ private function removeReturnTag(ClassMethod $classMethod): void
177176
return;
178177
}
179178

180-
if ($phpDocInfo->getReturnType() instanceof ArrayType) {
179+
if ($phpDocInfo->getReturnType()->isArray()->yes()) {
181180
$keyType = $phpDocInfo->getReturnType()
182181
->getIterableKeyType();
183182
$itemType = $phpDocInfo->getReturnType()

0 commit comments

Comments
 (0)