summaryrefslogtreecommitdiff
path: root/Zend/tests/arg_unpack
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2016-04-16 22:33:23 +0200
committerNikita Popov <nikic@php.net>2016-04-16 22:33:23 +0200
commitd1a38743a57a7dcbeb3dbddb17e56817addcbb33 (patch)
tree5741d6628e7c20b4218c61e6895ca0928e9b9340 /Zend/tests/arg_unpack
parent15d1d4f45bea8c7f9eedf0534ffee804640baaf1 (diff)
downloadphp-git-d1a38743a57a7dcbeb3dbddb17e56817addcbb33.tar.gz
Fix SEND_UNPACK array separation
Separating only immutable arrays is not enough.
Diffstat (limited to 'Zend/tests/arg_unpack')
-rw-r--r--Zend/tests/arg_unpack/by_ref_separation.phpt36
1 files changed, 36 insertions, 0 deletions
diff --git a/Zend/tests/arg_unpack/by_ref_separation.phpt b/Zend/tests/arg_unpack/by_ref_separation.phpt
new file mode 100644
index 0000000000..b52c28168a
--- /dev/null
+++ b/Zend/tests/arg_unpack/by_ref_separation.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Array must be separated if unpacking by reference
+--FILE--
+<?php
+
+function inc(&... $args) {
+ foreach ($args as &$arg) {
+ $arg++;
+ }
+}
+
+$arr = [1, 2];
+$arr[] = 3;
+$arr2 = $arr;
+inc(...$arr);
+var_dump($arr);
+var_dump($arr2);
+
+?>
+--EXPECT--
+array(3) {
+ [0]=>
+ int(2)
+ [1]=>
+ int(3)
+ [2]=>
+ int(4)
+}
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}