History log of /PHP-Parser/lib/PhpParser/PrettyPrinterAbstract.php (Results 26 – 50 of 157)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 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 ...


# e9416a0e 26-Feb-2023 Nikita Popov

Support fixup for dynamic class const name

This is new in PHP 8.3.


# 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.


# 6a88bdb0 26-Feb-2023 Nikita Popov

Support new variables in fixup


# 1eb6b565 26-Feb-2023 Nikita Popov

Properly handle new/instanceof operand restrictions

Fixes #912.


# d24745dd 26-Feb-2023 Nikita Popov

Respect precedence during clone pretty printing

Clone is the prefix operator with the highest operator precedence,
but was not treated as an operator at all.


# b0edd4c4 21-Sep-2022 Nikita Popov

Bail out on PHP tags in removed code

If dropping a node would drop PHP tags, bail out of formatting
preservation. This will lose formatting, but at least produce
legal code.

Bail out on PHP tags in removed code

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.

show more ...


# 4bcdf74b 21-Sep-2022 Nikita Popov

Add support for perserving formatting for static modifier change

Closes GH-891.


# f7b448fa 17-Sep-2022 Nikita Popov

Bail out on list insertion of non-Node

PhpStan correctly detected that this is not supported. We could
add support for it, but for now just make sure it doesn't crash.


# f98341f6 17-Sep-2022 Nikita Popov

Specify more types


# 48f470ea 11-Sep-2022 Nikita Popov

Add missing return types


# 9b5a2c89 11-Sep-2022 Nikita Popov

Use PHPStan level 5


# 8dfce13d 11-Sep-2022 Nikita Popov

Add phpstan baseline


# 44c6a977 04-Sep-2022 Nikita Popov

Fix empty list insertion of multiple attributes


# a7728533 03-Sep-2022 Nikita Popov

Fix formatting preservation for match


# c585a2d7 03-Sep-2022 Nikita Popov

Switch list insertion maps to use class name

Also highlights that the list insertion entry for Expr\Match
was not used.


# 8ed76726 03-Sep-2022 Nikita Popov

Switch modifierChangeMap to use class name

For better refactoring support, prefer class name over node type.


# 5f3ad315 03-Sep-2022 Nikita Popov

Fix ArrayItem entries in pretty printer maps

The tests were written in such a way that the regression was not
caught.


# 4917c71a 03-Sep-2022 Nikita Popov

Rename Stmt\UseUse to UseItem


# e1345f0c 03-Sep-2022 Nikita Popov

Rename Stmt\PropertyProperty to PropertyItem


# a44faa63 03-Sep-2022 Nikita Popov

Rename Scalar\Encapsed to Scalar\InterpolatedString


# f4ec6a1e 03-Sep-2022 Nikita Popov

Rename Scalar\EncapsedStringPart to InterpolatedStringPart

It is no longer an expression node, which unfortunately does
require a more awkward type for the Encaps node.


# a2608f0b 03-Sep-2022 Nikita Popov

Support empty list insertion for attributes


# dd63ddbc 28-Aug-2022 Nikita Popov

Add php-cs-fixer config and reformat

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 st

Add php-cs-fixer config and reformat

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.

show more ...


# f62b2bfd 28-Aug-2022 Nikita Popov

Introduce separate Modifiers class

Use PhpParser\Modifiers::PUBLIC instead of
PhpParser\Node\Stmt\Class_::MODIFIER_PUBLIC, etc. Old constants
of course remain available.

Fix

Introduce separate Modifiers class

Use PhpParser\Modifiers::PUBLIC instead of
PhpParser\Node\Stmt\Class_::MODIFIER_PUBLIC, etc. Old constants
of course remain available.

Fixes #476.

show more ...


1234567