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