diff --git a/rules-tests/TypeDeclaration/Rector/FuncCall/AddArrowFunctionParamArrayWhereDimFetchRector/Fixture/skip_integer_index_on_string.php.inc b/rules-tests/TypeDeclaration/Rector/FuncCall/AddArrowFunctionParamArrayWhereDimFetchRector/Fixture/skip_integer_index_on_string.php.inc new file mode 100644 index 00000000000..1846fac2c0d --- /dev/null +++ b/rules-tests/TypeDeclaration/Rector/FuncCall/AddArrowFunctionParamArrayWhereDimFetchRector/Fixture/skip_integer_index_on_string.php.inc @@ -0,0 +1,19 @@ + strtoupper((string) $name[0]), + explode('.', $username), + ), + ); + } +} diff --git a/rules/TypeDeclaration/Rector/FuncCall/AddArrowFunctionParamArrayWhereDimFetchRector.php b/rules/TypeDeclaration/Rector/FuncCall/AddArrowFunctionParamArrayWhereDimFetchRector.php index 9e404ea0acc..7d04f95de39 100644 --- a/rules/TypeDeclaration/Rector/FuncCall/AddArrowFunctionParamArrayWhereDimFetchRector.php +++ b/rules/TypeDeclaration/Rector/FuncCall/AddArrowFunctionParamArrayWhereDimFetchRector.php @@ -146,6 +146,12 @@ private function resolveDimFetchVariableNames(Closure|ArrowFunction $closureExpr foreach ($arrayDimFetches as $arrayDimFetch) { if ($arrayDimFetch->var instanceof Variable) { + $type = $this->nodeTypeResolver->getNativeType($arrayDimFetch->var); + + if ($type->isString()->yes()) { + continue; + } + $usedDimFetchVariableNames[] = (string) $this->getName($arrayDimFetch->var); } }