comparison vendor/squizlabs/php_codesniffer/src/Sniffs/AbstractPatternSniff.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents a9cd425dd02b
children
comparison
equal deleted inserted replaced
4:a9cd425dd02b 5:12f9dff5fda9
151 * 151 *
152 * @param array $pattern The pattern to acquire the listener for. 152 * @param array $pattern The pattern to acquire the listener for.
153 * 153 *
154 * @return int The position in the pattern that this test should register 154 * @return int The position in the pattern that this test should register
155 * as the listener. 155 * as the listener.
156 * @throws RuntimeException If we could not determine a token to listen for. 156 * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If we could not determine a token to listen for.
157 */ 157 */
158 private function getListenerTokenPos($pattern) 158 private function getListenerTokenPos($pattern)
159 { 159 {
160 $tokenTypes = $this->getPatternTokenTypes($pattern); 160 $tokenTypes = $this->getPatternTokenTypes($pattern);
161 $tokenCodes = array_keys($tokenTypes); 161 $tokenCodes = array_keys($tokenTypes);
193 $this->currFile = $file; 193 $this->currFile = $file;
194 } 194 }
195 195
196 $tokens = $phpcsFile->getTokens(); 196 $tokens = $phpcsFile->getTokens();
197 197
198 if (in_array($tokens[$stackPtr]['code'], $this->supplementaryTokens) === true) { 198 if (in_array($tokens[$stackPtr]['code'], $this->supplementaryTokens, true) === true) {
199 $this->processSupplementary($phpcsFile, $stackPtr); 199 $this->processSupplementary($phpcsFile, $stackPtr);
200 } 200 }
201 201
202 $type = $tokens[$stackPtr]['code']; 202 $type = $tokens[$stackPtr]['code'];
203 203
258 $pattern = $patternInfo['pattern']; 258 $pattern = $patternInfo['pattern'];
259 $patternCode = $patternInfo['pattern_code']; 259 $patternCode = $patternInfo['pattern_code'];
260 $errors = []; 260 $errors = [];
261 $found = ''; 261 $found = '';
262 262
263 $ignoreTokens = [T_WHITESPACE]; 263 $ignoreTokens = [T_WHITESPACE => T_WHITESPACE];
264 if ($this->ignoreComments === true) { 264 if ($this->ignoreComments === true) {
265 $ignoreTokens 265 $ignoreTokens += Tokens::$commentTokens;
266 = array_merge($ignoreTokens, Tokens::$commentTokens);
267 } 266 }
268 267
269 $origStackPtr = $stackPtr; 268 $origStackPtr = $stackPtr;
270 $hasError = false; 269 $hasError = false;
271 270