Skip to content

Commit f7d8165

Browse files
committed
Fixed bug #1025 : Syntax error in JS file can cause undefined index for parenthesis_closer
1 parent c8fa8b2 commit f7d8165

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

CodeSniffer/File.php

+7
Original file line numberDiff line numberDiff line change
@@ -1761,6 +1761,13 @@ private static function _createTokenMap(&$tokens, $tokenizer, $eolChar)
17611761
}//end switch
17621762
}//end for
17631763

1764+
// Cleanup for any openers that we didn't find closers for.
1765+
// This typically means there was a syntax error breaking things.
1766+
foreach ($openers as $opener) {
1767+
unset($tokens[$opener]['parenthesis_opener']);
1768+
unset($tokens[$opener]['parenthesis_owner']);
1769+
}
1770+
17641771
if (PHP_CODESNIFFER_VERBOSITY > 1) {
17651772
echo "\t*** END TOKEN MAP ***".PHP_EOL;
17661773
}

package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
5151
-- Thanks to Derek Henderson for the patch
5252
- Fixed bug #1015 : The Squiz.Commenting.FunctionComment sniff doesn't allow description in @return tag
5353
-- Thanks to Alexander Obuhovich for the patch
54+
- Fixed bug #1025 : Syntax error in JS file can cause undefined index for parenthesis_closer
5455
</notes>
5556
<contents>
5657
<dir name="/">

0 commit comments

Comments
 (0)