Skip to content

v0.25.0

Choose a tag to compare

@github-actions github-actions released this 22 Oct 15:33
· 186 commits to main since this release
4fec7f4

Errors are now machine-readable: every ParseError has a stable code, and every compile-time error names the rule it breaks. Version-targeted parsing follows each PHP version from 7.4 to 8.6 much more closely.

Added

  • ForbiddenRule on ParseError::Forbidden (rule, forbidden_rule()), so tools can match errors by rule instead of by message. Includes ForbiddenRule::ALL, phase() (Phase::Parse or Phase::Compile, as php -l reports it), FromStr and Display (php-rs-parser).
  • ParseError::code(), a stable identifier for every error, and ParseError::leaves_ast_incomplete() (php-rs-parser). Errors returned by parse carry the code (php-wasm).
  • LexerErrorKind::UnterminatedComment and LexerErrorKind::InvalidNumericLiteral, which replaces Other for literals such as 1_ (php-lexer).
  • Name::join_parts_in(src), which borrows a multi-part name from the source when possible (php-ast).

Changed

  • ParseError::UnclosedDelimiter reads missing closing ')'; the opening offset stays in opened_at (php-rs-parser).
  • Name::join_parts and Name::to_string_repr borrow single-part names instead of allocating (php-ast).

Removed

  • Breaking: ParseError::ExpectedExpression, ExpectedStatement and ExpectedOpenTag; use ParseError::Expected, whose message also names the token found (php-rs-parser).

Fixed

  • Version gates follow PHP from 7.4 to 8.6: errors that older versions report (trailing commas in parameter lists before 8.0, ?false before 8.2, new readonly class before 8.3, exit and clone argument forms, …), valid PHP 7.4 that was rejected (mixed as a class name, function match(), #[...] as a comment, …), keywords such as readonly, never and __PROPERTY__ read as names before they were introduced, and PHP 8.6 features (readonly property defaults, partial function application in constant expressions, property writes through constant objects). \static and namespace\static in types are rejected from PHP 8.5 (php-rs-parser).
  • Lexing: nothing after __halt_compiler() is lexed, casts need only spaces or tabs around the keyword, a lone \r is a line break, and interpolations are scanned correctly past comments, backticks, heredocs and nested strings (php-lexer, php-rs-parser).
  • Parsing: bare yield before ?, ??, :, => and as; var, insteadof and hook names match case-insensitively; ** stays out of an instanceof operand; :: works on non-constant array expressions; self and parent are valid global constant names and stay unresolved in anonymous class types (php-rs-parser).
  • Compile-time checks no longer reject valid code (Enum in intersection types, foldable class names, short-circuit folding, set hook parameter types, heredoc indentation inside interpolations) and now catch stray semicolons in class bodies, var with other modifiers, final private and pre-8.1 final constants, reserved enum names, invalid typed enum constants, by-reference get hooks with a set hook and <?= without an expression (php-rs-parser).
  • A parenthesized constant named like a cast keyword, such as (int), no longer prints as a cast (php-printer).