Annotation of embedaddon/php/Zend/tests/bug37632.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Bug #37632 (Protected method access problem)
3: --FILE--
4: <?php
5:
6: class A1
7: {
8: protected function test()
9: {
10: echo __METHOD__ . "\n";
11: }
12: }
13:
14: class B1 extends A1
15: {
16: public function doTest(A1 $obj)
17: {
18: echo __METHOD__ . "\n";
19: $obj->test();
20: }
21: }
22:
23: class C1 extends A1
24: {
25: protected function test()
26: {
27: echo __METHOD__ . "\n";
28: }
29: }
30:
31: $b = new B1;
32: $b->doTest(new C1);
33:
34: class A2
35: {
36: static protected function test()
37: {
38: echo __METHOD__ . "\n";
39: }
40: }
41:
42: class B2 extends A2
43: {
44: static public function doTest(A2 $obj)
45: {
46: echo __METHOD__ . "\n";
47: $obj->test();
48: }
49: }
50:
51: class C2 extends A2
52: {
53: static protected function test()
54: {
55: echo __METHOD__ . "\n";
56: }
57: }
58:
59: B2::doTest(new C2);
60:
61: /* Right now Ctor's cannot be made protected when defined in a ctor. That is
62: * we cannot decrease visibility.
63: *
64:
65: interface Ctor
66: {
67: function __construct($x);
68: }
69:
70: class A3 implements Ctor
71: {
72: protected function __construct()
73: {
74: echo __METHOD__ . "\n";
75: }
76: }
77:
78: class B3 extends A3
79: {
80: static public function doTest()
81: {
82: echo __METHOD__ . "\n";
83: new C3;
84: }
85: }
86:
87: class C3 extends A3
88: {
89: protected function __construct()
90: {
91: echo __METHOD__ . "\n";
92: }
93: }
94:
95: B3::doTest();
96:
97: */
98:
99: class A4
100: {
101: protected function __construct()
102: {
103: echo __METHOD__ . "\n";
104: }
105: }
106:
107: class B4 extends A4
108: {
109: static public function doTest()
110: {
111: echo __METHOD__ . "\n";
112: new C4;
113: }
114: }
115:
116: class C4 extends A4
117: {
118: protected function __construct()
119: {
120: echo __METHOD__ . "\n";
121: }
122: }
123:
124: B4::doTest();
125:
126: ?>
127: ===DONE===
128: --EXPECTF--
129: B1::doTest
130: C1::test
131: B2::doTest
132: C2::test
133: B4::doTest
134:
135: Fatal error: Call to protected C4::__construct() from context 'B4' in %sbug37632.php on line %d
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>