Skip to content

Commit 0e3e3ec

Browse files
committed
Merge branch 'PHP-7.1'
* PHP-7.1: Added tests and NEWS entry Fixed bug #72598 (Reference is lost after array_slice())
2 parents c1e0c66 + 62ab40b commit 0e3e3ec

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

Zend/tests/bug72598.phpt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Bug #72598 (Reference is lost after array_slice())
3+
--FILE--
4+
<?php
5+
function ref(&$ref) {
6+
var_dump($ref);
7+
}
8+
9+
new class {
10+
function __construct() {
11+
$args = [&$this];
12+
for ($i = 0; $i < 2; $i++) {
13+
$a = array_slice($args, 0, 1);
14+
call_user_func_array('ref', $a);
15+
}
16+
}
17+
};
18+
?>
19+
--EXPECTF--
20+
Warning: Parameter 1 to ref() expected to be a reference, value given in %sbug72598.php on line 11
21+
object(class@anonymous)#1 (0) {
22+
}
23+
24+
Warning: Parameter 1 to ref() expected to be a reference, value given in %sbug72598.php on line 11
25+
object(class@anonymous)#1 (0) {
26+
}

Zend/tests/bug72598_2.phpt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
Bug #72598.2 (Reference is lost after array_slice())
3+
--FILE--
4+
<?php
5+
function ref(&$ref) {
6+
var_dump($ref);
7+
$ref = 1;
8+
}
9+
10+
new class {
11+
function __construct() {
12+
$b = 0;
13+
$args = [&$b];
14+
unset($b);
15+
for ($i = 0; $i < 2; $i++) {
16+
$a = array_slice($args, 0, 1);
17+
call_user_func_array('ref', $a);
18+
}
19+
}
20+
};
21+
?>
22+
--EXPECTF--
23+
Warning: Parameter 1 to ref() expected to be a reference, value given in %sbug72598_2.php on line 14
24+
int(0)
25+
26+
Warning: Parameter 1 to ref() expected to be a reference, value given in %sbug72598_2.php on line 14
27+
int(0)

0 commit comments

Comments
 (0)