NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Packagist, #18 most downloaded on Packagist
A PHP parser written in PHP
Latest stable
v5.9.0
Last release 2 months ago
13 Sep 2026
Release timing varies
gaps range from 9 days to 7 months
Nearly every release is documented
notes for 60 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
15 years old
113 releases · first in 2012
Drag across the ruler to compare, or tap a release to open it.
Fix attribute insertion on enums and enum cases in formatting-preserving pretty printer.
\u{10FFFF}. Previously the limit was \u{1FFFFF}.(void) cast emulation.ArgPlaceholder nodes.Treat _ as label character in formatting-preserving pretty printer.
_ as label character in formatting-preserving pretty printer.void parameter types now generate a (recoverable) error during parsing.fn keywords when targeting PHP before 7.4.Your coding agent can read these notes before it upgrades. Set up the MCP server →
Fix PHP 8.5 deprecation warning in php-parse binary.
shouldPrintRawValue attribute to Scalar\Int_, which makes the pretty printer use the rawValue of the node. This can be used to print integers with separators.Fixed chr() deprecation warning on PHP 8.5.
chr() deprecation warning on PHP 8.5.Param::isFinal() method.Fixed PHP 8.5 deprecation warnings for SplObjectStorage methods.
Param::isPublic() for parameters with asymmetric visibility keyword.SplObjectStorage methods.kind attributes to Cast\Int_, Cast\Bool_ and Cast\String_. These allow distinguishing the deprecated versions of these casts.[8.5] Added support for clone with arbitrary function arguments. This will be parsed as an Expr\FuncCall node, instead of the usual Expr\Clone_ node.
clone with arbitrary function arguments. This will be parsed as an Expr\FuncCall node, instead of the usual Expr\Clone_ node.function clone for use in stubs.Expr\BinaryOp\Pipe.(void) cast, represented by Expr\Cast\Void_.final modifier on promoted properties.CallLike::getArg() to fetch an argument by position and name.[8.5] Added support for attributes on constants. Stmt\Const_ now has an attrGroups subnode.
Stmt\Const_ now has an attrGroups subnode.weakReferences option to NodeConnectingVisitor and ParentConnectingVisitor. This will create the parent/next/prev references as WeakReferences, to avoid making the AST cyclic and thus increasing GC pressure.Added Property::isAbstract() and Property::isFinal() methods.
Property::isAbstract() and Property::isFinal() methods.PropertyHook::isFinal() method.Param::isPromoted() and Param::isPublic() now returns true for parameters that have property hooks but no explicit visibility modifier.PropertyHook::getStmts() now correctly desugars short set hooks. set => $value will be expanded to set { $this->propertyName = $value; }. This requires the propertyName attribute on the hook to be set, which is now also set by the parser. If the attribute is not set, getStmts() will throw an error for short set hooks, as it is not possible to produce a correct desugaring.Added support for declaring functions with name exit or die , to allow their use in stubs.
exit or die, to allow their use in stubs.Added indent option to pretty printer, which can be used to specify the indentation to use (defaulting to four spaces). This also allows using tab ind
indent option to pretty printer, which can be used to specify the indentation to use (defaulting to four spaces). This also allows using tab indentation.PropertyHooks in the NameResolver.Stmt\GroupUse nodes, making them consistent with Stmt\Use_ nodes.ValueErrors.[8.4] Added support for __PROPERTY__ magic constant, represented using a Node\Scalar\MagicConst\Property node.
__PROPERTY__ magic constant, represented using a Node\Scalar\MagicConst\Property node.hooks subnode on Node\Stmt\Property and Node\Param, which contains an array of Node\PropertyHook.flags can now hold the additional bits Modifiers::PUBLIC_SET, Modifiers::PROTECTED_SET and Modifiers::PRIVATE_SET.Node\Expr\Exit_ node. Otherwise (e.g. if a named argument is used) it will be represented as a plain Node\Expr\FuncCall.BuilderFactory::val().$array{0} from the PHP 8 parser. It is still supported by the PHP 7 parser. This is necessary in order to support property hooks.[8.4] Added support for dereferencing new expressions without parentheses.
new expressions without parentheses.Fix handling of indentation on next line after opening PHP tag in formatting-preserving pretty printer.
Parser objects. This means that no longer used parser objects are immediately destroyed now, instead of requiring cycle GC.PhpVersion::getNewestSupported() to report PHP 8.3 instead of PHP 8.2.Added check to detect use of PHP-Parser with libraries that define T_* compatibility tokens with incorrect type (such as string instead of int). This
T_* compatibility tokens with incorrect type (such as string instead of int). This would lead to TypeErrors down the line. Now an Error will be thrown early to indicate the problem.Removed deprecated Error constructor taking a line number instead of an attributes array.
See the upgrading guide for detailed migration instructions. The changelog is relative to PHP-Parser 4.18.0.
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.Parser::getTokens() method.Modifiers class, as a replacement for Stmt\Class_::MODIFIER_*.REMOVE_NODE from NodeVisitor::enterNode().isPromoted(), isPublic(), isProtected(), isPrivate() and isReadonly() methods on Param.PrettyPrinter interface.php-parse binary now accepts - as the file name, in which case it will read from stdin.NodeVisitor::REPLACE_WITH_NULL.newline option.NodeTraverser constructor. A separate call to addVisitor() is no longer required.kind) in NodeDumper.rawValue attribute to InterpolatedStringPart and heredoc/nowdoc String_s, which provides the original, unparsed value. It was previously only available for non-interpolated single/double quoted strings.Stmt\Block to represent {} code blocks. Previously, such code blocks were flattened into the parent statements array. Stmt\Block will not be created for structures that are typically used with code blocks, for example if ($x) { $y; } will be represented as previously, while if ($x) { { $x; } } will have an extra Stmt\Block wrapper.PhpParser\Token class, which is compatible with PHP 8 token representation (PhpToken).Expr\List_ nodes, even if it uses [] syntax.Expr/Stmt hierarchy. Compatibility shims for the old names have been retained.yield in parentheses, unless the target version is set to older than PHP 7.0.else if { } instead of else { if { } }.leaveNode() method on visitors is now invoked in reverse order of enterNode().NodeTraverser::REMOVE_NODE etc. to NodeVisitor::REMOVE_NODE. The old constants are still available for compatibility.Name subnode parts has been replaced by name, which stores the name as a string rather than an array of parts separated by namespace separators. The getParts() method returns the old representation.Identifier, Name or ComplexType must be passed.Comment::getReformattedText() now normalizes CRLF newlines to LF newlines.Lexer no longer accepts options. Lexer\Emulative only accepts a PhpVersion. The startLexing(), getTokens() and handleHaltCompiler() methods have been removed. Instead, there is a single method tokenize() returning the tokens.Error constructor taking a line number instead of an attributes array.Comment::getLine(), Comment::getTokenPos() and Comment::getFilePos() methods have been removed. Use Comment::getStartLine(), Comment::getStartTokenPos() and Comment::getStartFilePos() instead.Stmt\Throw_ node, use Expr\Throw_ inside Stmt\Expression instead.ParserFactory::create().clone, throw and arrow functions.\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.\u escape sequences.Differ.Node::getLine() method has been deprecated. Use Node::getStartLine() instead.See UPGRADE-5.0 for detailed migration instructions.
PropertyItem and UseItem.Fixed deprecation warnings on PHP 8.5.
Remove the Parser\Php8 class from PHP-Parser 5.x that was mistakenly added. It could cause errors when using something like composer preload.
Parser\Php8 class from PHP-Parser 5.x that was mistakenly added. It could cause errors when using something like composer preload.Include the trailing semicolon inside Stmt\GroupUse nodes, making them consistent with Stmt\Use_ nodes.
Stmt\GroupUse nodes, making them consistent with Stmt\Use_ nodes.ValueErrors.Added support for passing enum values to various builder methods, like BuilderFactory::val().
BuilderFactory::val().Fixed "Optional parameter before required parameter" deprecation warning introduced in previous version.
Do not use implicitly nullable parameters, which are deprecated in PHP 8.4.
Added methods ParserFactory::createForNewestSupportedVersion() and ParserFactory::createForHostVersion() for forward-compatibility with PHP-Parser 5.0
ParserFactory::createForNewestSupportedVersion() and ParserFactory::createForHostVersion() for forward-compatibility with PHP-Parser 5.0.grammar/ directory has been excluded from exported git archives.Fixed phpdoc mismatches for ClassConst::$type introduced in previous release.
ClassConst::$type introduced in previous release.[PHP 8.3] Added support for typed class constants.
(CONST)::$x and similar.Deprecated direct access to Name::$parts, which will be removed in PHP-Parser 5.
Name::getParts() method for forward-compatibility with PHP-Parser 5.Name::$parts, which will be removed in PHP-Parser 5.Added makePrivate(), makeProtected(), makePublic() and makeReadonly() methods to Builder\Param to allow the creation of promoted parameters.
makePrivate(), makeProtected(), makePublic() and makeReadonly() methods to Builder\Param to allow the creation of promoted parameters.Fixed formatting-preservation for alternative if syntax with trailing comments.
Support readonly property with PHP 8.2 DNF type.
Fixed parsing of large hex float literals that contain an "e" character.
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
PHP 8.2: Added support for true type.
true type.readonly as a function name.__serialize and __unserialize to magic method list.Name::slice().Added support for readonly classes.
rawValue attribute to LNumber, DNumber and String_ nodes, which stores the unparsed value of the literal (e.g. "1_000" rather than 1000).The namespacedName property populated by the NameResolver is now declared on relevant nodes, to avoid a dynamic property deprecation warning with PHP…
namespacedName property populated by the NameResolver is now declared on relevant nodes,
to avoid a dynamic property deprecation warning with PHP 8.2.Support reserved keywords as enum cases.
This release features full PHP 8.1 support.
This release features full PHP 8.1 support.
IntersectionType node. Additionally a ComplexType parent class for NullableType, UnionType and IntersectionType has been added.VariadicPlaceholder. The representation is intended to be forward-compatible with partial function application, just like the PHP feature itself. Call nodes now extend from Expr\CallLike, which provides an isFirstClassCallable() method to determine whether a placeholder id present. getArgs() can be used to assert that the call is not a first-class callable and returns Arg[] rather than array<Arg|VariadicPlaceholder>.public readonly for promoted properties.[PHP 8.1] Added support for readonly properties (through a new MODIFIER_READONLY).
MODIFIER_READONLY).& tokens are now canonicalized to the T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG and T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG tokens used in PHP 8.1. This happens unconditionally, regardless of whether the emulative lexer is used.BuilderFactory::args() now accepts named arguments.
BuilderFactory::args() now accepts named arguments.BuilderFactory::attribute() has been added.addAttribute() method accepting an Attribute or AttributeGroup has been added to all builders that accept attributes, such as Builder\Class_.NameResolver now handles enums.PrettyPrinter now prints backing enum type.never type.[PHP 8.1] Added support for enums. These are represented using the Stmt\Enum_ and Stmt\EnumCase nodes.
Stmt\Enum_ and Stmt\EnumCase nodes.Identifier rather than Name.ClassConst builder.Fixed position information for variable-variables (#741).
Fixed formatting-preserving pretty printing for "{$x}".
"{$x}".error_clear_last() call in lexer, which may interfere with fatal error handlers if invoked during shutdown.Fixed check for token emulation conflicts with other libraries.
Added support for recovering from a missing semicolon after a property or class constant declaration.
[PHP 8.0] Added support for attributes. These are represented using a new AttributeGroup node containing Attribute nodes. A new attrGroups subnode is
AttributeGroup node containing Attribute nodes. A new attrGroups subnode is available on all node types that support attributes, i.e. Stmt\Class_, Stmt\Trait_, Stmt\Interface_, Stmt\Function_, Stmt\ClassMethod, Stmt\ClassConst, Stmt\Property, Expr\Closure, Expr\ArrowFunction and Param.Added support for removing the first element of a list to the formatting-preserving pretty printer.
[PHP 8.0] Added support for named arguments, represented using a new name subnode on Arg.
name subnode on Arg.Expr\Throw_ node. For backwards compatibility reasons, throw expressions in statement context continue to be represented using Stmt\Throw_.[PHP 8.0] Added support for nullsafe operator, represented using the new Expr\NullsafePropertyFetch and Expr\NullsafeMethodCall nodes.
Expr\NullsafePropertyFetch and Expr\NullsafeMethodCall nodes.phpVersion option to the emulative lexer, which allows controlling the target version to emulate (defaults to the latest available, currently PHP 8.0). This is useful to parse code that uses reserved keywords from newer PHP versions as identifiers.Add ParentConnectingVisitor and NodeConnectingVisitor classes.
ParentConnectingVisitor and NodeConnectingVisitor classes.Expr\Match_ containing MatchArms.T_NAME_* tokens, using emulationg on older PHP versions. Full support for reserved keywords in namespaced names is not yet present.[PHP 8.0] Added support for trailing commas in parameter lists.
Node\Param::$flags.[PHP 8.0] Added support for the mixed type. This means mixed types are now parsed as an Identifier rather than a Name.
mixed types are now parsed as an Identifier rather than a Name.Catch_::$var may now be null.Added support for passing union types in builders.
getProperty() method to ClassLike nodes.getDocComment() no longer requires that the very last comment before a node be a doc comment. There may not be non-doc comments between the doc comment and the declaration.isset() and list(), rather than just variables. In particular, this allows isset(($x)), which is legal PHP code.[PHP 8.0] Added support for union types using a new UnionType node.
UnionType node.Tests and documentation are no longer included in source archives. They can still be accessed by cloning the repository.
Added getProperties(), getConstants() and getTraitUses() to ClassLike. (#629, #630)
[PHP 7.4] Add support for numeric literal separators.
[PHP 7.4] Add support for arrow functions using a new Expr\ArrowFunction node.
Expr\ArrowFunction node. (#602)unpack subnode on ArrayItem. (#609)php-parse will now print messages to stderr, so that stdout only contains the actual result of the operation (such as a JSON dump). (#605)[PHP 7.4] Add support for ??= operator through a new AssignOp\Coalesce node.
??= operator through a new AssignOp\Coalesce node. (#575)[PHP 7.4] Add support for typed properties through a new type subnode of Stmt\Property. Additionally Builder\Property now has a setType() method.
type subnode of Stmt\Property. Additionally Builder\Property now has a setType() method. (#567)kind attribute to Cast\Double_, which allows to distinguish between (float), (double) and (real). The form of the cast will be preserved by the pretty printer. (#565)Fix "undefined offset" notice when parsing specific malformed code (#551).
function foo() : {}) (#544).Added support for PHP 7.3 flexible heredoc/nowdoc strings, completing support for PHP 7.3. There are two caveats for this feature:
DONT_TRAVERSE_CURRENT_AND_CHILDREN to NodeTraverser to skip both traversal of child nodes, and prevent subsequent visitors from visiting the current node.Builder\Param::setTypeHint() has been deprecated in favor of the newly introduced Builder\Param::setType().
BuilderFactory:
useTrait() (fluent builder)traitUseAdaptation() (fluent builder)useFunction() (fluent builder)useConst() (fluent builder)var()propertyFetch()Builder\Param::setTypeHint() has been deprecated in favor of the newly introduced Builder\Param::setType().One column per quarter.