Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #26 +/- ##
============================================
+ Coverage 72.77% 78.11% +5.34%
- Complexity 378 386 +8
============================================
Files 39 39
Lines 922 946 +24
============================================
+ Hits 671 739 +68
+ Misses 251 207 -44 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Issue
The Tactix library's
ReturnTypeFactorythrew aLogicExceptionwhen analyzing code with union return types (e.g.,Response|Error). It only supported scalar types, class names, and nullable types.Solution
Extended Tactix to fully parse and preserve union and intersection type information.
Files Modified
1.
ReturnType.phpLocation:
src/Analyzer/Class/ReturnType.phpChanges:
$unionTypes: Name[]property to store all types in a union$intersectionTypes: Name[]property to store all types in an intersectionunion(array $types)factory method to accept array of types (signature change from singleNametoName[])intersection(array $types)factory method to accept array of types (signature change from singleNametoName[])isUnion(): boolandisIntersection(): boolhelper methods__toString()to render unions asType1|Type2|Type3and intersections asType1&Type2&Type3Impact: Backward compatible for clients that check
isUnion()orisIntersection()on the enum. Theunion()andintersection()factory methods now require arrays, which is a breaking change to that API surface.2.
ReturnTypeFactory.phpLocation:
src/Analyzer/Class/ReturnTypeFactory.phpChanges:
UnionTypeandIntersectionTypefromPhpParser\NodeUnionTypenodes: extracts all member types and passes array toReturnType::union()IntersectionTypenodes: extracts all member types and passes array toReturnType::intersection()Impact: No breaking changes. Factory properly handles all modern PHP type syntax.
Summary of Impact
$unionTypes/$intersectionTypesResponse|Error,Foo&BarisUnion(),isIntersection()