Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. RequireNullSafeObjectOperatorSniff.php

function RequireNullSafeObjectOperatorSniff::getConditionData

*

Return value

array{0: int|null, 1: int|null, 2: int|null}

2 calls to RequireNullSafeObjectOperatorSniff::getConditionData()
RequireNullSafeObjectOperatorSniff::checkTernaryOperator in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/ControlStructures/RequireNullSafeObjectOperatorSniff.php
RequireNullSafeObjectOperatorSniff::process in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/ControlStructures/RequireNullSafeObjectOperatorSniff.php
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *

File

vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/ControlStructures/RequireNullSafeObjectOperatorSniff.php, line 493

Class

RequireNullSafeObjectOperatorSniff

Namespace

SlevomatCodingStandard\Sniffs\ControlStructures

Code

private function getConditionData(File $phpcsFile, int $pointerBeforeIdentical, int $pointerAfterIdentical) : array {
    $tokens = $phpcsFile->getTokens();
    $isYoda = $tokens[$pointerBeforeIdentical]['code'] === T_NULL;
    if ($isYoda) {
        $identificatorStartPointer = $pointerAfterIdentical;
        $identificatorEndPointer = $this->findIdentificatorEnd($phpcsFile, $identificatorStartPointer);
        $conditionStartPointer = $pointerBeforeIdentical;
    }
    else {
        $identificatorEndPointer = $pointerBeforeIdentical;
        $identificatorStartPointer = $this->findIdentificatorStart($phpcsFile, $identificatorEndPointer);
        $conditionStartPointer = $identificatorStartPointer;
    }
    return [
        $identificatorStartPointer,
        $identificatorEndPointer,
        $conditionStartPointer,
    ];
}
RSS feed
Powered by Drupal