本文整理汇总了PHP中Node::getAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP Node::getAttributes方法的具体用法?PHP Node::getAttributes怎么用?PHP Node::getAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Node
的用法示例。
在下文中一共展示了Node::getAttributes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAttributes
/**
* Returns node attributes including (lazily) calculated ones.
*
* @return array
* @see Node::getAttributes()
*/
public function getAttributes()
{
$attributes = parent::getAttributes();
$errors = count($this->errors);
$failures = count($this->failures);
if (0 < $errors) {
$attributes['errors'] = $errors;
}
if (0 < $failures) {
$attributes['failures'] = $failures;
}
return $attributes;
}
示例2: testConstruct
/**
* @dataProvider provideNodes
*/
public function testConstruct(array $attributes, Node $node)
{
$this->assertSame('Dummy', $node->getType());
$this->assertSame(array('subNode1', 'subNode2'), $node->getSubNodeNames());
$this->assertSame(10, $node->getLine());
$this->assertSame('/** doc comment */', $node->getDocComment()->getText());
$this->assertSame('value1', $node->subNode1);
$this->assertSame('value2', $node->subNode2);
$this->assertTrue(isset($node->subNode1));
$this->assertTrue(isset($node->subNode2));
$this->assertFalse(isset($node->subNode3));
$this->assertSame($attributes, $node->getAttributes());
return $node;
}
示例3: applyArgs
protected function applyArgs(Node $node)
{
if ($node instanceof TextNode) {
$node->setContent($this->interpolate($node->getContent()));
} else {
if ($node instanceof Element) {
foreach ($node->getAttributes() as $attr => $value) {
$node->setAttribute($attr, $this->interpolate($value));
}
}
}
foreach ($node->getChildren() as $child) {
$this->applyArgs($child);
}
}
示例4: getAttributes
/**
* Returns node attributes including (lazily) calculated ones.
*
* @return array
* @see Node::getAttributes()
*/
public function getAttributes()
{
$attributes = parent::getAttributes();
$tests = count($this->cases);
$errors = 0;
$failures = 0;
$time = 0;
if (count($this->cases)) {
foreach ($this->cases as $case) {
$errors += $case->getAttribute('errors');
$failures += $case->getAttribute('failures');
$time += (double) $case->getAttribute('time');
}
}
if (count($this->suites)) {
foreach ($this->suites as $suite) {
$errors += $suite->getAttribute('errors');
$failures += $suite->getAttribute('failures');
$tests += $suite->getAttribute('tests');
$time += $suite->getAttribute('time');
}
}
if (0 < $errors) {
$attributes['errors'] = $errors;
}
if (0 < $failures) {
$attributes['failures'] = $failures;
}
if (0 < $tests) {
$attributes['tests'] = $tests;
}
if (0 < $time) {
$attributes['time'] = $time;
}
return $attributes;
}
示例5: toArray
/**
* Returns an array representation of the given Node structure.
*
* @param Node $node
*
* @return array
*/
public function toArray(Node $node)
{
return array('name' => $node->getName(), 'value' => $node->getValue(), 'attributes' => $node->getAttributes(), 'children' => array_map(function (Node $child) {
return $this->toArray($child);
}, $node->getChildren()));
}