Skip to content

Commit

Permalink
Merge 6593f61 into e411e6b
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfnl committed May 17, 2020
2 parents e411e6b + 6593f61 commit dba24f6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion PHPCSUtils/Utils/ControlStructures.php
Expand Up @@ -383,7 +383,7 @@ public static function getCaughtExceptions(File $phpcsFile, $stackPtr)
$firstToken = null;
$lastToken = null;

for ($i = ($opener + 1); $i < $closer; $i++) {
for ($i = ($opener + 1); $i <= $closer; $i++) {
if (isset(Tokens::$emptyTokens[$tokens[$i]['code']])) {
continue;
}
Expand Down
3 changes: 3 additions & 0 deletions Tests/Utils/ControlStructures/GetCaughtExceptionsTest.inc
Expand Up @@ -27,6 +27,9 @@ try {
/* testMultiCatchCompoundNames */
} catch (\NS\RuntimeException | My\ParseErrorException | namespace \ AnotherException $e) {

/* testPHP8NonCapturingCatch */
} catch (RuntimeException | AnotherException) {

/* testLiveCoding */
// Intentional parse error.
} catch (
15 changes: 15 additions & 0 deletions Tests/Utils/ControlStructures/GetCaughtExceptionsTest.php
Expand Up @@ -197,6 +197,21 @@ public function dataGetCaughtExceptions()
],
],
],
'non-capturing-catch' => [
'target' => '/* testPHP8NonCapturingCatch */',
'expected' => [
[
'type' => 'RuntimeException',
'type_token' => 3,
'type_end_token' => 3,
],
[
'type' => 'AnotherException',
'type_token' => 7,
'type_end_token' => 7,
],
],
],
];
}
}

0 comments on commit dba24f6

Please sign in to comment.