private static function registerSniffAliases() { $sniffFinder = new SniffFinder(new SniffClassRobotLoaderFactory(), new SniffClassFilter()); $sniffClasses = $sniffFinder->findAllSniffClassesInDirectory(VendorDirProvider::provide() . '/squizlabs/php_codesniffer/src/Standards'); foreach ($sniffClasses as $sniffCode => $sniffClass) { $legacySniffClass = self::convertSniffCodeToLegacyClassName($sniffCode); class_alias($sniffClass, $legacySniffClass); } }
public function getClassFromSniffCode(string $sniffCode) : string { $sniffCode = $this->normalizeToSniffClassCode($sniffCode); if (isset($this->foundClasses[$sniffCode])) { return $this->foundClasses[$sniffCode]; } $sniffClasses = $this->sniffFinder->findAllSniffClasses(); if (isset($sniffClasses[$sniffCode])) { return $sniffClasses[$sniffCode]; } return ''; }
/** * @return Sniff[] */ private function createSniffsFromOwnRuleset(string $rulesetXmlFile) : array { $rulesetDir = dirname($rulesetXmlFile); $sniffDir = $rulesetDir . DIRECTORY_SEPARATOR . 'Sniffs'; if (!is_dir($sniffDir)) { return []; } $sniffClassNames = $this->sniffFinder->findAllSniffClassesInDirectory($sniffDir); $sniffs = []; foreach ($sniffClassNames as $sniffClassName) { if ($sniff = $this->singleSniffFactory->create($sniffClassName)) { $sniffs[] = $sniff; } } return $sniffs; }