Nothing yet.
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)??= operator through a new AssignOp\Coalesce node. (#575)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)function foo() : {}) (#544).DONT_TRAVERSE_CURRENT_AND_CHILDREN to NodeTraverser to skip both traversal of child
nodes, and prevent subsequent visitors from visiting the current node.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().foreach without as.function (Type ) {}).function ($foo)).BuilderFactory, to simplify creation of expressions:
funcCall()methodCall()staticCall()new()constFetch()classConstFetch()Autoloader class has been removed. It is now required to use the Composer autoloader.replaceNodes option to NameResolver, defaulting to true. If this option is disabled,
resolved names will be added as resolvedName attributes, instead of replacing the original
names.NodeFinder class, which can be used to find nodes based on a callback or class name. This
is a utility to avoid custom node visitor implementations for simple search operations.ClassMethod::isMagic() method.BuilderFactory methods: val() method for creating an AST for a simple value, concat()
for creating concatenation trees, args() for preparing function arguments.NameContext class, which encapsulates the NameResolver logic independently of the actual
AST traversal. This facilitates use in other context, such as class names in doc comments.
Additionally it provides an API for getting the shortest representation of a name.Node::setAttributes() method.JsonDecoder. This allows conversion JSON back into an AST.Name methods toLowerString() and isSpecialClassName().Identifier and VarLikeIdentifier nodes, which are used in place of simple strings in
many places.getComments(), getStartLine(), getEndLine(), getStartTokenPos(), getEndTokenPos(),
getStartFilePos() and getEndFilePos() methods to Node. These provide a more obvious access
point for the already existing attributes of the same name.ConstExprEvaluator to evaluate constant expressions to PHP values.Expr\BinaryOp::getOperatorSigil(), returning + for Expr\BinaryOp\Plus, etc.Identifier (or VarLikeIdentifier)
nodes. Please see the UPGRADE-4.0 file for an exhaustive list of affected nodes and some notes on
possible impact.expr;) are now represented using a Stmt\Expression node. Previously
these statements were directly represented as their constituent expression.name subnode of Param has been renamed to var and now contains a Variable rather than
a plain string.name subnode of StaticVar has been renamed to var and now contains a Variable rather
than a plain string.var subnode of ClosureUse now contains a Variable rather than a plain string.var subnode of Catch now contains a Variable rather than a plain string.alias subnode of UseUse is now null if no explicit alias is given. As such,
use Foo\Bar and use Foo\Bar as Bar are now represented differently. The getAlias() method
can be used to get the effective alias, even if it is not explicitly given.type subnode on Class, ClassMethod and Property nodes. Use flags instead.ClassConst::isStatic() method has been removed. Constants cannot have a static modifier.NodeTraverser no longer accepts false as a return value from a leaveNode() method.
NodeTraverser::REMOVE_NODE should be returned instead.Node::setLine() method has been removed. If you really need to, you can use setAttribute()
instead.Class_::VISIBILITY_MODIFER_MASK constant has been dropped in favor of
Class_::VISIBILITY_MODIFIER_MASK.Serializer\XML, and
Unserializer\XML, as well as the interfaces Serializer and Unserializer no longer exist.BuilderAbstract class has been removed. It’s functionality is moved into BuilderHelpers.
However, this is an internal class and should not be used directly.-(-$x) and +(+$x). (#459)NodeAbstract::getType().Stmt\Nop node. (#382)kind attribute for Stmt\Namespace_ node, which is one of KIND_SEMICOLON or
KIND_BRACED. (#417)setDocComment() method to namespace builder. (#437)object type. This means object types will now be represented as a
builtin type (a simple "object" string), rather than a class Name.Name::$parts is no longer deprecated.Class_::VISIBILITY_MODIFIER_MASK. The previous spelling of
Class_::VISIBILITY_MODIFER_MASK is preserved for backwards compatibility.Builder\Param::makeVariadic().Node::setLine() method has been deprecated.NullableTypes is now performed earlier, so that a fully resolved signature is
available when a function is entered. (#360)Error nodes are now considered empty, while previously they extended until the token where the
error occurred. This made some nodes larger than expected. (#359)pUseType() is now public and pPrec() calls
into p(), instead of directly dispatching to the type-specific printing method).bin/php-parse script."$foo[0]" the 0 is now parsed as an LNumber rather than String. (#325)LogicException when trying to pretty-print an Error node. Previously this resulted in
an undefined method exception or fatal error."$foo[-1]"preserveOriginalNames option to NameResolver. If this option is enabled, an
originalName attribute, containing the unresolved name, will be added to each resolved name.php-parse --with-positions option, which dumps nodes with position information.Serializer\XML,
Unserializer\XML, as well as the interfaces Serializer and Unserializer are deprecated.list()s: If the nested list was unkeyed, it was directly included in
the list items. If it was keyed, it was wrapped in ArrayItem. Now nested List_ nodes are
always wrapped in ArrayItems. (#321)dumpPositions option.$, new, Foo::.This release primarily improves our support for error recovery.
Node::setDocComment() method.Error::getMessageWithColumnInfo() method.ErrorHandler interface, and ErrorHandler\Throwing and ErrorHandler\Collecting as
specific implementations. These provide a general mechanism for handling error recovery.ErrorHandler argument to Parser::parse(), Lexer::startLexing() and
NameResolver::__construct().NameResolver now adds a namespacedName attribute on name nodes that cannot be statically
resolved (unqualified unaliased function or constant names in namespaces).GroupUse prefix and variables in interpolated strings.NameTraverserInterface have been moved into the NameTraverser class.Parser interface and Lexer API have changed.~__EMU__~ sequences.
This changes the protected API of the lexer.Name::slice() method now returns null for empty slices, previously new Name([]) was
used. Name::concat() now also supports concatenation with null.Name::append() and Name::prepend(). These mutable methods have been superseded by
the immutable Name::concat().Error::getRawLine() and Error::setRawLine(). These methods have been superseded by
Error::getStartLine() and Error::setStartLine().NodeTraverser.$separator argument from Name::toString().throw_on_error parser option and Parser::getErrors() method. Use the ErrorHandler
mechanism instead.JsonSerializable. The node kind is stored in a nodeType
property.InlineHTML node now has an hasLeadingNewline attribute, that specifies whether the
preceding closing tag contained a newline. The pretty printer honors this attribute.$obj-> (with missing property name) is now supported in error recovery mode.php-parse script through the --with-recovery
or -r flags.The following changes are also part of PHP-Parser 2.1.1:
$var =& new Obj assignments.void and iterable types. These will now be represented as strings
(instead of Name instances) similar to other builtin types.ClassConst node now has a flags subnode
holding the visibility modifier, as well as isPublic(), isProtected() and isPrivate()
methods. The constructor changed to accept the additional subnode.NullableType node
with a single type subnode.Array nodes may now
appear as the left-hand-side of assignments and foreach value targets. Additionally the array
items may now contain null values if elements are skipped.List subnode vars has been renamed
to items and now contains ArrayItems instead of plain variables.Catch subnode type has been renamed to types and
is now an array of Names.Name::slice() now supports lengths and negative offsets. This brings it in line with
array_slice() functionality.Due to PHP 7.1 support additions described above, the node structure changed as follows:
void and iterable types are now stored as strings if the PHP 7 parser is used.ClassConst constructor changed to accept an additional flags subnode.Array subnode items may now contain null elements (destructuring).List subnode vars has been renamed to items and now contains ArrayItems instead of
plain variables.Catch subnode type has been renamed to types and is now an array of Names.Additionally the following changes were made:
type subnode on Class, ClassMethod and Property has been renamed to flags. The
type subnode has retained for backwards compatibility and is populated to the same value as
flags. However, writes to type will not update flags.TryCatch subnode finallyStmts has been replaced with a finally subnode that holds an
explicit Finally node. This allows for more accurate attribute assignment.Trait constructor now has the same form as the Class and Interface constructors: It
takes an array of subnodes. Unlike classes/interfaces, traits can only have a stmts subnode.NodeDumper now prints class/method/property/constant modifiers, as well as the include and
use type in a textual representation, instead of only showing the number.PrettyPrinter\Standard are now protected. Previously most of them were public.Comment::setLine() and Comment::setText() methods have been removed.Name::set(), Name::setFirst() and Name::setLast() methods have been removed.\x00-\x1F inside double
quoted strings. If no special escape sequence is available, an octal escape will be used.$var =& new Obj assignments.B"" strings (with uppercase B) in a number of places.dumpComments option to node dumper, to enable dumping of comments associated with nodes.Stmt\Nop node, that is used to collect comments located at the end of a block or at the
end of a file (without a following node with which they could otherwise be associated).kind attribute to Expr\Exit to distinguish between exit and die.kind attribute to Scalar\LNumber to distinguish between decimal, binary, octal and
hexadecimal numbers.kind attribute to Expr\Array to distinguish between array() and [].kind attribute to Scalar\String and Scalar\Encapsed to distinguish between
single-quoted, double-quoted, heredoc and nowdoc string.docLabel attribute to Scalar\String and Scalar\Encapsed, if it is a heredoc or
nowdoc string.Comment nodes.setReturnType() method to function and method builders.-h and --help options to php-parse script.AbstractPrettyPrinter::pComments() method no longer returns a trailing newline.PhpParser for easier downstream distribution.Comment::setLine() and Comment::setText() methods have been deprecated. Construct new
objects instead.Scalar\LNumber::parse() has been removed. A non-internal
LNumber::fromString() method has been added instead.declare() {} and declare(); are not semantically equivalent and will now result in different
ASTs. The format case will have an empty stmts array, while the latter will set stmts to
null.#!/usr/bin/env php is now allowed at the start of a namespaced file.
Previously this generated an exception.prettyPrintFile() method will not strip a trailing ?> from the raw data that follows a
__halt_compiler() statement.prettyPrintFile() method will not strip an opening <?php if the file starts with a
comment followed by InlineHTML.Scalar\EncapsStringPart nodes.
Previously raw strings were used. This affects the parts child of Scalar\Encaps and
Expr\ShellExec. The change has been done to allow assignment of attributes to encapsed string
parts.php-parse.php to php-parse and registered it as a composer bin.shortArraySyntax option to pretty printer, to print all arrays using short syntax.A more detailed description of backwards incompatible changes can be found in the upgrading guide.
getSubNodeNames() method now.Stmt\GroupUse nodes. Furthermore a type
attribute was added to Stmt\UseUse to handle mixed group use declarations.'bool', 'int', 'float' and 'string'
as the type. The PHP 5 parser also accepts these, however they’ll be Name instances there.PhpParser\ParserFactory class, which should be used to create parser instances.Name::concat() which concatenates two names.Name->slice() which takes a subslice of a name.PhpParser\Parser is now an interface, implemented by Parser\Php5, Parser\Php7 and
Parser\Multiple. The Multiple parser will try multiple parsers, until one succeeds.PhpParser\Parser\Tokens rather than PhpParser\Parser.Name->set(), Name->append(), Name->prepend() and Name->setFirst() methods are
deprecated in favor of Name::concat() and Name->slice().NodeTraverser no longer clones nodes by default. The old behavior can be restored by
passing true to the constructor.Scalar nodes no longer has a default value. E.g. new LNumber() should now
be written as new LNumber(0).This changelog only includes changes from the 2.0 series. For older changes see the 1.x series changelog and the 0.9 series changelog.