diff --git a/src/Analyser/Analyser.php b/src/Analyser/Analyser.php index 32a1c064..dcea7e6e 100644 --- a/src/Analyser/Analyser.php +++ b/src/Analyser/Analyser.php @@ -32,6 +32,7 @@ use Boundwize\StructArmed\Rule\UsedTraitAwareRuleInterface; use Boundwize\StructArmed\Util\Path; +use function array_change_key_case; use function array_fill_keys; use function array_filter; use function array_key_exists; @@ -1080,7 +1081,7 @@ private function markFunctionUsage(array $classNodes, ExtractionResult $extracti foreach ([...$classNodes, ...$extractionResult->anonymousClassNodes] as $classLikeNode) { foreach ($classLikeNode->functionCalls as $functionCall) { - $used[strtolower($functionCall)] = true; + $used[$functionCall] = true; } } @@ -1094,7 +1095,7 @@ private function markFunctionUsage(array $classNodes, ExtractionResult $extracti } foreach ($anonymousFunctionNode->functionCalls as $functionCall) { - $used[strtolower($functionCall)] = true; + $used[$functionCall] = true; } } @@ -1107,11 +1108,14 @@ private function markFunctionUsage(array $classNodes, ExtractionResult $extracti foreach ($functionNode->functionCalls as $functionCall) { if (strcasecmp($functionCall, $functionNode->functionName) !== 0) { - $used[strtolower($functionCall)] = true; + $used[$functionCall] = true; } } } + // Deduplicate call spellings across scopes before normalizing their case. + $used = array_change_key_case($used); + foreach ($extractionResult->fileReferences as $references) { foreach ($references as $reference) { $referenceKey = strtolower($reference);