Skip to content

Skip constant expressions and evaluate spread call once on DowngradeArraySpreadRector - #426

Merged
TomasVotruba merged 1 commit into
mainfrom
downgrade-array-spread-const-expr
Dec 2, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
downgrade-array-spread-const-expr

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Two fixes:

  1. A spread that cannot be inlined in a class constant, property default or param default became array_merge(), which is a fatal error there ("Constant expression contains invalid operations"):
private const ITEMS = array_merge(self::USES_SELF); // fatal

Such arrays are now skipped (on_class_constant_not_movable became skip_on_class_constant_not_movable, plus a property/param default skip fixture).

  1. A spread call of unknown type was called twice (is_array($this->get()) ? $this->get() : iterator_to_array($this->get())). The result is now assigned once:
is_array($items = $this->get()) ? $items : iterator_to_array($items)

@TomasVotruba
TomasVotruba force-pushed the downgrade-array-spread-const-expr branch from 3172c03 to ab92732 Compare December 2, 2026 11:02
@TomasVotruba
TomasVotruba force-pushed the downgrade-array-spread-const-expr branch from ab92732 to 03ffa6c Compare December 2, 2026 11:05
@TomasVotruba
TomasVotruba enabled auto-merge (squash) December 2, 2026 11:05
@TomasVotruba
TomasVotruba merged commit 6fc56ee into main Dec 2, 2026
9 checks passed
@TomasVotruba
TomasVotruba deleted the downgrade-array-spread-const-expr branch December 2, 2026 11:05
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