Releases: nikic/PHP-Parser
Releases Β· nikic/PHP-Parser
PHP-Parser 4.16.0
Added
- Added
Name::getParts()
method for forward-compatibility with PHP-Parser 5.
Deprecated
- Deprecated direct access to
Name::$parts
, which will be removed in PHP-Parser 5.
PHP-Parser 5.0.0-alpha3
See UPGRADE-5.0 for detailed migration instructions.
Added
- [PHP 8.3] Added support for typed constants.
- [PHP 8.3] Added support for readonly anonymous classes.
- Added support for
NodeVisitor::REPLACE_WITH_NULL
. - Added support for CRLF newlines in the pretty printer, using the new
newline
option.
Changed
- Use PHP 7.1 as the default target version for the pretty printer.
- Print
else if { }
instead ofelse { if { } }
. - The
leaveNode()
method on visitors is now invoked in reverse order ofenterNode()
. - Moved
NodeTraverser::REMOVE_NODE
etc. toNodeVisitor::REMOVE_NODE
. The old constants are still available for compatibility. - The
Name
subnodeparts
has been replaced byname
, which stores the name as a string rather than an array of parts separated by namespace separators. ThegetParts()
method returns the old representation. - No longer accept strings for types in Node constructors. Instead, either an
Identifier
,Name
orComplexType
must be passed. Comment::getReformattedText()
now normalizes CRLF newlines to LF newlines.
Fixed
- Don't trim leading whitespace in formatting preserving printer.
- Treat DEL as a label character in the formatting preserving printer depending on the targeted PHP version.
- Fix error reporting in emulative lexer without explicitly specified error handler.
- Gracefully handle non-contiguous array indices in the
Differ
.
PHP-Parser 4.15.5
Added
- Added
makePrivate()
,makeProtected()
,makePublic()
andmakeReadonly()
methods toBuilder\Param
to allow the creation of promoted parameters.
PHP-Parser 5.0.0-alpha2
See UPGRADE-5.0 for detailed migration instructions.
Added
- [PHP 8.3] Added support for dynamic class constant fetch.
- Added many additional type annotations. PhpStan is now used.
- Added a fuzzing target for PHP-Fuzzer, which was how a lot of pretty printer bugs were found.
- Added
isPromoted()
,isPublic()
,isProtected()
,isPrivate()
andisReadonly()
methods onParam
. - Added support for class constants in trait builder.
- Added
PrettyPrinter
interface. - Added support for formatting preservation when toggling static modifiers.
- The
php-parse
binary now accepts-
as the file name, in which case it will read from stdin.
Fixed
- The pretty printer now uses a more accurate treatment of unary operator precedence, and will only wrap them in parentheses if required. This allowed fixing a number of other precedence related bugs.
- The pretty printer now respects the precedence of
clone
,throw
and arrow functions. - The pretty printer no longer unconditionally wraps
yield
in parentheses, unless the target version is set to older than PHP 7.0. - Fixed formatting preservation for alternative elseif/else syntax.
- Fixed checks for when it is safe to print strings as heredoc/nowdoc to accommodate flexible doc string semantics.
- The pretty printer now prints parentheses around new/instanceof operands in all required situations.
- Similar, differences in allowed expressions on the LHS of
->
and::
are now taken into account. - Fixed various cases where
\r
at the end of a doc string could be incorrectly merged into a CRLF sequence with a following\n
. __halt_compiler
is no longer recognized as a semi-reserved keyword, in line with PHP behavior.<?=
is no longer recognized as a semi-reserved keyword.- Fix handling of very large overflowing
\u
escape sequences.
Removed
- Removed deprecated
Error
constructor taking a line number instead of an attributes array.
PHP-Parser 4.15.4
Fixed
- Fixed formatting-preservation for alternative if syntax with trailing comments.
PHP-Parser 4.15.3
Fixed
- Support readonly property with PHP 8.2 DNF type.
- Fixed PHP attribute group and PHP-Parser attribute mixup in EnumCase builder.
PHP-Parser 4.15.2
Fixed
- Fixed parsing of large hex float literals that contain an "e" character.
- Fixed tests to pass on 32-bit.
- Fixed generation of invalid code when using formatting-preserving pretty printer with code that uses inline HTML.
PHP-Parser 5.0.0-alpha1
See UPGRADE-5.0 for detailed migration instructions.
Changed
- PHP 7.1 is now required to run PHP-Parser.
- Formatting of the standard pretty printer has been adjusted to match PSR-12 more closely.
- The internal token representation now uses a
PhpParser\Token
class, which is compatible with PHP 8 token representation (PhpToken
). - Destructuring is now always represented using
Expr\List_
nodes, even if it uses[]
syntax. - Renamed a number of node classes, and moved things that were not real expressions/statements outside the
Expr
/Stmt
hierarchy. Compatibility shims for the old names have been retained.
Added
- Added
PhpVersion
class, which is accepted in a number of places (e.g. ParserFactory, Parser, Lexer, PrettyPrinter) and gives more precise control over the PHP version being targeted. - Added PHP 8 parser though it only differs from the PHP 7 parser in concatenation precedence.
- Added
Parser::getLexer()
method. - Added a
Modifiers
class, as a replacement forStmt\Class_::MODIFIER_*
. - Added support for returning an array or
REMOVE_NODE
fromNodeVisitor::enterNode()
.
Removed
- The PHP 5 parser has been removed. The PHP 7 parser has been adjusted to deal with PHP 5 code more gracefully.
PHP-Parser 4.15.1
Fixed
- Fixed formatting preservation when adding multiple attributes to a class/method/etc that previously had none. This fixes a regression in the 4.15.0 release.
PHP-Parser 4.15.0
Added
- PHP 8.2: Added support for
true
type. - PHP 8.2: Added support for DNF types.
Fixed
- Support
readonly
as a function name. - Added
__serialize
and__unserialize
to magic method list. - Fixed bounds check in
Name::slice()
. - Fixed formatting preservation when adding attributes to a class/method/etc that previously had none.