1--TEST-- 2Array must be separated if unpacking by reference 3--FILE-- 4<?php 5 6function inc(&... $args) { 7 foreach ($args as &$arg) { 8 $arg++; 9 } 10} 11 12$arr = [1, 2]; 13$arr[] = 3; 14$arr2 = $arr; 15inc(...$arr); 16var_dump($arr); 17var_dump($arr2); 18 19?> 20--EXPECT-- 21array(3) { 22 [0]=> 23 int(2) 24 [1]=> 25 int(3) 26 [2]=> 27 int(4) 28} 29array(3) { 30 [0]=> 31 int(1) 32 [1]=> 33 int(2) 34 [2]=> 35 int(3) 36} 37