Skip to content

Fix PHPStan errors - #348

Merged
swissspidy merged 1 commit into
mainfrom
fix/phpstan-errors
Oct 7, 2026
Merged

swissspidy merged 1 commit into
mainfrom
fix/phpstan-errors

Conversation

@swissspidy

@swissspidy swissspidy commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Fixes the newly reported PHPStan errors from the scheduled code quality run (https://github.com/wp-cli/core-command/actions/runs/37563662550):

src/Core_Command.php:920   Parameter #1 $filename of function is_writable expects string, string|false given.
src/Core_Command.php:1001  Parameter #1 $filename of function file_get_contents expects string, string|false given.
src/Core_Command.php:1011  Parameter #1 $filename of function file_put_contents expects string, string|false given.

Utils\locate_wp_config() returns false when no wp-config.php is found. This PR guards against that case:

  • In multisite_convert, the constants are written only if a config path was found. Otherwise the existing "could not be written" warning is shown.
  • modify_wp_config() returns false early when there is no config path.

🤖 Generated with Claude Code

https://claude.ai/code/session_014Q2gK8eSLNEQDwqibeyVJ6


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Multisite conversion now handles cases where wp-config.php cannot be located without attempting to check whether the missing file is writable. Existing configuration updates are unchanged when the file is available.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014Q2gK8eSLNEQDwqibeyVJ6
Copilot AI balanced review requested due to automatic review settings October 7, 2026 06:47
@swissspidy
swissspidy requested a review from a team as a code owner October 7, 2026 06:47

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 Oct 7, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b0f9919d-d909-4cec-96ff-ad390591027d
📥 Commits

Reviewing files that changed from the base of the PR and between ae82325 and 7eb789d.

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

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


📝 Walkthrough

Walkthrough

The config conversion flow now checks that a wp-config.php path is available before checking writability or modifying the file. modify_wp_config() returns false when no config path can be located.

Changes

wp-config path guard

Layer / File(s) Summary
Guard config path access
src/Core_Command.php
The conversion flow checks for a config path before checking writability and modifying the file. modify_wp_config() returns false when no path is available.

Priority: ⬇️ Low

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

Change: Bug fix

Suggested reviewers: schlessera

Merge Risk: ⚪ Minimal · up to 7eb78

When wp-config.php cannot be located, the command warns that the multisite constants may need to be added manually instead of attempting file I/O. No merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title, “Fix PHPStan errors,” matches the pull request’s goal of guarding against a missing wp-config.php path that caused PHPStan errors.
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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 automated-pr bug command:core Related to 'core' command command:core-multisite-convert Related to 'core multisite-convert' command labels Oct 7, 2026
@codecov

codecov Bot commented Oct 7, 2026

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Patch % Lines
src/Core_Command.php 66.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@swissspidy
swissspidy merged commit 8110d2a into main Oct 7, 2026
56 of 57 checks passed
@swissspidy
swissspidy deleted the fix/phpstan-errors branch October 7, 2026 07:02
@swissspidy swissspidy added this to the 3.0.2 milestone Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated-pr bug command:core Related to 'core' command command:core-multisite-convert Related to 'core multisite-convert' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants