Skip to content

Commit 9a70ae2

Browse files
committed
Fixed PHP tokenizer problem that caused an infinite loop when checking a comment with specific content
1 parent 490f858 commit 9a70ae2

File tree

4 files changed

+5
-1
lines changed

4 files changed

+5
-1
lines changed

CodeSniffer/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,5 @@ function myFunction()
8383
// http://www.google.com
8484

8585
// Base config function.
86+
87+
// function ()

CodeSniffer/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public function getWarningList($testFile='CommentedOutCodeUnitTest.inc')
6464
8 => 1,
6565
15 => 1,
6666
19 => 1,
67+
87 => 1,
6768
);
6869
break;
6970
case 'CommentedOutCodeUnitTest.css':

CodeSniffer/Tokenizers/PHP.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ public function processAdditional(&$tokens, $eolChar)
10141014

10151015
$tokenAfterReturnTypeHint = $tokens[$i]['scope_opener'];
10161016
} else if (isset($tokens[$i]['parenthesis_closer']) === true) {
1017-
for ($x = ($tokens[$i]['parenthesis_closer'] + 1); $i < $numTokens; $x++) {
1017+
for ($x = ($tokens[$i]['parenthesis_closer'] + 1); $x < $numTokens; $x++) {
10181018
if ($tokens[$x]['code'] === T_SEMICOLON) {
10191019
$tokenAfterReturnTypeHint = $x;
10201020
break;

package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
4848
-- Removes the error Squiz.Commenting.ClassComment.SpaceBefore
4949
- Renamed Squiz.CSS.Opacity.SpacingAfterPoint to Squiz.CSS.Opacity.DecimalPrecision
5050
-- Please update your ruleset if you are referencing this error code directly
51+
- Fixed PHP tokenizer problem that caused an infinite loop when checking a comment with specific content
5152
- Squiz CSS IndentationSniff no longer assumes the class opening brace is at the end of a line
5253
- Squiz FunctionCommentThrowTagSniff now ignores non-docblock comments
5354
- Squiz ComparisonOperatorUsageSniff now allows conditions like while(true)

0 commit comments

Comments
 (0)