Fix PHPStan errors with WordPress 7.1 stubs - #257
Conversation
`WP_Query::$posts` is now nullable and `wp_get_attachment_metadata()` returns a precise array shape where `sizes` is optional.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe media commands now validate query post results before processing them and iterate over local post arrays. The attachment metadata docblock now allows an optional ChangesMedia command updates
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change only adds safe handling for WordPress query results and updates a metadata type annotation, with no intended runtime or interface change. No actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
php-stubs/wordpress-stubsv7.1.0 tightened a couple of WP core types, which surfaced four new PHPStan errors:WP_Query::$postsis nowWP_Post[]|int[]|null. The threeforeach ( $images->posts ... )loops now read the property into a local and include it in the existing "No images found." guard.wp_get_attachment_metadata()now returns a precise array shape in whichsizesis optional, so the@paramofMedia_Command::update_attachment_metadata_for_image_size()was corrected toarray{sizes?: array<string, mixed>}|false.No runtime behaviour change.
composer phpstanandphpcsare clean.Generated by Claude Code
Summary by CodeRabbit
Bug Fixes
Documentation