Add missing PHP 8.5 syntax support#1238
Conversation
Add a snapshot test for PHP 8.5 clone-with syntax by parsing `clone($obj, ["name" => $name, "id" => getId(...)])` with parser version 8.5. Update the clone snapshot to assert the expected AST shape, including the `Clone` node, property override array entries, the `getId(...)` call, and the variadic placeholder. This documents the new syntax and provides regression coverage for clone expressions with property overrides.
Add parser support for PHP 8.5 clone-with syntax such as `clone($obj, ["name" => $name])`. Extend clone expression parsing to accept the parenthesized 8.5 form with optional property overrides, preserve the existing clone behavior for older syntax, and expose the override expression on the `Clone` AST node. Update the type definitions accordingly so the new AST shape is represented consistently.
Update the PHP 8.5 pipe operator tests to match the final accepted syntax. Wrap the valid arrow function step in parentheses and add a regression test asserting that unparenthesized arrow functions in a pipe chain are rejected. Update the pipe snapshots to reflect the new expected AST and error behavior.
Align PHP 8.5 pipe operator parsing with the final accepted RFC behavior. Reject unparenthesized arrow functions when they are used as a step in a pipe chain, while preserving the existing PHP 8.5 version gate and the current behavior for valid pipe expressions.
…ions Add snapshot coverage for closures in PHP 8.5 attribute constant expressions. Parse an attribute argument containing a static anonymous function with parser version 8.5 and update the attribute snapshots to capture the expected AST. This provides regression coverage for the new constant-expression closure syntax inside attributes.
Allow the attribute lexer to tokenize closure bodies used inside PHP 8.5 attribute constant expressions. Accept the missing closure-body terminals in attribute parsing so static anonymous functions inside attribute arguments can be parsed correctly, while preserving the existing attribute parsing behavior for other expressions.
Adjust the clone AST and snapshot test files to match the repository's Prettier formatting rules. This resolves the lint failures reported in CI without changing the clone-with behavior.
Regenerate `types.d.ts` so the committed type definitions match the current JSDoc output. This updates the generated declaration for the `Clone.properties` field and resolves the type-check diff reported in CI.
jorgsowa
left a comment
There was a problem hiding this comment.
CI fails. If you can please add more test cases with the location, because I'm not sure if location numbers are correct for those features. Otherwise looks good to go. Thanks!
Add location snapshot coverage for the new PHP 8.5 syntax cases introduced in this PR. Cover `clone with` expressions, pipe chains with parenthesized arrow functions, and closures in attribute constant expressions with `withPositions` and `withSource` enabled. This helps verify that the location metadata for the new syntax is computed correctly.
|
Thanks! I added focused location coverage for the new PHP 8.5 syntax cases ( The previous CI failure was due to a diff in |
Regenerate `types.d.ts` from a fresh Linux checkout so the committed output matches the CI environment.
|
I found the My earlier Docker check was using the mounted Windows workspace, which turned out not to be a clean reproduction of the GitHub runner. A fresh Linux checkout generates slightly different JSDoc formatting in |
|
Thanks! |
|
Hi! Just checking in regarding the next release timeline for the php-parser. The PHP 8.5 support was merged a while ago, and I’m currently waiting for the next release so I can use it in a personal project. Is there already an approximate plan for when the next release might happen? Just asking so I can plan accordingly. Thanks! |
|
I'm sorry, but I cannot give clear answer now. I'm not releasing new versions, I'm only fixing bugs in this project. |
|
No problem, thanks for the clarification! I appreciate the work you're putting into maintaining the project. |
|
Hi @EverstormDevelopment, I’ll cut a new release when I’m back from my leave, latest in early June! |
|
That’s great news, thanks for the update! Looking forward to the release. |
Closes #1237
This PR adds the remaining PHP 8.5 syntax support that was still missing or incomplete in the parser.
Included changes:
clone withsyntax such asclone($obj, ["name" => $name])#[A(static function () { return 1; })]Tests:
clone with