Mercurial > hg > isophonics-drupal-site
diff vendor/squizlabs/php_codesniffer/src/Tokenizers/Tokenizer.php @ 18:af1871eacc83
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:33:08 +0100 |
parents | 129ea1e6d783 |
children |
line wrap: on
line diff
--- a/vendor/squizlabs/php_codesniffer/src/Tokenizers/Tokenizer.php Thu Feb 28 13:21:36 2019 +0000 +++ b/vendor/squizlabs/php_codesniffer/src/Tokenizers/Tokenizer.php Thu May 09 15:33:08 2019 +0100 @@ -37,6 +37,27 @@ protected $tokens = []; /** + * The number of tokens in the tokens array. + * + * @var integer + */ + protected $numTokens = 0; + + /** + * A list of tokens that are allowed to open a scope. + * + * @var array + */ + public $scopeOpeners = []; + + /** + * A list of tokens that end the scope. + * + * @var array + */ + public $endScopeTokens = []; + + /** * Known lengths of tokens. * * @var array<int, int> @@ -59,7 +80,7 @@ * @param string $eolChar The EOL char used in the content. * * @return void - * @throws TokenizerException If the file appears to be minified. + * @throws \PHP_CodeSniffer\Exceptions\TokenizerException If the file appears to be minified. */ public function __construct($content, $config, $eolChar='\n') { @@ -163,7 +184,7 @@ $encoding = $this->config->encoding; $tabWidth = $this->config->tabWidth; - $this->tokensWithTabs = [ + $tokensWithTabs = [ T_WHITESPACE => true, T_COMMENT => true, T_DOC_COMMENT => true, @@ -186,7 +207,7 @@ $length = $this->knownLengths[$this->tokens[$i]['code']]; $currColumn += $length; } else if ($tabWidth === 0 - || isset($this->tokensWithTabs[$this->tokens[$i]['code']]) === false + || isset($tokensWithTabs[$this->tokens[$i]['code']]) === false || strpos($this->tokens[$i]['content'], "\t") === false ) { // There are no tabs in this content, or we aren't replacing them. @@ -369,6 +390,17 @@ $this->ignoredLines[$this->tokens[$i]['line']] = ['.all' => true]; } + // Need to maintain case here, to get the correct sniff code. + $parts = explode(' ', substr($commentText, 10)); + if (count($parts) >= 2) { + $sniffParts = explode('.', $parts[0]); + if (count($sniffParts) >= 3) { + $this->tokens[$i]['sniffCode'] = array_shift($parts); + $this->tokens[$i]['sniffProperty'] = array_shift($parts); + $this->tokens[$i]['sniffPropertyValue'] = rtrim(implode(' ', $parts), " */\r\n"); + } + } + $this->tokens[$i]['code'] = T_PHPCS_SET; $this->tokens[$i]['type'] = 'T_PHPCS_SET'; } else if (substr($commentTextLower, 0, 16) === 'phpcs:ignorefile') { @@ -502,7 +534,7 @@ } if ($lineHasOtherContent === false) { - // Completely ignore the comment line, and set the folllowing + // Completely ignore the comment line, and set the following // line to include the ignore rules we've set. $this->ignoredLines[$this->tokens[$i]['line']] = ['.all' => true]; $this->ignoredLines[($this->tokens[$i]['line'] + 1)] = $ignoreRules;