This release adds full compatibility with PHP 7.1. There are no major API changes, however specific details of the node structure have changed for a number of nodes
A description of backwards incompatible changes between version 2.x and 3.0 can be found in the upgrading guide.
Added
- [7.1] Added support for
void
anditerable
types. These will now be represented as strings (instead ofName
instances) similar to other builtin types. - [7.1] Added support for class constant visibility. The
ClassConst
node now has aflags
subnode holding the visibility modifier, as well asisPublic()
,isProtected()
andisPrivate()
methods. The constructor changed to accept the additional subnode. - [7.1] Added support for nullable types. These are represented using a new
NullableType
node with a singletype
subnode. - [7.1] Added support for short array destructuring syntax. This means that
Array
nodes may now appear as the left-hand-side of assignments and foreach value targets. Additionally the array items may now containnull
values if elements are skipped. - [7.1] Added support for keys in list() destructuring. The
List
subnodevars
has been renamed toitems
and now containsArrayItem
s instead of plain variables. - [7.1] Added support for multi-catch. The
Catch
subnodetype
has been renamed totypes
and is now an array ofName
s. Name::slice()
now supports lengths and negative offsets. This brings it in line witharray_slice()
functionality.
Changed
Due to PHP 7.1 support additions described above, the node structure changed as follows:
void
anditerable
types are now stored as strings if the PHP 7 parser is used.- The
ClassConst
constructor changed to accept an additionalflags
subnode. - The
Array
subnodeitems
may now containnull
elements (destructuring). - The
List
subnodevars
has been renamed toitems
and now containsArrayItem
s instead of plain variables. - The
Catch
subnodetype
has been renamed totypes
and is now an array ofName
s.
Additionally the following changes were made:
- The
type
subnode onClass
,ClassMethod
andProperty
has been renamed toflags
. Thetype
subnode has retained for backwards compatibility and is populated to the same value asflags
. However, writes totype
will not updateflags
. - The
TryCatch
subnodefinallyStmts
has been replaced with afinally
subnode that holds an explicitFinally
node. This allows for more accurate attribute assignment. - The
Trait
constructor now has the same form as theClass
andInterface
constructors: It takes an array of subnodes. Unlike classes/interfaces, traits can only have astmts
subnode. - The
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. - All methods on
PrettyPrinter\Standard
are now protected. Previously most of them were public.
Removed
- Removed support for running on PHP 5.4. It is however still possible to parse PHP 5.2-5.4 code while running on a newer version.
- The deprecated
Comment::setLine()
andComment::setText()
methods have been removed. - The deprecated
Name::set()
,Name::setFirst()
andName::setLast()
methods have been removed.