github nikic/PHP-Parser v3.0.0alpha1
PHP-Parser 3.0.0 Alpha 1

latest releases: v4.19.1, v4.19.0, v5.0.2...
pre-release7 years ago

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 and iterable types. These will now be represented as strings (instead of Name instances) similar to other builtin types.
  • [7.1] Added support for class constant visibility. The 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.
  • [7.1] Added support for nullable types. These are represented using a new NullableType node with a single type 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 contain null values if elements are skipped.
  • [7.1] Added support for keys in list() destructuring. The List subnode vars has been renamed to items and now contains ArrayItems instead of plain variables.
  • [7.1] Added support for multi-catch. The 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.

Changed

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.
  • The ClassConst constructor changed to accept an additional flags subnode.
  • The Array subnode items may now contain null elements (destructuring).
  • The List subnode vars has been renamed to items and now contains ArrayItems instead of plain variables.
  • The Catch subnode type has been renamed to types and is now an array of Names.

Additionally the following changes were made:

  • The 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.
  • The TryCatch subnode finallyStmts has been replaced with a finally subnode that holds an explicit Finally node. This allows for more accurate attribute assignment.
  • The 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.
  • 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() and Comment::setText() methods have been removed.
  • The deprecated Name::set(), Name::setFirst() and Name::setLast() methods have been removed.

Don't miss a new PHP-Parser release

NewReleases is sending notifications on new releases.