diff --git a/rules/code-quality/src/Rector/Array_/ArrayThisCallToThisMethodCallRector.php b/rules/code-quality/src/Rector/Array_/ArrayThisCallToThisMethodCallRector.php index 3033c43c77d..eb91b287fac 100644 --- a/rules/code-quality/src/Rector/Array_/ArrayThisCallToThisMethodCallRector.php +++ b/rules/code-quality/src/Rector/Array_/ArrayThisCallToThisMethodCallRector.php @@ -95,6 +95,10 @@ PHP [$class, $method] = $arrayCallable; + if (! method_exists($class, $method)) { + return null; + } + $methodReflection = new ReflectionMethod($class, $method); if ($methodReflection->getNumberOfParameters() > 0) { return null; diff --git a/rules/code-quality/tests/Rector/Array_/ArrayThisCallToThisMethodCallRector/Fixture/skip_non_existing_method.php.inc b/rules/code-quality/tests/Rector/Array_/ArrayThisCallToThisMethodCallRector/Fixture/skip_non_existing_method.php.inc new file mode 100644 index 00000000000..4b867f4fa9c --- /dev/null +++ b/rules/code-quality/tests/Rector/Array_/ArrayThisCallToThisMethodCallRector/Fixture/skip_non_existing_method.php.inc @@ -0,0 +1,12 @@ +