本文整理匯總了PHP中PhpParser\Node\Stmt::getAttribute方法的典型用法代碼示例。如果您正苦於以下問題:PHP Stmt::getAttribute方法的具體用法?PHP Stmt::getAttribute怎麽用?PHP Stmt::getAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PhpParser\Node\Stmt
的用法示例。
在下文中一共展示了Stmt::getAttribute方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: addCommentsFromAttributes
/**
* @param \EBT\ExtensionBuilder\Domain\Model\AbstractObject $object
* @param \PhpParser\Node\Stmt $node
*/
protected function addCommentsFromAttributes(Model\AbstractObject $object, \PhpParser\Node\Stmt $node)
{
$comments = $node->getAttribute('comments');
if (is_array($comments)) {
foreach ($comments as $comment) {
if ($comment instanceof \PhpParser\Comment\Doc) {
$object->setDocComment($comment->getReformattedText());
} elseif ($comment instanceof \PhpParser\Comment) {
$object->addComment($comment->getText());
}
}
}
}
示例2: getEndLine
/**
* Get the line number that this function ends on.
*
* @return int
*/
public function getEndLine()
{
return (int) $this->node->getAttribute('endLine', -1);
}
示例3: verifyNotControlStructure
private function verifyNotControlStructure(Node\Stmt $node)
{
$nodeType = str_replace('Stmt_', '', $node->getType());
if (isset(self::$constructStructureMap[$nodeType])) {
throw ASTException::containsControlStructure(self::$constructStructureMap[$nodeType], $node->getAttribute('startLine'));
}
}
示例4: buildClassLikeReflection
protected function buildClassLikeReflection(AbstractNode $node)
{
if ($node instanceof InterfaceNode) {
$class = new ReflectionInterface((string) $node->namespacedName);
} elseif ($node instanceof TraitNode) {
$class = new ReflectionTrait((string) $node->namespacedName);
} else {
$class = new ReflectionClass((string) $node->namespacedName);
}
$class->setFilename((string) $this->context->getFilePath());
$class->setStartLine((int) $node->getAttribute('startLine'));
$class->setEndLine((int) $node->getAttribute('endLine'));
$class->setAliases($this->context->getAliases());
$class->setDocComment((string) $node->getDocComment());
$this->context->enterReflection($class);
return $class;
}