/**
  * Creates a Descriptor from the provided data.
  *
  * @param MethodReflector $data
  *
  * @return MethodDescriptor
  */
 public function create($data)
 {
     $methodDescriptor = new MethodDescriptor();
     $methodDescriptor->setFullyQualifiedStructuralElementName($data->getName() . '()');
     $methodDescriptor->setName($data->getShortName());
     $methodDescriptor->setVisibility($data->getVisibility() ?: 'public');
     $methodDescriptor->setFinal($data->isFinal());
     $methodDescriptor->setAbstract($data->isAbstract());
     $methodDescriptor->setStatic($data->isStatic());
     $this->assembleDocBlock($data->getDocBlock(), $methodDescriptor);
     foreach ($data->getArguments() as $argument) {
         $argumentAssembler = new ArgumentAssembler();
         $argumentDescriptor = $argumentAssembler->create($argument, $methodDescriptor->getTags()->get('param', array()));
         $methodDescriptor->getArguments()->set($argumentDescriptor->getName(), $argumentDescriptor);
     }
     $methodDescriptor->setLine($data->getLinenumber());
     return $methodDescriptor;
 }
 /**
  * Adds the reflected Arguments to the Descriptor.
  *
  * @param MethodReflector  $reflector
  * @param MethodDescriptor $descriptor
  *
  * @return void
  */
 protected function addArguments($reflector, $descriptor)
 {
     foreach ($reflector->getArguments() as $argument) {
         $this->addArgument($argument, $descriptor);
     }
 }
Exemplo n.º 3
0
 private function getArgumentString(MethodReflector $method)
 {
     $req_args = array();
     $opt_args = array();
     foreach ($method->getArguments() as $argument) {
         if ($optDefault = $argument->getDefault()) {
             $opt_args[] = $argument->getName() . ' = ' . $optDefault;
         } else {
             $req_args[] = $argument->getName();
         }
     }
     $args = implode(', ', $req_args) . ($opt_args ? $req_args ? ' [, ' : '[ ' : '') . implode(' [, ', $opt_args) . str_repeat(']', count($opt_args));
     return $args;
 }