annotate vendor/nikic/php-parser/UPGRADE-4.0.md @ 5:12f9dff5fda9 tip

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