Example #1
0
 /**
  * The command-line arguments and options.
  *
  * @return void
  */
 protected function configure()
 {
     $this->setName('generate')->setDescription('Generate the documentation output from JSON source definitions.');
     $options = (include __DIR__ . '/generate_configs.php');
     $options = ConfigStore::convert($options);
     foreach ($options as $option => $details) {
         list($type, $description, $default) = $details;
         if (!is_null($default)) {
             if (is_bool($default)) {
                 $default = $default ? 'true' : 'false';
             }
             $description .= ConsoleUtil::formatters()->gold->apply(' (default: ' . (is_array($default) ? ParseUtils::unwrapArray($default) : $default) . ')');
         }
         $this->addOption($option, null, $type, $description);
     }
 }
Example #2
0
 /**
  * Retrieve the properties for the class.
  *
  * @return array A list of properties.
  */
 public function getProperties()
 {
     $rproperties = $this->class->getProperties();
     foreach ($rproperties as $rproperty) {
         if (!isset($this->properties['count'])) {
             $this->properties['count'] = count($rproperties);
         }
         if (!isset($this->properties['property'])) {
             $this->properties['property'] = array();
         }
         $rproperty = InheritdocHandler::resolve($rproperty);
         $_tags = new TagHandler($rproperty->getDocComment(), $this->ancestry);
         $property_docblock = new DocBlock($rproperty->getDocComment());
         // Property-specific data
         $entry = array();
         $entry['name'] = $rproperty->getName();
         $entry['visibility'] = $this->access($rproperty);
         // Where are we?
         SystemStore::add('_.current', $this->class->getName() . '::$' . $rproperty->getName());
         if ($description = $_tags->getDescription()) {
             $entry['description'] = $description;
         }
         // Property inheritance
         if (($declaring_class = $rproperty->getDeclaringClass()->getName()) !== $this->class->getName()) {
             if (!isset($entry['inheritance'])) {
                 $entry['inheritance'] = array();
             }
             if (!isset($entry['inheritance']['class'])) {
                 $entry['inheritance']['class'] = array();
             }
             $declaring_class = $rproperty->getDeclaringClass();
             $subentry = array();
             $subentry['name'] = $declaring_class->getName();
             if ($declaring_class->getFileName()) {
                 $subentry['path'] = str_replace(VANITY_PROJECT_WORKING_DIR . '/', '', $declaring_class->getFileName());
             }
             $entry['inheritance']['class'][] = $subentry;
         }
         // Default value, if accessible
         if ($rproperty->isPublic()) {
             $rvalue = $rproperty->getValue($this->class);
             $adjusted_rvalue = null;
             switch (strtolower(gettype($rvalue))) {
                 case 'boolean':
                     $adjusted_rvalue = $rvalue == 1 ? 'true' : 'false';
                     break;
                 case 'null':
                     $adjusted_rvalue = 'null';
                     break;
                 case 'string':
                     $adjusted_rvalue = $rvalue;
                     break;
                 case 'integer':
                     $adjusted_rvalue = (int) $rvalue;
                     break;
                 case 'array':
                     $adjusted_rvalue = ParseUtil::unwrapArray($rvalue);
                     break;
             }
             $entry['initializer'] = array();
             $entry['initializer']['type'] = gettype($rvalue);
             $entry['initializer']['value'] = $adjusted_rvalue;
         }
         // Property tags
         if ($t = $_tags->getTags()) {
             $entry['metadata'] = $t;
         }
         $this->properties['property'][] = $entry;
     }
     return $this->properties;
 }