-
Notifications
You must be signed in to change notification settings - Fork 1
feat: hook handler argument types (sniff + PHPStan rule) #28
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
Draft
d4mation
wants to merge
17
commits into
main
Choose a base branch
from
feature/hook-handler-types
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
ec4104c
feat: add hook handler argument types checks
d4mation b9f414a
fix: enforce type-less filter handlers; resolve &$this callbacks
d4mation a340807
refactor: drop prefix config; forbid native param types on all handlers
d4mation 99d47e8
docs: advise validating/casting hook arguments inside the callback
d4mation cc7bd30
feat: resolve container callbacks in the PHPStan rule
d4mation 47b4c85
docs: note container-callback support in the capability table
d4mation 4f51487
feat: resolve hook-registration wrapper methods in the PHPStan rule
d4mation 6cbe578
feat: resolve $this->add_action/add_filter wrappers in the sniff
d4mation ed358ca
ci: add GitHub Actions workflow running composer test across PHP 7.4-8.4
d4mation 0d990ed
ci: allow manual workflow_dispatch runs
d4mation 6cd789a
ci: run PHPUnit suite directly with --testdox; drop workflow_dispatch
d4mation 2268a84
ci: bump checkout to v7 and composer-install to v4 (Node 24)
d4mation 0d28d13
docs: note PHPStan 2.x (php-parser 5.x) would remove the 7.4 test skip
d4mation b04547e
fix: report but do not auto-fix wrapper-resolved hook handlers
d4mation 28b21f5
docs: complete param/return docblocks and scope the phpcs suppression
d4mation 99a94af
refactor: dedupe hook-handler resolution and report each hook name
d4mation d1d674f
test: avoid stdlib call in multi-hook fixture (fixes PHP 8.0 CI)
d4mation File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # Continuous Integration for stellarwp/coding-standards. | ||
| # | ||
| # On every push to main and every pull request: validates composer.json and runs | ||
| # the PHPUnit suite (the HookHandlerTypes sniff and PHPStan rule tests) across a | ||
| # range of PHP versions. | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Test (PHP ${{ matrix.php-version }}) | ||
| runs-on: ubuntu-latest | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| # PHPUnit 9.6 and PHPStan 1.x support this range. The PHPStan rule test | ||
| # skips on 7.4 (a php-parser emulation quirk in the test harness only); | ||
| # the sniff test runs on every version. | ||
| php-version: | ||
| - '7.4' | ||
| - '8.0' | ||
| - '8.1' | ||
| - '8.2' | ||
| - '8.3' | ||
| - '8.4' | ||
|
|
||
| steps: | ||
| - name: Check out the code | ||
| uses: actions/checkout@v7 | ||
|
|
||
| - name: Configure PHP ${{ matrix.php-version }} | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: ${{ matrix.php-version }} | ||
| extensions: mbstring | ||
| coverage: none | ||
|
|
||
| - name: Validate composer.json | ||
| run: composer validate --no-check-lock | ||
|
|
||
| - name: Install dependencies | ||
| uses: ramsey/composer-install@v4 | ||
|
|
||
| # Runs the sniff (AbstractSniffUnitTest) and PHPStan rule (RuleTestCase) | ||
| # tests. The sniff test constructs the full StellarWP ruleset, so a broken | ||
| # ruleset fails here too. --testdox lists each test and its result. | ||
| - name: Run the test suite | ||
| run: composer phpunit |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,4 +3,6 @@ vendor/ | |
| phpcs.xml | ||
| .phpcs.xml | ||
| composer.lock | ||
| .DS_Store | ||
| .DS_Store | ||
| .phpunit.result.cache | ||
| .phpunit.cache/ | ||
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
Oops, something went wrong.
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.
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.
This whole slice of the code was based on MemberDash's implementation, but Give has its own version of this idea which wouldn't be immediately compatible with this code: https://github.com/impress-org/givewp/blob/150cf56a1af2e4f58941a3f910d960170ae40340/src/Helpers/Hooks.php
Maybe it isn't worth trying to account for cases like this here? 🤔