Skip to content

Commit 980ce82

Browse files
committed
Squiz CommentedOutCodeSniff is now better at ignoring URLs inside comments
1 parent 2aa34aa commit 980ce82

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

CodeSniffer/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
157157
T_STRING_CONCAT => true,
158158
T_ENCAPSED_AND_WHITESPACE => true,
159159
T_NONE => true,
160+
T_COMMENT => true,
160161
);
161162

162163
$numTokens = count($stringTokens);
@@ -198,6 +199,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
198199
$numComment++;
199200
} else if (in_array($stringTokens[$i]['code'], PHP_CodeSniffer_Tokens::$comparisonTokens) === true
200201
|| in_array($stringTokens[$i]['code'], PHP_CodeSniffer_Tokens::$arithmeticTokens) === true
202+
|| $stringTokens[$i]['code'] === T_GOTO_LABEL
201203
) {
202204
// Commented out HTML/XML and other docs contain a lot of these
203205
// characters, so it is best to not use them directly.

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,5 @@ function myFunction()
7979
/*
8080
[^\'"]
8181
*/
82-
?>
82+
83+
// http://www.google.com

package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
3131
- Defined tokens for lower PHP versions are now phpcs-specific string instead of ints
3232
-- Stops conflict with other projects, like PHP_CodeCoverage
3333
- Added more guard code for syntax errors to various sniffs
34+
- Squiz CommentedOutCodeSniff is now better at ignoring URLs inside comments
3435
- Fixed bug #584 : Squiz.Arrays.ArrayDeclaration sniff gives incorrect NoComma error for multiline string values
3536
- Fixed bug #594 : Tokenizer issue on closure that returns by reference
3637
</notes>

0 commit comments

Comments
 (0)