Skip to content

Commit ab0c8b7

Browse files
authored
[TypeDeclarationDocblocks] Cover dummy iterable on UsefulArrayTagNodeAnalyzer (#7405)
1 parent 8929abc commit ab0c8b7

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
namespace Rector\Tests\TypeDeclarationDocblocks\Rector\ClassMethod\AddParamArrayDocblockFromDataProviderRector\Fixture;
4+
5+
use PHPUnit\Framework\Attributes\DataProvider;
6+
use PHPUnit\Framework\TestCase;
7+
8+
final class CoverDummyIterable extends TestCase
9+
{
10+
/**
11+
* @param iterable $names
12+
*/
13+
#[DataProvider('provideData')]
14+
public function test(iterable $names): void
15+
{
16+
}
17+
18+
public static function provideData()
19+
{
20+
yield [['Tom', 'John']];
21+
yield [[]];
22+
yield [['John', 'Doe']];
23+
}
24+
}
25+
26+
?>
27+
-----
28+
<?php
29+
30+
namespace Rector\Tests\TypeDeclarationDocblocks\Rector\ClassMethod\AddParamArrayDocblockFromDataProviderRector\Fixture;
31+
32+
use PHPUnit\Framework\Attributes\DataProvider;
33+
use PHPUnit\Framework\TestCase;
34+
35+
final class CoverDummyIterable extends TestCase
36+
{
37+
/**
38+
* @param string[] $names
39+
*/
40+
#[DataProvider('provideData')]
41+
public function test(iterable $names): void
42+
{
43+
}
44+
45+
public static function provideData()
46+
{
47+
yield [['Tom', 'John']];
48+
yield [[]];
49+
yield [['John', 'Doe']];
50+
}
51+
}
52+
53+
?>

rules/TypeDeclarationDocblocks/TagNodeAnalyzer/UsefulArrayTagNodeAnalyzer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function isUsefulArrayTag(null|ReturnTagValueNode|ParamTagValueNode|VarTa
2424
return ! $this->isMixedArray($type);
2525
}
2626

27-
return ! in_array($type->name, ['array', 'mixed'], true);
27+
return ! in_array($type->name, ['array', 'mixed', 'iterable'], true);
2828
}
2929

3030
public function isMixedArray(TypeNode $typeNode): bool

0 commit comments

Comments
 (0)