Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: nikic/PHP-Parser
base: 77d58a4151
...
head fork: nikic/PHP-Parser
compare: ce08ea46c2
  • 3 commits
  • 2 files changed
  • 0 commit comments
  • 2 contributors
Showing with 64 additions and 0 deletions.
  1. +34 −0 lib/PHPParser/Node.php
  2. +30 −0 lib/PHPParser/NodeAbstract.php
View
34 lib/PHPParser/Node.php
@@ -43,4 +43,38 @@ public function getDocComment();
* @param null|string $docComment Nearest doc comment or null
*/
public function setDocComment($docComment);
+
+ /**
+ * Sets an attribute on a node.
+ *
+ * @param string $key
+ * @param mixed $value
+ */
+ public function setAttribute($key, $value);
+
+ /**
+ * Returns whether an attribute exists.
+ *
+ * @param string $key
+ *
+ * @return Boolean
+ */
+ public function hasAttribute($key);
+
+ /**
+ * Returns the value of an attribute.
+ *
+ * @param string $key
+ * @param mixed $default
+ *
+ * @return mixed
+ */
+ public function getAttribute($key, $default = null);
+
+ /**
+ * Returns all attributes for the given node.
+ *
+ * @return array
+ */
+ public function getAttributes();
}
View
30 lib/PHPParser/NodeAbstract.php
@@ -5,6 +5,7 @@
protected $subNodes;
protected $line;
protected $docComment;
+ protected $attributes;
/**
* Creates a Node.
@@ -17,6 +18,7 @@ public function __construct(array $subNodes, $line = -1, $docComment = null) {
$this->subNodes = $subNodes;
$this->line = $line;
$this->docComment = $docComment;
+ $this->attributes = array();
}
/**
@@ -72,6 +74,34 @@ public function getDocComment() {
public function setDocComment($docComment) {
$this->docComment = $docComment;
}
+
+ /**
+ * @inheritDoc
+ */
+ public function setAttribute($key, $value) {
+ $this->attributes[$key] = $value;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function hasAttribute($key) {
+ return array_key_exists($key, $this->attributes);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getAttribute($key, $default = null) {
+ return array_key_exists($key, $this->attributes) ? $this->attributes[$key] : $default;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getAttributes() {
+ return $this->attributes;
+ }
/* Magic interfaces */

No commit comments for this range

Something went wrong with that request. Please try again.