Skip to content

Fix PHPStan errors for optional embed provider match flags - #99

Closed
swissspidy wants to merge 1 commit into
mainfrom
fix-phpstan-2.3-errors
Closed

swissspidy wants to merge 1 commit into
mainfrom
fix-phpstan-2.3-errors

Conversation

@swissspidy

@swissspidy swissspidy commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Fixes the PHPStan job failing on main (run):

src/Provider_Command.php
  158  Strict comparison using !== between null and mixed will always evaluate to true.
  160  Strict comparison using !== between null and mixed will always evaluate to true.

The get_flag_value() return type extension from wp-cli-tests resolves the type from the $assoc_args array shape but ignores that 'limit-response-size'? and 'link-type'? are optional keys, so it drops null from the result.

This reads the two flags with $assoc_args[ ... ] ?? null instead, which is exactly what get_flag_value() does internally (isset() ? value : default), so there is no behavior change. The underlying extension issue should also be fixed in wp-cli-tests.

Verified locally with PHPStan 2.3.0: composer phpstan reports no errors; composer phpcs passes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HsH4o5pKmm1Qd5cqwAm7vB


Generated by Claude Code

Summary by CodeRabbit

  • Refactor
    • Streamlined how the command reads response-size and link-type options. Supplied values and fallback defaults remain in effect, while discovery compatibility checks and subsequent option handling are unchanged. No changes to the command’s user-facing capabilities are noted.

Read the optional `limit-response-size` and `link-type` flags directly
so PHPStan knows they can be null.

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

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 6, 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: 9af71a0a-030f-41c7-86c3-3eef2075acbf
📥 Commits

Reviewing files that changed from the base of the PR and between a14f218 and 2e85cae.

📒 Files selected for processing (1)
  • src/Provider_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

match_provider now reads limit-response-size and link-type directly from $assoc_args. Both values default to null when missing or null. Discovery compatibility checks and later option handling remain unchanged.

Changes

Provider option handling

Layer / File(s) Summary
Read provider options
src/Provider_Command.php
match_provider reads limit-response-size and link-type from $assoc_args with null-coalescing defaults instead of using Utils::get_flag_value.

Priority: ⬇️ Low

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

Change: Refactor

Suggested reviewers: ernilambar

Merge Risk: ⚪ Minimal · up to 2e85c

The optional provider flags retain their null defaults in the inspected WP-CLI implementation. No actionable merge-blocking risk is established by this change.

🚥 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 for optional embed provider match flags.
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:embed-provider-match Related to 'embed provider match' command labels Oct 6, 2026
@codecov

codecov Bot commented Oct 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Member Author

Closing in favour of fixing the root cause in the get_flag_value() PHPStan extension: wp-cli/wp-cli-tests#368. With that change, this package's existing code analyses cleanly, so no change is needed here.


Generated by Claude Code

@swissspidy swissspidy closed this Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated-pr bug command:embed-provider-match Related to 'embed provider match' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants