1Upgrading from PHP-Parser 3.x to 4.0 2==================================== 3 4### PHP version requirements 5 6PHP-Parser now requires PHP 7.0 or newer to run. It is however still possible to *parse* PHP 5.2-5.6 7source code, while running on a newer version. 8 9HHVM is no longer actively supported. 10 11### Changes to the node structure 12 13* Many subnodes that previously held simple strings now store `Identifier` nodes instead (or 14 `VarLikeIdentifier` nodes if they have form `$ident`). The constructors of the affected nodes will 15 automatically convert strings to `Identifier`s and `Identifier`s implement `__toString()`. As such 16 some code continues to work without changes, but anything using `is_string()`, type-strict 17 comparisons or strict-mode may require adjustment. The following is an exhaustive list of all 18 affected subnodes: 19 20 * `Const_::$name` 21 * `NullableType::$type` (for simple types) 22 * `Param::$type` (for simple types) 23 * `Expr\ClassConstFetch::$name` 24 * `Expr\Closure::$returnType` (for simple types) 25 * `Expr\MethodCall::$name` 26 * `Expr\PropertyFetch::$name` 27 * `Expr\StaticCall::$name` 28 * `Expr\StaticPropertyFetch::$name` (uses `VarLikeIdentifier`) 29 * `Stmt\Class_::$name` 30 * `Stmt\ClassMethod::$name` 31 * `Stmt\ClassMethod::$returnType` (for simple types) 32 * `Stmt\Function_::$name` 33 * `Stmt\Function_::$returnType` (for simple types) 34 * `Stmt\Goto_::$name` 35 * `Stmt\Interface_::$name` 36 * `Stmt\Label::$name` 37 * `Stmt\PropertyProperty::$name` (uses `VarLikeIdentifier`) 38 * `Stmt\TraitUseAdaptation\Alias::$method` 39 * `Stmt\TraitUseAdaptation\Alias::$newName` 40 * `Stmt\TraitUseAdaptation\Precedence::$method` 41 * `Stmt\Trait_::$name` 42 * `Stmt\UseUse::$alias` 43 44* Expression statements (`expr;`) are now represented using a `Stmt\Expression` node. Previously 45 these statements were directly represented as their constituent expression. 46* The `name` subnode of `Param` has been renamed to `var` and now contains a `Variable` rather than 47 a plain string. 48* The `name` subnode of `StaticVar` has been renamed to `var` and now contains a `Variable` rather 49 than a plain string. 50* The `var` subnode of `ClosureUse` now contains a `Variable` rather than a plain string. 51* The `var` subnode of `Catch_` now contains a `Variable` rather than a plain string. 52* The `alias` subnode of `UseUse` is now `null` if no explicit alias is given. As such, 53 `use Foo\Bar` and `use Foo\Bar as Bar` are now represented differently. The `getAlias()` method 54 can be used to get the effective alias, even if it is not explicitly given. 55 56### Miscellaneous 57 58* The indentation handling in the pretty printer has been changed (this is only relevant if you 59 extend the pretty printer). Previously indentation was automatic, and parts were excluded using 60 `pNoindent()`. Now no-indent is the default and newlines that require indentation should use 61 `$this->nl`. 62 63### Removed functionality 64 65* Removed `type` subnode on `Class_`, `ClassMethod` and `Property` nodes. Use `flags` instead. 66* The `ClassConst::isStatic()` method has been removed. Constants cannot have a static modifier. 67* The `NodeTraverser` no longer accepts `false` as a return value from a `leaveNode()` method. 68 `NodeTraverser::REMOVE_NODE` should be returned instead. 69* The `Node::setLine()` method has been removed. If you really need to, you can use `setAttribute()` 70 instead. 71* The misspelled `Class_::VISIBILITY_MODIFER_MASK` constant has been dropped in favor of 72 `Class_::VISIBILITY_MODIFIER_MASK`. 73* The XML serializer has been removed. As such, the classes `Serializer\XML`, and 74 `Unserializer\XML`, as well as the interfaces `Serializer` and `Unserializer` no longer exist. 75* The `BuilderAbstract` class has been removed. It's functionality is moved into `BuilderHelpers`. 76 However, this is an internal class and should not be used directly. 77* The `Autoloader` class has been removed in favor of relying on the Composer autoloader. 78