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

Breadcrumb

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

function VariableAnalysisSniff::processCompact

* Called to process variables named in a call to compact(). * *

Parameters

File $phpcsFile The PHP_CodeSniffer file where this token was found.: * @param int $stackPtr The position where the call to compact() was found. * * @return void

1 call to VariableAnalysisSniff::processCompact()
VariableAnalysisSniff::process in vendor/sirbrillig/phpcs-variable-analysis/VariableAnalysis/Sniffs/CodeAnalysis/VariableAnalysisSniff.php
* Scan and process a token. * * This is the main processing function of the sniff. Will run on every token * for which `register()` returns true. * *

File

vendor/sirbrillig/phpcs-variable-analysis/VariableAnalysis/Sniffs/CodeAnalysis/VariableAnalysisSniff.php, line 1880

Class

VariableAnalysisSniff

Namespace

VariableAnalysis\Sniffs\CodeAnalysis

Code

protected function processCompact(File $phpcsFile, $stackPtr) {
    Helpers::debug("processCompact at {$stackPtr}");
    $arguments = Helpers::findFunctionCallArguments($phpcsFile, $stackPtr);
    $variables = Helpers::getVariablesInsideCompact($phpcsFile, $stackPtr, $arguments);
    foreach ($variables as $variable) {
        $currScope = Helpers::findVariableScope($phpcsFile, $stackPtr, $variable->name);
        if ($currScope === null) {
            continue;
        }
        $variablePosition = $variable->firstRead ? $variable->firstRead : $stackPtr;
        $this->markVariableReadAndWarnIfUndefined($phpcsFile, $variable->name, $variablePosition, $currScope);
    }
}

API Navigation

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