Skip to content

Fix PHPStan errors with WordPress 7.1 stubs - #44

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

Fix PHPStan errors with WordPress 7.1 stubs#44
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 WP core types, which surfaced one new PHPStan error at level 9.

WP_Filesystem_Base::abspath() is now typed as string|false (it returns false when the remote root cannot be located, e.g. over FTP). Passing that straight into trailingslashit() no longer type-checks — and at runtime it would have silently produced /.maintenance. It now bails out with a proper error instead.

PHPStan is clean again with the new stubs.


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved maintenance mode status checks when the WordPress root directory cannot be determined.
    • Displays a clear error message instead of attempting to continue with an invalid path.

`WP_Filesystem_Base::abspath()` is now typed as `string|false`, so bail out
with an error instead of building a bogus `.maintenance` path.
@swissspidy
swissspidy requested a review from a team as a code owner August 29, 2026 07:57
Copilot AI lite review requested due to automatic review settings August 29, 2026 07:57

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: cac02fdf-3e88-42aa-beec-d8f8bc7ac060

📥 Commits

Reviewing files that changed from the base of the PR and between 7ce3b13 and 87e4c53.

📒 Files selected for processing (1)
  • src/MaintenanceModeCommand.php

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


📝 Walkthrough

Walkthrough

The maintenance mode status check now validates the WordPress root path before constructing the .maintenance file path. It reports an error when the filesystem cannot determine the root path.

Changes

Maintenance mode validation

Layer / File(s) Summary
Root path error handling
src/MaintenanceModeCommand.php
get_maintenance_mode_status() checks the result of $wp_filesystem->abspath() and calls WP_CLI::error() when it returns false.

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

Merge Risk: ⚪ Minimal · up to 87e4c

The command now reports an error when the WordPress root cannot be resolved instead of constructing an invalid maintenance-file path. No actionable merge-blocking risk remains after normal checks and review.

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 describes the main change: fixing 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 1 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:maintenance-mode Related to 'maintenance-mode' command command:maintenance-mode-activate Related to 'maintenance-mode activate' command labels Aug 29, 2026
@codecov

codecov Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/MaintenanceModeCommand.php 75.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@swissspidy swissspidy added this to the 3.0.1 milestone Aug 29, 2026
@swissspidy
swissspidy merged commit e1ff83b into main Aug 29, 2026
56 of 57 checks passed
@swissspidy
swissspidy deleted the fix/phpstan-wp71 branch August 29, 2026 08:03
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:maintenance-mode Related to 'maintenance-mode' command command:maintenance-mode-activate Related to 'maintenance-mode activate' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants