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

Breadcrumb

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

function StaticThisUsageSniff::processTokenWithinScope

Processes this test, when one of its tokens is encountered.

Parameters

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

int $stackPtr The position of the current token in the: stack passed in $tokens.

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

Return value

void

Overrides AbstractScopeSniff::processTokenWithinScope

File

vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Scope/StaticThisUsageSniff.php, line 40

Class

StaticThisUsageSniff

Namespace

PHP_CodeSniffer\Standards\Squiz\Sniffs\Scope

Code

public function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope) {
    $tokens = $phpcsFile->getTokens();
    // Determine if this is a function which needs to be examined.
    $conditions = $tokens[$stackPtr]['conditions'];
    end($conditions);
    $deepestScope = key($conditions);
    if ($deepestScope !== $currScope) {
        return;
    }
    // Ignore abstract functions.
    if (isset($tokens[$stackPtr]['scope_closer']) === false) {
        return;
    }
    $next = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true);
    if ($next === false || $tokens[$next]['code'] !== T_STRING) {
        // Not a function declaration, or incomplete.
        return;
    }
    $methodProps = $phpcsFile->getMethodProperties($stackPtr);
    if ($methodProps['is_static'] === false) {
        return;
    }
    $next = $stackPtr;
    $end = $tokens[$stackPtr]['scope_closer'];
    $this->checkThisUsage($phpcsFile, $next, $end);
}

API Navigation

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