示例#1
0
文件: CLI.php 项目: hco/Autoload
 /**
  * Main executor method
  *
  * @return void
  */
 public function run()
 {
     try {
         $input = $this->setupInput();
         $input->process();
         if ($input->getOption('help')->value === TRUE) {
             $this->showVersion();
             $this->showUsage();
             exit(CLI::RC_OK);
         }
         if ($input->getOption('version')->value === TRUE) {
             $this->showVersion();
             exit(CLI::RC_OK);
         }
         $config = $this->configure($input);
         $this->factory->setConfig($config);
         if (!$config->isQuietMode()) {
             $this->showVersion();
         }
         $rc = $this->factory->getApplication()->run();
         exit($rc);
     } catch (\ezcConsoleException $e) {
         $this->showVersion();
         echo $e->getMessage() . "\n\n";
         $this->showUsage();
         exit(CLI::RC_PARAM_ERROR);
     } catch (\Exception $e) {
         $this->showVersion();
         fwrite(STDERR, "\nError while processing request:\n - " . $e->getMessage() . "\n");
         exit(CLI::RC_EXEC_ERROR);
     }
 }
示例#2
0
文件: CLI.php 项目: zonuexe/Autoload
 /**
  * Main executor method
  *
  * @return void
  */
 public function run()
 {
     try {
         $this->preBootstrap();
         $input = $this->setupInput();
         $input->process();
         if ($input->getOption('help')->value === TRUE) {
             $this->showVersion();
             $this->showUsage();
             exit(CLI::RC_OK);
         }
         if ($input->getOption('version')->value === TRUE) {
             $this->showVersion();
             exit(CLI::RC_OK);
         }
         $config = $this->configure($input);
         $this->factory->setConfig($config);
         if (!$config->isQuietMode()) {
             $this->showVersion();
         }
         $rc = $this->factory->getApplication()->run();
         exit($rc);
     } catch (CLIEnvironmentException $e) {
         $this->showVersion();
         fwrite(STDERR, 'Sorry, but your PHP environment is currently not able to run phpab due to');
         fwrite(STDERR, "\nthe following issue(s):\n\n" . $e->getMessage() . "\n\n");
         fwrite(STDERR, "Please adjust your PHP configuration and try again.\n\n");
         exit(CLI::RC_EXEC_ERROR);
     } catch (\ezcConsoleException $e) {
         $this->showVersion();
         echo $e->getMessage() . "\n\n";
         $this->showUsage();
         exit(CLI::RC_PARAM_ERROR);
     } catch (CollectorException $e) {
         switch ($e->getCode()) {
             case CollectorException::InFileRedeclarationFound:
             case CollectorException::RedeclarationFound:
             case CollectorException::ParseErrror:
                 $message = $e->getMessage();
                 break;
             default:
                 $message = "Unexpected error in collector process: " . $e->getMessage() . "\n\nPlease report this as a bug.\n\n";
         }
         $this->showVersion();
         fwrite(STDERR, $message . "\n\n");
         exit(CLI::RC_EXEC_ERROR);
     } catch (\Exception $e) {
         $this->showVersion();
         fwrite(STDERR, "\nError while processing request:\n - " . $e->getMessage() . "\n");
         exit(CLI::RC_EXEC_ERROR);
     }
 }
示例#3
0
 public function testBugIsFixed()
 {
     $config = new Config(array());
     $config->setLowercaseMode(true);
     $factory = new Factory();
     $factory->setConfig($config);
     $collector = $factory->getCollector();
     $scanner = $factory->getScanner()->getIterator(__DIR__ . '/_data/bug65');
     $collector->processDirectory($scanner);
     $result = $collector->getResult();
     $sorter = new ClassDependencySorter($result->getUnits(), $result->getDependencies());
     $expected = array('phpunit_extensions_database_testcase_trait' => __DIR__ . "/_data/bug65/trait.php", 'phpunit_extensions_database_testcase' => __DIR__ . "/_data/bug65/class.php");
     $this->assertEquals($expected, $sorter->process());
 }