@param Stmt\While_ $node

@return string
773637
public function pStmt_While(Stmt\While_ $node)
    {
        return sprintf(
            "%s (%s) %s%s\n%s",
            $this->color('while', SyntaxHighlighterConfig::TYPE_KEYWORD),
            $this->p($node->cond),
            $this->color('{', SyntaxHighlighterConfig::TYPE_BRACE),
            $this->pStmts($node->stmts),
            $this->color('}', SyntaxHighlighterConfig::TYPE_BRACE)
        );
    }
1372936
public function pStmt_Catch(Stmt\Catch_ $node)
    {
        return sprintf(
            " %s (%s $%s) %s%s\n%s",
            $this->color('catch', SyntaxHighlighterConfig::TYPE_KEYWORD),
            $this->p($node->type),
            $node->var,
            $this->color('{', SyntaxHighlighterConfig::TYPE_BRACE),
            $this->pStmts($node->stmts),
            $this->color('}', SyntaxHighlighterConfig::TYPE_BRACE)
        );
    }
665654
public function enterNode(PhpParser\Node $node, &$traverseChildren = true)
    {
        $attrs = $node->getAttributes();

        if ($cs = $node->getComments()) {
            /** @var int */
            $stmt_start_pos = $cs[0]->getFilePos();
        } else {
            /** @var int */
            $stmt_start_pos = $attrs['startFilePos'];
        }

        /** @var int */
        $stmt_end_pos = $attrs['endFilePos'];

        $start_offset = 0;
        $end_offset = 0;

        $line_offset = 0;

        foreach ($this->offset_map as list($a_s, $a_e, $b_s, $b_e, $line_diff)) {
            if ($a_s > $stmt_end_pos) {
                break;
            }

            $end_offset = $b_e - $a_e;

            if ($a_s < $stmt_start_pos) {
                $start_offset = $b_s - $a_s;
            }

            if ($a_e < $stmt_start_pos) {
                $start_offset = $end_offset;

                $line_offset = $line_diff;

                continue;
            }

            if ($node instanceof PhpParser\Node\Stmt\ClassMethod
                || $node instanceof PhpParser\Node\Stmt\Namespace_
                || $node instanceof PhpParser\Node\Stmt\ClassLike
            ) {
                if ($node instanceof PhpParser\Node\Stmt\ClassMethod) {
                    if ($a_s >= $stmt_start_pos && $a_e <= $stmt_end_pos) {
                        foreach ($this->offset_map as list($a_s2, $a_e2, $b_s2, $b_e2)) {
                            if ($a_s2 > $stmt_end_pos) {
                                break;
                            }

                            // we have a diff that goes outside the bounds that we care about
                            if ($a_e2 > $stmt_end_pos) {
                                $this->must_rescan = true;
                                return PhpParser\NodeTraverser::STOP_TRAVERSAL;
                            }

                            $end_offset = $b_e2 - $a_e2;

                            if ($a_s2 < $stmt_start_pos) {
                                $start_offset = $b_s2 - $a_s2;
                            }

                            if ($a_e2 < $stmt_start_pos) {
                                $start_offset = $end_offset;

                                $line_offset = $line_diff;

                                continue;
                            }

                            if ($a_s2 >= $stmt_start_pos && $a_e2 <= $stmt_end_pos) {
                                $this->non_method_changes--;
                            }
                        }

                        $stmt_start_pos += $start_offset;
                        $stmt_end_pos += $end_offset;

                        $current_line = substr_count(substr($this->b_file_contents, 0, $stmt_start_pos), "\n");

                        $method_contents = substr(
                            $this->b_file_contents,
                            $stmt_start_pos,
                            $stmt_end_pos - $stmt_start_pos + 1
                        );

                        if (!$method_contents) {
                            $this->must_rescan = true;
                            return PhpParser\NodeTraverser::STOP_TRAVERSAL;
                        }

                        $error_handler = new \PhpParser\ErrorHandler\Collecting();

                        $fake_class = "<?php class _ {" . $method_contents . "}";

                        /** @var array<PhpParser\Node\Stmt> */
                        $replacement_stmts = $this->parser->parse(
                            $fake_class,
                            $error_handler
                        ) ?: [];

                        if (!$replacement_stmts
                            || !$replacement_stmts[0] instanceof PhpParser\Node\Stmt\ClassLike
                            || count($replacement_stmts[0]->stmts) !== 1
                        ) {
                            if ($replacement_stmts
                                && $replacement_stmts[0] instanceof PhpParser\Node\Stmt\ClassLike
                                && count($replacement_stmts[0]->stmts) !== 1
                            ) {
                                $this->must_rescan = true;
                                return PhpParser\NodeTraverser::STOP_TRAVERSAL;
                            }

                            $hacky_class_fix = preg_replace('/(\)[\s]*):([\s]*\{)/', '$1 $2', $fake_class);

                            // allows autocompletion
                            $hacky_class_fix = str_replace(["->\n", "::\n"], "~;\n", $hacky_class_fix);

                            /** @var array<PhpParser\Node\Stmt> */
                            $replacement_stmts = $this->parser->parse(
                                $hacky_class_fix,
                                $error_handler
                            ) ?: [];

                            if (!$replacement_stmts
                                || !$replacement_stmts[0] instanceof PhpParser\Node\Stmt\ClassLike
                                || count($replacement_stmts[0]->stmts) > 1
                            ) {
                                $this->must_rescan = true;
                                return PhpParser\NodeTraverser::STOP_TRAVERSAL;
                            }
                        }

                        $replacement_stmts = $replacement_stmts[0]->stmts;

                        $renumbering_traverser = new PhpParser\NodeTraverser;
                        $position_shifter = new \Psalm\Internal\Visitor\OffsetShifterVisitor(
                            $stmt_start_pos - 15,
                            $current_line
                        );
                        $renumbering_traverser->addVisitor($position_shifter);
                        $replacement_stmts = $renumbering_traverser->traverse($replacement_stmts);

                        if ($error_handler->hasErrors()) {
                            foreach ($error_handler->getErrors() as $error) {
                                if ($error->hasColumnInfo()) {
                                    $error_attrs = $error->getAttributes();
                                    /** @psalm-suppress MixedOperand */
                                    $error = new PhpParser\Error(
                                        $error->getRawMessage(),
                                        [
                                            'startFilePos' =>
                                                $stmt_start_pos + $error_attrs['startFilePos'] - 15,
                                            'endFilePos' =>
                                                $stmt_start_pos + $error_attrs['endFilePos'] - 15,
                                            'startLine' =>
                                                $error->getStartLine() + $current_line + $line_offset
                                        ]
                                    );
                                }

                                $this->error_handler->handleError($error);
                            }
                        }

                        $traverseChildren = false;

                        return reset($replacement_stmts);
                    }

                    $this->must_rescan = true;
                    return PhpParser\NodeTraverser::STOP_TRAVERSAL;
                }

                if ($node->stmts) {
                    /** @var int */
                    $stmt_inner_start_pos = $node->stmts[0]->getAttribute('startFilePos');

                    /** @var int */
                    $stmt_inner_end_pos = $node->stmts[count($node->stmts) - 1]->getAttribute('endFilePos');

                    if ($node instanceof PhpParser\Node\Stmt\ClassLike) {
                        /** @psalm-suppress PossiblyFalseOperand */
                        $stmt_inner_start_pos = strrpos(
                            $this->a_file_contents,
                            '{',
                            $stmt_inner_start_pos - $this->a_file_contents_length
                        ) + 1;

                        if ($stmt_inner_end_pos < $this->a_file_contents_length) {
                            $stmt_inner_end_pos = strpos($this->a_file_contents, '}', $stmt_inner_end_pos + 1);
                        }
                    }

                    if ($a_s > $stmt_inner_start_pos && $a_e < $stmt_inner_end_pos) {
                        continue;
                    }
                }
            }

            $this->must_rescan = true;
            return PhpParser\NodeTraverser::STOP_TRAVERSAL;
        }

        if ($start_offset !== 0 || $end_offset !== 0 || $line_offset !== 0) {
            if ($start_offset !== 0) {
                if ($cs) {
                    $new_comments = [];

                    foreach ($cs as $c) {
                        if ($c instanceof PhpParser\Comment\Doc) {
                            $new_comments[] = new PhpParser\Comment\Doc(
                                $c->getText(),
                                $c->getLine() + $line_offset,
                                $c->getFilePos() + $start_offset
                            );
                        } else {
                            $new_comments[] = new PhpParser\Comment(
                                $c->getText(),
                                $c->getLine() + $line_offset,
                                $c->getFilePos() + $start_offset
                            );
                        }
                    }

                    $node->setAttribute('comments', $new_comments);

                    /** @psalm-suppress MixedOperand */
                    $node->setAttribute('startFilePos', $attrs['startFilePos'] + $start_offset);
                } else {
                    /** @psalm-suppress MixedOperand */
                    $node->setAttribute('startFilePos', $stmt_start_pos + $start_offset);
                }
            }

            if ($end_offset !== 0) {
                /** @psalm-suppress MixedOperand */
                $node->setAttribute('endFilePos', $stmt_end_pos + $end_offset);
            }

            if ($line_offset !== 0) {
                /** @psalm-suppress MixedOperand */
                $node->setAttribute('startLine', $attrs['startLine'] + $line_offset);
            }

            return $node;
        }



        return null;
    }
522068
public static function normalize(PyStringNode $node): string
    {
        return rtrim(
            array_reduce($node->getStrings(), function ($carry, $string) {
                return $carry . str_pad(rtrim($string), 80) . "\r\n";
            }),
            "\r\n"
        );
    }
550810
public function pStmt_Case(Stmt\Case_ $node)
    {
        return sprintf(
            "%s:%s",
            (null !== $node->cond ? 'case ' . $this->p($node->cond) : 'default'),
            $this->pStmts($node->stmts)
        );
    }
185292
public function enterNode(Node $node)
    {
        if ($node instanceof Dir) {
            return new FuncCall(new Name('getcwd'), [], $node->getAttributes());
        } elseif ($node instanceof File) {
            return new String_('', $node->getAttributes());
        }
    }
371641
public function pStmt_Switch(Stmt\Switch_ $node)
    {
        return sprintf(
            "%s (%s) %s%s\n%s",
            $this->color('switch', SyntaxHighlighterConfig::TYPE_KEYWORD),
            $this->p($node->cond),
            $this->color('{', SyntaxHighlighterConfig::TYPE_BRACE),
            $this->pStmts($node->cases),
            $this->color('}', SyntaxHighlighterConfig::TYPE_BRACE)
        );
    }
154639
static private function generateRandom($ns, $node) {
    $uuid = self::$m_uuid_field;

    $uuid['time_hi'] = (4 << 12) | (mt_rand(0, 0x1000));
    $uuid['clock_seq_hi'] = (1 << 7) | mt_rand(0, 128);
    $uuid['time_low'] = mt_rand(0, 0xffff) + (mt_rand(0, 0xffff) << 16);
    $uuid['time_mid'] = mt_rand(0, 0xffff);
    $uuid['clock_seq_low'] = mt_rand(0, 255);
    for ($i = 0; $i < 6; $i++)
      $uuid['node'][$i] = mt_rand(0, 255);
    return ($uuid);
  }
624637
public function enterNode(Node $node)
    {
        if ($node instanceof Namespace_) {
            $this->resetContext($node->name);
        }

        $this->recordDoc($node->getAttribute('comments', []));

        return $node;
    }
1010499
public function pStmt_Throw(Stmt\Throw_ $node)
    {
        return sprintf(
            '%s %s;',
            $this->color('throw', SyntaxHighlighterConfig::TYPE_KEYWORD),
            $this->p($node->expr)
        );
    }
385658
private static function getContainingClassFqn(Node $node)
    {
        $classNode = $node->getFirstAncestor(Node\Statement\ClassDeclaration::class);
        if ($classNode === null) {
            return null;
        }
        return (string)$classNode->getNamespacedName();
    }
498232
public function _body($node) {
		$params = '';
		if (isset($node['@attrib'])) {
			$params = $this->resolveAttr($node['@attrib']);
			unset($node['@attrib']);
		}
		$content = array();
		// bypass inner content nodes
		foreach ($node as $el)
			$content[] = $this->template->build($el);
		return '<body'.$params.'>'.implode("\n", $content)."\n".
			$this->render('footer')."\n".'</body>';
	}
844049
protected function pScalar_String(String_ $node): string
    {
        $kind = $node->getAttribute('kind', String_::KIND_SINGLE_QUOTED);
        if ($kind === String_::KIND_DOUBLE_QUOTED && $node->getAttribute('is_regular_pattern')) {
            return '"' . $node->value . '"';
        }

        return parent::pScalar_String($node);
    }
161410
private function getIndex($node) {
    $oidStr = $node->getOID()->__toString();
    if (!isset($this->nodeIndexMap[$oidStr])) {
      $this->nodeIndexMap[$oidStr] = $this->getNextIndex();
    }
    return $this->nodeIndexMap[$oidStr];
  }
538996
public function enterNode(Node $node)
    {
        if ($node instanceof ConstFetch || $node instanceof FuncCall) {
            $node->name = null;
        }

        if ($node instanceof FullyQualified) {
            $this->names[] = $node->toString();
        }

        return $node;
    }
1016841
private function generateTmlTags($node) {
        $buffer = "";
        foreach($node->childNodes as $child) {
            if ($child->nodeType == 3) {                    // text node
                $buffer = $buffer . $child->wholeText;
            } else {
                $buffer = $buffer . $this->generateTmlTags($child);
            }
        }

        $token_context = $this->generateHtmlToken($node);
        $token = $this->adjustName($node);
        $token = $this->contextualize($token, $token_context);

        $value = $this->sanitizeValue($buffer);

        if ($this->isSelfClosingNode($node))
            return '{'.$token.'}';

        if ($this->isShortToken($token, $value))
            return '['.$token.': '.$value.']';

        return '['.$token.']'.$value.'[/'.$token.']';
    }
579422
public static function getName(Node\Stmt\ClassLike $node): string
    {
        if ($node->name === null) {
            return NameInterface::UNKNOWN_NAME;
        }
        return $node->name;
    }