diff --git a/rules-tests/TypeDeclaration/Rector/ClassMethod/StrictArrayParamDimFetchRector/Fixture/direct-coalesce.php.inc b/rules-tests/TypeDeclaration/Rector/ClassMethod/StrictArrayParamDimFetchRector/Fixture/direct-coalesce.php.inc new file mode 100644 index 00000000000..e2c3d7b3b08 --- /dev/null +++ b/rules-tests/TypeDeclaration/Rector/ClassMethod/StrictArrayParamDimFetchRector/Fixture/direct-coalesce.php.inc @@ -0,0 +1,27 @@ + +----- + diff --git a/rules-tests/TypeDeclaration/Rector/ClassMethod/StrictArrayParamDimFetchRector/Fixture/skip_coalesce.php.inc b/rules-tests/TypeDeclaration/Rector/ClassMethod/StrictArrayParamDimFetchRector/Fixture/skip_coalesce_without_dim_fetch.php.inc similarity index 87% rename from rules-tests/TypeDeclaration/Rector/ClassMethod/StrictArrayParamDimFetchRector/Fixture/skip_coalesce.php.inc rename to rules-tests/TypeDeclaration/Rector/ClassMethod/StrictArrayParamDimFetchRector/Fixture/skip_coalesce_without_dim_fetch.php.inc index d20e3653beb..05e8f27e94c 100644 --- a/rules-tests/TypeDeclaration/Rector/ClassMethod/StrictArrayParamDimFetchRector/Fixture/skip_coalesce.php.inc +++ b/rules-tests/TypeDeclaration/Rector/ClassMethod/StrictArrayParamDimFetchRector/Fixture/skip_coalesce_without_dim_fetch.php.inc @@ -2,7 +2,7 @@ namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\StrictArrayParamDimFetchRector\Fixture; -final class SkipCoalesce +final class SkipCoalesceWithoutDimFetch { public function run($productOptions) { diff --git a/rules/TypeDeclaration/Rector/ClassMethod/StrictArrayParamDimFetchRector.php b/rules/TypeDeclaration/Rector/ClassMethod/StrictArrayParamDimFetchRector.php index 834254697d9..61dfdf1de41 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/StrictArrayParamDimFetchRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/StrictArrayParamDimFetchRector.php @@ -236,7 +236,7 @@ private function shouldStop(Node $node, Param $param, string $paramName): bool $nodeToCheck = $node->var; } - if ($this->isMethodCallOrArrayDimFetch($paramName, $nodeToCheck)) { + if ($this->isMethodCall($paramName, $nodeToCheck)) { return true; } @@ -295,16 +295,12 @@ private function isEmptyOrEchoedOrCasted(Node $node, string $paramName): bool return $node instanceof Array_ && $node->expr instanceof Variable && $this->isName($node->expr, $paramName); } - private function isMethodCallOrArrayDimFetch(string $paramName, ?Node $node): bool + private function isMethodCall(string $paramName, ?Node $node): bool { if ($node instanceof MethodCall) { return $node->var instanceof Variable && $this->isName($node->var, $paramName); } - if ($node instanceof ArrayDimFetch) { - return $node->var instanceof Variable && $this->isName($node->var, $paramName); - } - return false; }