1.2.1135. Spread Operator For Array

The variadic operator may be used with arrays. This has been introduced in PHP 7.4.

list() is not allowed to use this operator, as list() expected variables, not values.

<?php

$array = [1, 2, 3];
$extended_array = [...$array, 4, 5, 6];

// invalid syntax
[...$a] = [1,2,3];

?>

See also Spread Operator in Array Expression.

1.2.1135.1. Specs

Short name

Php/SpreadOperatorForArray

Rulesets

All, Appinfo, CE

Exakat since

1.9.4

PHP Version

With PHP 7.4 and more recent

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

High

Features

variadic

Available in

Entreprise Edition, Community Edition, Exakat Cloud