[Chore]: Add ActionClassesMustBeInvokable rule and related tests - #148
Merged
Conversation
Signed-off-by: Kevin Ullyott <kevin.ullyott@canyongbs.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new PHPStan rule to enforce an “invokable action” convention (only __invoke may be public, aside from __construct) for configured Action namespaces, along with Pest tests and fixtures to validate the rule behavior.
Changes:
- Introduces
ActionClassesMustBeInvokableRuleand wires it intophpstan-extension.neonwith configurable include/exclude namespace patterns. - Adds a dedicated PHPStan test config plus a Pest test that runs PHPStan against fixtures.
- Adds fixture classes covering valid/invalid actions, modular namespaces, non-action namespaces, abstract actions, and Filament exclusions.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/Rules/ActionClassesMustBeInvokable/ActionClassesMustBeInvokableRule.php |
New PHPStan rule enforcing invokable-only public API for action classes matched by namespace patterns. |
phpstan-extension.neon |
Registers the new rule and adds default include/exclude namespace pattern parameters + schema. |
tests/PHPStan/Configs/action-classes-must-be-invokable.neon |
Standalone PHPStan config used by tests to exercise the rule with specific namespace patterns. |
tests/PHPStan/ActionClassesMustBeInvokableTest.php |
Pest test that runs PHPStan against fixtures and asserts identifiers are/aren’t reported. |
tests/PHPStan/Fixtures/ActionInvokableFixture.php |
Fixture for a valid action (__invoke public, helpers protected). |
tests/PHPStan/Fixtures/ActionMissingInvokeFixture.php |
Fixture missing __invoke and exposing a disallowed public method. |
tests/PHPStan/Fixtures/ActionWithExtraPublicMethodFixture.php |
Fixture with __invoke plus an extra public method (should be reported). |
tests/PHPStan/Fixtures/AbstractActionFixture.php |
Fixture ensuring abstract action classes are ignored. |
tests/PHPStan/Fixtures/NonActionOutsideNamespaceFixture.php |
Fixture ensuring non-action namespaces are ignored. |
tests/PHPStan/Fixtures/ModularActionMissingInvokeFixture.php |
Fixture exercising wildcard include patterns for modular action namespaces. |
tests/PHPStan/Fixtures/FilamentActionExcludedFixture.php |
Fixture intended to verify Filament action namespaces are excluded. |
tests/PHPStan/Fixtures/NestedFilamentActionExcludedFixture.php |
Fixture intended to verify nested Filament action namespaces are excluded. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Signed-off-by: Kevin Ullyott <kevin.ullyott@canyongbs.com>
danharrin
approved these changes
Aug 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ticket(s) or GitHub Issue
Technical Description
Adds the
ActionClassesMustBeInvokablePHPStan rule to make it so actions must only have one public method and it should be__invokeso that they are invokable classes.Excludes Filament "Action" classes.
Any deployment steps required?
No
Are any Feature Flags and/or Data Migrations that can eventually be removed Added?
No
Before contributing and submitting this PR, make sure you have Read, agree, and are compliant with the contributing guidelines.