Skip to content

Fix PHPStan errors - #253

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 error from the scheduled code quality run (https://github.com/wp-cli/package-command/actions/runs/37563545559):

src/Package_Command.php:1754  Anonymous function has an unused use $error_array.  (closure.unusedUse)

The shutdown closure imported a dummy $error_array "to preallocate memory", but it immediately overwrote it with error_get_last(). Because the new value is created before the old one is freed, the preallocation never saved any memory. This PR removes the dummy array and drops it from the use list.

🤖 Generated with Claude Code

https://claude.ai/code/session_014Q2gK8eSLNEQDwqibeyVJ6


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Shutdown error handling continues to check for memory-limit errors without relying on a preallocated placeholder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014Q2gK8eSLNEQDwqibeyVJ6
@swissspidy
swissspidy requested a review from a team as a code owner October 7, 2026 06:47
Copilot AI balanced review requested due to automatic review settings 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: 8071444f-5a5d-411b-9793-689bcdab483a
📥 Commits

Reviewing files that changed from the base of the PR and between 2341b28 and 2e32c00.

📒 Files selected for processing (1)
  • src/Package_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 shutdown callback no longer captures a preallocated error array. It still obtains the last error with error_get_last() and checks for the memory-limit message.

Changes

Shutdown callback

Layer / File(s) Summary
Remove unused error array capture
src/Package_Command.php
The callback no longer captures the preallocated error array. It continues to assign error_get_last() locally.

Priority: ⬇️ Low

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

Change: Other

Suggested reviewers: schlessera

Merge Risk: ⚪ Minimal · up to 2e32c

The change removes an unused allocation while preserving the shutdown callback’s revert and memory-limit diagnostic behavior. No actionable merge risk remains.

🚥 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 states the main purpose: fixing PHPStan errors caused by the unused closure capture.
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
  • 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:package Related to 'package' command labels Oct 7, 2026
@codecov

codecov Bot commented Oct 7, 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 3.0.2 milestone Oct 7, 2026
@swissspidy
swissspidy merged commit e68a413 into main Oct 7, 2026
65 checks passed
@swissspidy
swissspidy deleted the fix/phpstan-errors branch October 7, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated-pr bug command:package Related to 'package' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants