NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Packagist · #13 most downloaded on Packagist
A PHP parser written in PHP
Last release 25 days ago
13 Sep 2026
Release timing varies
gaps range from 9 days to 7 months
Most releases are documented
notes for 42 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
15 years old
113 releases · first in 2012
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.One column per quarter.
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.See UPGRADE-5.0 for detailed migration instructions.
See UPGRADE-5.0 for detailed migration instructions.
PropertyItem and UseItem.Fixed deprecation warnings on PHP 8.5.
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
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.
[PHP 8.1] Added support for intersection types using a new IntersectionType node. Additionally a ComplexType parent class for NullableType, UnionType
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 adde 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().Your coding agent can read these notes before it upgrades. Set up the MCP server →