Skip to content

Commit ad559e4

Browse files
committed
Generic/ScopeIndent: bug fix for debug mode
Prevent an "Undefined array index" PHP notice when running in debug mode when there are no scopes left. Issue can be reproduced by running: ```bash phpcs ./src/Runner.php --runtime-set scope_indent_debug 1 ```
1 parent 50f03b3 commit ad559e4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ public function process(File $phpcsFile, $stackPtr)
644644
}
645645

646646
$conditionToken = array_pop($openScopes);
647-
if ($this->debug === true) {
647+
if ($this->debug === true && $conditionToken !== null) {
648648
$line = $tokens[$conditionToken]['line'];
649649
$type = $tokens[$conditionToken]['type'];
650650
echo "\t=> removed open scope $conditionToken ($type) on line $line".PHP_EOL;

0 commit comments

Comments
 (0)