*/ public function register() { return [\T_CONST]; } /** * Processes this test, when one of its tokens is encountered. * * @since 7.1.4 * * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. * @param int $stackPtr The position of the current token in the * stack passed in $tokens. * * @return void */ public function process(File $phpcsFile, $stackPtr) { if (ScannedCode::shouldRunOnOrBelow('5.5') === \false) { return; } $tokens = $phpcsFile->getTokens(); $find = Collections::arrayOpenTokensBC(); while (($hasArray = $phpcsFile->findNext($find, $stackPtr + 1, null, \false, null, \true)) !== \false) { if ($tokens[$hasArray]['code'] === \T_ARRAY || Arrays::isShortArray($phpcsFile, $hasArray) === \true) { $phpcsFile->addError('Constant arrays using the "const" keyword are not allowed in PHP 5.5 or earlier', $hasArray, 'Found'); } // Skip past the content of the array. $stackPtr = $hasArray; if (isset($tokens[$hasArray]['bracket_closer'])) { $stackPtr = $tokens[$hasArray]['bracket_closer']; } elseif (isset($tokens[$hasArray]['parenthesis_closer'])) { $stackPtr = $tokens[$hasArray]['parenthesis_closer']; } } } }