예제 #1
0
 /**
  * Returns a list of paths to XML standard files for all sniffs in a standard.
  *
  * Any sniffs that do not have an XML standard file are obviously not included
  * in the returned array. If documentation is only being generated for some
  * sniffs (ie. $this->_sniffs is not empty) then all others sniffs will
  * be filtered from the results as well.
  *
  * @return array(string)
  */
 protected function getStandardFiles()
 {
     if (is_dir($this->_standard) === true) {
         // This is a custom standard.
         $standardDir = $this->_standard;
         $standard = basename($this->_standard);
     } else {
         $standardDir = realpath(dirname(__FILE__) . '/../Standards/' . $this->_standard);
         $standard = $this->_standard;
     }
     $phpcs = new PHP_CodeSniffer();
     $sniffs = $phpcs->getSniffFiles($standardDir, $standard);
     $standardFiles = array();
     foreach ($sniffs as $sniff) {
         if (empty($this->_sniffs) === false) {
             // We are limiting the docs to certain sniffs only, so filter
             // out any unwanted sniffs.
             $sniffName = substr($sniff, strrpos($sniff, '/') + 1);
             $sniffName = substr($sniffName, 0, -9);
             if (in_array($sniffName, $this->_sniffs) === false) {
                 continue;
             }
         }
         $standardFile = str_replace(DIRECTORY_SEPARATOR . 'Sniffs' . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR . 'Docs' . DIRECTORY_SEPARATOR, $sniff);
         $standardFile = str_replace('Sniff.php', 'Standard.xml', $standardFile);
         if (is_file($standardFile) === true) {
             $standardFiles[] = $standardFile;
         }
     }
     //end foreach
     return $standardFiles;
 }