summaryrefslogtreecommitdiff
path: root/ext/reflection/tests/ReflectionClass_getModifierNames_basic.phpt
blob: 91a0a18f1aaaaa80e019adbc8011fff574a8ca20 (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--
ReflectionClass::getModifierNames() basic tests
--CREDITS--
Felix De Vliegher <felix.devliegher@gmail.com>
--FILE--
<?php

class a {}
abstract class b {}
final class c {}

class x
{
	function __construct() {}
	function __destruct() {}
	private function a() {}
	private static function b() {}
	protected function c() {}
	protected static function d() {}
	public function e() {}
	public static function f() {}
	final function g() {}
	function h() {}
}

abstract class y
{
	abstract function a();
	abstract protected function b();
}

function dump_modifierNames($class) {
	$obj = new ReflectionClass($class);
	var_dump($obj->getName(), Reflection::getModifierNames($obj->getModifiers()));
}

function dump_methodModifierNames($class) {
	$obj = new ReflectionClass($class);
	foreach($obj->getMethods() as $method) {
		var_dump($obj->getName() . "::" . $method->getName(), Reflection::getModifierNames($method->getModifiers()));
	}
}

dump_modifierNames('a');
dump_modifierNames('b');
dump_modifierNames('c');

dump_methodModifierNames('x');
dump_methodModifierNames('y');

?>
==DONE==
--EXPECT--
string(1) "a"
array(0) {
}
string(1) "b"
array(1) {
  [0]=>
  string(8) "abstract"
}
string(1) "c"
array(1) {
  [0]=>
  string(5) "final"
}
string(14) "x::__construct"
array(1) {
  [0]=>
  string(6) "public"
}
string(13) "x::__destruct"
array(1) {
  [0]=>
  string(6) "public"
}
string(4) "x::a"
array(1) {
  [0]=>
  string(7) "private"
}
string(4) "x::b"
array(2) {
  [0]=>
  string(7) "private"
  [1]=>
  string(6) "static"
}
string(4) "x::c"
array(1) {
  [0]=>
  string(9) "protected"
}
string(4) "x::d"
array(2) {
  [0]=>
  string(9) "protected"
  [1]=>
  string(6) "static"
}
string(4) "x::e"
array(1) {
  [0]=>
  string(6) "public"
}
string(4) "x::f"
array(2) {
  [0]=>
  string(6) "public"
  [1]=>
  string(6) "static"
}
string(4) "x::g"
array(2) {
  [0]=>
  string(5) "final"
  [1]=>
  string(6) "public"
}
string(4) "x::h"
array(1) {
  [0]=>
  string(6) "public"
}
string(4) "y::a"
array(2) {
  [0]=>
  string(8) "abstract"
  [1]=>
  string(6) "public"
}
string(4) "y::b"
array(2) {
  [0]=>
  string(8) "abstract"
  [1]=>
  string(9) "protected"
}
==DONE==