本文整理汇总了PHP中PHPParser_Node_Stmt::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPParser_Node_Stmt::setAttribute方法的具体用法?PHP PHPParser_Node_Stmt::setAttribute怎么用?PHP PHPParser_Node_Stmt::setAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPParser_Node_Stmt
的用法示例。
在下文中一共展示了PHPParser_Node_Stmt::setAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addCommentAttributes
/**
* @param \EBT\ExtensionBuilder\Domain\Model\AbstractObject $object
* @param \PHPParser_Node_Stmt $node
*/
protected function addCommentAttributes(\EBT\ExtensionBuilder\Domain\Model\AbstractObject $object, \PHPParser_Node_Stmt $node)
{
$commentAttributes = array();
$comments = $object->getComments();
if (count($comments) > 0) {
foreach ($comments as $comment) {
$commentAttributes[] = new \PHPParser_Comment($comment);
}
}
if ($object->hasDescription() || $object->hasTags()) {
$commentAttributes[] = new \PHPParser_Comment_Doc($object->getDocComment());
}
$node->setAttribute('comments', $commentAttributes);
}
示例2: 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);
}
}
}