xref: /PHP-8.2/Zend/tests/bug72598.phpt (revision 960318ed)
1--TEST--
2Bug #72598 (Reference is lost after array_slice())
3--FILE--
4<?php
5function ref(&$ref) {
6    var_dump($ref);
7}
8
9new 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--
20Warning: ref(): Argument #1 ($ref) must be passed by reference, value given in %s on line %d
21object(class@anonymous)#1 (0) {
22}
23
24Warning: ref(): Argument #1 ($ref) must be passed by reference, value given in %s on line %d
25object(class@anonymous)#1 (0) {
26}
27