$builder
$builder : \phpDocumentor\Descriptor\ProjectDescriptorBuilder|null
Assembles an ArgumentDescriptor using an ArgumentReflector and ParamDescriptors.
$builder : \phpDocumentor\Descriptor\ProjectDescriptorBuilder|null
getBuilder() : null|\phpDocumentor\Descriptor\ProjectDescriptorBuilder
Returns the builder for this Assembler or null if none is set.
setBuilder(\phpDocumentor\Descriptor\ProjectDescriptorBuilder $builder) : void
Registers the Builder with this Assembler.
The Builder may be used to recursively assemble Descriptors using the ProjectDescriptorBuilder::buildDescriptor() method.
\phpDocumentor\Descriptor\ProjectDescriptorBuilder | $builder |
create(\phpDocumentor\Reflection\FunctionReflector\ArgumentReflector $data, array<mixed,\phpDocumentor\Descriptor\Tag\ParamDescriptor> $params = array()) : \phpDocumentor\Descriptor\ArgumentDescriptor
Creates a Descriptor from the provided data.
\phpDocumentor\Reflection\FunctionReflector\ArgumentReflector | $data | |
array<mixed,\phpDocumentor\Descriptor\Tag\ParamDescriptor> | $params |
assembleDocBlock(\phpDocumentor\Reflection\DocBlock|null $docBlock, \phpDocumentor\Descriptor\DescriptorAbstract $target) : void
Assemble DocBlock.
\phpDocumentor\Reflection\DocBlock|null | $docBlock | |
\phpDocumentor\Descriptor\DescriptorAbstract | $target |
overwriteTypeAndDescriptionFromParamTag(\phpDocumentor\Reflection\FunctionReflector\ArgumentReflector $argument, \phpDocumentor\Descriptor\Tag\ParamDescriptor $paramDescriptor, \phpDocumentor\Descriptor\ArgumentDescriptor $argumentDescriptor) : void
Overwrites the type and description in the Argument Descriptor with that from the tag if the names match.
\phpDocumentor\Reflection\FunctionReflector\ArgumentReflector | $argument | |
\phpDocumentor\Descriptor\Tag\ParamDescriptor | $paramDescriptor | |
\phpDocumentor\Descriptor\ArgumentDescriptor | $argumentDescriptor |
<?php
/**
* phpDocumentor
*
* PHP Version 5.3
*
* @copyright 2010-2014 Mike van Riel / Naenius (http://www.naenius.com)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Descriptor\Builder\Reflector;
use phpDocumentor\Descriptor\ArgumentDescriptor;
use phpDocumentor\Reflection\DocBlock\Type\Collection;
use phpDocumentor\Descriptor\Tag\ParamDescriptor;
use phpDocumentor\Reflection\FunctionReflector\ArgumentReflector;
/**
* Assembles an ArgumentDescriptor using an ArgumentReflector and ParamDescriptors.
*/
class ArgumentAssembler extends AssemblerAbstract
{
/**
* 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(
$this->builder->buildDescriptor(
$data->getType() ? new Collection(array($data->getType())) : new Collection()
)
);
foreach ($params as $paramDescriptor) {
$this->overwriteTypeAndDescriptionFromParamTag($data, $paramDescriptor, $argumentDescriptor);
}
$argumentDescriptor->setDefault($data->getDefault());
$argumentDescriptor->setByReference($data->isByRef());
return $argumentDescriptor;
}
/**
* 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'))
)
);
}
}