コード例 #1
0
 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);
     }
 }
コード例 #2
0
ファイル: Router.php プロジェクト: symplify/php7_codesniffer
 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 '';
 }
コード例 #3
0
 /**
  * @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;
 }