History log of /PHP-Parser/lib/PhpParser/PrettyPrinter/Standard.php (Results 1 – 25 of 160)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 03caf4cc 14-Jul-2024 Nikita Popov

[8.4] Add support for property hooks

Add hooks subnode to Stmt\Property and Param, which contains an
array of PropertyHook.

The property hook support is considered experimental

[8.4] Add support for property hooks

Add hooks subnode to Stmt\Property and Param, which contains an
array of PropertyHook.

The property hook support is considered experimental and subject
to change.

RFC: https://wiki.php.net/rfc/property-hooks

show more ...


# d8235a27 14-Jul-2024 Nikita Popov

[8.4] Add support for __PROPERTY__ magic constant

Part of property hooks RFC.


# b4183c2b 25-Sep-2023 Nikita Popov

Remove Stmt\Throw

This was a backwards-compatibility shim for Expr\Throw.


# a1ccf577 24-Sep-2023 Nikita Popov

Introduce Stmt\Block

Stmt\Block will be created for { $a; } style blocks, unless these
occur directly inside some structure that is usually combined
with a block.

For exampl

Introduce Stmt\Block

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.

show more ...


# ab51e9d3 17-Sep-2023 Nikita Popov

Remove superfluous phpdoc tags

These just specify a type that is already specified as a real PHP
type.


# e395f042 17-Sep-2023 Nikita Popov

Add php-cs-fixer CI job


# 5da5231f 27-Aug-2023 Nikita Popov

Indent heredoc/nowdoc when targeting PHP >= 7.3


# 23647573 21-May-2023 Nikita Popov

Represent names using string rather than array of parts

In most circumstances we are interested in the whole string, not
the parts split by namespace separator. As names are common, this

Represent names using string rather than array of parts

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.

show more ...


# d43edfbb 21-May-2023 Nikita Popov

Support CRLF newlines in pretty printer

Can be enabled using the "newlines" option.


# 5c267f55 20-May-2023 Nikita Popov

Add support for typed constants

RFC: https://wiki.php.net/rfc/typed_class_constants


# 779b6950 20-May-2023 Nikita Popov

Fix coding style


# aa721520 05-Mar-2023 Nikita Popov

Don't generate braces for "else if"

Mentioned in #915.


# a0ed229b 04-Mar-2023 Nikita Popov

Revert "Rename PrettyPrinterAbstract to PrettyPrinter"

This reverts commit 2217f14d6e039f1c0572329e6fcc99f6c17178a3.


# 698ff1ca 04-Mar-2023 Nikita Popov

Don't always omit parentheses for argument-less yield

We may need parentheses around an argument-less yield to distinguish
(yield) - $a from yield -$a and similar.

Treat argumen

Don't always omit parentheses for argument-less yield

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.

show more ...


# b3158e0b 04-Mar-2023 Nikita Popov

Respect namespace style for enum scalar type printing

Doesn't matter in any practical sense because such types are always
invalid, but makes sure pretty printing round-trips.


# 2217f14d 01-Mar-2023 Nikita Popov

Rename PrettyPrinterAbstract to PrettyPrinter


# 57d4a026 27-Feb-2023 Nikita Popov

Handle isolated \r in doc string

Doc strings have a trailing \n and these will get interpreted as
\r\n and removed from the string contents.

For nowdoc, fall back to single quot

Handle isolated \r in doc string

Doc strings have a trailing \n and these will get interpreted as
\r\n and removed from the string contents.

For nowdoc, fall back to single quote if there's a trailing \r.
For heredoc, escape all isolated \r -- unlike \n and \r\n this is
really a special character, because this is no longer relevant as
an actual newline character.

show more ...


# 8e100f1e 27-Feb-2023 Nikita Popov

Handle another yield edge case

match also uses =>, so we need to make sure that a trailing yield
is wrapped in parentheses.


# fcd5934d 27-Feb-2023 Nikita Popov

Prevent merging of consecutive -/+ more thoroughly

The unary -/+ or --/++ might not be the direct child. Instead
determine this by actually printing the operand and checking
whether

Prevent merging of consecutive -/+ more thoroughly

The unary -/+ or --/++ might not be the direct child. Instead
determine this by actually printing the operand and checking
whether it starts with -/+.

show more ...


# cb60eda7 26-Feb-2023 Nikita Popov

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 alw

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.

show more ...


# 1cb460ae 26-Feb-2023 Nikita Popov

Handle throw precedence

Now that this is an expression, we also need to handle precedence.


# 3bd38c5b 25-Feb-2023 Nikita Popov

Properly support prefix operator precedence printing

The pretty printer is supposed to produce a minimal-parentheses
printing for expressions. However, for prefix operators, we were

Properly support prefix operator precedence printing

The pretty printer is supposed to produce a minimal-parentheses
printing for expressions. However, for prefix operators, we were
failing to do so in ways that are practically meaningful, e.g.
$a = yield from $b produced redundant parentheses around the
yield from.

For prefix operators, the precedence of the direct parent operator
is not actually relevant: What matters is the precedence of any
infix operator whose LHS it appears on. For example, $a . include $b
does not require parentheses, but (include $a) . $b does.

To handle this, keep separate track of the parent operator
precedence, and a special LHS precedence which is used for unary
operator printing only. Because the LHS precedence may not come
from the direct parent, we have to pass it down the call stack.
And if we do that, we may as well do the same for the parent
precedence.

This also fixes an integration test failure with php-src, because
arrow function precedence was previously not respected (and would
be ugly to respect without this change).

show more ...


# 7b4a8c1e 26-Feb-2023 Nikita Popov

Properly handle static deref LHS

The rules for static and array/object deref are slightly different:
The former does not allow constants.


# 9476cff3 26-Feb-2023 Nikita Popov

Doc string end label may have leading whitespace

When detecting whether the string contains the end label, allow
leading whitespace in front of it. This is legal since the
introducti

Doc string end label may have leading whitespace

When detecting whether the string contains the end label, allow
leading whitespace in front of it. This is legal since the
introduction of flexible doc strings.

show more ...


# 1eb6b565 26-Feb-2023 Nikita Popov

Properly handle new/instanceof operand restrictions

Fixes #912.


1234567