function TokenHelper::findFirstNonWhitespaceOnPreviousLine
*
Parameters
int $pointer Search starts at this token, inclusive:
2 calls to TokenHelper::findFirstNonWhitespaceOnPreviousLine()
- InlineDocCommentDeclarationSniff::checkVariable in vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ Commenting/ InlineDocCommentDeclarationSniff.php - *
- RequireExplicitAssertionSniff::process in vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ PHP/ RequireExplicitAssertionSniff.php - * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *
File
-
vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Helpers/ TokenHelper.php, line 422
Class
- TokenHelper
- @internal
Namespace
SlevomatCodingStandard\HelpersCode
public static function findFirstNonWhitespaceOnPreviousLine(File $phpcsFile, int $pointer) : ?int {
$newLinePointerOnPreviousLine = self::findPreviousContent($phpcsFile, [
T_WHITESPACE,
T_DOC_COMMENT_WHITESPACE,
], $phpcsFile->eolChar, $pointer);
if ($newLinePointerOnPreviousLine === null) {
return null;
}
$newLinePointerBeforePreviousLine = self::findPreviousContent($phpcsFile, [
T_WHITESPACE,
T_DOC_COMMENT_WHITESPACE,
], $phpcsFile->eolChar, $newLinePointerOnPreviousLine - 1);
if ($newLinePointerBeforePreviousLine === null) {
return null;
}
$nextPointer = self::findNextExcluding($phpcsFile, [
T_WHITESPACE,
T_DOC_COMMENT_WHITESPACE,
], $newLinePointerBeforePreviousLine + 1);
$tokens = $phpcsFile->getTokens();
if ($nextPointer !== null && $tokens[$pointer]['line'] === $tokens[$nextPointer]['line'] + 1) {
return $nextPointer;
}
return null;
}