1--TEST--
2Test ReflectionMethod::setAccessible().
3--FILE--
4<?php
5class A {
6    private function aPrivate($a) { print __METHOD__ . "\n"; }
7    private static function aPrivateStatic($a) { print __METHOD__ . "\n"; }
8    protected function aProtected($a) { print __METHOD__ . "\n"; }
9    protected static function aProtectedStatic($a) { print __METHOD__ . "\n"; }
10}
11
12$private         = new ReflectionMethod('A', 'aPrivate');
13$privateStatic   = new ReflectionMethod('A', 'aPrivateStatic');
14$protected       = new ReflectionMethod('A', 'aProtected');
15$protectedStatic = new ReflectionMethod('A', 'aProtectedStatic');
16
17try {
18    $private->invoke(new A, NULL);
19}
20
21catch (ReflectionException $e) {
22    var_dump($e->getMessage());
23}
24
25try {
26    $private->invokeArgs(new A, array(NULL));
27}
28
29catch (ReflectionException $e) {
30    var_dump($e->getMessage());
31}
32
33try {
34    $privateStatic->invoke(NULL, NULL);
35}
36
37catch (ReflectionException $e) {
38    var_dump($e->getMessage());
39}
40
41try {
42    $privateStatic->invokeArgs(NULL, array(NULL));
43}
44
45catch (ReflectionException $e) {
46    var_dump($e->getMessage());
47}
48
49try {
50    $protected->invoke(new A, NULL);
51}
52
53catch (ReflectionException $e) {
54    var_dump($e->getMessage());
55}
56
57try {
58    $protected->invokeArgs(new A, array(NULL));
59}
60
61catch (ReflectionException $e) {
62    var_dump($e->getMessage());
63}
64
65try {
66    $protectedStatic->invoke(NULL, NULL);
67}
68
69catch (ReflectionException $e) {
70    var_dump($e->getMessage());
71}
72
73try {
74    $protectedStatic->invokeArgs(NULL, array(NULL));
75}
76
77catch (ReflectionException $e) {
78    var_dump($e->getMessage());
79}
80
81$private->setAccessible(TRUE);
82$privateStatic->setAccessible(TRUE);
83$protected->setAccessible(TRUE);
84$protectedStatic->setAccessible(TRUE);
85
86$private->invoke(new A, NULL);
87$private->invokeArgs(new A, array(NULL));
88$privateStatic->invoke(NULL, NULL);
89$privateStatic->invokeArgs(NULL, array(NULL));
90$protected->invoke(new A, NULL);
91$protected->invokeArgs(new A, array(NULL));
92$protectedStatic->invoke(NULL, NULL);
93$protectedStatic->invokeArgs(NULL, array(NULL));
94?>
95--EXPECT--
96string(73) "Trying to invoke private method A::aPrivate() from scope ReflectionMethod"
97string(73) "Trying to invoke private method A::aPrivate() from scope ReflectionMethod"
98string(79) "Trying to invoke private method A::aPrivateStatic() from scope ReflectionMethod"
99string(79) "Trying to invoke private method A::aPrivateStatic() from scope ReflectionMethod"
100string(77) "Trying to invoke protected method A::aProtected() from scope ReflectionMethod"
101string(77) "Trying to invoke protected method A::aProtected() from scope ReflectionMethod"
102string(83) "Trying to invoke protected method A::aProtectedStatic() from scope ReflectionMethod"
103string(83) "Trying to invoke protected method A::aProtectedStatic() from scope ReflectionMethod"
104A::aPrivate
105A::aPrivate
106A::aPrivateStatic
107A::aPrivateStatic
108A::aProtected
109A::aProtected
110A::aProtectedStatic
111A::aProtectedStatic
112