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

Breadcrumb

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

function RequireTernaryOperatorSniff::isCompatibleScope

1 call to RequireTernaryOperatorSniff::isCompatibleScope()
RequireTernaryOperatorSniff::process in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/ControlStructures/RequireTernaryOperatorSniff.php
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *

File

vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/ControlStructures/RequireTernaryOperatorSniff.php, line 216

Class

RequireTernaryOperatorSniff

Namespace

SlevomatCodingStandard\Sniffs\ControlStructures

Code

private function isCompatibleScope(File $phpcsFile, int $scopeOpenerPointer, int $scopeCloserPointer) : bool {
    $semicolonPointer = TokenHelper::findNext($phpcsFile, T_SEMICOLON, $scopeOpenerPointer + 1, $scopeCloserPointer);
    if ($semicolonPointer === null) {
        return false;
    }
    if (TokenHelper::findNext($phpcsFile, T_INLINE_THEN, $scopeOpenerPointer + 1, $semicolonPointer) !== null) {
        return false;
    }
    if ($this->ignoreMultiLine) {
        $firstContentPointer = TokenHelper::findNextEffective($phpcsFile, $scopeOpenerPointer + 1);
        if (TokenHelper::findNextContent($phpcsFile, T_WHITESPACE, $phpcsFile->eolChar, $firstContentPointer + 1, $semicolonPointer) !== null) {
            return false;
        }
    }
    $pointerAfterSemicolon = TokenHelper::findNextEffective($phpcsFile, $semicolonPointer + 1);
    return $pointerAfterSemicolon === $scopeCloserPointer;
}
RSS feed
Powered by Drupal