/**
  * Overwrites the type and description in the Argument Descriptor with that from the tag if the names match.
  *
  * @param ArgumentReflector  $argument
  * @param ParamDescriptor    $paramDescriptor
  * @param ArgumentDescriptor $argumentDescriptor
  *
  * @return void
  */
 protected function overwriteTypeAndDescriptionFromParamTag(ArgumentReflector $argument, ParamDescriptor $paramDescriptor, ArgumentDescriptor $argumentDescriptor)
 {
     if ($paramDescriptor->getVariableName() != $argument->getName()) {
         return;
     }
     $argumentDescriptor->setDescription($paramDescriptor->getDescription());
     $argumentDescriptor->setTypes($paramDescriptor->getTypes() ?: $this->builder->buildDescriptor(new Collection(array($argument->getType() ?: 'mixed'))));
 }
 /**
  * Creates a Descriptor from the provided data.
  *
  * @param ArgumentReflector $data
  * @param ParamDescriptor[] $params
  *
  * @return ArgumentDescriptor
  */
 public function create($data, $params = array())
 {
     $argumentDescriptor = new ArgumentDescriptor();
     $argumentDescriptor->setName($data->getName());
     $argumentDescriptor->setTypes($data->getType() ? array($data->getType()) : array());
     /** @var ParamDescriptor $tag */
     foreach ($params as $tag) {
         if ($tag->getVariableName() == $data->getName()) {
             $argumentDescriptor->setDescription($tag->getDescription());
             $types = $tag->getTypes() ?: array($data->getType() ?: 'mixed');
             $argumentDescriptor->setTypes($types);
         }
     }
     $argumentDescriptor->setDefault($data->getDefault());
     return $argumentDescriptor;
 }
 /**
  * Checks if there is a variadic argument in the `@param` tags and adds it to the list of Arguments in
  * the Descriptor unless there is already one present.
  *
  * @param MethodReflector  $data
  * @param MethodDescriptor $methodDescriptor
  *
  * @return void
  */
 protected function addVariadicArgument($data, $methodDescriptor)
 {
     if (!$data->getDocBlock()) {
         return;
     }
     $paramTags = $data->getDocBlock()->getTagsByName('param');
     /** @var ParamTag $lastParamTag */
     $lastParamTag = end($paramTags);
     if (!$lastParamTag) {
         return;
     }
     if ($lastParamTag->isVariadic() && !in_array($lastParamTag->getVariableName(), array_keys($methodDescriptor->getArguments()->getAll()))) {
         $types = $this->builder->buildDescriptor(new Collection($lastParamTag->getTypes()));
         $argument = new ArgumentDescriptor();
         $argument->setName($lastParamTag->getVariableName());
         $argument->setTypes($types);
         $argument->setDescription($lastParamTag->getDescription());
         $argument->setLine($methodDescriptor->getLine());
         $argument->setVariadic(true);
         $methodDescriptor->getArguments()->set($argument->getName(), $argument);
     }
 }