Skip to content

[Chore]: Add ActionClassesMustBeInvokable rule and related tests - #148

Merged
danharrin merged 5 commits into
mainfrom
chore/invokable-actions-rule
Aug 24, 2026
Merged

[Chore]: Add ActionClassesMustBeInvokable rule and related tests#148
danharrin merged 5 commits into
mainfrom
chore/invokable-actions-rule

Conversation

@Orrison

@Orrison Orrison commented Aug 23, 2026

Copy link
Copy Markdown
Member

Ticket(s) or GitHub Issue

  • N/A

Technical Description

Adds the ActionClassesMustBeInvokable PHPStan rule to make it so actions must only have one public method and it should be __invoke so 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.

Signed-off-by: Kevin Ullyott <kevin.ullyott@canyongbs.com>
@Orrison
Orrison requested a review from danharrin August 23, 2026 19:48
@Orrison
Orrison requested a review from a team as a code owner August 23, 2026 19:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ActionClassesMustBeInvokableRule and wires it into phpstan-extension.neon with 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.

Comment thread tests/PHPStan/Fixtures/FilamentActionExcludedFixture.php Outdated
Comment thread tests/PHPStan/Fixtures/NestedFilamentActionExcludedFixture.php Outdated
Signed-off-by: Kevin Ullyott <kevin.ullyott@canyongbs.com>
@danharrin
danharrin merged commit a92763f into main Aug 24, 2026
10 checks passed
@danharrin
danharrin deleted the chore/invokable-actions-rule branch August 24, 2026 14:18
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.

3 participants