Skip to content

Parse union types for circular dependency detection#86

Merged
dereuromark merged 1 commit intomasterfrom
fix/union-type-circular-dependency
Mar 23, 2026
Merged

Parse union types for circular dependency detection#86
dereuromark merged 1 commit intomasterfrom
fix/union-type-circular-dependency

Conversation

@dereuromark
Copy link
Copy Markdown
Contributor

Summary

  • Add extractDtoNamesFromType() method that splits union types on | and extracts DTO names from each part
  • Union types like UserDto|AdminDto are now correctly analyzed for circular dependencies

Fixes #85

Example

'Container' => [
    'fields' => [
        'item' => [
            'type' => 'ItemADto|ItemBDto', // Both types are now checked
        ],
    ],
],
'ItemA' => [
    'fields' => [
        'container' => ['type' => 'ContainerDto'], // This creates a cycle
    ],
],

Previously, the union type ItemADto|ItemBDto was not parsed, so the circular dependency Container -> ItemA -> Container was not detected. Now it is correctly detected.

Fixes #85

Union types like `UserDto|AdminDto` are now split and each type is
checked for circular dependencies. Added `extractDtoNamesFromType()`
method that handles union types by splitting on `|` and extracting
DTO names from each part.
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.46%. Comparing base (72fd6ef) to head (9c14efe).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master      #86      +/-   ##
============================================
+ Coverage     83.42%   83.46%   +0.03%     
- Complexity     1382     1386       +4     
============================================
  Files            40       40              
  Lines          3336     3344       +8     
============================================
+ Hits           2783     2791       +8     
  Misses          553      553              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dereuromark dereuromark merged commit 1821437 into master Mar 23, 2026
12 checks passed
@dereuromark dereuromark deleted the fix/union-type-circular-dependency branch March 23, 2026 01:27
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.

Circular dependency detection doesn't parse union types

1 participant