Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed bug #19804 : JS Tokenizer wrong /**/ parsing

  • Loading branch information...
commit 77a430b809ed1a66d46354c9113011ccf433d5c9 1 parent 8b66feb
@gsherwood gsherwood authored
Showing with 20 additions and 7 deletions.
  1. +19 −7 CodeSniffer/Tokenizers/JS.php
  2. +1 −0  package.xml
View
26 CodeSniffer/Tokenizers/JS.php
@@ -481,14 +481,26 @@ public function tokenizeString($string, $eolChar='\n')
if (in_array(strtolower($charBuffer), $tokenTypes) === true) {
// We've found something larger that matches
- // so we can ignore this char.
- if (PHP_CODESNIFFER_VERBOSITY > 1) {
- $type = $this->tokenValues[strtolower($charBuffer)];
- echo "\t\t* look ahead found more specific token ($type), ignoring $i *".PHP_EOL;
+ // so we can ignore this char. Except for 1 very specific
+ // case where a comment like /**/ needs to tokenize as
+ // T_COMMENT and not T_DOC_COMMENT.
+ $oldType = $this->tokenValues[strtolower($buffer)];
+ $newType = $this->tokenValues[strtolower($charBuffer)];
+ if ($oldType === 'T_COMMENT'
+ && $newType === 'T_DOC_COMMENT'
+ && $chars[($i + $x + 1)] === '/'
+ ) {
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
+ echo "\t\t* look ahead ignored T_DOC_COMMENT, continuing *".PHP_EOL;
+ }
+ } else {
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
+ echo "\t\t* look ahead found more specific token ($newType), ignoring $i *".PHP_EOL;
+ }
+
+ $matchedToken = true;
+ break;
}
-
- $matchedToken = true;
- break;
}
}//end for
}//end if
View
1  package.xml
@@ -48,6 +48,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
- Fixed bug #19775 : False positive in NonExecutableCode sniff when not using curly braces
- Fixed bug #19782 : Invalid found size functions in loop when using object operator
- Fixed bug #19799 : config folder is not created automatically
+ - Fixed bug #19804 : JS Tokenizer wrong /**/ parsing
</notes>
<contents>
<dir name="/">
Please sign in to comment.
Something went wrong with that request. Please try again.