Skip to content

Commit aecc0f5

Browse files
committed
fix
1 parent 3db9174 commit aecc0f5

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

rules/TypeDeclaration/Rector/ClassMethod/AddParamFromDimFetchKeyUseRector.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
1414
use Rector\Rector\AbstractRector;
1515
use Rector\StaticTypeMapper\StaticTypeMapper;
16+
use Rector\TypeDeclaration\Guard\ParamTypeAddGuard;
1617
use Rector\TypeDeclarationDocblocks\NodeFinder\ArrayDimFetchFinder;
1718
use Rector\VendorLocker\ParentClassMethodTypeOverrideGuard;
1819
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
@@ -26,7 +27,8 @@ final class AddParamFromDimFetchKeyUseRector extends AbstractRector
2627
public function __construct(
2728
private readonly ArrayDimFetchFinder $arrayDimFetchFinder,
2829
private readonly StaticTypeMapper $staticTypeMapper,
29-
private readonly ParentClassMethodTypeOverrideGuard $parentClassMethodTypeOverrideGuard
30+
private readonly ParentClassMethodTypeOverrideGuard $parentClassMethodTypeOverrideGuard,
31+
private readonly ParamTypeAddGuard $paramTypeAddGuard
3032
) {
3133
}
3234

@@ -107,6 +109,10 @@ public function refactor(Node $node): ?Node
107109
continue;
108110
}
109111

112+
if (! $this->paramTypeAddGuard->isLegal($param, $classMethod)) {
113+
continue;
114+
}
115+
110116
foreach ($dimFetches as $dimFetch) {
111117
$dimFetchType = $this->getType($dimFetch->var);
112118

0 commit comments

Comments
 (0)