Repository navigation
Fix GH-269: Render union and intersection types in IDE formats - #271
Open
RaphaelFakhri wants to merge 1 commit into
Open
RaphaelFakhri wants to merge 1 commit into
RaphaelFakhri wants to merge 1 commit into
Conversation
The IDE formats kept only the last member of a union or intersection type, so array_key_first() was documented as returning null instead of int|string|null. Build the full type from the nested <type> elements, including DNF types, and escape types in the IDE XML output.
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.
The IDE package formats (
json,xml,php,sqlite,phpstub) keep only the text of the last<type>element they read. For a union or intersection type, every nested<type>overwrites the previous one, soarray_key_first()getsnullas its return type instead ofint|string|null. Parameter types are affected the same way.Changes
Package_IDE_Basenow handles the<type>element and builds the type from its nested<type>children:unionmembers are joined with|,intersectionmembers with&, and an intersection nested in a union is wrapped in parentheses (DNF types, for example(Countable&Traversable)|null).Package_IDE_XMLescapes the parameter and return types, so an intersection type does not produce invalid XML.tests/package/ide/type_rendering_001.phptcovers union, intersection and DNF types for the JSON and XML formats.Example output for
array_key_first()in thejsonformat:Tests
make test: 65 tests pass. The new test fails without the change toPackage_IDE_Base.This change does not cover the missing initializers that are wrapped in
<constant>, also reported in GH-269.