Skip to content

Commit 39b8764

Browse files
rodrigoprimojrfnl
authored andcommitted
Generic/CallTimePassByReference: remove unnecessary condition
This commit removes the `|| $prevCode === T_CLASS` condition from a if statement. The removed check is not necessary as the next thing the sniff does is to check for an opening parenthesis after `$stackPtr` and bow out if one is not found. Class definitions will never have an opening parentesis after its name. Anonymous classes do have a opening parenthesis after the T_CLASS token. They are currently not handled correctly by this sniff and this will be addressed on another commit.
1 parent af7af18 commit 39b8764

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ public function process(File $phpcsFile, $stackPtr)
5050

5151
$prev = $phpcsFile->findPrevious($findTokens, ($stackPtr - 1), null, true);
5252

53-
// Skip tokens that are the names of functions or classes
53+
// Skip tokens that are the names of functions
5454
// within their definitions. For example: function myFunction...
5555
// "myFunction" is T_STRING but we should skip because it is not a
5656
// function or method *call*.
5757
$prevCode = $tokens[$prev]['code'];
58-
if ($prevCode === T_FUNCTION || $prevCode === T_CLASS) {
58+
if ($prevCode === T_FUNCTION) {
5959
return;
6060
}
6161

0 commit comments

Comments
 (0)