Skip to content

Fix PHPStan errors with WordPress 7.1 stubs - #29

Merged
swissspidy merged 1 commit into
mainfrom
fix/phpstan-wp71
Aug 29, 2026
Merged

Fix PHPStan errors with WordPress 7.1 stubs#29
swissspidy merged 1 commit into
mainfrom
fix/phpstan-wp71

Conversation

@swissspidy

@swissspidy swissspidy commented Aug 29, 2026

Copy link
Copy Markdown
Member

php-stubs/wordpress-stubs v7.1.0 tightened the WP core types, which made PHPStan fail on main.

  • wp_supports_ai(), wp_ai_client_prompt(), wp_get_connector(), wp_get_connectors() and the WordPress\AiClient DTOs are now declared, so the @phpstan-ignore function.notFound / class.notFound comments no longer match anything and are removed.
  • wp_ai_client_prompt() declares a native WP_AI_Client_Prompt_Builder return type and never returns a WP_Error (only the generating methods do), so the unreachable is_wp_error( $builder ) guards are dropped.
  • The prompt builder params/returns were documented as \WordPress\AI_Client\Builders\Prompt_Builder, a class that does not exist; they now use \WP_AI_Client_Prompt_Builder, which also removes the mixed return types on the image input helpers.

No baseline entries or new ignores. composer phpstan and composer phpcs pass locally.


Generated by Claude Code

Summary by CodeRabbit

  • Refactor
    • Improved code quality and static analysis coverage across AI generation and connector functionality.
    • Updated internal type documentation for prompt-building operations.
    • Removed obsolete error-handling and analysis-suppression annotations without changing user-facing behavior.

The WordPress 7.1 stubs now declare the AI and connector functions, so the
`@phpstan-ignore` comments are obsolete and the prompt builder can be typed
as `WP_AI_Client_Prompt_Builder`.
Copilot AI lite review requested due to automatic review settings August 29, 2026 08:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 63bc69b6-3077-46b1-bbe6-6237f93ad511

📥 Commits

Reviewing files that changed from the base of the PR and between 2fe73b7 and f545412.

📒 Files selected for processing (2)
  • src/AI_Command.php
  • src/Connectors_Command.php
💤 Files with no reviewable changes (1)
  • src/Connectors_Command.php

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The change removes PHPStan suppression comments from AI and connector command methods. It updates AI prompt builder docblock types, removes prompt builder error checks, and keeps connector command runtime logic unchanged.

Changes

Command static analysis cleanup

Layer / File(s) Summary
AI command checks and builder types
src/AI_Command.php
AI command methods remove PHPStan suppressions, remove is_wp_error() checks on prompt builders, and use \WP_AI_Client_Prompt_Builder in docblocks.
Connector command suppressions
src/Connectors_Command.php
The list_() and get() methods remove PHPStan suppressions. Runtime logic is unchanged.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to f5454

This change updates PHPStan annotations and removes unreachable error checks to match WordPress 7.1 declarations without changing deployment behavior or external contracts. No actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: updating the codebase to resolve PHPStan errors caused by the WordPress 7.1 stubs.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 1 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/phpstan-wp71

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added bug Something isn't working command:ai Related to 'ai' command scope:testing Related to testing labels Aug 29, 2026
@codecov

codecov Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@swissspidy swissspidy added this to the 1.0.3 milestone Aug 29, 2026
@swissspidy
swissspidy merged commit 420bd11 into main Aug 29, 2026
52 checks passed
@swissspidy
swissspidy deleted the fix/phpstan-wp71 branch August 29, 2026 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working command:ai Related to 'ai' command scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants