Skip to content

Commit f81d76c

Browse files
Merge pull request #142 from VincentLanglet/fixExceptionMessage
Handle exception without parenthesis
2 parents 743a390 + bfafc58 commit f81d76c

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

SymfonyCustom/Sniffs/Errors/ExceptionMessageSniff.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ public function register(): array
2929
public function process(File $phpcsFile, $stackPtr): void
3030
{
3131
$tokens = $phpcsFile->getTokens();
32-
$opener = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr);
32+
$opener = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr, null, false, null, true);
33+
if (false === $opener) {
34+
return;
35+
}
36+
3337
$concat = $phpcsFile->findNext(
3438
T_STRING_CONCAT,
3539
$tokens[$opener]['parenthesis_opener'],

SymfonyCustom/Tests/Errors/ExceptionMessageUnitTest.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,9 @@ class Errors
1616

1717
throw new \RuntimeException('Unrecognized option '.$option);
1818
}
19+
20+
public function testLast(\Exception $exception)
21+
{
22+
throw $exception;
23+
}
1924
}

0 commit comments

Comments
 (0)