From 7b88c12592ece09e099397b3c20e3c347d997d4f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 9 Nov 2024 00:38:35 +0100 Subject: [PATCH] Universal/SeparateFunctionsFromOO: simplify skipping the rest of the file 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. Includes minor fix to the return type as the method never returns `void`. --- Universal/Sniffs/Files/SeparateFunctionsFromOOSniff.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Universal/Sniffs/Files/SeparateFunctionsFromOOSniff.php b/Universal/Sniffs/Files/SeparateFunctionsFromOOSniff.php index c274e751..9cf191e0 100644 --- a/Universal/Sniffs/Files/SeparateFunctionsFromOOSniff.php +++ b/Universal/Sniffs/Files/SeparateFunctionsFromOOSniff.php @@ -81,8 +81,7 @@ public function register() * @param int $stackPtr The position of the current token * in the stack passed in $tokens. * - * @return int|void Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int Integer stack pointer to skip forward. */ public function process(File $phpcsFile, $stackPtr) { @@ -185,6 +184,6 @@ public function process(File $phpcsFile, $stackPtr) } // Ignore the rest of the file. - return ($phpcsFile->numTokens + 1); + return $phpcsFile->numTokens; } }