7309b316587485c4ac9fac09ed2d31bbf428cddb
[yaffs-website] / vendor / nikic / php-parser / CHANGELOG.md
1 Version 4.0.2-dev
2 -----------------
3
4 Nothing yet.
5
6 Version 4.0.1 (2018-03-25)
7 --------------------------
8
9 ### Added
10
11 * [PHP 7.3] Added support for trailing commas in function calls.
12 * [PHP 7.3] Added support for by-reference array destructuring. 
13 * Added checks to node traverser to prevent replacing a statement with an expression or vice versa.
14   This should prevent common mistakes in the implementation of node visitors.
15 * Added the following methods to `BuilderFactory`, to simplify creation of expressions:
16   * `funcCall()`
17   * `methodCall()`
18   * `staticCall()`
19   * `new()`
20   * `constFetch()`
21   * `classConstFetch()`
22
23 Version 4.0.0 (2018-02-28)
24 --------------------------
25
26 * No significant code changes since the beta 1 release.
27
28 Version 4.0.0-beta1 (2018-01-27)
29 --------------------------------
30
31 ### Fixed
32
33 * In formatting-preserving pretty printer: Fixed indentation when inserting into lists. (#466)
34
35 ### Added
36
37 * In formatting-preserving pretty printer: Improved formatting of elements inserted into multi-line
38   arrays.
39
40 ### Removed
41
42 * The `Autoloader` class has been removed. It is now required to use the Composer autoloader.
43
44 Version 4.0.0-alpha3 (2017-12-26)
45 ---------------------------------
46
47 ### Fixed
48
49 * In the formatting-preserving pretty printer:
50   * Fixed comment indentation.
51   * Fixed handling of inline HTML in the fallback case.
52   * Fixed insertion into list nodes that require creation of a code block.
53
54 ### Added
55
56 * Added support for inserting at the start of list nodes in formatting-preserving pretty printer.
57
58 Version 4.0.0-alpha2 (2017-11-10)
59 ---------------------------------
60
61 ### Added
62
63 * In the formatting-preserving pretty printer:
64   * Added support for changing modifiers.
65   * Added support for anonymous classes.
66   * Added support for removing from list nodes.
67   * Improved support for changing comments.
68 * Added start token offsets to comments.
69
70 Version 4.0.0-alpha1 (2017-10-18)
71 ---------------------------------
72
73 ### Added
74
75 * Added experimental support for format-preserving pretty-printing. In this mode formatting will be
76   preserved for parts of the code which have not been modified.
77 * Added `replaceNodes` option to `NameResolver`, defaulting to true. If this option is disabled,
78   resolved names will be added as `resolvedName` attributes, instead of replacing the original
79   names.
80 * Added `NodeFinder` class, which can be used to find nodes based on a callback or class name. This
81   is a utility to avoid custom node visitor implementations for simple search operations.
82 * Added `ClassMethod::isMagic()` method.
83 * Added `BuilderFactory` methods: `val()` method for creating an AST for a simple value, `concat()`
84   for creating concatenation trees, `args()` for preparing function arguments.
85 * Added `NameContext` class, which encapsulates the `NameResolver` logic independently of the actual
86   AST traversal. This facilitates use in other context, such as class names in doc comments.
87   Additionally it provides an API for getting the shortest representation of a name.
88 * Added `Node::setAttributes()` method.
89 * Added `JsonDecoder`. This allows conversion JSON back into an AST.
90 * Added `Name` methods `toLowerString()` and `isSpecialClassName()`.
91 * Added `Identifier` and `VarLikeIdentifier` nodes, which are used in place of simple strings in
92   many places.
93 * Added `getComments()`, `getStartLine()`, `getEndLine()`, `getStartTokenPos()`, `getEndTokenPos()`,
94   `getStartFilePos()` and `getEndFilePos()` methods to `Node`. These provide a more obvious access
95   point for the already existing attributes of the same name.
96 * Added `ConstExprEvaluator` to evaluate constant expressions to PHP values.
97 * Added `Expr\BinaryOp::getOperatorSigil()`, returning `+` for `Expr\BinaryOp\Plus`, etc.
98
99 ### Changed
100
101 * Many subnodes that previously held simple strings now use `Identifier` (or `VarLikeIdentifier`)
102   nodes. Please see the UPGRADE-4.0 file for an exhaustive list of affected nodes and some notes on
103   possible impact.
104 * Expression statements (`expr;`) are now represented using a `Stmt\Expression` node. Previously
105   these statements were directly represented as their constituent expression.
106 * The `name` subnode of `Param` has been renamed to `var` and now contains a `Variable` rather than
107   a plain string.
108 * The `name` subnode of `StaticVar` has been renamed to `var` and now contains a `Variable` rather
109   than a plain string.
110 * The `var` subnode of `ClosureUse` now contains a `Variable` rather than a plain string.
111 * The `var` subnode of `Catch` now contains a `Variable` rather than a plain string.
112 * The `alias` subnode of `UseUse` is now `null` if no explicit alias is given. As such,
113   `use Foo\Bar` and `use Foo\Bar as Bar` are now represented differently. The `getAlias()` method
114   can be used to get the effective alias, even if it is not explicitly given.
115
116 ### Removed
117
118 * Support for running on PHP 5 and HHVM has been removed. You can however still parse code of old
119   PHP versions (such as PHP 5.2), while running on PHP 7.
120 * Removed `type` subnode on `Class`, `ClassMethod` and `Property` nodes. Use `flags` instead.
121 * The `ClassConst::isStatic()` method has been removed. Constants cannot have a static modifier.
122 * The `NodeTraverser` no longer accepts `false` as a return value from a `leaveNode()` method.
123   `NodeTraverser::REMOVE_NODE` should be returned instead.
124 * The `Node::setLine()` method has been removed. If you really need to, you can use `setAttribute()`
125   instead.
126 * The misspelled `Class_::VISIBILITY_MODIFER_MASK` constant has been dropped in favor of
127   `Class_::VISIBILITY_MODIFIER_MASK`.
128 * The XML serializer has been removed. As such, the classes `Serializer\XML`, and
129   `Unserializer\XML`, as well as the interfaces `Serializer` and `Unserializer` no longer exist.
130 * The `BuilderAbstract` class has been removed. It's functionality is moved into `BuilderHelpers`.
131   However, this is an internal class and should not be used directly.
132
133 Version 3.1.5 (2018-02-28)
134 --------------------------
135
136 ### Fixed
137
138 * Fixed duplicate comment assignment in switch statements. (#469)
139 * Improve compatibility with PHP-Scoper. (#477)
140
141 Version 3.1.4 (2018-01-25)
142 --------------------------
143
144 ### Fixed
145
146 * Fixed pretty printing of `-(-$x)` and `+(+$x)`. (#459)
147
148 Version 3.1.3 (2017-12-26)
149 --------------------------
150
151 ### Fixed
152
153 * Improve compatibility with php-scoper, by supporting prefixed namespaces in
154   `NodeAbstract::getType()`.
155
156 Version 3.1.2 (2017-11-04)
157 --------------------------
158
159 ### Fixed
160
161 * Comments on empty blocks are now preserved on a `Stmt\Nop` node. (#382)
162
163 ### Added
164
165 * Added `kind` attribute for `Stmt\Namespace_` node, which is one of `KIND_SEMICOLON` or
166   `KIND_BRACED`. (#417)
167 * Added `setDocComment()` method to namespace builder. (#437)
168
169 Version 3.1.1 (2017-09-02)
170 --------------------------
171
172 ### Fixed
173
174 * Fixed syntax error on comment after brace-style namespace declaration. (#412)
175 * Added support for TraitUse statements in trait builder. (#413)
176
177 Version 3.1.0 (2017-07-28)
178 --------------------------
179
180 ### Added
181
182 * [PHP 7.2] Added support for trailing comma in group use statements.
183 * [PHP 7.2] Added support for `object` type. This means `object` types will now be represented as a
184   builtin type (a simple `"object"` string), rather than a class `Name`.
185
186 ### Fixed
187
188 * Floating-point numbers are now printed correctly if the LC_NUMERIC locale uses a comma as decimal
189   separator.
190
191 ### Changed
192
193 * `Name::$parts` is no longer deprecated.
194
195 Version 3.0.6 (2017-06-28)
196 --------------------------
197
198 ### Fixed
199
200 * Fixed the spelling of `Class_::VISIBILITY_MODIFIER_MASK`. The previous spelling of
201   `Class_::VISIBILITY_MODIFER_MASK` is preserved for backwards compatibility.
202 * The pretty printing will now preserve comments inside array literals and function calls by
203   printing the array items / function arguments on separate lines. Array literals and functions that
204   do not contain comments are not affected.
205
206 ### Added
207
208 * Added `Builder\Param::makeVariadic()`.
209
210 ### Deprecated
211
212 * The `Node::setLine()` method has been deprecated.
213
214 Version 3.0.5 (2017-03-05)
215 --------------------------
216
217 ### Fixed
218
219 * Name resolution of `NullableType`s is now performed earlier, so that a fully resolved signature is
220   available when a function is entered. (#360)
221 * `Error` nodes are now considered empty, while previously they extended until the token where the
222   error occurred. This made some nodes larger than expected. (#359)
223 * Fixed notices being thrown during error recovery in some situations. (#362)
224
225 Version 3.0.4 (2017-02-10)
226 --------------------------
227
228 ### Fixed
229
230 * Fixed some extensibility issues in pretty printer (`pUseType()` is now public and `pPrec()` calls
231   into `p()`, instead of directly dispatching to the type-specific printing method).
232 * Fixed notice in `bin/php-parse` script.
233
234 ### Added
235
236 * Error recovery from missing semicolons is now supported in more cases.
237 * Error recovery from trailing commas in positions where PHP does not support them is now supported.
238
239 Version 3.0.3 (2017-02-03)
240 --------------------------
241
242 ### Fixed
243
244 * In `"$foo[0]"` the `0` is now parsed as an `LNumber` rather than `String`. (#325)
245 * Ensure integers and floats are always pretty printed preserving semantics, even if the particular
246   value can only be manually constructed.
247 * Throw a `LogicException` when trying to pretty-print an `Error` node. Previously this resulted in
248   an undefined method exception or fatal error.
249
250 ### Added
251
252 * [PHP 7.1] Added support for negative interpolated offsets: `"$foo[-1]"`
253 * Added `preserveOriginalNames` option to `NameResolver`. If this option is enabled, an
254   `originalName` attribute, containing the unresolved name, will be added to each resolved name.
255 * Added `php-parse --with-positions` option, which dumps nodes with position information.
256
257 ### Deprecated
258
259 * The XML serializer has been deprecated. In particular, the classes `Serializer\XML`,
260   `Unserializer\XML`, as well as the interfaces `Serializer` and `Unserializer` are deprecated.
261
262 Version 3.0.2 (2016-12-06)
263 --------------------------
264
265 ### Fixed
266
267 * Fixed name resolution of nullable types. (#324)
268 * Fixed pretty-printing of nullable types.
269
270 Version 3.0.1 (2016-12-01)
271 --------------------------
272
273 ### Fixed
274
275 * Fixed handling of nested `list()`s: If the nested list was unkeyed, it was directly included in
276   the list items. If it was keyed, it was wrapped in `ArrayItem`. Now nested `List_` nodes are
277   always wrapped in `ArrayItem`s. (#321)
278
279 Version 3.0.0 (2016-11-30)
280 --------------------------
281
282 ### Added
283
284 * Added support for dumping node positions in the NodeDumper through the `dumpPositions` option.
285 * Added error recovery support for `$`, `new`, `Foo::`.
286
287 Version 3.0.0-beta2 (2016-10-29)
288 --------------------------------
289
290 This release primarily improves our support for error recovery.
291
292 ### Added
293
294 * Added `Node::setDocComment()` method.
295 * Added `Error::getMessageWithColumnInfo()` method.
296 * Added support for recovery from lexer errors.
297 * Added support for recovering from "special" errors (i.e. non-syntax parse errors).
298 * Added precise location information for lexer errors.
299 * Added `ErrorHandler` interface, and `ErrorHandler\Throwing` and `ErrorHandler\Collecting` as
300   specific implementations. These provide a general mechanism for handling error recovery.
301 * Added optional `ErrorHandler` argument to `Parser::parse()`, `Lexer::startLexing()` and
302   `NameResolver::__construct()`.
303 * The `NameResolver` now adds a `namespacedName` attribute on name nodes that cannot be statically
304   resolved (unqualified unaliased function or constant names in namespaces).
305
306 ### Fixed
307
308 * Fixed attribute assignment for `GroupUse` prefix and variables in interpolated strings.
309
310 ### Changed
311
312 * The constants on `NameTraverserInterface` have been moved into the `NameTraverser` class.
313 * Due to the error handling changes, the `Parser` interface and `Lexer` API have changed.
314 * The emulative lexer now directly postprocesses tokens, instead of using `~__EMU__~` sequences.
315   This changes the protected API of the lexer.
316 * The `Name::slice()` method now returns `null` for empty slices, previously `new Name([])` was
317   used. `Name::concat()` now also supports concatenation with `null`.
318
319 ### Removed
320
321 * Removed `Name::append()` and `Name::prepend()`. These mutable methods have been superseded by
322   the immutable `Name::concat()`.
323 * Removed `Error::getRawLine()` and `Error::setRawLine()`. These methods have been superseded by
324   `Error::getStartLine()` and `Error::setStartLine()`.
325 * Removed support for node cloning in the `NodeTraverser`.
326 * Removed `$separator` argument from `Name::toString()`.
327 * Removed `throw_on_error` parser option and `Parser::getErrors()` method. Use the `ErrorHandler`
328   mechanism instead.
329
330 Version 3.0.0-beta1 (2016-09-16)
331 --------------------------------
332
333 ### Added
334
335 * [7.1] Function/method and parameter builders now support PHP 7.1 type hints (void, iterable and
336   nullable types).
337 * Nodes and Comments now implement `JsonSerializable`. The node kind is stored in a `nodeType`
338   property.
339 * The `InlineHTML` node now has an `hasLeadingNewline` attribute, that specifies whether the
340   preceding closing tag contained a newline. The pretty printer honors this attribute.
341 * Partial parsing of `$obj->` (with missing property name) is now supported in error recovery mode.
342 * The error recovery mode is now exposed in the `php-parse` script through the `--with-recovery`
343   or `-r` flags.
344
345 The following changes are also part of PHP-Parser 2.1.1:
346
347 * The PHP 7 parser will now generate a parse error for `$var =& new Obj` assignments.
348 * Comments on free-standing code blocks will now be retained as comments on the first statement in
349   the code block.
350
351 Version 3.0.0-alpha1 (2016-07-25)
352 ---------------------------------
353
354 ### Added
355
356 * [7.1] Added support for `void` and `iterable` types. These will now be represented as strings
357   (instead of `Name` instances) similar to other builtin types.
358 * [7.1] Added support for class constant visibility. The `ClassConst` node now has a `flags` subnode
359   holding the visibility modifier, as well as `isPublic()`, `isProtected()` and `isPrivate()`
360   methods. The constructor changed to accept the additional subnode.
361 * [7.1] Added support for nullable types. These are represented using a new `NullableType` node
362   with a single `type` subnode.
363 * [7.1] Added support for short array destructuring syntax. This means that `Array` nodes may now
364   appear as the left-hand-side of assignments and foreach value targets. Additionally the array
365   items may now contain `null` values if elements are skipped.
366 * [7.1] Added support for keys in list() destructuring. The `List` subnode `vars` has been renamed
367   to `items` and now contains `ArrayItem`s instead of plain variables.
368 * [7.1] Added support for multi-catch. The `Catch` subnode `type` has been renamed to `types` and
369   is now an array of `Name`s.
370 * `Name::slice()` now supports lengths and negative offsets. This brings it in line with
371   `array_slice()` functionality.
372
373 ### Changed
374
375 Due to PHP 7.1 support additions described above, the node structure changed as follows:
376
377 * `void` and `iterable` types are now stored as strings if the PHP 7 parser is used.
378 * The `ClassConst` constructor changed to accept an additional `flags` subnode.
379 * The `Array` subnode `items` may now contain `null` elements (destructuring).
380 * The `List` subnode `vars` has been renamed to `items` and now contains `ArrayItem`s instead of
381   plain variables.
382 * The `Catch` subnode `type` has been renamed to `types` and is now an array of `Name`s.
383
384 Additionally the following changes were made:
385
386 * The `type` subnode on `Class`, `ClassMethod` and `Property` has been renamed to `flags`. The
387   `type` subnode has retained for backwards compatibility and is populated to the same value as
388   `flags`. However, writes to `type` will not update `flags`.
389 * The `TryCatch` subnode `finallyStmts` has been replaced with a `finally` subnode that holds an
390   explicit `Finally` node. This allows for more accurate attribute assignment.
391 * The `Trait` constructor now has the same form as the `Class` and `Interface` constructors: It
392   takes an array of subnodes. Unlike classes/interfaces, traits can only have a `stmts` subnode.
393 * The `NodeDumper` now prints class/method/property/constant modifiers, as well as the include and
394   use type in a textual representation, instead of only showing the number.
395 * All methods on `PrettyPrinter\Standard` are now protected. Previously most of them were public.
396
397 ### Removed
398
399 * Removed support for running on PHP 5.4. It is however still possible to parse PHP 5.2-5.4 code
400   while running on a newer version.
401 * The deprecated `Comment::setLine()` and `Comment::setText()` methods have been removed.
402 * The deprecated `Name::set()`, `Name::setFirst()` and `Name::setLast()` methods have been removed.
403
404 Version 2.1.1 (2016-09-16)
405 --------------------------
406
407 ### Changed
408
409 * The pretty printer will now escape all control characters in the range `\x00-\x1F` inside double
410   quoted strings. If no special escape sequence is available, an octal escape will be used.
411 * The quality of the error recovery has been improved. In particular unterminated expressions should
412   be handled more gracefully.
413 * The PHP 7 parser will now generate a parse error for `$var =& new Obj` assignments.
414 * Comments on free-standing code blocks will no be retained as comments on the first statement in
415   the code block.
416
417 Version 2.1.0 (2016-04-19)
418 --------------------------
419
420 ### Fixed
421
422 * Properly support `B""` strings (with uppercase `B`) in a number of places.
423 * Fixed reformatting of indented parts in a certain non-standard comment style.
424
425 ### Added
426
427 * Added `dumpComments` option to node dumper, to enable dumping of comments associated with nodes.
428 * Added `Stmt\Nop` node, that is used to collect comments located at the end of a block or at the
429   end of a file (without a following node with which they could otherwise be associated).
430 * Added `kind` attribute to `Expr\Exit` to distinguish between `exit` and `die`.
431 * Added `kind` attribute to `Scalar\LNumber` to distinguish between decimal, binary, octal and
432   hexadecimal numbers.
433 * Added `kind` attribute to `Expr\Array` to distinguish between `array()` and `[]`.
434 * Added `kind` attribute to `Scalar\String` and `Scalar\Encapsed` to distinguish between
435   single-quoted, double-quoted, heredoc and nowdoc string.
436 * Added `docLabel` attribute to `Scalar\String` and `Scalar\Encapsed`, if it is a heredoc or
437   nowdoc string.
438 * Added start file offset information to `Comment` nodes.
439 * Added `setReturnType()` method to function and method builders.
440 * Added `-h` and `--help` options to `php-parse` script.
441
442 ### Changed
443
444 * Invalid octal literals now throw a parse error in PHP 7 mode.
445 * The pretty printer takes all the new attributes mentioned in the previous section into account.
446 * The protected `AbstractPrettyPrinter::pComments()` method no longer returns a trailing newline.
447 * The bundled autoloader supports library files being stored in a different directory than
448   `PhpParser` for easier downstream distribution.
449
450 ### Deprecated
451
452 * The `Comment::setLine()` and `Comment::setText()` methods have been deprecated. Construct new
453   objects instead.
454
455 ### Removed
456
457 * The internal (but public) method `Scalar\LNumber::parse()` has been removed. A non-internal
458   `LNumber::fromString()` method has been added instead.
459
460 Version 2.0.1 (2016-02-28)
461 --------------------------
462
463 ### Fixed
464
465 * `declare() {}` and `declare();` are not semantically equivalent and will now result in different
466   ASTs. The format case will have an empty `stmts` array, while the latter will set `stmts` to
467   `null`.
468 * Magic constants are now supported as semi-reserved keywords.
469 * A shebang line like `#!/usr/bin/env php` is now allowed at the start of a namespaced file.
470   Previously this generated an exception.
471 * The `prettyPrintFile()` method will not strip a trailing `?>` from the raw data that follows a
472   `__halt_compiler()` statement.
473 * The `prettyPrintFile()` method will not strip an opening `<?php` if the file starts with a
474   comment followed by InlineHTML.
475
476 Version 2.0.0 (2015-12-04)
477 --------------------------
478
479 ### Changed
480
481 * String parts of encapsed strings are now represented using `Scalar\EncapsStringPart` nodes.
482   Previously raw strings were used. This affects the `parts` child of `Scalar\Encaps` and
483   `Expr\ShellExec`. The change has been done to allow assignment of attributes to encapsed string
484   parts.
485
486 Version 2.0.0-beta1 (2015-10-21)
487 --------------------------------
488
489 ### Fixed
490
491 * Fixed issue with too many newlines being stripped at the end of heredoc/nowdoc strings in some
492   cases. (#227)
493
494 ### Changed
495
496 * Update group use support to be in line with recent PHP 7.0 builds.
497 * Renamed `php-parse.php` to `php-parse` and registered it as a composer bin.
498 * Use composer PSR-4 autoloader instead of custom autoloader.
499 * Specify phpunit as a dev dependency.
500
501 ### Added
502
503 * Added `shortArraySyntax` option to pretty printer, to print all arrays using short syntax.
504
505 Version 2.0.0-alpha1 (2015-07-14)
506 ---------------------------------
507
508 A more detailed description of backwards incompatible changes can be found in the
509 [upgrading guide](UPGRADE-2.0.md).
510
511 ### Removed
512
513 * Removed support for running on PHP 5.3. It is however still possible to parse PHP 5.2 and PHP 5.3
514   code while running on a newer version.
515 * Removed legacy class name aliases. This includes the old non-namespaced class names and the old
516   names for classes that were renamed for PHP 7 compatibility.
517 * Removed support for legacy node format. All nodes must have a `getSubNodeNames()` method now.
518
519 ### Added
520
521 * Added support for remaining PHP 7 features that were not present in 1.x:
522   * Group use declarations. These are represented using `Stmt\GroupUse` nodes. Furthermore a `type`
523     attribute was added to `Stmt\UseUse` to handle mixed group use declarations.
524   * Uniform variable syntax.
525   * Generalized yield operator.
526   * Scalar type declarations. These are presented using `'bool'`, `'int'`, `'float'` and `'string'`
527     as the type. The PHP 5 parser also accepts these, however they'll be `Name` instances there.
528   * Unicode escape sequences.
529 * Added `PhpParser\ParserFactory` class, which should be used to create parser instances.
530 * Added `Name::concat()` which concatenates two names.
531 * Added `Name->slice()` which takes a subslice of a name.
532
533 ### Changed
534
535 * `PhpParser\Parser` is now an interface, implemented by `Parser\Php5`, `Parser\Php7` and
536   `Parser\Multiple`. The `Multiple` parser will try multiple parsers, until one succeeds.
537 * Token constants are now defined on `PhpParser\Parser\Tokens` rather than `PhpParser\Parser`.
538 * The `Name->set()`, `Name->append()`, `Name->prepend()` and `Name->setFirst()` methods are
539   deprecated in favor of `Name::concat()` and `Name->slice()`.
540 * The `NodeTraverser` no longer clones nodes by default. The old behavior can be restored by
541   passing `true` to the constructor.
542 * The constructor for `Scalar` nodes no longer has a default value. E.g. `new LNumber()` should now
543   be written as `new LNumber(0)`.
544
545 ---
546
547 **This changelog only includes changes from the 2.0 series. For older changes see the
548 [1.x series changelog](https://github.com/nikic/PHP-Parser/blob/1.x/CHANGELOG.md) and the
549 [0.9 series changelog](https://github.com/nikic/PHP-Parser/blob/0.9/CHANGELOG.md).**