<?php
class Wrapper
{
public function foo (&...$args) {
return $this->dostuff(...$args);
}
public function dostuff($param1, $param2, &$arr) {
$arr[] = $param1;
$arr[] = $param2;
return count($arr);
}
}
$values = [1,2];
$a=3;
$b=4;
$obj = new Wrapper();
#all parameter must be variables here because there are by ref now
$count = $obj->foo($a,$b, $values);
echo "Elements count: $count\r\n";
print_r($values); //Expected [1,2,3,4]