Skip to content

Commit 5ba5f85

Browse files
committed
Add more documentation for the Attribute node.
1 parent 6215ceb commit 5ba5f85

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

src/Exporter/Ascii.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function export(NodeInterface $node): string
5858
protected function getNodeRepresentation(NodeInterface $node): string
5959
{
6060
if ($node instanceof ValueNodeInterface) {
61-
return $node->getValue();
61+
return (string) $node->getValue();
6262
}
6363

6464
return \sha1(\spl_object_hash($node));

src/Node/AttributeNode.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(
3333
/**
3434
* {@inheritdoc}
3535
*/
36-
public function getAttribute($key)
36+
public function getAttribute(string $key)
3737
{
3838
return $this->getAttributes()[$key] ?? null;
3939
}

src/Node/AttributeNodeInterface.php

+25-5
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,42 @@
1010
interface AttributeNodeInterface extends NaryNodeInterface
1111
{
1212
/**
13-
* {@inheritdoc}
13+
* Get an attribute.
14+
*
15+
* @return mixed
16+
* The value of the attribute.
1417
*/
15-
public function getAttribute($key);
18+
public function getAttribute(string $key);
1619

1720
/**
18-
* {@inheritdoc}
21+
* Get the attributes.
22+
*
23+
* @return \Traversable
24+
* The attributes.
1925
*/
2026
public function getAttributes(): \Traversable;
2127

2228
/**
23-
* {@inheritdoc}
29+
* Set an attribute.
30+
*
31+
* @param string $key
32+
* The attribute key.
33+
* @param mixed $value
34+
* The attribute value.
35+
*
36+
* @return \drupol\phptree\Node\AttributeNodeInterface
37+
* The node.
2438
*/
2539
public function setAttribute(string $key, $value): AttributeNodeInterface;
2640

2741
/**
28-
* {@inheritdoc}
42+
* Set the attributes.
43+
*
44+
* @param \Traversable $attributes
45+
* The attributes.
46+
*
47+
* @return \drupol\phptree\Node\AttributeNodeInterface
48+
* The node.
2949
*/
3050
public function setAttributes(\Traversable $attributes): AttributeNodeInterface;
3151
}

0 commit comments

Comments
 (0)