Skip to content

Commit

Permalink
ControlStructures/RequireSingleLineCondition: prevent error for parse…
Browse files Browse the repository at this point in the history
… error

```
An error occurred during processing; checking has been aborted. The error message was: Undefined array key "" in path\to\SlevomatCodingStandard\Sniffs\ControlStructures\RequireSingleLineConditionSniff.php on line 41
```
  • Loading branch information
jrfnl committed Sep 28, 2023
1 parent fc778da commit ec354af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public function process(File $phpcsFile, $controlStructurePointer): void
$parenthesisOpenerPointer = $tokens[$controlStructurePointer]['parenthesis_opener'];
$parenthesisCloserPointer = $tokens[$controlStructurePointer]['parenthesis_closer'];

if (isset($parenthesisOpenerPointer, $parenthesisCloserPointer) === false) {
return;
}

if ($tokens[$parenthesisOpenerPointer]['line'] === $tokens[$parenthesisCloserPointer]['line']) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ function () {

}
};

// Live coding/parse error.
// This must be the last test in the file.
if ($a = 1

0 comments on commit ec354af

Please sign in to comment.