annotate vendor/nikic/php-parser/lib/PhpParser/Node.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 5fb285c0d0e3
children
rev   line source
Chris@13 1 <?php declare(strict_types=1);
Chris@0 2
Chris@0 3 namespace PhpParser;
Chris@0 4
Chris@0 5 interface Node
Chris@0 6 {
Chris@0 7 /**
Chris@0 8 * Gets the type of the node.
Chris@0 9 *
Chris@0 10 * @return string Type of the node
Chris@0 11 */
Chris@13 12 public function getType() : string;
Chris@0 13
Chris@0 14 /**
Chris@0 15 * Gets the names of the sub nodes.
Chris@0 16 *
Chris@0 17 * @return array Names of sub nodes
Chris@0 18 */
Chris@13 19 public function getSubNodeNames() : array;
Chris@13 20
Chris@13 21 /**
Chris@13 22 * Gets line the node started in (alias of getStartLine).
Chris@13 23 *
Chris@13 24 * @return int Start line (or -1 if not available)
Chris@13 25 */
Chris@13 26 public function getLine() : int;
Chris@0 27
Chris@0 28 /**
Chris@0 29 * Gets line the node started in.
Chris@0 30 *
Chris@13 31 * Requires the 'startLine' attribute to be enabled in the lexer (enabled by default).
Chris@13 32 *
Chris@13 33 * @return int Start line (or -1 if not available)
Chris@0 34 */
Chris@13 35 public function getStartLine() : int;
Chris@0 36
Chris@0 37 /**
Chris@13 38 * Gets the line the node ended in.
Chris@0 39 *
Chris@13 40 * Requires the 'endLine' attribute to be enabled in the lexer (enabled by default).
Chris@0 41 *
Chris@13 42 * @return int End line (or -1 if not available)
Chris@0 43 */
Chris@13 44 public function getEndLine() : int;
Chris@13 45
Chris@13 46 /**
Chris@13 47 * Gets the token offset of the first token that is part of this node.
Chris@13 48 *
Chris@13 49 * The offset is an index into the array returned by Lexer::getTokens().
Chris@13 50 *
Chris@13 51 * Requires the 'startTokenPos' attribute to be enabled in the lexer (DISABLED by default).
Chris@13 52 *
Chris@13 53 * @return int Token start position (or -1 if not available)
Chris@13 54 */
Chris@13 55 public function getStartTokenPos() : int;
Chris@13 56
Chris@13 57 /**
Chris@13 58 * Gets the token offset of the last token that is part of this node.
Chris@13 59 *
Chris@13 60 * The offset is an index into the array returned by Lexer::getTokens().
Chris@13 61 *
Chris@13 62 * Requires the 'endTokenPos' attribute to be enabled in the lexer (DISABLED by default).
Chris@13 63 *
Chris@13 64 * @return int Token end position (or -1 if not available)
Chris@13 65 */
Chris@13 66 public function getEndTokenPos() : int;
Chris@13 67
Chris@13 68 /**
Chris@13 69 * Gets the file offset of the first character that is part of this node.
Chris@13 70 *
Chris@13 71 * Requires the 'startFilePos' attribute to be enabled in the lexer (DISABLED by default).
Chris@13 72 *
Chris@13 73 * @return int File start position (or -1 if not available)
Chris@13 74 */
Chris@13 75 public function getStartFilePos() : int;
Chris@13 76
Chris@13 77 /**
Chris@13 78 * Gets the file offset of the last character that is part of this node.
Chris@13 79 *
Chris@13 80 * Requires the 'endFilePos' attribute to be enabled in the lexer (DISABLED by default).
Chris@13 81 *
Chris@13 82 * @return int File end position (or -1 if not available)
Chris@13 83 */
Chris@13 84 public function getEndFilePos() : int;
Chris@13 85
Chris@13 86 /**
Chris@13 87 * Gets all comments directly preceding this node.
Chris@13 88 *
Chris@13 89 * The comments are also available through the "comments" attribute.
Chris@13 90 *
Chris@13 91 * @return Comment[]
Chris@13 92 */
Chris@13 93 public function getComments() : array;
Chris@0 94
Chris@0 95 /**
Chris@0 96 * Gets the doc comment of the node.
Chris@0 97 *
Chris@0 98 * The doc comment has to be the last comment associated with the node.
Chris@0 99 *
Chris@0 100 * @return null|Comment\Doc Doc comment object or null
Chris@0 101 */
Chris@0 102 public function getDocComment();
Chris@0 103
Chris@0 104 /**
Chris@0 105 * Sets the doc comment of the node.
Chris@0 106 *
Chris@0 107 * This will either replace an existing doc comment or add it to the comments array.
Chris@0 108 *
Chris@0 109 * @param Comment\Doc $docComment Doc comment to set
Chris@0 110 */
Chris@0 111 public function setDocComment(Comment\Doc $docComment);
Chris@0 112
Chris@0 113 /**
Chris@0 114 * Sets an attribute on a node.
Chris@0 115 *
Chris@0 116 * @param string $key
Chris@0 117 * @param mixed $value
Chris@0 118 */
Chris@13 119 public function setAttribute(string $key, $value);
Chris@0 120
Chris@0 121 /**
Chris@0 122 * Returns whether an attribute exists.
Chris@0 123 *
Chris@0 124 * @param string $key
Chris@0 125 *
Chris@0 126 * @return bool
Chris@0 127 */
Chris@13 128 public function hasAttribute(string $key) : bool;
Chris@0 129
Chris@0 130 /**
Chris@0 131 * Returns the value of an attribute.
Chris@0 132 *
Chris@0 133 * @param string $key
Chris@0 134 * @param mixed $default
Chris@0 135 *
Chris@0 136 * @return mixed
Chris@0 137 */
Chris@13 138 public function getAttribute(string $key, $default = null);
Chris@0 139
Chris@0 140 /**
Chris@13 141 * Returns all the attributes of this node.
Chris@0 142 *
Chris@0 143 * @return array
Chris@0 144 */
Chris@13 145 public function getAttributes() : array;
Chris@13 146
Chris@13 147 /**
Chris@13 148 * Replaces all the attributes of this node.
Chris@13 149 *
Chris@13 150 * @param array $attributes
Chris@13 151 */
Chris@13 152 public function setAttributes(array $attributes);
Chris@13 153 }