Skip to content

Commit 8e3a124

Browse files
authored
Merge pull request #360 from rodrigoprimo/byte-order-mark-improvement
Generic/ByteOrderMark: small performance improvement
2 parents 29cf01e + 57d9e89 commit 8e3a124

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ public function register()
4949
* @param int $stackPtr The position of the current token in
5050
* the stack passed in $tokens.
5151
*
52-
* @return void
52+
* @return int
5353
*/
5454
public function process(File $phpcsFile, $stackPtr)
5555
{
5656
// The BOM will be the very first token in the file.
5757
if ($stackPtr !== 0) {
58-
return;
58+
return $phpcsFile->numTokens;
5959
}
6060

6161
$tokens = $phpcsFile->getTokens();
@@ -68,12 +68,14 @@ public function process(File $phpcsFile, $stackPtr)
6868
$error = 'File contains %s byte order mark, which may corrupt your application';
6969
$phpcsFile->addError($error, $stackPtr, 'Found', $errorData);
7070
$phpcsFile->recordMetric($stackPtr, 'Using byte order mark', 'yes');
71-
return;
71+
return $phpcsFile->numTokens;
7272
}
7373
}
7474

7575
$phpcsFile->recordMetric($stackPtr, 'Using byte order mark', 'no');
7676

77+
return $phpcsFile->numTokens;
78+
7779
}//end process()
7880

7981

0 commit comments

Comments
 (0)