You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a bug i noticed when running SublimeLinter-phpcs, which copies the content of the current file to a temporary file and runs phpcs on that temporary file.
My CPU went to 100% and freezed my computer, and after digging through the logs I found the problem.
This code:
<?php/*$a = array( */
);
I know the code is wrong and will trigger syntax errors, but it will also freeze up phpcs.
It will print two errors forever:
PHP Notice: Undefined index: in .../PHP_CodeSniffer/CodeSniffer/File.php on line 3431
PHP Notice: Undefined index: in .../PHP_CodeSniffer/CodeSniffer/File.php on line 3443
On similar code such as:
<?php/*$a = [ */
];
and:
<?php/*if (true) { */
}
the checking will work as expected on. So without really checking the source it seems the parentheses triggers the problem.
PHP_CodeSniffer might not be meant as a way to check error code but should using it on a file with syntax errors not work, I don't know.
Might need to rethink using the plugin in that case, just thought I'd report this.
EDIT
Changed line 3430 from: for ($i = $start; $i >= 0; $i--) {
to: for ($i = (int) $start; $i >= 0; $i--) {
will end the infinite loop, but not solve the problem fully.
Checking the $start variable shows it being null, which created the infinite loop. Forcing it to an integer instead goes through the code, shows the errors but triggers other notices.
PHP Notice: Undefined index: parenthesis_opener in .../PHP_CodeSniffer/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php on line 226
PHP Notice: Undefined index: in .../PHP_CodeSniffer/CodeSniffer/File.php on line 3431
The text was updated successfully, but these errors were encountered:
gsherwood
changed the title
Block comment ending inside array, started before
ScopeIndentSniff causes errors when encountering an unmatched parenthesis
Apr 17, 2015
Wherever possible, I like PHPCS to be able to recover from a parse error. I've fixed this problem in the ScopeIndent sniff - it was always assuming parenthesis were matched.
This is a bug i noticed when running SublimeLinter-phpcs, which copies the content of the current file to a temporary file and runs phpcs on that temporary file.
My CPU went to 100% and freezed my computer, and after digging through the logs I found the problem.
This code:
I know the code is wrong and will trigger syntax errors, but it will also freeze up phpcs.
It will print two errors forever:
On similar code such as:
and:
the checking will work as expected on. So without really checking the source it seems the parentheses triggers the problem.
PHP_CodeSniffer might not be meant as a way to check error code but should using it on a file with syntax errors not work, I don't know.
Might need to rethink using the plugin in that case, just thought I'd report this.
EDIT
Changed line 3430 from:
for ($i = $start; $i >= 0; $i--) {
to:
for ($i = (int) $start; $i >= 0; $i--) {
will end the infinite loop, but not solve the problem fully.
Checking the $start variable shows it being null, which created the infinite loop. Forcing it to an integer instead goes through the code, shows the errors but triggers other notices.
The text was updated successfully, but these errors were encountered: