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

Breadcrumb

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

function FunctionCall::isFunctionCall

Checks if this is a function call.

Parameters

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

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

Return value

bool

3 calls to FunctionCall::isFunctionCall()
FunctionCall::process in vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/FunctionCall.php
Processes this test, when one of its tokens is encountered.
GlobalFunctionSniff::process in vendor/drupal/coder/coder_sniffer/DrupalPractice/Sniffs/Objects/GlobalFunctionSniff.php
Processes this test, when one of its tokens is encountered.
ThemeSniff::process in vendor/drupal/coder/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/ThemeSniff.php
Processes this function call.

File

vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/FunctionCall.php, line 127

Class

FunctionCall
Helper class to sniff for specific function calls.

Namespace

Drupal\Sniffs\Semantics

Code

protected function isFunctionCall(File $phpcsFile, $stackPtr) {
    $tokens = $phpcsFile->getTokens();
    // Find the next non-empty token.
    $openBracket = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true);
    if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) {
        // Not a function call.
        return false;
    }
    if (isset($tokens[$openBracket]['parenthesis_closer']) === false) {
        // Not a function call.
        return false;
    }
    // Find the previous non-empty token.
    $search = Tokens::$emptyTokens;
    $search[] = T_BITWISE_AND;
    $previous = $phpcsFile->findPrevious($search, $stackPtr - 1, null, true);
    if ($tokens[$previous]['code'] === T_FUNCTION) {
        // It's a function definition, not a function call.
        return false;
    }
    if ($tokens[$previous]['code'] === T_OBJECT_OPERATOR && $this->includeMethodCalls === false) {
        // It's a method invocation, not a function call.
        return false;
    }
    if ($tokens[$previous]['code'] === T_DOUBLE_COLON && $this->includeMethodCalls === false) {
        // It's a static method invocation, not a function call.
        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