Skip to content

Commit 9419fa3

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 fc85906 commit 9419fa3

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
@@ -635,7 +635,7 @@ public function process(File $phpcsFile, $stackPtr)
635635
}
636636

637637
$conditionToken = array_pop($openScopes);
638-
if ($this->debug === true) {
638+
if ($this->debug === true && $conditionToken !== null) {
639639
$line = $tokens[$conditionToken]['line'];
640640
$type = $tokens[$conditionToken]['type'];
641641
Common::printStatusMessage("=> removed open scope $conditionToken ($type) on line $line", 1);

0 commit comments

Comments
 (0)