-
-
Notifications
You must be signed in to change notification settings - Fork 0
Add support for LiveComponents in PHPStan rules and documentation #6
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
c25c1a6 to
c1dc2e8
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 extends PHPStan rule support to cover LiveComponents (classes annotated with #[AsLiveComponent]) in addition to TwigComponents. Since LiveComponents are enhanced TwigComponents, all existing validation rules now apply to both component types.
Key Changes
- Added
AttributeFinder::findAnyAttribute()method to check for multiple attribute types - Updated all 6 TwigComponent rules to support both
#[AsTwigComponent]and#[AsLiveComponent]attributes - Added comprehensive test coverage with LiveComponent fixtures for all rules
- Updated documentation (README.md, AGENTS.md) to clarify that rules apply to both component types
- Added
symfony/ux-live-componentas a dev dependency
Reviewed changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/NodeAnalyzer/AttributeFinder.php |
Added findAnyAttribute() method to support checking multiple attribute types in a single call |
src/Rules/TwigComponent/PublicPropertiesShouldBeCamelCaseRule.php |
Updated to check for both AsTwigComponent and AsLiveComponent attributes |
src/Rules/TwigComponent/ForbiddenInheritanceRule.php |
Updated to check for both AsTwigComponent and AsLiveComponent attributes |
src/Rules/TwigComponent/ForbiddenClassPropertyRule.php |
Updated to check for both AsTwigComponent and AsLiveComponent attributes |
src/Rules/TwigComponent/ForbiddenAttributesPropertyRule.php |
Updated to check for both attributes and dynamically reference attribute name in error messages |
src/Rules/TwigComponent/ExposePublicPropsShouldBeFalseRule.php |
Updated to check for both AsTwigComponent and AsLiveComponent attributes |
src/Rules/TwigComponent/ClassNameShouldNotEndWithComponentRule.php |
Updated to check for both AsTwigComponent and AsLiveComponent attributes |
tests/Rules/TwigComponent/PublicPropertiesShouldBeCamelCaseRule/PublicPropertiesShouldBeCamelCaseRuleTest.php |
Added tests for LiveComponent with snake_case and camelCase properties |
tests/Rules/TwigComponent/PublicPropertiesShouldBeCamelCaseRule/Fixture/LiveComponentWithSnakeCaseProperty.php |
Added test fixture demonstrating violations with LiveComponent |
tests/Rules/TwigComponent/PublicPropertiesShouldBeCamelCaseRule/Fixture/LiveComponentWithCamelCaseProperties.php |
Added test fixture demonstrating compliant LiveComponent usage |
tests/Rules/TwigComponent/ForbiddenInheritanceRule/ForbiddenInheritanceRuleTest.php |
Added tests for LiveComponent with and without inheritance |
tests/Rules/TwigComponent/ForbiddenInheritanceRule/Fixture/LiveComponentWithoutInheritance.php |
Added test fixture for compliant LiveComponent without inheritance |
tests/Rules/TwigComponent/ForbiddenInheritanceRule/Fixture/LiveComponentWithInheritance.php |
Added test fixture demonstrating violation with LiveComponent inheritance |
tests/Rules/TwigComponent/ForbiddenClassPropertyRule/ForbiddenClassPropertyRuleTest.php |
Added tests for LiveComponent with and without class property |
tests/Rules/TwigComponent/ForbiddenClassPropertyRule/Fixture/LiveComponentWithNoClassProperty.php |
Added test fixture for compliant LiveComponent |
tests/Rules/TwigComponent/ForbiddenClassPropertyRule/Fixture/LiveComponentWithClassProperty.php |
Added test fixture demonstrating class property violation |
tests/Rules/TwigComponent/ForbiddenAttributesPropertyRule/ForbiddenAttributesPropertyRuleTest.php |
Added tests for LiveComponent with and without attributes property |
tests/Rules/TwigComponent/ForbiddenAttributesPropertyRule/Fixture/LiveComponentWithNoAttributesProperty.php |
Added test fixture for compliant LiveComponent |
tests/Rules/TwigComponent/ForbiddenAttributesPropertyRule/Fixture/LiveComponentWithAttributesProperty.php |
Added test fixture demonstrating attributes property violation |
tests/Rules/TwigComponent/ExposePublicPropsShouldBeFalseRule/Fixture/LiveComponentWithExposePublicPropsTrue.php |
Added test fixture demonstrating exposePublicProps violation with LiveComponent |
tests/Rules/TwigComponent/ExposePublicPropsShouldBeFalseRule/Fixture/LiveComponentWithExposePublicPropsFalse.php |
Added test fixture for compliant LiveComponent with exposePublicProps set to false |
tests/Rules/TwigComponent/ExposePublicPropsShouldBeFalseRule/ExposePublicPropsShouldBeFalseRuleTest.php |
Added test for LiveComponent with exposePublicProps configurations |
tests/Rules/TwigComponent/ClassNameShouldNotEndWithComponentRule/Fixture/ValidLiveComponentName.php |
Added test fixture for LiveComponent with valid naming |
tests/Rules/TwigComponent/ClassNameShouldNotEndWithComponentRule/Fixture/InvalidLiveComponentName.php |
Added test fixture demonstrating naming violation with LiveComponent |
tests/Rules/TwigComponent/ClassNameShouldNotEndWithComponentRule/ClassNameShouldNotEndWithComponentRuleTest.php |
Added tests for LiveComponent naming validation |
composer.json |
Added symfony/ux-live-component as dev dependency for testing |
README.md |
Added note clarifying that all rules apply to LiveComponents; improved installation section formatting |
AGENTS.md |
Updated project overview and rule creation examples to include LiveComponent support |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tests/Rules/TwigComponent/ForbiddenInheritanceRule/Fixture/LiveComponentWithInheritance.php
Show resolved
Hide resolved
c1dc2e8 to
f83735b
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 28 out of 28 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.