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

Breadcrumb

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

function Helpers::getScopeCloseForScopeOpen

*

Parameters

File $phpcsFile: * @param int $scopeStartIndex * * @return int

1 call to Helpers::getScopeCloseForScopeOpen()
ScopeManager::recordScopeStartAndEnd in vendor/sirbrillig/phpcs-variable-analysis/VariableAnalysis/Lib/ScopeManager.php
* Add a scope's start and end index to our record for the file. * *

File

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

Class

Helpers

Namespace

VariableAnalysis\Lib

Code

public static function getScopeCloseForScopeOpen(File $phpcsFile, $scopeStartIndex) {
    $tokens = $phpcsFile->getTokens();
    $scopeCloserIndex = isset($tokens[$scopeStartIndex]['scope_closer']) ? $tokens[$scopeStartIndex]['scope_closer'] : 0;
    if (self::isArrowFunction($phpcsFile, $scopeStartIndex)) {
        $arrowFunctionInfo = self::getArrowFunctionOpenClose($phpcsFile, $scopeStartIndex);
        $scopeCloserIndex = $arrowFunctionInfo ? $arrowFunctionInfo['scope_closer'] : $scopeCloserIndex;
    }
    if ($scopeStartIndex === 0) {
        $scopeCloserIndex = self::getLastNonEmptyTokenIndexInFile($phpcsFile);
    }
    return $scopeCloserIndex;
}
RSS feed
Powered by Drupal