Skip to content

Fix PHPStan error when unpacking mapped sources in make-json - #508

Merged
swissspidy merged 1 commit into
mainfrom
fix-phpstan-2.3-errors
Oct 6, 2026
Merged

swissspidy merged 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/MakeJsonCommand.php
  346  Only iterables can be unpacked, mixed given in argument #2.

In reference_map(), the mapped values come from a array<string, mixed> map, so array_push( $references, ...$sources ) could be handed a non-iterable. The loop previously only skipped null; it now skips anything that isn't an array, which still covers the null case.

Verified locally with PHPStan 2.3.0: composer phpstan reports no errors; composer phpunit passes (62 tests).

🤖 Generated with Claude Code

https://claude.ai/code/session_01HsH4o5pKmm1Qd5cqwAm7vB


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Mapping values that aren’t in the expected format are now handled like missing mappings, preventing them from being processed as valid references. This makes reference handling more consistent when mapping data is incomplete or contains unexpected values.

Only unpack mapped sources that are actually arrays.

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
Contributor

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: 3913b644-2a89-46a9-b6f5-09b016d1be70
📥 Commits

Reviewing files that changed from the base of the PR and between 2f8df3f and 72a1e5d.

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

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


📝 Walkthrough

Walkthrough

reference_map() now skips mapped values that are not arrays. This replaces the previous check for null.

Changes

Reference Mapping

Layer / File(s) Summary
Skip non-array mappings
src/MakeJsonCommand.php
reference_map() skips mapped values that are not arrays before the subsequent spread operation.

Priority: ⬇️ Low

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

Change: Bug fix

Suggested reviewers: schlessera

Merge Risk: ⚪ Minimal · up to 72a1e

Valid mappings remain intact, while invalid values are skipped before unpacking. No material 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 PHPStan issue and the affected make-json behavior. It matches the main change in the pull request.
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:i18n-make-json Related to 'i18n make-json' 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!

@swissspidy
swissspidy merged commit 24380c5 into main Oct 6, 2026
65 checks passed
@swissspidy
swissspidy deleted the fix-phpstan-2.3-errors branch October 6, 2026 08:09
@swissspidy swissspidy added this to the 3.0.2 milestone 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:i18n-make-json Related to 'i18n make-json' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants