本文整理匯總了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()));
}