/** * @param \phpDocumentor\Reflection\BaseReflector $reflector * @param Context $context * @param array $config */ public function __construct($reflector = null, $context = null, $config = []) { parent::__construct($config); if ($reflector === null) { return; } // base properties $this->name = ltrim($reflector->getName(), '\\'); $this->startLine = $reflector->getNode()->getAttribute('startLine'); $this->endLine = $reflector->getNode()->getAttribute('endLine'); $docblock = $reflector->getDocBlock(); if ($docblock !== null) { $this->shortDescription = ucfirst($docblock->getShortDescription()); if (empty($this->shortDescription) && !$this instanceof PropertyDoc && $context !== null && $docblock->getTagsByName('inheritdoc') === null) { $context->errors[] = ['line' => $this->startLine, 'file' => $this->sourceFile, 'message' => "No short description for " . substr(StringHelper::basename(get_class($this)), 0, -3) . " '{$this->name}'"]; } $this->description = $docblock->getLongDescription()->getContents(); $this->phpDocContext = $docblock->getContext(); $this->tags = $docblock->getTags(); foreach ($this->tags as $i => $tag) { if ($tag instanceof SinceTag) { $this->since = $tag->getVersion(); unset($this->tags[$i]); } elseif ($tag instanceof DeprecatedTag) { $this->deprecatedSince = $tag->getVersion(); $this->deprecatedReason = $tag->getDescription(); unset($this->tags[$i]); } } } elseif ($context !== null) { $context->errors[] = ['line' => $this->startLine, 'file' => $this->sourceFile, 'message' => "No docblock for element '{$this->name}'"]; } }
/** * Export this tag to the given DocBlock. * * @param \DOMElement $parent Element to * augment. * @param \phpDocumentor\Reflection\DocBlock\Tag $tag The tag to * export. * @param \phpDocumentor\Reflection\BaseReflector $element Element to * log from. * * @return void */ public function export(\DOMElement $parent, $tag, $element) { $child = new \DOMElement('tag'); $parent->appendChild($child); $child->setAttribute('line', $parent->getAttribute('line')); $element->dispatch('reflection.docblock.tag.export', array('object' => $tag, 'xml' => simplexml_import_dom($child))); }
/** * Constructor * * @param string $name Name of the "entity" * @param DocBlock|null $docblock Docblock * @param BaseReflector|null $source Source Element. */ public function __construct($name, $docblock = null, $source = null) { $this->entityName = $name; $this->lineNumber = $docblock ? $docblock->getLocation()->getLineNumber() : $source->getLineNumber(); $this->docblock = $docblock; $this->source = $source; }
/** * Constructor * * @param \phpDocumentor\Plugin\Plugin $plugin Plugin to which this * validator belongs. * @param string $name Name of the "entity" * @param \phpDocumentor\Reflection\DocBlock|null $docblock Docblock * @param \phpDocumentor\Reflection\BaseReflector|null $source Source Element. */ public function __construct($plugin, $name, $docblock = null, $source = null) { $this->entityName = $name; $this->lineNumber = $docblock ? $docblock->line_number : $source->getLineNumber(); $this->docblock = $docblock; $this->source = $source; parent::__construct($plugin->getEventDispatcher(), $plugin->getConfiguration(), $plugin->getTranslator()); }
/** * Exports the given reflection object to the parent XML element. * * This method creates a new child element on the given parent XML element * and takes the properties of the Reflection argument and sets the * elements and attributes on the child. * * If a child DOMElement is provided then the properties and attributes are * set on this but the child element is not appended onto the parent. This * is the responsibility of the invoker. Essentially this means that the * $parent argument is ignored in this case. * * @param \DOMElement $parent The parent element * to augment. * @param \phpDocumentor\Reflection\BaseReflector $element The data source. * * @return void */ public function export(\DOMElement $parent, $element) { $docblock = $element->getDocBlock(); if (!$docblock) { $parent->setAttribute('package', $element->getDefaultPackageName()); return; } $child = new \DOMElement('docblock'); $parent->appendChild($child); // TODO: custom attached member variable, make real $child->setAttribute('line', $docblock->line_number); $this->addDescription($child, $docblock); $this->addLongDescription($child, $docblock); $this->addTags($child, $docblock->getTags(), $element); $this->setParentsPackage($parent, $docblock, $element); }
/** * Initializes the reflector using the function statement object of * PHP-Parser. * * @param \PHPParser_Node_Stmt $node Function object coming from PHP-Parser. */ public function __construct(\PHPParser_Node_Stmt $node) { parent::__construct($node); /** @var \PHPParser_Node_Param $param */ foreach ($node->params as $param) { $reflector = new FunctionReflector\ArgumentReflector($param); $this->arguments[$reflector->getName()] = $reflector; } }
/** * Initializes the reflector using the function statement object of * PHP-Parser. * * @param \PhpParser\Node\Stmt $node Function object coming from PHP-Parser. * @param Context $context The context in which the node occurs. */ public function __construct(\PhpParser\Node\Stmt $node, Context $context) { parent::__construct($node, $context); /** @var \PhpParser\Node\Param $param */ foreach ($node->params as $param) { $reflector = new FunctionReflector\ArgumentReflector($param, $context); $this->arguments[$reflector->getName()] = $reflector; } }
/** * @param BaseReflector|ReflectionAbstract $element * * @return array */ function export_docblock($element) { $docblock = $element->getDocBlock(); if (!$docblock) { return array('description' => '', 'long_description' => '', 'tags' => array()); } $output = array('description' => preg_replace('/[\\n\\r]+/', ' ', $docblock->getShortDescription()), 'long_description' => preg_replace('/[\\n\\r]+/', ' ', $docblock->getLongDescription()->getFormattedContents()), 'tags' => array()); foreach ($docblock->getTags() as $tag) { $tag_data = array('name' => $tag->getName(), 'content' => preg_replace('/[\\n\\r]+/', ' ', format_description($tag->getDescription()))); if (method_exists($tag, 'getTypes')) { $tag_data['types'] = $tag->getTypes(); } if (method_exists($tag, 'getLink')) { $tag_data['link'] = $tag->getLink(); } if (method_exists($tag, 'getVariableName')) { $tag_data['variable'] = $tag->getVariableName(); } if (method_exists($tag, 'getReference')) { $tag_data['refers'] = $tag->getReference(); } if (method_exists($tag, 'getVersion')) { // Version string. $version = $tag->getVersion(); if (!empty($version)) { $tag_data['content'] = $version; } // Description string. if (method_exists($tag, 'getDescription')) { $description = preg_replace('/[\\n\\r]+/', ' ', format_description($tag->getDescription())); if (!empty($description)) { $tag_data['description'] = $description; } } } $output['tags'][] = $tag_data; } return $output; }
public function getName() { return '$' . parent::getName(); }
/** * Registers the Constant Statement and Node with this reflector. * * @param PHPParser_Node_Stmt_Const $stmt * @param Context $context * @param PHPParser_Node_Const $node */ public function __construct(PHPParser_Node_Stmt_ClassConst $stmt, Context $context, PHPParser_Node_Const $node) { BaseReflector::__construct($node, $context); $this->constant = $stmt; }
/** * Checks the typehint of the argument versus the @param tag. * * If the argument has no typehint we do not check anything. When multiple * type are given then the typehint needs to be one of them. * * @param ParamTag $param * @param ArgumentReflector $argument * @param BaseReflector $element * * @return Error|null */ protected function doesArgumentTypehintMatchParam(ParamTag $param, ArgumentReflector $argument, BaseReflector $element) { if (!$argument->getType() || in_array($argument->getType(), $param->getTypes())) { return null; } elseif ($argument->getType() == 'array' && substr($param->getType(), -2) == '[]') { return null; } return new Error(LogLevel::ERROR, 'PPC:ERR-50016', $argument->getLinenumber(), array($argument->getName(), $element->getName())); }
/** * Overload method so we can test the protected method * * @param Expr $value * * @return string */ public function getRepresentationOfValueMock(Expr $value = null) { return parent::getRepresentationOfValue($value); }
/** * Overload method so we can test the protected method * * @param PHPParser_Node_Expr $value * * @return string */ public function getRepresentationOfValueMock(PHPParser_Node_Expr $value = null) { return parent::getRepresentationOfValue($value); }
/** * Registers the Constant Statement and Node with this reflector. * * @param PHPParser_Node_Stmt_Const $stmt * @param PHPParser_Node_Const $node */ public function __construct(PHPParser_Node_Stmt_Const $stmt, Context $context, PHPParser_Node_Const $node) { parent::__construct($node, $context); $this->constant = $stmt; }
/** * Sets the package of the parent element. * * This method inspects the current DocBlock and extract an @package * element. If that tag is present than the associated element's package * name is set to that value. * * If no @package tag is present in the DocBlock then the default package * name is set. * * @param \DOMElement $parent * @param DocBlock $docblock * @param BaseReflector $element * * @return void */ protected function setParentsPackage(\DOMElement $parent, DocBlock $docblock, $element) { /** @var \phpDocumentor\Reflection\DocBlock\Tag $package */ $package = current($docblock->getTagsByName('package')); /** @var \phpDocumentor\Reflection\DocBlock\Tag $subpackage */ $subpackage = current($docblock->getTagsByName('subpackage')); $package_name = ''; if ($package) { $package_name = str_replace(array('.', '_'), '\\', $package->getContent() . ($subpackage ? '\\' . $subpackage->getContent() : '')); } if (!$package_name) { $package_name = $element->getDefaultPackageName(); } $parent->setAttribute('package', $package_name); }
/** * Registers the Constant Statement and Node with this reflector. * * @param ConstStmt $stmt * @param Const_ $node */ public function __construct(ConstStmt $stmt, Context $context, Const_ $node) { parent::__construct($node, $context); $this->constant = $stmt; }
/** * Registers the Constant Statement and Node with this reflector. * * @param ClassConst $stmt * @param Context $context * @param Const_ $node */ public function __construct(ClassConst $stmt, Context $context, Const_ $node) { BaseReflector::__construct($node, $context); $this->constant = $stmt; }