dev: Update Composer deps and remediate PHPStan smells - #777
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the project’s PHP dev toolchain (Composer/PHPStan-related dependencies and stubs) and adjusts code annotations/config so PHPStan passes cleanly against the newer stubs (notably WP 7.0-era definitions), while keeping analysis scoped appropriately.
Changes:
- Bump Composer dev dependencies (including
php-stubs/wordpress-stubs@7.0via an alias) and update the lockfile accordingly. - Simplify
phpstan.neon.distby removing now-unnecessaryignoreErrors/excludePathsentries. - Add targeted inline PHPStan suppressions and refine PHPDoc types/array-shapes where newer stubs expose mismatches.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| phpstan.neon.dist | Removes no-longer-needed ignores/exclusions after stub updates. |
| includes/Services/AI_Service.php | Adds inline PHPStan ignore around model config usage for stub/type mismatches. |
| includes/REST/Models_Controller.php | Adds inline PHPStan ignores and var annotations for AI Client model/provider metadata handling. |
| includes/Logging/REST/AI_Request_Log_Controller.php | Adds property annotations for REST controller namespace/base to satisfy static analysis. |
| includes/helpers.php | Adds/adjusts var annotations and ignores around provider/model capability inspection. |
| includes/Contracts/Feature.php | Tightens get_id() PHPDoc to indicate lowercase feature IDs. |
| includes/Asset_Loader.php | Adds inline PHPStan ignore for wp_enqueue_script() dependencies typing mismatch. |
| includes/Admin/Dashboard/AI_Capabilities_Widget.php | Adds var annotations/ignores while enumerating provider capabilities. |
| includes/Abstracts/Abstract_Feature.php | Tightens $id PHPDoc to lowercase-string intersection type. |
| includes/Abstracts/Abstract_Ability.php | Adds inline PHPStan ignore around provider model selection call. |
| includes/Abilities/Image/Generate_Image.php | Refines return array-shape PHPDoc and adds inline PHPStan ignores for AI Client SDK typing. |
| composer.lock | Updates locked versions/hashes and records the wordpress-stubs alias. |
| composer.json | Adds direct wordpress-stubs alias dependency, bumps wp-phpunit, and increases PHPStan memory limit. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #777 +/- ##
==========================================
Coverage 76.50% 76.51%
Complexity 1868 1868
==========================================
Files 89 89
Lines 7985 7987 +2
==========================================
+ Hits 6109 6111 +2
Misses 1876 1876
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@justlevine is this still in progress or can it come out of draft for review? |
|
Per WordPress/php-ai-client#257 (comment), the FQCN bug has been patched upstream, so wordpress-stubs will be fixed when 7.1 generates. I think that changes the math here, and I should move the ignores out of the file and into |
That makes sense to me 👍🏻 |
|
@justlevine heads up that I'm punting this to the next release, so you've got some time (especially to see what lands in WP 7.1 beta 1) before this ideally gets wrapped up |
What?
Bumps Composer deps to their latest versions, and remediates the resulting PHPStan errors.
More specifically, it makes
php-stubs/wordpress-stubs@7.0a direct dependency aliased to WP 6.9.4, and then adds various inline ignores, where issues with the lack of FQCN cause type mismatches.Now-unnecessary ignores have been removed from the PHPStan config.
Why?
Broadly, it's better to use the latest stubs - and suppress the type errors - than outdated ones, and type-hinting with inline-ignore annotations for improper hints are better than
ignoreErrorsbecause it allows the rest of the related code to still be typehinted correctly.While Adjust
php-stubs/wordpress-stubsdependency range so 7.0 can be used php-stubs/wp-cli-stubs#24 fixed the use of SemVer to allow v7.x, releases are tied to WP-CLI and therefore it hasn't hit downstream. Aliasing to 6.9.4 solves this temporarily.How?
Use of AI Tools
None.
Testing Instructions
Screenshots or screencast
Changelog Entry