Skip to content

Fix PHPStan 2.4 error in Core_Command::check_update() - #362

Merged
ernilambar merged 1 commit into
mainfrom
claude/fervent-dijkstra-s7tgz3
Dec 4, 2026
Merged

ernilambar merged 1 commit into
mainfrom
claude/fervent-dijkstra-s7tgz3

Conversation

@swissspidy

@swissspidy swissspidy commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

PHPStan 2.4.0 reports a new error in Core_Command::check_update():

src/Core_Command.php:105: Elseif condition is always false. [elseif.alwaysFalse]

get_updates() resets $version_check_error to null. The property is then set by the pre_http_request and http_api_debug hooks during wp_version_check(), but PHPStan 2.4 can't see that and assumes the property is still null when check_update() reads it.

This reads the property through a small private getter instead. Behavior does not change. PHPStan 2.3.7 reported nothing here.


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Update-check warnings now display the reported error, making it clearer when a version check cannot be completed.

PHPStan 2.4 no longer sees that the version check error property can be
set by the HTTP API hooks that run during get_updates(), and reports the
elseif branch as always false. Read the property through a getter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UWTd5ovnS4Susin8tXeDDr
@coderabbitai

coderabbitai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

check_update() now obtains the version-check error through a private getter and uses the returned value in its warning branch.

Changes: Version-check error access

Layer / File(s) Summary
Add and use the error getter
src/Core_Command.php
A private getter returns the stored version-check error or null. check_update() uses the getter’s result in its warning branch.

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

Change: Refactor

Suggested reviewers: schlessera, ernilambar

Merge Risk: Minimal · up to 8239a

This change reads the version-check error through a private getter to satisfy a newer static analysis tool. Runtime behavior of the update check is unchanged, and no merge-blocking risk remains.

Security architecture risk: Minimal · up to 8239a

The core update command reads the same stored error through a private getter and keeps its existing warning behavior. No caller or operator changes are needed.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the fix (PHPStan 2.4 error) and the affected method (Core_Command::check_update()). The change adds a private getter for version_check_error and has check_update() read the error throu…
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.
Full details: Title check

Explanation

The title names the fix (PHPStan 2.4 error) and the affected method (Core_Command::check_update()). The change adds a private getter for version_check_error and has check_update() read the error through it. This matches the stated PR objective of avoiding the elseif.alwaysFalse report. The title is specific and describes the main change.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 785591be-48dc-4d14-ae75-873c62a6d18b
Commits

Reviewing files that changed from the base of the PR and between 1f93f95 and 8239adc.

Files selected for processing: 1

  • src/Core_Command.php

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

@github-actions github-actions Bot added automated-pr command:core-check-update Related to 'core check-update' command scope:testing Related to testing labels Dec 4, 2026
@codecov

codecov Bot commented Dec 4, 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 marked this pull request as ready for review December 4, 2026 12:23
@swissspidy
swissspidy requested a review from a team as a code owner December 4, 2026 12:23
Copilot AI balanced review requested due to automatic review settings December 4, 2026 12:23

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 insufficient remaining quota. Try requesting a review at a lower effort level.

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.

🟢 Approval recommended

There are no active review issues for the update-check error getter change.

No open issues 🎉

Review effort: Balanced

@ernilambar
ernilambar merged commit 5aa7e94 into main Dec 4, 2026
62 checks passed
@ernilambar
ernilambar deleted the claude/fervent-dijkstra-s7tgz3 branch December 4, 2026 12:36
@github-actions github-actions Bot added this to the 3.0.4 milestone Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated-pr command:core-check-update Related to 'core check-update' command scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants