function RequireMultiLineTernaryOperatorSniff::getEndOfLineBefore
1 call to RequireMultiLineTernaryOperatorSniff::getEndOfLineBefore()
- RequireMultiLineTernaryOperatorSniff::process in vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ ControlStructures/ RequireMultiLineTernaryOperatorSniff.php - * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *
File
-
vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ ControlStructures/ RequireMultiLineTernaryOperatorSniff.php, line 117
Class
Namespace
SlevomatCodingStandard\Sniffs\ControlStructuresCode
private function getEndOfLineBefore(File $phpcsFile, int $pointer) : int {
$tokens = $phpcsFile->getTokens();
$endOfLineBefore = null;
$startPointer = $pointer - 1;
while (true) {
$possibleEndOfLinePointer = TokenHelper::findPrevious($phpcsFile, array_merge([
T_WHITESPACE,
T_OPEN_TAG,
T_OPEN_TAG_WITH_ECHO,
], TokenHelper::$inlineCommentTokenCodes), $startPointer);
if ($tokens[$possibleEndOfLinePointer]['code'] === T_WHITESPACE && $tokens[$possibleEndOfLinePointer]['content'] === $phpcsFile->eolChar) {
$endOfLineBefore = $possibleEndOfLinePointer;
break;
}
if ($tokens[$possibleEndOfLinePointer]['code'] === T_OPEN_TAG || $tokens[$possibleEndOfLinePointer]['code'] === T_OPEN_TAG_WITH_ECHO) {
$endOfLineBefore = $possibleEndOfLinePointer;
break;
}
if (in_array($tokens[$possibleEndOfLinePointer]['code'], TokenHelper::$inlineCommentTokenCodes, true) && substr($tokens[$possibleEndOfLinePointer]['content'], -1) === $phpcsFile->eolChar) {
$endOfLineBefore = $possibleEndOfLinePointer;
break;
}
$startPointer = $possibleEndOfLinePointer - 1;
}
/** @var int $endOfLineBefore */
$endOfLineBefore = $endOfLineBefore;
return $endOfLineBefore;
}