From 2ad9dd97e424062a68655cba9bee74d84fee1a8e Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Wed, 10 Jun 2020 20:50:00 +0200 Subject: [PATCH] skip non-existing method --- .../Array_/ArrayThisCallToThisMethodCallRector.php | 4 ++++ .../Fixture/skip_non_existing_method.php.inc | 12 ++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 rules/code-quality/tests/Rector/Array_/ArrayThisCallToThisMethodCallRector/Fixture/skip_non_existing_method.php.inc 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 @@ +