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

Breadcrumb

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

function SubversionPropertiesSniff::process

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

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

int

Overrides Sniff::process

File

vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php, line 55

Class

SubversionPropertiesSniff

Namespace

PHP_CodeSniffer\Standards\Generic\Sniffs\VersionControl

Code

public function process(File $phpcsFile, $stackPtr) {
    $path = $phpcsFile->getFilename();
    $properties = $this->getProperties($path);
    if ($properties === null) {
        // Not under version control.
        return $phpcsFile->numTokens;
    }
    $allProperties = $properties + $this->properties;
    foreach ($allProperties as $key => $value) {
        if (isset($properties[$key]) === true && isset($this->properties[$key]) === false) {
            $error = 'Unexpected Subversion property "%s" = "%s"';
            $data = [
                $key,
                $properties[$key],
            ];
            $phpcsFile->addError($error, $stackPtr, 'Unexpected', $data);
            continue;
        }
        if (isset($properties[$key]) === false && isset($this->properties[$key]) === true) {
            $error = 'Missing Subversion property "%s" = "%s"';
            $data = [
                $key,
                $this->properties[$key],
            ];
            $phpcsFile->addError($error, $stackPtr, 'Missing', $data);
            continue;
        }
        if ($properties[$key] !== null && $properties[$key] !== $this->properties[$key]) {
            $error = 'Subversion property "%s" = "%s" does not match "%s"';
            $data = [
                $key,
                $properties[$key],
                $this->properties[$key],
            ];
            $phpcsFile->addError($error, $stackPtr, 'NoMatch', $data);
        }
    }
    
    //end foreach
    // Ignore the rest of the file.
    return $phpcsFile->numTokens;
}
RSS feed
Powered by Drupal