In most circumstances we are interested in the whole string, not
the parts split by namespace separator. As names are common, this
representation measurably improves memory usage and performance.
In preparation for switching this to a plain string in
PHP-Parser 5, deprecate direct access to the property and
provide an API that will work on both versions.
(cherry picked from commit c9e5a13d68486e9fd75f9be1b4639644e54e7f4f)
Normalize CRLF to LF in getReformattedText(). That was, if the
comment is pretty-printed, we will use proper LF newlines, rather
than inserting indentation between the CR and LF.
At the same time, this also makes it easier to emit actual CRLF
newlines with a custom pretty printer.
Fixes#599.
Node visitation is now properly nested. The call sequence will
now be
$visitor1->enterNode($n);
$visitor2->enterNode($n);
$visitor2->leaveNode($n);
$visitor1->leaveNode($n);
rather than
$visitor1->enterNode($n);
$visitor2->enterNode($n);
$visitor1->leaveNode($n);
$visitor2->leaveNode($n);
Fixes#899.
For types the use of a string is ambiguous -- it could be either
an Identifier or a Name. Don't guess.
Retain the implicit promotion to Identifier in places where only
Identifier is legal, e.g. various symbol names.
By making flags on the Param builder configurable by providing make(Public|Protected|Private) methods we can promote parameters to properties from the constructor
In formatting-preserving pretty printing, treat DEL as a label
character based on the target PHP version (the default of 7.1
implying it isn't one).
This avoids failure to round-trip an unchanged input.
We shouldn't ltrim when printing a whole file, that way we will
not just fail to preserve formatting, but actually change semantics
by dropping meaningful whitespace.
We may need parentheses around an argument-less yield to distinguish
(yield) - $a from yield -$a and similar.
Treat argument-less yield like a prefix operator. This will print
parentheses a bit more often than is really required, because the
arity ambiguity only exists for certain operators. This seems like
a reasonably good approximation through, as it only affects
argument-less yield on the LHS of infix operators.