Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. PrettyPrinterAbstract.php

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

PrettyPrinterAbstract

Namespace

PhpParser

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal