/** * Creates a Descriptor from the provided data. * * @param FunctionReflector $data * * @return FunctionDescriptor */ public function create($data) { $functionDescriptor = new FunctionDescriptor(); $functionDescriptor->setFullyQualifiedStructuralElementName($data->getName() . '()'); $functionDescriptor->setName($data->getShortName()); $functionDescriptor->setLine($data->getLinenumber()); // Reflection library formulates namespace as global but this is not wanted for phpDocumentor itself $functionDescriptor->setNamespace('\\' . (strtolower($data->getNamespace()) == 'global' ? '' : $data->getNamespace())); $this->assembleDocBlock($data->getDocBlock(), $functionDescriptor); foreach ($data->getArguments() as $argument) { $argumentAssembler = new ArgumentAssembler(); $argumentDescriptor = $argumentAssembler->create($argument, $functionDescriptor->getTags()->get('param', array())); $functionDescriptor->getArguments()->set($argumentDescriptor->getName(), $argumentDescriptor); } return $functionDescriptor; }
/** * Export this function definition to the given parent DOMElement. * * @param \DOMElement $parent Element to augment. * @param FunctionReflector $function Element to export. * @param \DOMElement $child if supplied this element will be * augmented instead of freshly added. * * @return void */ public function export(\DOMElement $parent, $function, \DOMElement $child = null) { if (!$child) { $child = new \DOMElement('function'); $parent->appendChild($child); } $child->setAttribute('namespace', $function->getNamespace() ? $function->getNamespace() : $parent->getAttribute('namespace')); $child->setAttribute('line', $function->getLineNumber()); $short_name = method_exists($function, 'getShortName') ? $function->getShortName() : $function->getName(); $child->appendChild(new \DOMElement('name', $short_name)); $child->appendChild(new \DOMElement('full_name', $function->getName())); $object = new DocBlockExporter(); $function->setDefaultPackageName($parent->getAttribute('package')); $object->export($child, $function); foreach ($function->getArguments() as $argument) { $object = new ArgumentExporter(); $object->export($child, $argument); } }
/** * Retrieves the Fully Qualified Namespace Name from the FunctionReflector. * * Reflection library formulates namespace as global but this is not wanted for phpDocumentor itself. * * @param FunctionReflector $reflector * * @return string */ protected function getFullyQualifiedNamespaceName($reflector) { return '\\' . (strtolower($reflector->getNamespace()) == 'global' ? '' : $reflector->getNamespace()); }