Skip to content

Commit 496c130

Browse files
authored
fix(UnusedPrivateMethod): Fix case insensitivity og PHP method calls (#3398208)
1 parent 5eccb7d commit 496c130

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

coder_sniffer/DrupalPractice/Sniffs/Objects/UnusedPrivateMethodSniff.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop
7777

7878
if ($tokens[$next]['code'] === T_OBJECT_OPERATOR) {
7979
$call = $phpcsFile->findNext(Tokens::$emptyTokens, ($next + 1), null, true);
80-
if ($call === false || $tokens[$call]['content'] !== $methodName) {
80+
// PHP method calls are case insensitive.
81+
if ($call === false || strcasecmp($tokens[$call]['content'], $methodName) !== 0) {
8182
continue;
8283
}
8384

tests/DrupalPractice/Objects/UnusedPrivateMethodUnitTest.inc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,18 @@ class Test {
1616

1717
}
1818

19+
/**
20+
* Method is called from somewhere in the class.
21+
*/
22+
private function isUsed() {
23+
24+
}
25+
26+
/**
27+
* Call method with different upper/lower case.
28+
*/
29+
public function doCalls() {
30+
$this->IsUsEd();
31+
}
32+
1933
}

0 commit comments

Comments
 (0)