Skip to content

Conversation

@Kocal
Copy link
Owner

@Kocal Kocal commented Nov 24, 2025

No description provided.

@Kocal Kocal self-assigned this Nov 24, 2025
@Kocal Kocal requested a review from Copilot November 24, 2025 08:23
Copilot finished reviewing on behalf of Kocal November 24, 2025 08:25
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 LiveListenerMethodsShouldBePublicRule that enforces public visibility for methods annotated with #[LiveListener] in LiveComponents. This ensures LiveListener methods are accessible when listening to frontend events, mirroring the existing LiveActionMethodsShouldBePublicRule for LiveAction methods.

Key Changes:

  • Implements LiveListenerMethodsShouldBePublicRule to validate method visibility for LiveListener-annotated methods
  • Adds comprehensive test coverage with fixtures for valid and invalid cases
  • Updates README documentation with usage examples demonstrating correct and incorrect patterns

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Rules/LiveComponent/LiveListenerMethodsShouldBePublicRule.php Implements the new PHPStan rule checking that all methods with #[LiveListener] are public
tests/Rules/LiveComponent/LiveListenerMethodsShouldBePublicRule/LiveListenerMethodsShouldBePublicRuleTest.php Test case validating the rule detects violations and correctly handles valid cases
tests/Rules/LiveComponent/LiveListenerMethodsShouldBePublicRule/Fixture/PrivateLiveListener.php Test fixture demonstrating violations with protected and private LiveListener methods
tests/Rules/LiveComponent/LiveListenerMethodsShouldBePublicRule/Fixture/PublicLiveListener.php Test fixture showing correct usage with public LiveListener methods
tests/Rules/LiveComponent/LiveListenerMethodsShouldBePublicRule/Fixture/NotAComponent.php Test fixture ensuring rule ignores classes without #[AsLiveComponent]
tests/Rules/LiveComponent/LiveListenerMethodsShouldBePublicRule/Fixture/NoLiveListener.php Test fixture ensuring rule ignores methods without #[LiveListener]
tests/Rules/LiveComponent/LiveListenerMethodsShouldBePublicRule/config/configured_rule.neon Configuration file for enabling the rule in tests
README.md Documentation explaining the rule's purpose with before/after code examples

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

@Kocal Kocal merged commit 769874e into main Nov 24, 2025
14 checks passed
@Kocal Kocal deleted the LiveListenerMethodsShouldBePublicRule branch November 24, 2025 08:27
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