Skip to content

Commit afd68f2

Browse files
authored
skip mixed type as not informative in AddParamArrayDocblockFromDataProviderRector (#7279)
1 parent d02183a commit afd68f2

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\Tests\TypeDeclarationDocblocks\Rector\ClassMethod\AddParamArrayDocblockFromDataProviderRector\Fixture;
6+
7+
use PHPUnit\Framework\Attributes\DataProvider;
8+
use PHPUnit\Framework\TestCase;
9+
10+
final class SkipMixed extends TestCase
11+
{
12+
#[DataProvider('provideData')]
13+
public function test(array $names): void
14+
{
15+
}
16+
17+
public static function provideData($item, $item2)
18+
{
19+
yield [[$item, $item2]];
20+
yield [[$item, $item2]];
21+
}
22+
}

rules/TypeDeclarationDocblocks/Rector/ClassMethod/AddParamArrayDocblockFromDataProviderRector.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use PhpParser\Node;
88
use PhpParser\Node\Stmt\Class_;
99
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
10+
use PHPStan\Type\ArrayType;
11+
use PHPStan\Type\MixedType;
1012
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
1113
use Rector\Comments\NodeDocBlock\DocBlockUpdater;
1214
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
@@ -144,6 +146,11 @@ public function refactor(Node $node): ?Node
144146
$dataProviderNodes->getClassMethods()
145147
);
146148

149+
// skip mixed type, as it is not informative
150+
if ($parameterType instanceof ArrayType && $parameterType->getItemType() instanceof MixedType) {
151+
continue;
152+
}
153+
147154
$generalizedParameterType = $this->typeNormalizer->generalizeConstantTypes($parameterType);
148155

149156
$parameterTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode(

0 commit comments

Comments
 (0)