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
Requires
- nikic/php-parser: ^5
Requires (Dev)
- drupal/coder: ^8.3.10
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.