Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function process($elongate = false)
 {
     $return = array();
     $return['name'] = $this->tag->getName();
     $content = $this->clean($this->tag->getContent());
     if (preg_match('/(<([^>]*)>)?\\s*([^\\s]*)\\s*(.*)?/', $content, $m)) {
         if (!empty($m[2])) {
             $return['type'] = $elongate ? AncestryHandler::elongateType($m[2], $this->ancestry) : $m[2];
         }
         if (!empty($m[3])) {
             $return['dispatches'] = $m[3];
         }
         if (!empty($m[4])) {
             $return['description'] = $m[4];
         }
     }
     return $return;
 }
 /**
  * {@inheritdoc}
  */
 public function process($elongate = false)
 {
     $return = array();
     $return['name'] = $this->tag->getName();
     $content = $this->clean($this->tag->getContent());
     $content = explode(' ', $content);
     $type = array_shift($content);
     $description = trim(implode(' ', $content));
     if (strpos($type, '|')) {
         $self = $this;
         $return['type'] = 'mixed';
         $return['types'] = explode('|', $type);
         $return['types'] = array_map(function ($type) use($self, $elongate) {
             return $elongate ? AncestryHandler::elongateType($type, $self->ancestry) : $type;
         }, $return['types']);
     } else {
         $return['type'] = $elongate ? AncestryHandler::elongateType($type, $this->ancestry) : $type;
     }
     if ($description) {
         $return['description'] = $description;
     }
     return $return;
 }
Beispiel #3
0
 /**
  * Converts short-form native types to long-form native types.
  * Also resolves namespace aliases with a provided alias mapping.
  *
  * @param  string          $type      The name of the type.
  * @param  AncestryHandler $ancestry  The ancestry data for the class.
  * @return string                     The long-form version of the type.
  */
 public static function elongateType($type, AncestryHandler $ancestry)
 {
     $native_types = self::listNativeTypes();
     $native_types = array_combine($native_types, $native_types);
     $native_types = array_merge($native_types, array('bool' => 'boolean', 'int' => 'integer', 'str' => 'string'));
     if (isset($native_types[strtolower($type)])) {
         return $native_types[strtolower($type)];
     }
     return $ancestry->resolveNamespace($type);
 }
 /**
  * Handle the arguments for the tag.
  *
  * @param  string  $arguments The raw arguments that have been parsed from the tag.
  * @param  boolean $elongate  Whether or not to elongate/resolve classes and aliases.
  * @return array              An array containing a `type` and `types` key that should be merged back into the
  *                            parent node.
  */
 public function handleArguments($arguments, $elongate)
 {
     $return = array();
     $return['arguments'] = array();
     $arguments = trim($arguments);
     if ($arguments) {
         foreach (explode(',', $arguments) as $argument) {
             preg_match('/^((\\w*)[\\s]*)?(&)?\\$(\\w*)([\\s]*=[\\s]*(.*))?$/', trim($argument), $matches);
             @(list(, , $type, $pbr, $name, , $default) = $matches);
             $pieces = array('name' => $name, 'type' => $type, 'required' => !$default, 'passed_by_reference' => (bool) $pbr);
             if ($type && strpos($type, '|')) {
                 $self = $this;
                 $pieces['type'] = 'mixed';
                 $pieces['types'] = explode('|', $type);
                 $pieces['types'] = array_map(function ($type) use($self, $elongate) {
                     return $elongate ? AncestryHandler::elongateType($type, $self->ancestry) : $type;
                 }, $pieces['types']);
             } elseif ($type) {
                 $pieces['type'] = $elongate ? AncestryHandler::elongateType($type, $this->ancestry) : $type;
             }
             $return['arguments'][] = $pieces;
         }
     }
     return $return;
 }