@@ -41,7 +41,7 @@ public function fromClassReflection(\ReflectionClass $from): ClassType
4141 $ class ->setExtends ($ from ->getParentClass ()->getName ());
4242 $ class ->setImplements (array_diff ($ class ->getImplements (), $ from ->getParentClass ()->getInterfaceNames ()));
4343 }
44- $ props = $ methods = [];
44+ $ props = $ methods = $ consts = [];
4545 foreach ($ from ->getProperties () as $ prop ) {
4646 if ($ prop ->isDefault () && $ prop ->getDeclaringClass ()->getName () === $ from ->getName ()) {
4747 $ props [] = $ this ->fromPropertyReflection ($ prop );
@@ -54,7 +54,14 @@ public function fromClassReflection(\ReflectionClass $from): ClassType
5454 }
5555 }
5656 $ 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+
5865 return $ class ;
5966 }
6067
@@ -127,6 +134,19 @@ public function fromParameterReflection(\ReflectionParameter $from): Parameter
127134 }
128135
129136
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+
130150 public function fromPropertyReflection (\ReflectionProperty $ from ): Property
131151 {
132152 $ defaults = $ from ->getDeclaringClass ()->getDefaultProperties ();
0 commit comments