10 Commits

Author SHA1 Message Date
Nikita Popov
d8e8065313 Don't parse unicode escapes for PHP < 7.0
We still had the option for this but were hardcoding it to true.
Make it conditional on the PHP version instead.
2023-09-23 17:35:51 +02:00
Nikita Popov
502b090900 Add property types
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.
2023-08-16 21:37:02 +02:00
Nikita Popov
bb4263ea1a Treat del as label character depending on PHP version
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.
2023-03-05 17:03:00 +01:00
Nikita Popov
cb60eda774 Support yield precedence
Since PHP 7.0 yield is a proper expression, so print it with
proper precedence. If the pretty printer is configured for
older version (non-default), then always print parentheses.

There is an interesting interaction here, in that => is resolved
in favor of yield if the yield occurs as part of an array (or
outer yield). This kind of bypasses the entire precedence hierarchy
and *only* affects yield expressions. For the sake of simplicity
this is modeled via normal LHS precedence, because this will only
add unnecessary parentheses to a handful of low precedence unary
operators. If desired, a special marker for this purpose could be
added though.
2023-02-26 22:58:53 +01:00
Anton
9857581ee8 Add array/callable to BUILTIN_TYPE_VERSIONS
Listing these is not strictly necessary, in that array/callable
are keywords, and as such don't use the relevant code path. We
can still include them for the sake of completeness.

Closes #872.
2022-08-29 22:09:29 +02:00
Nikita Popov
68fc1ba4cb Always use List_ node for array destructuring
Fixes #471.
2022-08-28 18:48:26 +02:00
Nikita Popov
652fb0c6c1 Print trailing comma in param list if supported 2022-08-07 16:43:53 +02:00
Nikita Popov
646b490735 Don't force newline after doc string when targeting PHP >= 7.3 2022-07-24 22:15:42 +02:00
Nikita Popov
a73c8ee03b Add a phpVersion option to the pretty printer
This is currently just used to initialize the default for short
array syntax.

The default target version in 7.0, which also means that the
default for short arrays is flipped to on.
2022-07-23 18:23:39 +02:00
Nikita Popov
1e89658cae Add PhpVersion class 2022-07-23 17:52:59 +02:00