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\GroupUse
nodes. Furthermore atype
attribute was added toStmt\UseUse
to 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 beName
instances there. - Unicode escape sequences.
- Group use declarations. These are represented using
- Added
PhpParser\ParserFactory
class, 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\Parser
is now an interface, implemented byParser\Php5
,Parser\Php7
andParser\Multiple
. TheMultiple
parser will try multiple parsers, until one succeeds.- Token constants are now defined on
PhpParser\Parser\Tokens
rather thanPhpParser\Parser
. - The
Name->set()
,Name->append()
,Name->prepend()
andName->setFirst()
methods are deprecated in favor ofName::concat()
andName->slice()
. - The
NodeTraverser
no longer clones nodes by default. The old behavior can be restored by passingtrue
to the constructor. - The constructor for
Scalar
nodes no longer has a default value. E.g.new LNumber()
should now be written asnew LNumber(0)
.