getTokens(); $currentToken = $tokens[$stackPtr]; $nextColon = $phpcsFile->findNext(T_COLON, $stackPtr); $nextSemicolon = $phpcsFile->findNext(T_SEMICOLON, $stackPtr); if ((false === $nextColon) || (false === $nextSemicolon)) { return; } $isVariableDeclaration = ($currentToken['line'] === $tokens[$nextColon]['line']) && ($currentToken['line'] === $tokens[$nextSemicolon]['line']) && (T_STRING === $tokens[$stackPtr + 1]['code']) && (T_COLON === $tokens[$stackPtr + 2]['code']); if (!$isVariableDeclaration) { return; } $classBefore = $phpcsFile->findPrevious(T_STYLE, $stackPtr); if (false !== $classBefore) { $phpcsFile->addError('Variable declaration located not in the beginning of general comments', $stackPtr); } $variableName = $tokens[$stackPtr + 1]['content']; if (preg_match('/[A-Z]/', $variableName)) { $phpcsFile->addError('Variable declaration contains uppercase symbols', $stackPtr); } } }