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

Breadcrumb

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

function Helpers::isVariableArrayPushShortcut

*

Parameters

File $phpcsFile: * @param int $stackPtr * * @return bool

1 call to Helpers::isVariableArrayPushShortcut()
VariableAnalysisSniff::markVariableReadAndWarnIfUndefined in vendor/sirbrillig/phpcs-variable-analysis/VariableAnalysis/Sniffs/CodeAnalysis/VariableAnalysisSniff.php
* Record a variable use and report a warning if the variable is undefined. * *

File

vendor/sirbrillig/phpcs-variable-analysis/VariableAnalysis/Lib/Helpers.php, line 1366

Class

Helpers

Namespace

VariableAnalysis\Lib

Code

public static function isVariableArrayPushShortcut(File $phpcsFile, $stackPtr) {
    $tokens = $phpcsFile->getTokens();
    $nonFunctionTokenTypes = Tokens::$emptyTokens;
    $arrayPushOperatorIndex1 = self::getIntOrNull($phpcsFile->findNext($nonFunctionTokenTypes, $stackPtr + 1, null, true, null, true));
    if (!is_int($arrayPushOperatorIndex1)) {
        return false;
    }
    if (!isset($tokens[$arrayPushOperatorIndex1]['content']) || $tokens[$arrayPushOperatorIndex1]['content'] !== '[') {
        return false;
    }
    $arrayPushOperatorIndex2 = self::getIntOrNull($phpcsFile->findNext($nonFunctionTokenTypes, $arrayPushOperatorIndex1 + 1, null, true, null, true));
    if (!is_int($arrayPushOperatorIndex2)) {
        return false;
    }
    if (!isset($tokens[$arrayPushOperatorIndex2]['content']) || $tokens[$arrayPushOperatorIndex2]['content'] !== ']') {
        return false;
    }
    $arrayPushOperatorIndex3 = self::getIntOrNull($phpcsFile->findNext($nonFunctionTokenTypes, $arrayPushOperatorIndex2 + 1, null, true, null, true));
    if (!is_int($arrayPushOperatorIndex3)) {
        return false;
    }
    if (!isset($tokens[$arrayPushOperatorIndex3]['content']) || $tokens[$arrayPushOperatorIndex3]['content'] !== '=') {
        return false;
    }
    return true;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal