xref: /PHP-7.0/Zend/tests/bug70547.phpt (revision de66e80d)
1--TEST--
2Bug #70547 (unsetting function variables corrupts backtrace)
3--FILE--
4<?php
5function brokenTrace($arg1, &$arg2, $arg3){
6	backtraceWrapper();
7	var_dump(func_get_args());
8	unset($arg3);
9	var_dump(func_get_arg(0));
10	var_dump(func_get_arg(1));
11	var_dump(func_get_arg(2));
12	var_dump(func_get_arg(3));
13	backtraceWrapper();
14	unset($arg1);
15	var_dump(func_get_args());
16	backtraceWrapper();
17	unset($arg2);
18	backtraceWrapper();
19	var_dump(func_get_arg(0));
20	var_dump(func_get_arg(1));
21	var_dump(func_get_arg(2));
22	var_dump(func_get_arg(3));
23}
24$arg2 = "2nd";
25brokenTrace("1st", $arg2, "3th", "4th");
26function backtraceWrapper(){
27	$bt = debug_backtrace();
28	var_dump($bt[1]['args']);
29}
30?>
31--EXPECT--
32array(4) {
33  [0]=>
34  string(3) "1st"
35  [1]=>
36  &string(3) "2nd"
37  [2]=>
38  string(3) "3th"
39  [3]=>
40  string(3) "4th"
41}
42array(4) {
43  [0]=>
44  string(3) "1st"
45  [1]=>
46  string(3) "2nd"
47  [2]=>
48  string(3) "3th"
49  [3]=>
50  string(3) "4th"
51}
52string(3) "1st"
53string(3) "2nd"
54NULL
55string(3) "4th"
56array(4) {
57  [0]=>
58  string(3) "1st"
59  [1]=>
60  &string(3) "2nd"
61  [2]=>
62  NULL
63  [3]=>
64  string(3) "4th"
65}
66array(4) {
67  [0]=>
68  NULL
69  [1]=>
70  string(3) "2nd"
71  [2]=>
72  NULL
73  [3]=>
74  string(3) "4th"
75}
76array(4) {
77  [0]=>
78  NULL
79  [1]=>
80  &string(3) "2nd"
81  [2]=>
82  NULL
83  [3]=>
84  string(3) "4th"
85}
86array(4) {
87  [0]=>
88  NULL
89  [1]=>
90  NULL
91  [2]=>
92  NULL
93  [3]=>
94  string(3) "4th"
95}
96NULL
97NULL
98NULL
99string(3) "4th"
100