-
-
Notifications
You must be signed in to change notification settings - Fork 0
Add MethodsShouldBePublicOrPrivateRule
#7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
5e5a777 to
4b52686
Compare
4b52686 to
7da321b
Compare
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 adds a new PHPStan rule MethodsShouldBePublicOrPrivateRule that enforces method visibility constraints for Symfony UX Twig Components. The rule ensures that methods in Twig Components (including Live Components) are either public or private, but never protected, since components must be final classes where protected methods serve no purpose.
Key changes:
- Implements
MethodsShouldBePublicOrPrivateRulefollowing established patterns for Twig Component rules - Adds comprehensive test coverage for both
#[AsTwigComponent]and#[AsLiveComponent]attributes - Configures ECS to skip
ProtectedToPrivateFixerfor test fixtures that intentionally use protected methods
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Rules/TwigComponent/MethodsShouldBePublicOrPrivateRule.php | Implements the new PHPStan rule that detects protected methods in Twig Components |
| tests/Rules/TwigComponent/MethodsShouldBePublicOrPrivateRule/MethodsShouldBePublicOrPrivateRuleTest.php | Test case with separate violation and no-violation test methods |
| tests/Rules/TwigComponent/MethodsShouldBePublicOrPrivateRule/config/configured_rule.neon | PHPStan configuration to enable the rule for tests |
| tests/Rules/TwigComponent/MethodsShouldBePublicOrPrivateRule/Fixture/*.php | Test fixtures covering all scenarios: violations with both attribute types, valid components, and non-components |
| ecs.php | Skips ProtectedToPrivateFixer for test fixtures that intentionally use protected methods |
| phpstan-baseline.neon | Adds baseline entries for intentionally unused private methods in test fixtures |
| README.md | Documents the new rule with usage examples and rationale (contains 2 spelling errors) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7da321b to
d550c76
Compare
d550c76 to
41ea205
Compare
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
Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.