History log of /PHP-Parser/lib/PhpParser/PrettyPrinterAbstract.php (Results 1 – 25 of 157)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 961f158f 29-Sep-2024 Nikita Popov

Avoid negative indendation in formatting-preserving printer

Fixes #1015.


# e50c67b7 21-Sep-2024 Nikita Popov

Add basic support for tab indentation

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

Add basic support for tab indentation

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.

show more ...


# b493c51c 31-Aug-2024 Nikita Popov

[8.4] Add support for asymmetric visibility modifiers

Represented using new PRIVATE_SET, PROTECTED_SET and PUBLIC_SET
bits in Modifiers.

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

[8.4] Add support for asymmetric visibility modifiers

Represented using new PRIVATE_SET, PROTECTED_SET and PUBLIC_SET
bits in Modifiers.

RFC: https://wiki.php.net/rfc/asymmetric-visibility-v2

show more ...


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


# a894652a 01-Jul-2024 Nikita Popov

Fix ternary precedence printing

The precedence table set the LHS and RHS precedence for the
ternary to -1, which is the dummy value used for unary operators.
Instead, it should be th

Fix ternary precedence printing

The precedence table set the LHS and RHS precedence for the
ternary to -1, which is the dummy value used for unary operators.
Instead, it should be the same as the operator precedence, as
the ternary is non-associative since PHP 8.

Fixes #1009.

show more ...


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


# 2d3dd4e2 17-Sep-2023 Nikita Popov

Don't align phpdoc tags

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.

Don't align phpdoc tags

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.

show more ...


# 8d583801 27-Aug-2023 Nikita Popov

Default pretty printer to PHP 7.4


# ea778075 17-Aug-2023 Nikita Popov

Add more property types

Some of these are not maximally accurate due to lack of union
types.


# 502b0909 16-Aug-2023 Nikita Popov

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 invali

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.

show more ...


# d43edfbb 21-May-2023 Nikita Popov

Support CRLF newlines in pretty printer

Can be enabled using the "newlines" option.


# 74caed64 20-May-2023 Nikita Popov

Fix labelCharMap for DEL character

This map is supposed to have string keys, not integer keys.


# 91da1914 20-May-2023 Nikita Popov

Support readonly anonymous classes


# 5c267f55 20-May-2023 Nikita Popov

Add support for typed constants

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


# bb4263ea 05-Mar-2023 Nikita Popov

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
imp

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.

show more ...


# 4ce0de2d 05-Mar-2023 Nikita Popov

Use PHP 7.1 as default pretty printer target


# a3bc900a 05-Mar-2023 Nikita Popov

Don't ltrim when preserving formatting

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

Don't ltrim when preserving formatting

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.

show more ...


# 64484a49 04-Mar-2023 Anthony Ferrara

Add PrettyPrinter interface

Closes #423.


# a0ed229b 04-Mar-2023 Nikita Popov

Revert "Rename PrettyPrinterAbstract to PrettyPrinter"

This reverts commit 2217f14d6e039f1c0572329e6fcc99f6c17178a3.


# 2217f14d 01-Mar-2023 Nikita Popov

Rename PrettyPrinterAbstract to PrettyPrinter


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


# cc34c245 27-Feb-2023 Nikita Popov

Fix logic for new operand parentheses requirement

We need to perform this check recursively.


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


1234567