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

Breadcrumb

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

function ConstructorNameSniff::loadFunctionNamesInScope

Extracts all the function names found in the given scope.

Parameters

\PHP_CodeSniffer\Files\File $phpcsFile The current file being scanned.:

int $currScope A pointer to the start of the scope.:

Return value

void

1 call to ConstructorNameSniff::loadFunctionNamesInScope()
ConstructorNameSniff::processTokenWithinScope in vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php
Processes this test when one of its tokens is encountered.

File

vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php, line 157

Class

ConstructorNameSniff

Namespace

PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions

Code

protected function loadFunctionNamesInScope(File $phpcsFile, $currScope) {
    $this->functionList = [];
    $tokens = $phpcsFile->getTokens();
    for ($i = $tokens[$currScope]['scope_opener'] + 1; $i < $tokens[$currScope]['scope_closer']; $i++) {
        if ($tokens[$i]['code'] !== T_FUNCTION) {
            continue;
        }
        $this->functionList[] = trim(strtolower($phpcsFile->getDeclarationName($i)));
        if (isset($tokens[$i]['scope_closer']) !== false) {
            // Skip past nested functions and such.
            $i = $tokens[$i]['scope_closer'];
        }
    }
}
RSS feed
Powered by Drupal