div, * #foo ~ div, * #foo\3Abar ~ div, * #foo\:bar ~ div, * #foo.bar .baz, * div#foo { * blah: 'abc'; * } */ public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); // Find the next non-selector token $nextToken = $phpcsFile->findNext($this->selectorTokens, $stackPtr + 1, null, true); // Anything except a { or a , means this is not a selector if ($nextToken !== false && in_array($tokens[$nextToken]['code'], [T_OPEN_CURLY_BRACKET, T_COMMA])) { $phpcsFile->addError('Id selector is used', $stackPtr, 'IdSelectorUsage'); } } }