05: Static analysis in CI - #5
Merged
Merged
Conversation
- --ignore-platform-reqs also disabled the config.platform.php pin, which resolved dev dependencies requiring PHP 8.1+; waive only the ext-* requirements a static-analysis run genuinely has no use for. - Run on 7.4, the floor the pin already targets, instead of an EOL 8.0 that matches neither end of the test matrix. - Fail when src/ holds no PHP files: PHPStan 1.x exits 0 on nothing to analyse, so a moved source root would leave the check green forever. - Narrow the token, cancel superseded PR runs, and cap the job, matching the tests workflow. - Drop reportUnmatchedIgnoredErrors: false; with no ignores yet it does nothing except guarantee the first stale one never gets reported. - Key the cache off head_ref, which is a branch name on pull_request.
Level 5 left coverage unused: the package analyses clean at 6, and 7 and 8 report the same single error, so 8 costs nothing beyond it. Level 9 is not taken -- its five findings are all in Sub_Plugin's untyped config reads, which are the runtime guards treatPhpDocTypesAsCertain: false exists to keep.
d4mation
reviewed
Aug 10, 2026
Comment on lines
+5639
to
+5642
| - **G** — PHPStan analyses `src/` only. Hand-written test-support code is thin for now, and adding | ||
| `tests/` wholesale would drag in Codeception's generated actor and `WPTestCase` module magic — | ||
| a well-known source of level-5 false positives. Once real support classes accumulate, put | ||
| `tests/_support` alone under a second config rather than widening `paths`. |
There was a problem hiding this comment.
We could just be more specific with excluded paths in our config to ensure these generated files aren't analyzed, right? I don't know if I like excluding tests/ from checks. While they can be annoying sometimes (intentionally providing weird data, having to force types sometimes, etc.) it helps ensure that our tests are strongly written and work exactly as intended without types, etc. being ignored.
Contributor
Author
There was a problem hiding this comment.
I had this concern tbh :D Fixed
| parameters: | ||
| phpVersion: 70400 | ||
| level: 8 | ||
| tmpDir: phpstan-cache |
There was a problem hiding this comment.
We'll want to ensure this is in .gitignore and even .gitattributes just to be safe.
Updated the PHPStan configuration to include the 'tests' directory for analysis while excluding generated test-support files to prevent false positives. Also, added 'phpstan-cache' to the export-ignore list in .gitattributes.
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.
PHPStan over
src/, plus the workflow that runs it.Stacked on #4 — this PR's diff is the two new files.
Sub_Plugin's untyped config reads, which are the runtime guardstreatPhpDocTypesAsCertain: falseexists to keep.