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

Breadcrumb

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

function LocalFile::process

Processes the file.

Return value

void

Overrides File::process

File

vendor/squizlabs/php_codesniffer/src/Files/LocalFile.php, line 85

Class

LocalFile

Namespace

PHP_CodeSniffer\Files

Code

public function process() {
    if ($this->ignored === true) {
        return;
    }
    if ($this->configCache['cache'] === false) {
        parent::process();
        return;
    }
    $hash = md5_file($this->path);
    $hash .= fileperms($this->path);
    $cache = Cache::get($this->path);
    if ($cache !== false && $cache['hash'] === $hash) {
        // We can't filter metrics, so just load all of them.
        $this->metrics = $cache['metrics'];
        if ($this->configCache['recordErrors'] === true) {
            // Replay the cached errors and warnings to filter out the ones
            // we don't need for this specific run.
            $this->configCache['cache'] = false;
            $this->replayErrors($cache['errors'], $cache['warnings']);
            $this->configCache['cache'] = true;
        }
        else {
            $this->errorCount = $cache['errorCount'];
            $this->warningCount = $cache['warningCount'];
            $this->fixableCount = $cache['fixableCount'];
        }
        if (PHP_CODESNIFFER_VERBOSITY > 0 || PHP_CODESNIFFER_CBF === true && empty($this->config->files) === false) {
            echo "[loaded from cache]... ";
        }
        $this->numTokens = $cache['numTokens'];
        $this->fromCache = true;
        return;
    }
    
    //end if
    if (PHP_CODESNIFFER_VERBOSITY > 1) {
        echo PHP_EOL;
    }
    parent::process();
    $cache = [
        'hash' => $hash,
        'errors' => $this->errors,
        'warnings' => $this->warnings,
        'metrics' => $this->metrics,
        'errorCount' => $this->errorCount,
        'warningCount' => $this->warningCount,
        'fixableCount' => $this->fixableCount,
        'numTokens' => $this->numTokens,
    ];
    Cache::set($this->path, $cache);
    // During caching, we don't filter out errors in any way, so
    // we need to do that manually now by replaying them.
    if ($this->configCache['recordErrors'] === true) {
        $this->configCache['cache'] = false;
        $this->replayErrors($this->errors, $this->warnings);
        $this->configCache['cache'] = true;
    }
}
RSS feed
Powered by Drupal