@@ -41,7 +41,7 @@ public function fromClassReflection(\ReflectionClass $from): ClassType
41
41
$ class ->setExtends ($ from ->getParentClass ()->getName ());
42
42
$ class ->setImplements (array_diff ($ class ->getImplements (), $ from ->getParentClass ()->getInterfaceNames ()));
43
43
}
44
- $ props = $ methods = [];
44
+ $ props = $ methods = $ consts = [];
45
45
foreach ($ from ->getProperties () as $ prop ) {
46
46
if ($ prop ->isDefault () && $ prop ->getDeclaringClass ()->getName () === $ from ->getName ()) {
47
47
$ props [] = $ this ->fromPropertyReflection ($ prop );
@@ -54,7 +54,14 @@ public function fromClassReflection(\ReflectionClass $from): ClassType
54
54
}
55
55
}
56
56
$ class ->setMethods ($ methods );
57
- $ class ->setConstants ($ from ->getConstants ());
57
+
58
+ foreach ($ from ->getReflectionConstants () as $ const ) {
59
+ if ($ const ->getDeclaringClass ()->name === $ from ->name ) {
60
+ $ consts [] = $ this ->fromConstantReflection ($ const );
61
+ }
62
+ }
63
+ $ class ->setConstants ($ consts );
64
+
58
65
return $ class ;
59
66
}
60
67
@@ -127,6 +134,19 @@ public function fromParameterReflection(\ReflectionParameter $from): Parameter
127
134
}
128
135
129
136
137
+ public function fromConstantReflection (\ReflectionClassConstant $ from ): Constant
138
+ {
139
+ $ const = new Constant ($ from ->name );
140
+ $ const ->setValue ($ from ->getValue ());
141
+ $ const ->setVisibility ($ from ->isPrivate ()
142
+ ? ClassType::VISIBILITY_PRIVATE
143
+ : ($ from ->isProtected () ? ClassType::VISIBILITY_PROTECTED : ClassType::VISIBILITY_PUBLIC )
144
+ );
145
+ $ const ->setComment (Helpers::unformatDocComment ((string ) $ from ->getDocComment ()));
146
+ return $ const ;
147
+ }
148
+
149
+
130
150
public function fromPropertyReflection (\ReflectionProperty $ from ): Property
131
151
{
132
152
$ defaults = $ from ->getDeclaringClass ()->getDefaultProperties ();
0 commit comments