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