function RequireNullSafeObjectOperatorSniff::getIdentificatorDifference
2 calls to RequireNullSafeObjectOperatorSniff::getIdentificatorDifference()
- RequireNullSafeObjectOperatorSniff::checkNextCondition in vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ ControlStructures/ RequireNullSafeObjectOperatorSniff.php - RequireNullSafeObjectOperatorSniff::checkTernaryOperator in vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ ControlStructures/ RequireNullSafeObjectOperatorSniff.php
File
-
vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ ControlStructures/ RequireNullSafeObjectOperatorSniff.php, line 450
Class
Namespace
SlevomatCodingStandard\Sniffs\ControlStructuresCode
private function getIdentificatorDifference(File $phpcsFile, string $identificator, int $nextIdentificatorStartPointer, int $nextIdentificatorEndPointer) : string {
$objectOperatorsCountInIdentificator = substr_count($identificator, '->');
$tokens = $phpcsFile->getTokens();
$objectOperatorsCountInNextIdentificator = 0;
$differencePointer = $nextIdentificatorStartPointer;
for ($i = $nextIdentificatorStartPointer; $i <= $nextIdentificatorEndPointer; $i++) {
if (in_array($tokens[$i]['code'], [
T_OBJECT_OPERATOR,
T_NULLSAFE_OBJECT_OPERATOR,
], true)) {
$objectOperatorsCountInNextIdentificator++;
}
if ($objectOperatorsCountInNextIdentificator > $objectOperatorsCountInIdentificator) {
$differencePointer = $i;
break;
}
}
return TokenHelper::getContent($phpcsFile, $differencePointer, $nextIdentificatorEndPointer);
}