Skip to content

v0.2.2

Latest

Choose a tag to compare

@rlerdorf rlerdorf released this 24 Nov 13:03
f6b6f22

More valid PHP that the parser rejected now parses (#18):

  • clone with an argument list (PHP 8.6): clone(?), clone(...), clone($obj, ?), clone(object: $obj), clone().
  • Modifiers of anonymous classes: new readonly class {}, new #[A] readonly class(1) {}.
  • Property hooks that return by reference: &get => $this->x;.
  • Hooks on constructor parameters: public int $x = 1 { get => ...; }, also after an object default (= new Foo() { get => ... }).
  • The magic constant __PROPERTY__.
  • Semi-reserved words in trait adaptations: f as list;, list as protected;, T::f as public array;.
  • Negative offsets in interpolated strings: "$a[-3]".
  • The binary prefix with interpolation: b"a $x", b<<<E.
  • Reserved words in use clauses: use string as X;, use function Foo\bar as string;.
  • Calls of a function named readonly: readonly(), new (readonly())().

Changes to the tree:

  • New children: CloneExpression::$argumentExpressionList (set instead of $expression when the parentheses hold anything other than the object and the optional modifications), ObjectCreationExpression::$modifiers, PropertyHook::$byRefToken, Parameter::$hookList.
  • "$a[-3]" has a UnaryOpExpression around the number as the offset.
  • The name of a readonly() call is a QualifiedName whose name part keeps the kind ReadonlyKeyword when php's tokenizer returns the keyword. getResolvedName() and getLastNamePart() accept it; the name resolves to the global function.

Now reported as errors, as in PHP:

  • More than one modifier on a trait method alias: A as protected public b;.
  • Curly-brace offsets in a parameter default ($x = C{0}): the braces start a hook list.