Closes #39 Add PHPCS and PHPStan static analysis to CI - #43
Merged
Conversation
Wire in the reusable wp-media/workflows PHPCS and PHPStan workflows via `uses:` rather than reimplementing them, and add the corresponding composer scripts and dev dependencies. To keep CI green without a big-bang rewrite of the ~19 pre-existing source files: - PHPStan (level 5) ships with a generated `phpstan-baseline.neon` covering the 76 pre-existing findings, so only new issues fail CI. - PHPCS is scoped to `Integration/HttpRequestTrait.php` only, the file already adopted as the WP Media reference style (declare(strict_types=1), full docblocks). A job that only `uses:` a reusable workflow cannot carry `continue-on-error`, so scoping the ruleset is the simplest way to avoid failing the build on untouched files while leaving room to widen the ruleset as files are brought up to standard opportunistically. HttpRequestTrait.php gets 3 missing method docblocks added (no logic change) so it passes PHPCS cleanly as the reference file. Co-Authored-By: Sonnet 5 <noreply@anthropic.com>
Bump phpstan/phpstan to ^2.0 and the related packages (phpstan-mockery, phpstan-phpunit, szepeviktor/phpstan-wordpress) to their v2 releases; extension-installer to ^1.4. Regenerate phpstan-baseline.neon under v2. The new phpunit.coversMethod rule (enabled by bleedingEdge in phpstan-phpunit v2) flags pre-existing @Covers annotations in the test fixtures; it is suppressed by identifier in phpstan.neon.dist rather than baselined, because the v2 baseline generator mangles @-leading messages (@@Covers) so they never re-match. composer phpstan and composer phpcs both pass clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
remyperona
marked this pull request as ready for review
August 13, 2026 20:31
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.
Closes #39
Description
This wires PHPCS and PHPStan into CI for the wp-media/phpunit package, adding static analysis gatekeeping while maintaining a green build.
What was done
New CI workflows:
.github/workflows/phpcs.ymland.github/workflows/phpstan.yml— thin callers to the shared reusable workflowswp-media/workflows/.github/workflows/{phpcs,phpstan}.yml@main(pull_request + workflow_dispatch, with concurrency cancellation).Configuration files:
phpcs.xml.dist— WP Media ruleset derived fromwp-media/mcp-oauth, adapted for this package (no i18n text-domain rule since this is a test-utility library,PrefixAllGlobalsprefixwpmedia,testVersion 7.4-). Scoped toIntegration/HttpRequestTrait.php— the reference file that already meets the WP Media bar. Scope is intended to widen opportunistically as files are touched.phpstan.neon.dist— level 5, scanning the root source files +Integration/,Unit/,Fixtures/,Tests/, with WordPress stubs. Generatedphpstan-baseline.neon(76 pre-existing findings) keeps the gate green today while catching new issues going forward.Composer updates:
allow-pluginsconfiguration.phpcs,phpcs:fix, andphpstancomposer scripts.Source changes:
Integration/HttpRequestTrait.php— added 3 missing method docblocks only (no logic change) to pass PHPCS cleanly as the reference file..gitignore— ignorephpcs-report.xml.Verification:
composer phpcs→ 0 errors;composer phpstan→ 0 errors (with baseline); full test suite green (unit 91 tests, integration 28, integration-admin 3).composer.lockis gitignored and intentionally not committed.Type of change
Affected features & QA scope
Technical description
The implementation wires in reusable workflows from
wp-media/workflowsto execute PHPCS and PHPStan, avoiding code duplication across wp-media projects. PHPCS is scoped to a single reference file initially to avoid a big-bang reformat; PHPStan level 5 runs on all test code and source with a baseline for pre-existing findings. This keeps CI green while establishing a foundation for gradual code quality improvement.New dependencies
Risks
None identified. Static analysis does not affect runtime behavior. The baseline ensures no new CI failures on existing code.