Пример #1
0
 /**
  * Main method.
  *
  * @param string $path Absolute path to file or directory.
  * @return boolean
  */
 public function run()
 {
     $path = $this->request->action;
     if (!($path = realpath($path))) {
         $this->error('Not a valid path.');
         return false;
     }
     if (!($this->_project = $this->_project($path))) {
         $this->error('Not a valid project.');
         return false;
     }
     if (is_dir($this->_project . '/.git')) {
         $this->_vcs = 'git';
     }
     $app = new Application(getcwd());
     $app->registerProgressPrinter($this);
     $file = Libraries::get('phpca', 'path') . '/Standard/lithium.ini';
     $config = new Configuration(getcwd());
     $config->setStandard(parse_ini_file($file, true));
     $config->setConfiguration(array());
     if (!isset($this->php)) {
         $this->php = PHP_BINDIR . '/' . (substr(PHP_OS, 0, 3) == 'WIN' ? 'php.exe' : 'php');
     }
     if (!file_exists($this->php)) {
         $message = 'You must specify a valid absolute path to a PHP executable. ';
         $message .= 'Try using `li3 syntax --php=PATH ...`.';
         $this->error($message);
         return false;
     }
     if (!$this->plain) {
         $this->header('Syntax');
         $this->out(null, 1);
     }
     $begin = microtime(true);
     try {
         $result = $app->run($this->php, $path, $config);
     } catch (Exception $e) {
         $this->out($message = $e->getMessage());
         return $message == 'No PHP files to analyze';
     }
     if ($this->metrics) {
         $this->_metrics($result, microtime(true) - $begin);
     }
     return !$result->hasErrors();
 }