Skip to content

Releases: nikic/PHP-Parser

PHP-Parser 5.0.0-alpha2

05 Mar 09:53
Compare
Choose a tag to compare
Pre-release

See UPGRADE-5.0 for detailed migration instructions.

Added

  • [PHP 8.3] Added support for dynamic class constant fetch.
  • Added many additional type annotations. PhpStan is now used.
  • Added a fuzzing target for PHP-Fuzzer, which was how a lot of pretty printer bugs were found.
  • Added isPromoted(), isPublic(), isProtected(), isPrivate() and isReadonly() methods on Param.
  • Added support for class constants in trait builder.
  • Added PrettyPrinter interface.
  • Added support for formatting preservation when toggling static modifiers.
  • The php-parse binary now accepts - as the file name, in which case it will read from stdin.

Fixed

  • The pretty printer now uses a more accurate treatment of unary operator precedence, and will only wrap them in parentheses if required. This allowed fixing a number of other precedence related bugs.
  • The pretty printer now respects the precedence of clone, throw and arrow functions.
  • The pretty printer no longer unconditionally wraps yield in parentheses, unless the target version is set to older than PHP 7.0.
  • Fixed formatting preservation for alternative elseif/else syntax.
  • Fixed checks for when it is safe to print strings as heredoc/nowdoc to accommodate flexible doc string semantics.
  • The pretty printer now prints parentheses around new/instanceof operands in all required situations.
  • Similar, differences in allowed expressions on the LHS of -> and :: are now taken into account.
  • Fixed various cases where \r at the end of a doc string could be incorrectly merged into a CRLF sequence with a following \n.
  • __halt_compiler is no longer recognized as a semi-reserved keyword, in line with PHP behavior.
  • <?= is no longer recognized as a semi-reserved keyword.
  • Fix handling of very large overflowing \u escape sequences.

Removed

  • Removed deprecated Error constructor taking a line number instead of an attributes array.

PHP-Parser 4.15.4

05 Mar 19:50
Compare
Choose a tag to compare

Fixed

  • Fixed formatting-preservation for alternative if syntax with trailing comments.

PHP-Parser 4.15.3

16 Jan 22:07
Compare
Choose a tag to compare

Fixed

  • Support readonly property with PHP 8.2 DNF type.
  • Fixed PHP attribute group and PHP-Parser attribute mixup in EnumCase builder.

PHP-Parser 4.15.2

12 Nov 15:39
Compare
Choose a tag to compare

Fixed

  • Fixed parsing of large hex float literals that contain an "e" character.
  • Fixed tests to pass on 32-bit.
  • Fixed generation of invalid code when using formatting-preserving pretty printer with code that uses inline HTML.

PHP-Parser 5.0.0-alpha1

04 Sep 17:02
Compare
Choose a tag to compare
Pre-release

See UPGRADE-5.0 for detailed migration instructions.

Changed

  • PHP 7.1 is now required to run PHP-Parser.
  • Formatting of the standard pretty printer has been adjusted to match PSR-12 more closely.
  • The internal token representation now uses a PhpParser\Token class, which is compatible with PHP 8 token representation (PhpToken).
  • Destructuring is now always represented using Expr\List_ nodes, even if it uses [] syntax.
  • Renamed a number of node classes, and moved things that were not real expressions/statements outside the Expr/Stmt hierarchy. Compatibility shims for the old names have been retained.

Added

  • Added PhpVersion class, which is accepted in a number of places (e.g. ParserFactory, Parser, Lexer, PrettyPrinter) and gives more precise control over the PHP version being targeted.
  • Added PHP 8 parser though it only differs from the PHP 7 parser in concatenation precedence.
  • Added Parser::getLexer() method.
  • Added a Modifiers class, as a replacement for Stmt\Class_::MODIFIER_*.
  • Added support for returning an array or REMOVE_NODE from NodeVisitor::enterNode().

Removed

  • The PHP 5 parser has been removed. The PHP 7 parser has been adjusted to deal with PHP 5 code more gracefully.

PHP-Parser 4.15.1

04 Sep 07:32
Compare
Choose a tag to compare

Fixed

  • Fixed formatting preservation when adding multiple attributes to a class/method/etc that previously had none. This fixes a regression in the 4.15.0 release.

PHP-Parser 4.15.0

03 Sep 19:56
Compare
Choose a tag to compare

Added

  • PHP 8.2: Added support for true type.
  • PHP 8.2: Added support for DNF types.

Fixed

  • Support readonly as a function name.
  • Added __serialize and __unserialize to magic method list.
  • Fixed bounds check in Name::slice().
  • Fixed formatting preservation when adding attributes to a class/method/etc that previously had none.

PHP-Parser 4.14.0

31 May 21:02
Compare
Choose a tag to compare

Added

  • Added support for readonly classes.
  • Added rawValue attribute to LNumber, DNumber and String_ nodes, which stores the unparsed value of the literal (e.g. "1_000" rather than 1000).

PHP-Parser 4.13.2

30 Nov 19:40
Compare
Choose a tag to compare

Added

  • Added builders for enums and enum cases.

Fixed

  • NullsafeMethodCall now extends from CallLike.
  • The namespacedName property populated by the NameResolver is now declared on relevant nodes,
    to avoid a dynamic property deprecation warning with PHP 8.2.

PHP-Parser 4.13.1

03 Nov 20:55
Compare
Choose a tag to compare

Fixed

  • Support reserved keywords as enum cases.
  • Support array unpacking in constant expression evaluator.