Lines Matching refs:node
53 * @param array|Node $node Node or array to dump
60 public function dump($node, ?string $code = null): string { argument
64 $this->dumpRecursive($node, false);
68 /** @param mixed $node */
69 protected function dumpRecursive($node, bool $indent = true): void { argument
73 if ($node instanceof Node) {
74 $this->res .= $node->getType();
75 if ($this->dumpPositions && null !== $p = $this->dumpPosition($node)) {
80 foreach ($node->getSubNodeNames() as $key) {
83 $value = $node->$key;
89 if ('type' === $key && $node instanceof Include_) {
94 … && ($node instanceof Use_ || $node instanceof UseItem || $node instanceof GroupUse)) {
102 if ($this->dumpComments && $comments = $node->getComments()) {
108 foreach ($node->getAttributes() as $key => $value) {
116 if ($node instanceof Int_) {
120 if ($node instanceof String_ || $node instanceof InterpolatedString) {
124 if ($node instanceof Array_) {
128 if ($node instanceof List_) {
138 } elseif (\is_array($node)) {
140 foreach ($node as $key => $value) {
145 } elseif ($node instanceof Comment) {
146 $this->res .= \str_replace("\n", $this->nl, $node->getReformattedText());
147 } elseif (\is_string($node)) {
148 $this->res .= \str_replace("\n", $this->nl, (string)$node);
149 } elseif (\is_int($node) || \is_float($node)) {
150 $this->res .= $node;
151 } elseif (null === $node) {
153 } elseif (false === $node) {
155 } elseif (true === $node) {
266 * @param Node $node Node for which to dump position
270 protected function dumpPosition(Node $node): ?string { argument
271 if (!$node->hasAttribute('startLine') || !$node->hasAttribute('endLine')) {
275 $start = $node->getStartLine();
276 $end = $node->getEndLine();
277 if ($node->hasAttribute('startFilePos') && $node->hasAttribute('endFilePos')
280 $start .= ':' . $this->toColumn($this->code, $node->getStartFilePos());
281 $end .= ':' . $this->toColumn($this->code, $node->getEndFilePos());