function RequireNullSafeObjectOperatorSniff::findIdentificatorStart
1 call to RequireNullSafeObjectOperatorSniff::findIdentificatorStart()
- RequireNullSafeObjectOperatorSniff::getConditionData in vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ ControlStructures/ RequireNullSafeObjectOperatorSniff.php - *
File
-
vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ ControlStructures/ RequireNullSafeObjectOperatorSniff.php, line 369
Class
Namespace
SlevomatCodingStandard\Sniffs\ControlStructuresCode
private function findIdentificatorStart(File $phpcsFile, int $identificatorEndPointer) : ?int {
$tokens = $phpcsFile->getTokens();
if ($tokens[$identificatorEndPointer]['code'] === T_CLOSE_PARENTHESIS) {
$pointerBeforeParenthesisOpener = TokenHelper::findPreviousEffective($phpcsFile, $tokens[$identificatorEndPointer]['parenthesis_opener'] - 1);
$identificatorStartPointer = IdentificatorHelper::findStartPointer($phpcsFile, $pointerBeforeParenthesisOpener);
}
else {
$identificatorStartPointer = IdentificatorHelper::findStartPointer($phpcsFile, $identificatorEndPointer);
}
if ($identificatorStartPointer !== null) {
$pointerBeforeIdentificatorStart = TokenHelper::findPreviousEffective($phpcsFile, $identificatorStartPointer - 1);
if (in_array($tokens[$pointerBeforeIdentificatorStart]['code'], [
T_DOUBLE_COLON,
T_OBJECT_OPERATOR,
T_NULLSAFE_OBJECT_OPERATOR,
], true)) {
$pointerBeforeOperator = TokenHelper::findPreviousEffective($phpcsFile, $pointerBeforeIdentificatorStart - 1);
return $this->findIdentificatorStart($phpcsFile, $pointerBeforeOperator);
}
}
return $identificatorStartPointer;
}