本文整理汇总了PHP中PHPParser_Node_Stmt::getAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPParser_Node_Stmt::getAttribute方法的具体用法?PHP PHPParser_Node_Stmt::getAttribute怎么用?PHP PHPParser_Node_Stmt::getAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPParser_Node_Stmt
的用法示例。
在下文中一共展示了PHPParser_Node_Stmt::getAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: extractAnnotation
/**
* Extracts annotations in the comment of a statement and injects them in
* attribute of the node
*
* @param \PHPParser_Node_Stmt $node
*/
protected function extractAnnotation(\PHPParser_Node_Stmt $node)
{
if ($node->hasAttribute('comments')) {
$compil = array();
foreach ($node->getAttribute('comments') as $comm) {
preg_match_all('#^.*@mondrian\\s+([\\w]+)\\s+([^\\s]+)\\s*$#m', $comm->getReformattedText(), $match);
foreach ($match[0] as $idx => $matchedOccur) {
$compil[$match[1][$idx]][] = $match[2][$idx];
}
}
// if there are annotations, we add them to the node
foreach ($compil as $attr => $lst) {
$node->setAttribute($attr, $lst);
}
}
}
示例2: 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());
}
}
}
}