Skip to content

fix: add parens around intersection type in union (DNF types) - #2470

Draft
jorgsowa wants to merge 1 commit into
prettier:mainfrom
jorgsowa:fix/dnf-type-missing-parens
Draft

jorgsowa wants to merge 1 commit into
prettier:mainfrom
jorgsowa:fix/dnf-type-missing-parens

Conversation

@jorgsowa

@jorgsowa jorgsowa commented Mar 25, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #2450

@elnebuloso

Copy link
Copy Markdown

Thanks for this fix, @jorgsowa!

I tested this branch on top of main (269374b) with

function f((A&B)|null $x): (A&B)|null { return $x; }

and the output keeps the parentheses: function f((A&B)|null $x): (A&B)|null. It passes php -l on PHP 8.5.11 and
keeps every token of the input. On main the parentheses are dropped, so the result no longer parses.

Would you be up for taking it out of draft? It would close #2450.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Combining intersection and union types leads to syntax error

2 participants