Add a new "indent" option for the pretty printer, which can be
use to control the indentation width, or switch it to use tabs.
Tab width is currenlty hardcoded to 4, but also shouldn't matter
much.
Possibly the formatting-preserving printer should auto-detect
the indentation in the future.
Stmt\Block will be created for { $a; } style blocks, unless these
occur directly inside some structure that is usually combined
with a block.
For example if ($a) { $b; } will continue to use the old
representation (plain array in in If_::$stmts), but a free-standing
{ $b; } will become a Stmt\Block.
Fixes#590.
I did this to start with, but then alignment kept being broken
during refactorings, and at some point I switched to not aligning,
and now we have a big mess.
Add a php-cs-fixer rule to consistently not align phpdoc tags.
Types omitted in two places where we violate them currently:
Namespace_::$stmts can be null during parsing, and Enum_::$scalarType
can be a complex type for invalid programs.
If dropping a node would drop PHP tags, bail out of formatting
preservation. This will lose formatting, but at least produce
legal code.
Closes GH-884.
The formatting in this project has become something of a mess,
because it changed over time. Add a CS fixer config and reformat
to the desired style, which is PSR-12, but with sane brace placement.
Instead of checking whether there is a {/} before/after the removed
note, check whether {/} occurs in the between-node range. Dropping
that is what we're really concerned about here.
This is a huge hack... We temporarily create a new node with the
correct structure and use that for printing.
I think it would be better to always use a separate node type for
NewAnonClass, rather than using a combination of New and Class,
but this would require some larger changes, as this node type would
have to be both Expr and ClassLike, which is not possible right now,
as the latter is a class rather than an interface...