From bad98719a5dee23e4e4d170dae718c0f44745c79 Mon Sep 17 00:00:00 2001 From: Maxim Tugaev Date: Wed, 16 Jun 2021 01:09:18 +0300 Subject: [PATCH] Incorrect behavior of RemoveUnusedPrivateMethodRector (#227) --- .../NodeCollector/NodeRepository.php | 2 +- ..._this_case_insensitive_method_name.php.inc | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 rules-tests/DeadCode/Rector/ClassMethod/RemoveUnusedPrivateMethodRector/Fixture/skip_array_callables_this_case_insensitive_method_name.php.inc diff --git a/packages/NodeCollector/NodeCollector/NodeRepository.php b/packages/NodeCollector/NodeCollector/NodeRepository.php index d5f05a95c30..82cf68fcf67 100644 --- a/packages/NodeCollector/NodeCollector/NodeRepository.php +++ b/packages/NodeCollector/NodeCollector/NodeRepository.php @@ -471,7 +471,7 @@ private function collectArray(Array_ $array): void return; } - $this->arrayCallablesByTypeAndMethod[$arrayCallable->getClass()][$arrayCallable->getMethod()][] = $arrayCallable; + $this->arrayCallablesByTypeAndMethod[$arrayCallable->getClass()][strtolower($arrayCallable->getMethod())][] = $arrayCallable; } private function addMethod(ClassMethod $classMethod): void diff --git a/rules-tests/DeadCode/Rector/ClassMethod/RemoveUnusedPrivateMethodRector/Fixture/skip_array_callables_this_case_insensitive_method_name.php.inc b/rules-tests/DeadCode/Rector/ClassMethod/RemoveUnusedPrivateMethodRector/Fixture/skip_array_callables_this_case_insensitive_method_name.php.inc new file mode 100644 index 00000000000..5222b048533 --- /dev/null +++ b/rules-tests/DeadCode/Rector/ClassMethod/RemoveUnusedPrivateMethodRector/Fixture/skip_array_callables_this_case_insensitive_method_name.php.inc @@ -0,0 +1,26 @@ + $b; + } + + private function SOrtCAseINSENsitivEMEthodnaME($a, $b) + { + return $a <=> $b; + } +}