Skip to content

Commit faa0988

Browse files
committed
Add upgrading information
1 parent b740076 commit faa0988

File tree

2 files changed

+47
-3
lines changed

2 files changed

+47
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Version 3.0.0-dev
2525
Due to PHP 7.1 support additions described above, the node structure changed as follows:
2626

2727
* `void` and `iterable` types are now stored as strings if the PHP 7 parser is used.
28-
* The `ClassConst` constructor changed to accept an additional `type` subnode.
28+
* The `ClassConst` constructor changed to accept an additional `flags` subnode.
2929
* The `Array` subnode `items` may now contain `null` elements (destructuring).
3030
* The `List` subnode `vars` has been renamed to `items` and now contains `ArrayItem`s instead of
3131
plain variables.
@@ -36,7 +36,7 @@ Additionally the following changes were made:
3636
* The `type` subnode on `Class`, `ClassMethod` and `Property` has been renamed to `flags`. The
3737
`type` subnode has retained for backwards compatibility and is populated to the same value as
3838
`flags`. However, writes to `type` will not update `flags`.
39-
* The `TryCatch::$finallyStmts` subnode has been replaced with a `$finally` subnode that holds an
39+
* The `TryCatch` subnode `finallyStmts` has been replaced with a `finally` subnode that holds an
4040
explicit `Finally` node. This allows for more accurate attribute assignment.
4141
* The `Trait` constructor now has the same form as the `Class` and `Interface` constructors: It
4242
takes an array of subnodes. Unlike classes/interfaces, traits can only have a `stmts` subnode.

UPGRADE-3.0.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,48 @@
11
Upgrading from PHP-Parser 2.x to 3.0
22
====================================
33

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

Comments
 (0)