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 18:21
@Kocal Kocal force-pushed the MethodsShouldBePublicOrPrivateRule branch from 5e5a777 to 4b52686 Compare November 23, 2025 18:22
Copilot finished reviewing on behalf of Kocal November 23, 2025 18:23
@Kocal Kocal force-pushed the MethodsShouldBePublicOrPrivateRule branch from 4b52686 to 7da321b Compare November 23, 2025 18:23
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 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 MethodsShouldBePublicOrPrivateRule following established patterns for Twig Component rules
  • Adds comprehensive test coverage for both #[AsTwigComponent] and #[AsLiveComponent] attributes
  • Configures ECS to skip ProtectedToPrivateFixer for 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.

@Kocal Kocal force-pushed the MethodsShouldBePublicOrPrivateRule branch from 7da321b to d550c76 Compare November 23, 2025 18:24
@Kocal Kocal force-pushed the MethodsShouldBePublicOrPrivateRule branch from d550c76 to 41ea205 Compare November 23, 2025 18:24
@Kocal Kocal requested a review from Copilot November 23, 2025 18:27
Copilot finished reviewing on behalf of Kocal November 23, 2025 18:29
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

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.

@Kocal Kocal merged commit a381ba7 into main Nov 23, 2025
14 checks passed
@Kocal Kocal deleted the MethodsShouldBePublicOrPrivateRule branch November 23, 2025 18:30
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