Repository navigation
Add PHP 8.2 DNF type support ((A&B)|C) - #6
Merged
Merged
Conversation
Parenthesized intersection types are now accepted as union members, e.g. (Countable&Traversable)|array, in parameter, return and property positions. The parenthesis tokens are kept on the Intersection node so the type prints back unchanged. Also fixes the stale github.com/TomasVotruba/reco imports left in php8.y after the module extraction, so regeneration produces the correct module path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Disjunctive Normal Form types (PHP 8.2) were not parsed. A parenthesized intersection inside a union, e.g.
failed with
unexpected '(', expecting T_VARIABLE.Change
internal/php8/php8.y): a parenthesized intersection'(' intersection_type ')'is now accepted as a union member, in the four combinations ((A&B)|C,C|(A&B),(A&B)|(C&D), and appended to a longer union). Adds zero new goyacc conflicts (baseline 3 shift/reduce, 7 reduce/reduce, unchanged).pkg/ast/node.go):IntersectiongainsOpenParenthesisTkn/CloseParenthesisTkn, set only when the intersection is parenthesized.php8.govia goyacc.github.com/TomasVotruba/recoimports inphp8.yleft from the module extraction, so regeneration yields the correct module path.internal/php8/dnf_types_test.go(parameter, return, two parenthesized intersections, and print-back-unchanged).Verification
Full suite and golangci-lint pass. With reco pointed at this branch, a
type-coveragescan ofsymfony/consoledrops from 3 unparseable files to 1 (the remaining one is an unrelated attribute-position gap).