xref: /PHP-8.1/ext/standard/tests/array/bug39576.phpt (revision dadb92ea)
1--TEST--
2Bug #39576 (array_walk() doesn't separate userdata zval)
3--FILE--
4<?php
5
6class Test {
7
8    public $_table = '';
9    public $_columns = array ();
10    public $_primary = array ();
11
12}
13
14$test = new Test ();
15$test->name = 'test';
16$test->_columns['name'] = new stdClass;
17
18function test ($value, $column, &$columns) {}
19
20array_walk (
21    get_object_vars ($test),
22    'test',
23    $test->_columns
24);
25
26var_dump($test);
27
28array_intersect_key (
29    get_object_vars ($test),
30    $test->_primary
31);
32
33echo "Done\n";
34?>
35--EXPECTF--
36Notice: Only variables should be passed by reference in %s on line %d
37
38Warning: test(): Argument #3 ($columns) must be passed by reference, value given in %s on line %d
39
40Warning: test(): Argument #3 ($columns) must be passed by reference, value given in %s on line %d
41
42Warning: test(): Argument #3 ($columns) must be passed by reference, value given in %s on line %d
43
44Warning: test(): Argument #3 ($columns) must be passed by reference, value given in %s on line %d
45object(Test)#%d (4) {
46  ["_table"]=>
47  string(0) ""
48  ["_columns"]=>
49  array(1) {
50    ["name"]=>
51    object(stdClass)#%d (0) {
52    }
53  }
54  ["_primary"]=>
55  array(0) {
56  }
57  ["name"]=>
58  string(4) "test"
59}
60Done
61