Skip to content

[TypeDeclaration] Skip non-array and template items on AddArrowFunctionParamArrayWhereDimFetchRector - #9074

Merged
TomasVotruba merged 1 commit into
mainfrom
fix/arrow-fn-array-param-non-array-items
Nov 26, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
fix/arrow-fn-array-param-non-array-items

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Follow-up to #9073. The rule still added array when items were known non-arrays or unbounded templates, causing a TypeError at runtime:

/** @param array<int, string> $items */
array_map(fn ($item) => $item[0], $items);
// became: fn (array $item) => ...

/** @template T @param array<int, T> $items */
array_map(fn ($item) => $item['id'], $items);
// became: fn (array $item) => ...

Fix: skip unless the item type is always an array. Plain mixed items are still typed as before; template types (which extend MixedType) are now skipped.

Added fixtures: skip_string_items.php.inc, skip_template_items.php.inc.

@TomasVotruba
TomasVotruba merged commit eef8017 into main Nov 26, 2026
51 checks passed
@TomasVotruba
TomasVotruba deleted the fix/arrow-fn-array-param-non-array-items branch November 26, 2026 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant