*/ public function register() { return [\T_NAMESPACE]; } /** * Processes this test, when one of its tokens is encountered. * * @since 1.0.0 * * @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 (Namespaces::isDeclaration($phpcsFile, $stackPtr) === false) { // Namespace operator, not a declaration; or live coding/parse error. return; } $tokens = $phpcsFile->getTokens(); if (isset($tokens[$stackPtr]['scope_condition']) === true && $tokens[$stackPtr]['scope_condition'] === $stackPtr ) { $phpcsFile->recordMetric($stackPtr, self::METRIC_NAME, 'yes'); return; } $phpcsFile->recordMetric($stackPtr, self::METRIC_NAME, 'no'); $phpcsFile->addError( 'Namespace declarations without curly braces are not allowed.', $stackPtr, 'Forbidden' ); } }