Annotation of embedaddon/php/tests/lang/bug22510.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Bug #22510 (segfault among complex references)
3: --INI--
4: error_reporting=E_ALL | E_DEPRECATED
5: --FILE--
6: <?php
7: class foo
8: {
9: public $list = array();
10:
11: function finalize() {
12: print __CLASS__."::".__FUNCTION__."\n";
13: $cl = &$this->list;
14: }
15:
16: function &method1() {
17: print __CLASS__."::".__FUNCTION__."\n";
18: return @$this->foo;
19: }
20:
21: function &method2() {
22: print __CLASS__."::".__FUNCTION__."\n";
23: return $this->foo;
24: }
25:
26: function method3() {
27: print __CLASS__."::".__FUNCTION__."\n";
28: return @$this->foo;
29: }
30: }
31:
32: class bar
33: {
34: function run1() {
35: print __CLASS__."::".__FUNCTION__."\n";
36: $this->instance = new foo();
37: $this->instance->method1($this);
38: $this->instance->method1($this);
39: }
40:
41: function run2() {
42: print __CLASS__."::".__FUNCTION__."\n";
43: $this->instance = new foo();
44: $this->instance->method2($this);
45: $this->instance->method2($this);
46: }
47:
48: function run3() {
49: print __CLASS__."::".__FUNCTION__."\n";
50: $this->instance = new foo();
51: $this->instance->method3($this);
52: $this->instance->method3($this);
53: }
54: }
55:
56: function ouch(&$bar) {
57: print __FUNCTION__."\n";
58: @$a = $a;
59: $bar->run1();
60: }
61:
62: function ok1(&$bar) {
63: print __FUNCTION__."\n";
64: $bar->run1();
65: }
66:
67: function ok2(&$bar) {
68: print __FUNCTION__."\n";
69: @$a = $a;
70: $bar->run2();
71: }
72:
73: function ok3(&$bar) {
74: print __FUNCTION__."\n";
75: @$a = $a;
76: $bar->run3();
77: }
78:
79: $bar = &new bar();
80: ok1($bar);
81: $bar->instance->finalize();
82: print "done!\n";
83: ok2($bar);
84: $bar->instance->finalize();
85: print "done!\n";
86: ok3($bar);
87: $bar->instance->finalize();
88: print "done!\n";
89: ouch($bar);
90: $bar->instance->finalize();
91: print "I'm alive!\n";
92: ?>
93: --EXPECTF--
94: Deprecated: Assigning the return value of new by reference is deprecated in %s on line %d
95: ok1
96: bar::run1
97: foo::method1
98:
99: Notice: Only variable references should be returned by reference in %s on line %d
100: foo::method1
101:
102: Notice: Only variable references should be returned by reference in %s on line %d
103: foo::finalize
104: done!
105: ok2
106: bar::run2
107: foo::method2
108: foo::method2
109: foo::finalize
110: done!
111: ok3
112: bar::run3
113: foo::method3
114: foo::method3
115: foo::finalize
116: done!
117: ouch
118: bar::run1
119: foo::method1
120:
121: Notice: Only variable references should be returned by reference in %s on line %d
122: foo::method1
123:
124: Notice: Only variable references should be returned by reference in %s on line %d
125: foo::finalize
126: I'm alive!
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>