Skip to content

v0.2.1

Choose a tag to compare

@rlerdorf rlerdorf released this 24 Nov 03:58
· 4 commits to main since this release
2efe456

Valid PHP that the parser rejected now parses (#17):

  • Partial function application (PHP 8.6): f(1, ?), f(1, ...), f(a: ?). ArgumentExpression has a new child questionToken; expression is null for placeholders.
  • The (void) cast (PHP 8.5), with a whole expression as its operand: (void) $x = f();. New token kind TokenKind::VoidCastToken.
  • Dereferencing and calling array literals and null/true/false: ['A', 'm'](), [0, 1][0], null?->x.
  • Properties with only a set visibility: protected(set) int $x;, public(set) readonly int $r;.
  • clone (expr)->prop and clone ($a)[0].
  • Hook lists after a constant default: public ?int $x = null { get => ... }, public int $x = self::A { ... }.

Changes to the tree:

  • The set visibility of a property stays in PropertyDeclaration::$modifiers, in source order. $setVisibilityToken still refers to it but is no longer in CHILD_NAMES.
  • intdiv(..., 3) and array(0)() no longer produce parse errors. A variadic placeholder that is not last is reported as a diagnostic ("Variadic placeholder must be last").

New diagnostics:

  • "Variadic placeholder must be last" / "Variadic placeholder may only appear once" for f(..., 1) and f(..., ...).
  • "Unexpected '(void)'" for a void cast that is not a statement or part of a for expression list: $x = (void) f();, for (; (void) f(); ).

Not yet supported: clone(?) and clone(...), new readonly class, &get hooks and hooks on promoted parameters with a default.