getTokens(); if ($sourceFile->findPrevious(T_STRING_CONCAT, $stackPtr, $stackPtr - 3) || $sourceFile->findNext(T_STRING_CONCAT, $stackPtr, $stackPtr + 3) ) { return; } $content = trim($tokens[$stackPtr]['content'], "\"'"); // replace double slashes from class name for avoiding problems with class autoload if (strpos($content, '\\') !== false) { $content = preg_replace('|\\\{2,}|', '\\', $content); } if (preg_match($this->literalNamespacePattern, $content) === 1 && $this->classExists($content)) { $sourceFile->addError( "Use ::class notation instead.", $stackPtr, 'LiteralClassUsage' ); } } /** * @param string $className * @return bool */ private function classExists($className) { if (!isset($this->classNames[$className])) { $this->classNames[$className] = class_exists($className) || interface_exists($className); } return $this->classNames[$className]; } }