Skip to content

Commit 9c4c42a

Browse files
committed
EarlyExitSniff: fixed internal exception
1 parent 549a623 commit 9c4c42a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

SlevomatCodingStandard/Sniffs/ControlStructures/EarlyExitSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private function processIf(\PHP_CodeSniffer\Files\File $phpcsFile, int $ifPointe
130130
$tokens = $phpcsFile->getTokens();
131131

132132
$nextPointer = TokenHelper::findNextExcluding($phpcsFile, T_WHITESPACE, $tokens[$ifPointer]['scope_closer'] + 1);
133-
if ($tokens[$nextPointer]['code'] !== T_CLOSE_CURLY_BRACKET) {
133+
if ($nextPointer === null || $tokens[$nextPointer]['code'] !== T_CLOSE_CURLY_BRACKET) {
134134
return;
135135
}
136136

tests/Sniffs/ControlStructures/data/earlyExitNoErrors.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,7 @@ function () {
139139
break;
140140
}
141141
}
142+
143+
if (!defined('PHPUNIT_COMPOSER_INSTALL')) {
144+
define('PHPUNIT_COMPOSER_INSTALL', __DIR__ . '/autoload.php');
145+
}

0 commit comments

Comments
 (0)