示例#1
0
 /**
  * Main entry point into the application.
  *
  * @return void
  */
 public function main()
 {
     $runner = new DocBlox_Task_Runner($_SERVER['argc'] == 1 ? false : $_SERVER['argv'][1], 'project:run');
     $task = $runner->getTask();
     $threshold = DocBlox_Core_Log::WARN;
     if (!$task->getQuiet()) {
         DocBlox_Core_Application::renderVersion();
     } else {
         $threshold = DocBlox_Core_Log::QUIET;
     }
     if ($task->getVerbose()) {
         $threshold = DocBlox_Core_Log::DEBUG;
     }
     $dispatcher = new sfEventDispatcher();
     $logger = new DocBlox_Core_Log(DocBlox_Core_Log::FILE_STDOUT);
     $logger->setThreshold($threshold);
     $dispatcher->connect('system.log', array($logger, 'log'));
     DocBlox_Parser_Abstract::$event_dispatcher = $dispatcher;
     DocBlox_Transformer_Abstract::$event_dispatcher = $dispatcher;
     DocBlox_Reflection_Abstract::$event_dispatcher = $dispatcher;
     try {
         $task->execute();
     } catch (Exception $e) {
         if (!$task->getQuiet()) {
             echo 'ERROR: ' . $e->getMessage() . PHP_EOL . PHP_EOL;
             echo $task->getUsageMessage();
         }
         die(1);
     }
 }
示例#2
0
 /**
  * Parses the configuration options and populates the data store.
  *
  * @param bool $force if true; forces parsing independently of the _parsed property.
  *
  * @return void
  */
 public function parse($force = false)
 {
     if ($this->_parsed === true && !$force) {
         return $this;
     }
     $this->_parsed = false;
     try {
         parent::parse();
     } catch (Zend_Exception $e) {
         $name = basename($_SERVER['SCRIPT_NAME'], '.php');
         echo $name . ': ' . $e->getMessage() . PHP_EOL;
         echo 'Try: \'' . $name . ' --help\' for more information.' . PHP_EOL;
         exit(22);
     }
     if ($this->getHelp()) {
         DocBlox_Core_Application::renderVersion();
         echo $this->getUsageMessage();
         exit(0);
     }
     // prevent the loading of configuration files by specifying 'none'.
     if (strtolower($this->getConfig()) == 'none') {
         return;
     }
     if ($this->getConfig()) {
         // when the configuration parameter is provided; merge that with the basic config
         DocBlox_Core_Abstract::config()->merge(new Zend_Config_Xml($this->getConfig()));
     } elseif (is_readable('docblox.xml')) {
         // when the configuration is not provided; check for the presence of a configuration file in the current directory
         // and merge that
         DocBlox_Core_Abstract::config()->merge(new Zend_Config_Xml('docblox.xml'));
     } elseif (is_readable('docblox.dist.xml')) {
         // when no docblox.xml is provided; check for a dist.xml file. Yes, compared to, for example, PHPUnit the xml
         // and dist is reversed; this is done on purpose so IDEs have an easier time on it.
         DocBlox_Core_Abstract::config()->merge(new Zend_Config_Xml('docblox.dist.xml'));
     }
     $this->prePopulate();
     // the parse method does not have a hook point to invoke the setter methods; thus we iterate through the options and
     // invoke the setters. If no setter exists the __call method will handle this.
     // We have explicitly kept this intact (as the __call's set does nothing special) to enable subclasses to override
     // the __call and receive the benefits.
     foreach ($this->getOptions() as $value) {
         $method_name = '';
         // loop through all aliases to check whether a real method was overridden
         foreach ($this->_rules[$value]['alias'] as $alias) {
             $method_name = 'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $alias)));
             if (method_exists($this, $method_name)) {
                 // found one! execute it and continue to the next
                 $this->{$method_name}($this->getOption($value));
                 continue 2;
             }
         }
         if ($method_name == '') {
             throw new Exception('Unable to find a name for the setter for argument ' . $value);
         }
         // no overridden methods found; just invoke the default name to trigger the __call method
         $this->{$method_name}($this->getOption($value));
     }
 }
示例#3
0
 /**
  * Main entry point into the application
  *
  * @return void
  */
 public function main()
 {
     require_once 'Image/GraphViz.php';
     require_once 'markdown.php';
     $runner = new DocBlox_Task_Runner($_SERVER['argc'] == 1 ? 'project:run' : $_SERVER['argv'][1]);
     $task = $runner->getTask();
     if (!$task->getQuiet()) {
         DocBlox_Core_Application::renderVersion();
     }
     try {
         $task->execute();
     } catch (Exception $e) {
         echo 'ERROR: ' . $e->getMessage() . PHP_EOL . PHP_EOL;
         echo $task->getUsageMessage();
     }
 }
示例#4
0
 /**
  * Parses the configuration options and populates the data store.
  *
  * @param bool $force if true; forces parsing independently of the _parsed property.
  *
  * @return void
  */
 public function parse($force = false)
 {
     if ($this->_parsed === true && !$force) {
         return $this;
     }
     $this->_parsed = false;
     try {
         parent::parse();
     } catch (Zend_Exception $e) {
         $name = basename($_SERVER['SCRIPT_NAME'], '.php');
         echo $name . ': ' . $e->getMessage() . PHP_EOL;
         echo 'Try: \'' . $name . ' --help\' for more information.' . PHP_EOL;
         exit(22);
     }
     if ($this->getHelp()) {
         DocBlox_Core_Application::renderVersion();
         echo $this->getUsageMessage();
         exit(0);
     }
     $this->prePopulate();
     // the parse method does not have a hook point to invoke the setter methods; thus we iterate through the options and
     // invoke the setters. If no setter exists the __call method will handle this.
     // We have explicitly kept this intact (as the __call's set does nothing special) to enable subclasses to override
     // the __call and receive the benefits.
     foreach ($this->getOptions() as $value) {
         $method_name = '';
         // loop through all aliases to check whether a real method was overridden
         foreach ($this->_rules[$value]['alias'] as $alias) {
             $method_name = 'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $alias)));
             if (method_exists($this, $method_name)) {
                 // found one! execute it and continue to the next
                 $this->{$method_name}($this->getOption($value));
                 continue 2;
             }
         }
         if ($method_name == '') {
             throw new Exception('Unable to find a name for the setter for argument ' . $value);
         }
         // no overridden methods found; just invoke the default name to trigger the __call method
         $this->{$method_name}($this->getOption($value));
     }
 }
示例#5
0
 /**
  * Main entry point into the application.
  *
  * @return void
  */
 public function main()
 {
     require_once 'markdown.php';
     $runner = new DocBlox_Task_Runner($_SERVER['argc'] == 1 ? false : $_SERVER['argv'][1], 'project:run');
     $task = $runner->getTask();
     if (!$task->getQuiet()) {
         DocBlox_Core_Application::renderVersion();
     }
     try {
         $task->execute();
     } catch (Exception $e) {
         echo 'ERROR: ' . $e->getMessage() . PHP_EOL . PHP_EOL;
         echo $task->getUsageMessage();
         // exit with the exception's code or 1 if null/0
         $exit = $e->getCode();
         if (!$exit) {
             $exit = 1;
         }
         exit($exit);
     }
 }
示例#6
0
文件: docblox.php 项目: rhysr/Docblox
if (extension_loaded('xhprof')) {
    // check whether one of the arguments is --profile; this will enable the profiler
    $profile = array_search('--profile', $argv);
    if (false !== $profile) {
        unset($_SERVER['argv'][$profile]);
        $_SERVER['argc']--;
        xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
    }
}
// determine base include folder, if @php_bin@ contains @php_bin then we do not install via PEAR
$base_include_folder = strpos('@php_dir@', '@php_dir') === 0 ? dirname(__FILE__) . '/../src' : '@php_dir@/DocBlox/src';
// set path to add lib folder, load the Zend Autoloader and include the symfony timer
set_include_path($base_include_folder . PATH_SEPARATOR . get_include_path());
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('DocBlox_');
$application = new DocBlox_Core_Application();
$application->main();
if (false !== $profile) {
    include_once 'XHProf/utils/xhprof_lib.php';
    include_once 'XHProf/utils/xhprof_runs.php';
    $xhprof_data = xhprof_disable();
    if ($xhprof_data !== null) {
        $xhprof_runs = new XHProfRuns_Default();
        $run_id = $xhprof_runs->save_run($xhprof_data, 'docblox');
        $profiler_url = sprintf('index.php?run=%s&source=%s', $run_id, 'docblox');
        echo 'Profile can be found at: ' . $profiler_url . PHP_EOL;
    }
}
// disable E_STRICT reporting on the end to prevent PEAR from throwing Strict warnings.
error_reporting(error_reporting() & ~E_STRICT);