Skip to content

Fix newly reported PHPStan errors - #634

Open
swissspidy wants to merge 2 commits into
mainfrom
fix/phpstan
Open

Fix newly reported PHPStan errors#634
swissspidy wants to merge 2 commits into
mainfrom
fix/phpstan

Conversation

@swissspidy

@swissspidy swissspidy commented Aug 6, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Documentation
    • Added inline type documentation for category data and metadata values.
    • Clarified the supported data formats without changing runtime behavior.

Copilot AI lite review requested due to automatic review settings August 6, 2026 09:03
@swissspidy
swissspidy requested a review from a team as a code owner August 6, 2026 09:03
@swissspidy swissspidy added the scope:testing Related to testing label Aug 6, 2026
@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

Pull request overview

This PR addresses newly reported PHPStan type errors by adding local PHPDoc @var annotations in WP-CLI command implementations to help static analysis understand variable shapes during runtime-validated flows.

Changes:

  • Added an inline @var annotation for $meta_value in CommandWithMeta::add() before passing the value into WP_CLI::read_value().
  • Added an inline @var annotation for $categories in Font_Collection_Command::list_categories() before passing data to the Formatter.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/WP_CLI/CommandWithMeta.php Adds a local PHPDoc type hint to clarify the expected $meta_value type for PHPStan.
src/Font_Collection_Command.php Adds a local PHPDoc type hint for $categories to satisfy PHPStan before formatting output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/WP_CLI/CommandWithMeta.php Outdated
list( $object_id, $meta_key ) = $args;

$meta_value = WP_CLI::get_value_from_arg_or_stdin( $args, 2 );
/** @var array<mixed>|string $meta_value */
Comment thread src/Font_Collection_Command.php Outdated

$fields = [ 'slug', 'name' ];
$formatter = new Formatter( $assoc_args, $fields, 'category' );
/** @var array<int, array<string, mixed>> $categories */
@coderabbitai

coderabbitai Bot commented Aug 6, 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: 5b2e97a2-6976-4cf3-907d-d89e60c8129c

📥 Commits

Reviewing files that changed from the base of the PR and between 6e4ff59 and d11edb5.

📒 Files selected for processing (2)
  • src/Font_Collection_Command.php
  • src/WP_CLI/CommandWithMeta.php
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/WP_CLI/CommandWithMeta.php
  • src/Font_Collection_Command.php

📝 Walkthrough

Walkthrough

The pull request adds PHPDoc annotations for category data and metadata values in two PHP command implementations. Runtime behavior remains unchanged.

Changes

Type Documentation

Layer / File(s) Summary
Add local variable annotations
src/Font_Collection_Command.php, src/WP_CLI/CommandWithMeta.php
The code documents $categories as an indexed array of string-keyed arrays and $meta_value as `array

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

🚥 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 and concisely describes the PHPDoc changes made to address newly reported PHPStan errors.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants