Skip to content

Commit 8b74801

Browse files
committed
fix
1 parent 0c96eac commit 8b74801

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

rules/TypeDeclaration/Rector/ClassMethod/AddParamFromDimFetchKeyUseRector.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,32 +108,34 @@ public function refactor(Node $node): ?Node
108108
continue;
109109
}
110110

111+
$paramTypeNode = null;
112+
111113
foreach ($dimFetches as $dimFetch) {
112114
$dimFetchType = $this->getType($dimFetch->var);
113115

114116
if (! $dimFetchType instanceof ArrayType && ! $dimFetchType instanceof ConstantArrayType) {
115-
continue;
117+
continue 2;
116118
}
117119

118120
if ($dimFetch->dim instanceof Variable) {
119121
$type = $this->nodeTypeResolver->getType($dimFetch->dim);
120122
if ($type instanceof UnionType) {
121-
continue;
123+
continue 2;
122124
}
123125
}
126+
}
124127

125-
$paramTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode(
126-
$dimFetchType->getKeyType(),
127-
TypeKind::PARAM
128-
);
129-
130-
if (! $paramTypeNode instanceof Node) {
131-
continue;
132-
}
128+
$paramTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode(
129+
$dimFetchType->getKeyType(),
130+
TypeKind::PARAM
131+
);
133132

134-
$param->type = $paramTypeNode;
135-
$hasChanged = true;
133+
if (! $paramTypeNode instanceof Node) {
134+
continue;
136135
}
136+
137+
$param->type = $paramTypeNode;
138+
$hasChanged = true;
137139
}
138140
}
139141

0 commit comments

Comments
 (0)