Skip to content

Commit

Permalink
Debug/TokenList: simplify skipping the rest of the file
Browse files Browse the repository at this point in the history
This commit updates the sniff to use `return $phpcsFile->numTokens` instead of `return ($phpcsFile->numTokens + 1)`.

If a sniff file contains 50 tokens, the last `$stackPtr` will be 49, so returning `50` will already get us passed the end of the token stack and the `+ 1` is redundant.
  • Loading branch information
jrfnl committed Sep 10, 2024
1 parent 311c824 commit e45d6da
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion PHPCSDebug/Sniffs/Debug/TokenListSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function process(File $phpcsFile, $stackPtr)
}

// Only do this once per file.
return ($phpcsFile->numTokens + 1);
return $phpcsFile->numTokens;
}

/**
Expand Down

0 comments on commit e45d6da

Please sign in to comment.