1.2.1144. 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.1144.1. Connex PHP features¶
1.2.1144.1.1. Specs¶
Short name |
Php/SpreadOperatorForArray |
Rulesets |
|
Exakat since |
1.9.4 |
PHP Version |
With PHP 7.4 and more recent |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Available in |