Linting tools: add PHPStan#26
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds PHPStan static analysis tooling to the WordPress plugin codebase to improve code quality and catch potential issues. The implementation includes PHPStan at level 4 with WordPress-specific extensions and integrates it into the existing CI/CD pipeline.
- Adds PHPStan 2.1.33 along with WordPress-specific extensions for static analysis
- Fixes PHPStan level 4 issues by adding missing return type documentation
- Integrates PHPStan into GitHub Actions workflow with memory limits to handle analysis requirements
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| phpstan.neon.dist | New PHPStan configuration file setting level 4 analysis for src and tests directories |
| composer.json | Adds PHPStan dependencies and creates phpstan script with memory limit configuration |
| composer.lock | Updates lock file with PHPStan and WordPress stubs dependencies |
| src/class-posts-on-this-day-widget.php | Adds @return void and @return string|void documentation for widget methods |
| .github/workflows/lint.yml | Adds new phpstan job to run static analysis in CI with 5-minute timeout |
| .gitattributes | Adds phpstan.neon.dist to export-ignore list and reformats for consistency |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ], | ||
| "phpstan": [ | ||
| "Composer\\Config::disableProcessTimeout", | ||
| "@composer update", |
There was a problem hiding this comment.
The phpstan script includes a composer update command which may cause unexpected dependency updates during static analysis. PHPStan should run against the current dependency state without updating packages. Consider removing the "@composer update" line to avoid unintended side effects during static analysis runs.
| "@composer update", |
Changes proposed in this Pull Request:
- Linting: add PHPStan tools to analyze the codebase
A few notes:
Edit: I see I get the same fatals in the CI already, even at level 4:
Testing instructions: