Permalink
Browse files

Merge branch 'PHP-5.6'

  • Loading branch information...
2 parents 45ec37f + 96d0bb7 commit bfd967c11f040e4cf8eaa11c103ea29c8aad7905 @nikic nikic committed Feb 26, 2014
@@ -30,12 +30,12 @@ test(...getArray([1, 2, 3]));
test(...arrayGen([]));
test(...arrayGen([1, 2, 3]));
-test(1, ...[2, 3], ...[4, 5], 6);
-test(1, ...getArray([2, 3]), ...arrayGen([4, 5]), 6);
+test(1, ...[2, 3], ...[4, 5]);
+test(1, ...getArray([2, 3]), ...arrayGen([4, 5]));
test2(...[1, 2]);
test2(...[1, 2, 3]);
-test2(...[1], ...[], ...[], ...[2, 3], 4, ...[5, 6]);
+test2(...[1], ...[], ...[], ...[2, 3], ...[4, 5]);
?>
--EXPECT--
@@ -75,7 +75,7 @@ array(3) {
[2]=>
int(3)
}
-array(6) {
+array(5) {
[0]=>
int(1)
[1]=>
@@ -86,10 +86,8 @@ array(6) {
int(4)
[4]=>
int(5)
- [5]=>
- int(6)
}
-array(6) {
+array(5) {
[0]=>
int(1)
[1]=>
@@ -100,8 +98,6 @@ array(6) {
int(4)
[4]=>
int(5)
- [5]=>
- int(6)
}
int(1)
int(2)
@@ -17,46 +17,37 @@ $array = [1, 2, 3];
test1(...$array);
var_dump($array);
-$array1 = [1, 2]; $val2 = 3; $array2 = [4, 5];
-test1(...$array1, $val2, ...$array2);
-var_dump($array1, $val2, $array2);
+$array1 = [1, 2]; $array2 = [3, 4];
+test1(...$array1, ...$array2);
+var_dump($array1, $array2);
function test2($val1, &$ref1, $val2, &$ref2) {
$ref1++;
$ref2++;
}
-$array = [1, 2, 3, 4];
+$array = [0, 0, 0, 0];
test2(...$array);
var_dump($array);
-$a = $b = $c = $d = 0;
+$array1 = [1, 2]; $array2 = [4, 5];
+test1(...$array1, ...$array2);
+var_dump($array1, $array2);
-$array = [];
-test2(...$array, $a, $b, $c, $d);
-var_dump($array, $a, $b, $c, $d);
+$a = $b = $c = $d = 0;
+$array = [0, 0, 0, 0];
-$array = [1];
-test2(...$array, $a, $b, $c, $d);
-var_dump($array, $a, $b, $c, $d);
+test2($a, ...$array);
+var_dump($a, $array);
-$array = [1, 2];
-test2(...$array, $a, $b, $c, $d);
-var_dump($array, $a, $b, $c, $d);
+test2($a, $b, ...$array);
+var_dump($a, $b, $array);
-$array = [1, 2, 3];
-test2(...$array, $a, $b, $c, $d);
-var_dump($array, $a, $b, $c, $d);
+test2($a, $b, $c, ...$array);
+var_dump($a, $b, $c, $array);
-$vars = [];
-$array = [];
-test2(...$array, $vars['a'], $vars['b'], $vars['c'], $vars['d']);
-var_dump($vars);
-
-$vars = [];
-$array = [1];
-test2(...$array, $vars['a'], $vars['b'], $vars['c'], $vars['d']);
-var_dump($vars);
+test2($a, $b, $c, $d, ...$array);
+var_dump($a, $b, $c, $d, $array);
?>
--EXPECTF--
@@ -74,76 +65,81 @@ array(2) {
[1]=>
int(3)
}
-int(4)
array(2) {
[0]=>
- int(5)
+ int(4)
[1]=>
- int(6)
+ int(5)
}
array(4) {
[0]=>
- int(1)
+ int(0)
[1]=>
- int(3)
+ int(1)
[2]=>
- int(3)
+ int(0)
[3]=>
- int(5)
-}
-array(0) {
+ int(1)
}
-int(0)
-int(1)
-int(0)
-int(1)
-array(1) {
+array(2) {
[0]=>
- int(1)
+ int(2)
+ [1]=>
+ int(3)
}
-int(1)
-int(1)
-int(1)
-int(1)
array(2) {
+ [0]=>
+ int(5)
+ [1]=>
+ int(6)
+}
+int(0)
+array(4) {
[0]=>
int(1)
[1]=>
- int(3)
+ int(0)
+ [2]=>
+ int(1)
+ [3]=>
+ int(0)
}
+int(0)
int(1)
-int(2)
-int(1)
-int(1)
-array(3) {
+array(4) {
[0]=>
int(1)
[1]=>
- int(3)
+ int(1)
[2]=>
- int(3)
+ int(1)
+ [3]=>
+ int(0)
}
+int(0)
int(2)
-int(2)
-int(1)
-int(1)
-
-Notice: Undefined index: a in %s on line %d
-
-Notice: Undefined index: c in %s on line %d
-array(2) {
- ["b"]=>
+int(0)
+array(4) {
+ [0]=>
+ int(2)
+ [1]=>
int(1)
- ["d"]=>
+ [2]=>
int(1)
+ [3]=>
+ int(0)
}
-
-Notice: Undefined index: b in %s on line %d
-
-Notice: Undefined index: d in %s on line %d
-array(2) {
- ["a"]=>
+int(0)
+int(3)
+int(0)
+int(1)
+array(4) {
+ [0]=>
+ int(2)
+ [1]=>
int(1)
- ["c"]=>
+ [2]=>
int(1)
+ [3]=>
+ int(0)
}
@@ -9,7 +9,7 @@ $fn = function(...$args) {
$fn(...[]);
$fn(...[1, 2, 3]);
-$fn(1, ...[2, 3], ...[], 4, 5);
+$fn(1, ...[2, 3], ...[], ...[4, 5]);
?>
--EXPECT--
@@ -12,7 +12,7 @@ test(...42);
test(...new stdClass);
test(1, 2, 3, ..."foo", ...[4, 5]);
-test(1, 2, ...new StdClass, 3, ...3.14, ...[4, 5]);
+test(1, 2, 3, ...new StdClass, ...3.14, ...[4, 5]);
?>
--EXPECTF--
@@ -14,8 +14,7 @@ class Foo {
}
$foo = new Foo;
-$foo->test(...[1, 2], 3, 4, ...[], 5);
-Foo::test2(1, 2, ...[3, 4], ...[], 5);
+Foo::test2(1, 2, ...[3, 4], ...[], ...[5]);
?>
--EXPECT--
@@ -31,15 +30,3 @@ array(5) {
[4]=>
int(5)
}
-array(5) {
- [0]=>
- int(1)
- [1]=>
- int(2)
- [2]=>
- int(3)
- [3]=>
- int(4)
- [4]=>
- int(5)
-}
@@ -11,7 +11,7 @@ class Foo {
new Foo(...[]);
new Foo(...[1, 2, 3]);
-new Foo(...[1], 2, ...[], ...[3, 4], 5);
+new Foo(...[1], ...[], ...[2, 3]);
?>
--EXPECT--
@@ -25,15 +25,11 @@ array(3) {
[2]=>
int(3)
}
-array(5) {
+array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
- [3]=>
- int(4)
- [4]=>
- int(5)
}
@@ -0,0 +1,10 @@
+--TEST--
+Positional arguments cannot be used after argument unpacking
+--FILE--
+<?php
+
+var_dump(...[1, 2, 3], 4);
+
+?>
+--EXPECTF--
+Fatal error: Cannot use positional argument after argument unpacking in %s on line %d
@@ -20,11 +20,11 @@ function gen() {
}
try {
- test(1, 2, ...new Foo, 3, 4);
+ test(1, 2, ...new Foo, ...[3, 4]);
} catch (Exception $e) { var_dump($e->getMessage()); }
try {
- test(1, 2, ...gen(), 3, 4);
+ test(1, 2, ...gen(), ...[3, 4]);
} catch (Exception $e) { var_dump($e->getMessage()); }
?>
@@ -13,8 +13,6 @@ function gen($array) {
}
}
-test(...gen([1, 2, 3]), $a);
-var_dump($a);
test(1, 2, 3, $b, ...gen([4, 5, 6]));
var_dump($b);
@@ -25,7 +23,6 @@ test(...gen([1, 2]), ...gen([3, 4]));
?>
--EXPECTF--
int(42)
-int(42)
Warning: Cannot pass by-reference argument 4 of test() by unpacking a Traversable, passing by-value instead in %s on line %d
Oops, something went wrong.

0 comments on commit bfd967c

Please sign in to comment.