Chris@0: getTokens(); Chris@0: Chris@0: // Only check constants in the global scope. Chris@0: if (empty($tokens[$stackPtr]['conditions']) === false) { Chris@0: return; Chris@0: } Chris@0: Chris@17: $coreVersion = Project::getCoreVersion($phpcsFile); Chris@0: if ($coreVersion !== '8.x') { Chris@0: return; Chris@0: } Chris@0: Chris@0: // Allow constants if they are deprecated. Chris@0: $commentEnd = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); Chris@0: if ($commentEnd !== null && $tokens[$commentEnd]['code'] === T_DOC_COMMENT_CLOSE_TAG) { Chris@0: // Go through all comment tags and check if one is @deprecated. Chris@0: $commentTag = $commentEnd; Chris@0: while ($commentTag !== null && $commentTag > $tokens[$commentEnd]['comment_opener']) { Chris@0: if ($tokens[$commentTag]['content'] === '@deprecated') { Chris@0: return; Chris@0: } Chris@0: Chris@0: $commentTag = $phpcsFile->findPrevious(T_DOC_COMMENT_TAG, ($commentTag - 1), $tokens[$commentEnd]['comment_opener']); Chris@0: } Chris@0: } Chris@0: Chris@0: $warning = 'Global constants should not be used, move it to a class or interface'; Chris@0: $phpcsFile->addWarning($warning, $stackPtr, 'GlobalConstant'); Chris@0: Chris@0: }//end process() Chris@0: Chris@0: Chris@0: }//end class