-
Notifications
You must be signed in to change notification settings - Fork 4
feat: trait modes, flatten optimization, dumper, CLI flag, docs, tests #35
Conversation
…r for managing trait relationships
…erifying node relationships directly
…gationTest for validation
…es class for improved encapsulation
…ustom sorting for relationships
…es classes for improved functionality
…ferences in related files
…onships and nodes
…RenderMode handling
…or trait handling
…ping and add TraitA/B classes for testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements trait rendering modes and relationship optimization features, adding support for both showing traits explicitly and flattening trait-derived relationships to consuming classes.
Key changes:
- Add
TraitRenderModeenum withWithTraitsandFlattenmodes for controlling trait visualization - Implement relationship optimization and deduplication to improve diagram clarity
- Add YAML dumper utility for debugging and CLI
--trait-modeflag for user control
Reviewed Changes
Copilot reviewed 42 out of 42 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/ClassDiagramRenderer/TraitRenderMode.php | New enum defining trait rendering strategies |
| src/ClassDiagramRenderer/Node/Trait_.php | New trait node implementation with proper rendering |
| src/ClassDiagramRenderer/Node/Relationship/TraitUsage.php | New relationship type for trait usage connections |
| src/ClassDiagramRenderer/Node/Relationship/Relationships.php | Major refactor adding optimization logic for both trait modes |
| src/ClassDiagramRenderer/RenderOptions/RenderOptions.php | Moved to subfolder and added trait mode parameter |
| src/ClassDiagramRenderer/Node/Connector/TraitUsageConnector.php | New connector for parsing trait usage from AST |
| src/ClassDiagramRenderer/ClassDiagramDumper.php | New YAML dumper utility for debugging |
| src/Console/Command/GenerateCommand.php | Added CLI flag for trait mode selection |
| tests/ | Comprehensive test coverage for new features and trait scenarios |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| $traits = $classUses[$from->nodeName()] ?? []; | ||
| $suppress = false; | ||
| foreach ($traits as $tName) { | ||
| if (!empty($traitProvides[get_class($rel)][$rel->to->nodeName()] ?? false)) { |
Copilot
AI
Aug 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic is incorrect. The condition checks if the trait provides the relationship type, but it should check if any trait used by the class provides the same relationship to the same target. The current code looks for the relationship type in $traitProvides but doesn't check if any of the traits in $traits array actually provide it.
| if (!empty($traitProvides[get_class($rel)][$rel->to->nodeName()] ?? false)) { | |
| if (!empty($traitProvides[get_class($rel)][$rel->to->nodeName()][$tName] ?? false)) { |
Closes #26
Summary
--trait-mode, and update docs/testsWhy