Skip to content

Conversation

@Kocal
Copy link
Owner

@Kocal Kocal commented Nov 23, 2025

No description provided.

@Kocal Kocal self-assigned this Nov 23, 2025
@Kocal Kocal requested a review from Copilot November 23, 2025 15:32
Copilot finished reviewing on behalf of Kocal November 23, 2025 15:33
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 adds a new PHPStan rule ForbiddenInheritanceRule that prevents the use of class inheritance in Symfony UX Twig Components, promoting composition via traits instead. This enforces a best practice that helps avoid tight coupling between components and improves code reusability.

Key Changes:

  • Implements ForbiddenInheritanceRule that detects when a Twig component extends another class
  • Adds comprehensive test coverage with fixtures for various scenarios (inheritance, traits, no parent)
  • Updates README with documentation and examples showing forbidden vs. recommended patterns

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Rules/TwigComponent/ForbiddenInheritanceRule.php Core rule implementation that checks for class inheritance in Twig components
tests/Rules/TwigComponent/ForbiddenInheritanceRule/ForbiddenInheritanceRuleTest.php Test suite with violations and no-violations test methods
tests/Rules/TwigComponent/ForbiddenInheritanceRule/config/configured_rule.neon PHPStan configuration file for the rule
tests/Rules/TwigComponent/ForbiddenInheritanceRule/Fixture/ComponentWithInheritance.php Fixture demonstrating violation case
tests/Rules/TwigComponent/ForbiddenInheritanceRule/Fixture/ComponentWithoutInheritance.php Fixture showing compliant component without inheritance
tests/Rules/TwigComponent/ForbiddenInheritanceRule/Fixture/ComponentUsingTrait.php Fixture showing recommended trait-based composition
tests/Rules/TwigComponent/ForbiddenInheritanceRule/Fixture/NotAComponent.php Fixture ensuring rule only applies to Twig components
README.md Documentation with usage instructions and examples

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Kocal Kocal merged commit 49fb964 into main Nov 23, 2025
14 checks passed
@Kocal Kocal deleted the ForbiddenInheritanceRule branch November 23, 2025 15:34
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.

2 participants