function PrettyPrinterAbstract::prettyPrintFile
Pretty prints a file of statements (includes the opening <?php tag if it is required).
Parameters
Node[] $stmts Array of statements:
Return value
string Pretty printed statements
Overrides PrettyPrinter::prettyPrintFile
File
-
vendor/
nikic/ php-parser/ lib/ PhpParser/ PrettyPrinterAbstract.php, line 291
Class
Namespace
PhpParserCode
public function prettyPrintFile(array $stmts) : string {
if (!$stmts) {
return "<?php" . $this->newline . $this->newline;
}
$p = "<?php" . $this->newline . $this->newline . $this->prettyPrint($stmts);
if ($stmts[0] instanceof Stmt\InlineHTML) {
$p = preg_replace('/^<\\?php\\s+\\?>\\r?\\n?/', '', $p);
}
if ($stmts[count($stmts) - 1] instanceof Stmt\InlineHTML) {
$p = preg_replace('/<\\?php$/', '', rtrim($p));
}
return $p;
}