chx/drupal-pretty-printer

Drupal pretty printer

Installs: 509

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 1

Open Issues: 0

pkg:composer/chx/drupal-pretty-printer

1.0.1 2025-07-17 10:37 UTC

This package is auto-updated.

Last update: 2025-10-17 11:08:41 UTC


README

This is a drop in replacement for PhpParser\PrettyPrinter\Standard printing Drupal coding style.

Recommended usage:

[$printer, $stmts] = DrupalPrettyPrinter::getPrinterAndParse($code);

This parses the code and returns the printer and the parsed statements. It recognizes PHP 8.2 syntax for parsing or later with the nikic/php-parser v5. The printer is ready for a $printer->printFormatPreserving($stmts) call, unlike with the standard printer, no other arguments are needed.

Of course, a simple

$printer = new DrupalPrettyPrinter();
$printer->prettyPrint($stmts);

also works. The factory method is just a convenience.