Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Conversation

@tasuku43
Copy link
Owner

@tasuku43 tasuku43 commented Aug 14, 2025

Closes #26

Summary

  • Add trait rendering modes (WithTraits/Flatten) and relationship optimization
  • Add YAML dumper, CLI flag --trait-mode, and update docs/tests

Why

  • Control and clarify trait visualization
  • Improve readability via dedup and flatten of trait-derived edges
  • Provide a lightweight debug view

Copy link

Copilot AI left a 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 TraitRenderMode enum with WithTraits and Flatten modes for controlling trait visualization
  • Implement relationship optimization and deduplication to improve diagram clarity
  • Add YAML dumper utility for debugging and CLI --trait-mode flag 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)) {
Copy link

Copilot AI Aug 15, 2025

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.

Suggested change
if (!empty($traitProvides[get_class($rel)][$rel->to->nodeName()] ?? false)) {
if (!empty($traitProvides[get_class($rel)][$rel->to->nodeName()][$tName] ?? false)) {

Copilot uses AI. Check for mistakes.
@tasuku43 tasuku43 merged commit b5ed066 into main Aug 31, 2025
1 check passed
@tasuku43 tasuku43 deleted the issue/26 branch August 31, 2025 09:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Include associations from traits

2 participants