1<?php declare(strict_types=1);
2
3namespace PhpParser;
4
5use PhpParser\Node\Expr;
6
7interface PrettyPrinter {
8    /**
9     * Pretty prints an array of statements.
10     *
11     * @param Node[] $stmts Array of statements
12     *
13     * @return string Pretty printed statements
14     */
15    public function prettyPrint(array $stmts): string;
16
17    /**
18     * Pretty prints an expression.
19     *
20     * @param Expr $node Expression node
21     *
22     * @return string Pretty printed node
23     */
24    public function prettyPrintExpr(Expr $node): string;
25
26    /**
27     * Pretty prints a file of statements (includes the opening <?php tag if it is required).
28     *
29     * @param Node[] $stmts Array of statements
30     *
31     * @return string Pretty printed statements
32     */
33    public function prettyPrintFile(array $stmts): string;
34
35    /**
36     * Perform a format-preserving pretty print of an AST.
37     *
38     * The format preservation is best effort. For some changes to the AST the formatting will not
39     * be preserved (at least not locally).
40     *
41     * In order to use this method a number of prerequisites must be satisfied:
42     *  * The startTokenPos and endTokenPos attributes in the lexer must be enabled.
43     *  * The CloningVisitor must be run on the AST prior to modification.
44     *  * The original tokens must be provided, using the getTokens() method on the lexer.
45     *
46     * @param Node[] $stmts Modified AST with links to original AST
47     * @param Node[] $origStmts Original AST with token offset information
48     * @param Token[] $origTokens Tokens of the original code
49     */
50    public function printFormatPreserving(array $stmts, array $origStmts, array $origTokens): string;
51}
52