1 <?php declare(strict_types=1);
8 * Gets the type of the node.
10 * @return string Type of the node
12 public function getType() : string;
15 * Gets the names of the sub nodes.
17 * @return array Names of sub nodes
19 public function getSubNodeNames() : array;
22 * Gets line the node started in (alias of getStartLine).
24 * @return int Start line (or -1 if not available)
26 public function getLine() : int;
29 * Gets line the node started in.
31 * Requires the 'startLine' attribute to be enabled in the lexer (enabled by default).
33 * @return int Start line (or -1 if not available)
35 public function getStartLine() : int;
38 * Gets the line the node ended in.
40 * Requires the 'endLine' attribute to be enabled in the lexer (enabled by default).
42 * @return int End line (or -1 if not available)
44 public function getEndLine() : int;
47 * Gets the token offset of the first token that is part of this node.
49 * The offset is an index into the array returned by Lexer::getTokens().
51 * Requires the 'startTokenPos' attribute to be enabled in the lexer (DISABLED by default).
53 * @return int Token start position (or -1 if not available)
55 public function getStartTokenPos() : int;
58 * Gets the token offset of the last token that is part of this node.
60 * The offset is an index into the array returned by Lexer::getTokens().
62 * Requires the 'endTokenPos' attribute to be enabled in the lexer (DISABLED by default).
64 * @return int Token end position (or -1 if not available)
66 public function getEndTokenPos() : int;
69 * Gets the file offset of the first character that is part of this node.
71 * Requires the 'startFilePos' attribute to be enabled in the lexer (DISABLED by default).
73 * @return int File start position (or -1 if not available)
75 public function getStartFilePos() : int;
78 * Gets the file offset of the last character that is part of this node.
80 * Requires the 'endFilePos' attribute to be enabled in the lexer (DISABLED by default).
82 * @return int File end position (or -1 if not available)
84 public function getEndFilePos() : int;
87 * Gets all comments directly preceding this node.
89 * The comments are also available through the "comments" attribute.
93 public function getComments() : array;
96 * Gets the doc comment of the node.
98 * The doc comment has to be the last comment associated with the node.
100 * @return null|Comment\Doc Doc comment object or null
102 public function getDocComment();
105 * Sets the doc comment of the node.
107 * This will either replace an existing doc comment or add it to the comments array.
109 * @param Comment\Doc $docComment Doc comment to set
111 public function setDocComment(Comment\Doc $docComment);
114 * Sets an attribute on a node.
117 * @param mixed $value
119 public function setAttribute(string $key, $value);
122 * Returns whether an attribute exists.
128 public function hasAttribute(string $key) : bool;
131 * Returns the value of an attribute.
134 * @param mixed $default
138 public function getAttribute(string $key, $default = null);
141 * Returns all the attributes of this node.
145 public function getAttributes() : array;
148 * Replaces all the attributes of this node.
150 * @param array $attributes
152 public function setAttributes(array $attributes);