|
1 | 1 | Upgrading from PHP-Parser 2.x to 3.0
|
2 | 2 | ====================================
|
3 | 3 |
|
4 |
| -Nothing yet. |
| 4 | +This version does not include any major API changes. Only specific details of the node |
| 5 | +representation have changed in some cases. |
| 6 | + |
| 7 | +### PHP version requirements |
| 8 | + |
| 9 | +PHP-Parser now requires PHP 5.5 or newer to run. It is however still possible to *parse* PHP 5.2, |
| 10 | +5.3 and 5.4 source code, while running on a newer version. |
| 11 | + |
| 12 | +### Changes to the node structure |
| 13 | + |
| 14 | +The following changes are likely to require code changes if the respective nodes are used: |
| 15 | + |
| 16 | + * The `List` subnode `vars` has been renamed to `items` and now contains `ArrayItem`s instead of |
| 17 | + plain variables. |
| 18 | + * The `Catch` subnode `type` has been renamed to `types` and is now an array of `Name`s. |
| 19 | + * The `TryCatch` subnode `finallyStmts` has been replaced with a `finally` subnode that holds an |
| 20 | + explicit `Finally` node. |
| 21 | + * The `type` subnode on `Class`, `ClassMethod` and `Property` has been renamed to `flags`. The |
| 22 | + `type` subnode has retained for backwards compatibility and is populated to the same value as |
| 23 | + `flags`. However, writes to `type` will not update `flags` and use of `type` is discouraged. |
| 24 | + |
| 25 | +The following changes are unlikely to require code changes: |
| 26 | + |
| 27 | + * The `ClassConst` constructor changed to accept an additional `flags` subnode. |
| 28 | + * The `Trait` constructor now has the same form as the `Class` and `Interface` constructors: It |
| 29 | + takes an array of subnodes. Unlike classes/interfaces, traits can only have a `stmts` subnode. |
| 30 | + * The `Array` subnode `items` may now contain `null` elements (due to destructuring). |
| 31 | + * `void` and `iterable` types are now stored as strings if the PHP 7 parser is used. Previously |
| 32 | + these would have been represented as `Name` instances. |
| 33 | + |
| 34 | +### Removed methods |
| 35 | + |
| 36 | +The following methods have been removed: |
| 37 | + |
| 38 | + * `Comment::setLine()`, `Comment::setText()`: Create new `Comment` instances instead. |
| 39 | + * `Name::set()`, `Name::setFirst()`, `Name::setLast()`: Create new `Name` instances instead. For |
| 40 | + the latter two a combination of `Name::concat()` and `Name::slice()` can be used. |
| 41 | + |
| 42 | +### Miscellaneous |
| 43 | + |
| 44 | + * All methods on `PrettyPrinter\Standard` are now protected. Previoulsy most of them were public. |
| 45 | + The pretty printer should only be invoked using the `prettyPrint()`, `prettyPrintFile()` and |
| 46 | + `prettyPrintExpr()` methods. |
| 47 | + * The node dumper now prints numeric values that act as enums/flags in a string representation. |
| 48 | + If node dumper results are used in tests, updates may be needed to account for this. |
0 commit comments