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
voidanditerabletypes. These will now be represented as strings (instead ofNameinstances) similar to other builtin types. - [7.1] Added support for class constant visibility. The
ClassConstnode now has aflagssubnode 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
NullableTypenode with a singletypesubnode. - [7.1] Added support for short array destructuring syntax. This means that
Arraynodes may now appear as the left-hand-side of assignments and foreach value targets. Additionally the array items may now containnullvalues if elements are skipped. - [7.1] Added support for keys in list() destructuring. The
Listsubnodevarshas been renamed toitemsand now containsArrayItems instead of plain variables. - [7.1] Added support for multi-catch. The
Catchsubnodetypehas been renamed totypesand is now an array ofNames. 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:
voidanditerabletypes are now stored as strings if the PHP 7 parser is used.- The
ClassConstconstructor changed to accept an additionalflagssubnode. - The
Arraysubnodeitemsmay now containnullelements (destructuring). - The
Listsubnodevarshas been renamed toitemsand now containsArrayItems instead of plain variables. - The
Catchsubnodetypehas been renamed totypesand is now an array ofNames.
Additionally the following changes were made:
- The
typesubnode onClass,ClassMethodandPropertyhas been renamed toflags. Thetypesubnode has retained for backwards compatibility and is populated to the same value asflags. However, writes totypewill not updateflags. - The
TryCatchsubnodefinallyStmtshas been replaced with afinallysubnode that holds an explicitFinallynode. This allows for more accurate attribute assignment. - The
Traitconstructor now has the same form as theClassandInterfaceconstructors: It takes an array of subnodes. Unlike classes/interfaces, traits can only have astmtssubnode. - The
NodeDumpernow 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\Standardare 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.