A more detailed description of backwards incompatible changes can be found in the upgrading guide.
Removed
- Removed support for running on PHP 5.4. It is however still possible to parse PHP 5.2 and PHP 5.3 code while running on a newer version.
- Removed legacy class name aliases. This includes the old non-namespaced class names and the old names for classes that were renamed for PHP 7 compatibility.
- Removed support for legacy node format. All nodes must have a
getSubNodeNames()method now.
Added
- Added support for remaining PHP 7 features that were not present in 1.x:
- Group use declarations. These are represented using
Stmt\GroupUsenodes. Furthermore atypeattribute was added toStmt\UseUseto handle mixed group use declarations. - Uniform variable syntax.
- Generalized yield operator.
- Scalar type declarations. These are presented using
'bool','int','float'and'string'as the type. The PHP 5 parser also accepts these, however they'll beNameinstances there. - Unicode escape sequences.
- Group use declarations. These are represented using
- Added
PhpParser\ParserFactoryclass, which should be used to create parser instances. - Added
Name::concat()which concatenates two names. - Added
Name->slice()which takes a subslice of a name.
Changed
PhpParser\Parseris now an interface, implemented byParser\Php5,Parser\Php7andParser\Multiple. TheMultipleparser will try multiple parsers, until one succeeds.- Token constants are now defined on
PhpParser\Parser\Tokensrather thanPhpParser\Parser. - The
Name->set(),Name->append(),Name->prepend()andName->setFirst()methods are deprecated in favor ofName::concat()andName->slice(). - The
NodeTraverserno longer clones nodes by default. The old behavior can be restored by passingtrueto the constructor. - The constructor for
Scalarnodes no longer has a default value. E.g.new LNumber()should now be written asnew LNumber(0).