Skip to content

Fix PHPStan errors with WordPress 7.1 stubs - #544

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

Fix PHPStan errors with WordPress 7.1 stubs#544
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. WP_Theme::get() now resolves to string|false for the known headers, which surfaced three new PHPStan errors where those values were passed straight into string parameters.

  • ExtensionUpgraderSkin::before(): guard the theme name before html_entity_decode(), mirroring the existing isset() check on the plugin branch.
  • ParseThemeNameInput::get_all_themes(): guard the theme description before wordwrap(), falling back to an empty string.

PHPStan is clean again; no behaviour change (wordwrap( false ) already produced an empty string).


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved theme update messages by omitting incomplete notices when a theme name is unavailable.
    • Prevented errors when processing themes without descriptions.
    • Ensured missing theme descriptions are handled cleanly in displayed theme information.

`WP_Theme::get()` is now typed as returning `string|false`, so guard the
header values before passing them to `html_entity_decode()`/`wordwrap()`.
@swissspidy
swissspidy requested a review from a team as a code owner August 29, 2026 07:58
Copilot AI lite review requested due to automatic review settings August 29, 2026 07:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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: 9dd31359-e897-4d49-8588-8a9323d42a66

📥 Commits

Reviewing files that changed from the base of the PR and between fc7965d and 7ef2b92.

📒 Files selected for processing (2)
  • src/WP_CLI/ExtensionUpgraderSkin.php
  • src/WP_CLI/ParseThemeNameInput.php

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


📝 Walkthrough

Walkthrough

The theme upgrader now skips update messages when the theme name is unavailable. Theme parsing now handles missing descriptions without calling wordwrap() on a false value.

Changes

Theme metadata handling

Layer / File(s) Summary
Guard missing theme metadata
src/WP_CLI/ExtensionUpgraderSkin.php, src/WP_CLI/ParseThemeNameInput.php
The upgrader caches the theme name and logs only when it is not false. The parser caches the description and returns an empty string when it is false.

Estimated code review effort: 2 (Simple) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 7ef2b

The change safely handles missing theme metadata before existing string operations without changing intended behavior, and no actionable merge-blocking risk remains.

Suggested reviewers: brianhenryie

🚥 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: fixing PHPStan errors caused by 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 2 functions across 2 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.

@swissspidy swissspidy added this to the 3.0.1 milestone 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 merged commit d02a92c into main Aug 29, 2026
57 checks passed
@swissspidy
swissspidy deleted the fix/phpstan-wp71 branch August 29, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants