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

Breadcrumb

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

function Helpers::getPreviousArrowFunctionIndex

* Move back from the stackPtr to the start of the enclosing scope until we * find a 'fn' token that starts an arrow function, returning the index of * that token. Returns null if there are no arrow functions before stackPtr. * * Note that this does not guarantee that stackPtr is inside the arrow * function scope we find! * *

Parameters

File $phpcsFile: * @param int $stackPtr * @param int $enclosingScopeIndex * * @return ?int

1 call to Helpers::getPreviousArrowFunctionIndex()
Helpers::getContainingArrowFunctionIndex in vendor/sirbrillig/phpcs-variable-analysis/VariableAnalysis/Lib/Helpers.php
*

File

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

Class

Helpers

Namespace

VariableAnalysis\Lib

Code

private static function getPreviousArrowFunctionIndex(File $phpcsFile, $stackPtr, $enclosingScopeIndex) {
    $tokens = $phpcsFile->getTokens();
    for ($index = $stackPtr - 1; $index > $enclosingScopeIndex; $index--) {
        $token = $tokens[$index];
        if ($token['content'] === 'fn' && self::isArrowFunction($phpcsFile, $index)) {
            return $index;
        }
    }
    return null;
}
RSS feed
Powered by Drupal