@@ -24,9 +24,9 @@ public function fromClassReflection(\ReflectionClass $from): ClassType
24
24
$ class = $ from ->isAnonymous ()
25
25
? new ClassType
26
26
: new ClassType ($ from ->getShortName (), new PhpNamespace ($ from ->getNamespaceName ()));
27
- $ class ->setType ($ from ->isInterface () ? ' interface ' : ($ from ->isTrait () ? ' trait ' : ' class ' ));
28
- $ class ->setFinal ($ from ->isFinal () && $ class ->getType () === ' class ' );
29
- $ class ->setAbstract ($ from ->isAbstract () && $ class ->getType () === ' class ' );
27
+ $ class ->setType ($ from ->isInterface () ? $ class :: TYPE_INTERFACE : ($ from ->isTrait () ? $ class :: TYPE_TRAIT : $ class:: TYPE_CLASS ));
28
+ $ class ->setFinal ($ from ->isFinal () && $ class ->getType () === $ class:: TYPE_CLASS );
29
+ $ class ->setAbstract ($ from ->isAbstract () && $ class ->getType () === $ class:: TYPE_CLASS );
30
30
31
31
$ ifaces = $ from ->getInterfaceNames ();
32
32
foreach ($ ifaces as $ iface ) {
@@ -65,7 +65,10 @@ public function fromMethodReflection(\ReflectionMethod $from): Method
65
65
$ method ->setParameters (array_map ([$ this , 'fromParameterReflection ' ], $ from ->getParameters ()));
66
66
$ method ->setStatic ($ from ->isStatic ());
67
67
$ isInterface = $ from ->getDeclaringClass ()->isInterface ();
68
- $ method ->setVisibility ($ from ->isPrivate () ? 'private ' : ($ from ->isProtected () ? 'protected ' : ($ isInterface ? null : 'public ' )));
68
+ $ method ->setVisibility ($ from ->isPrivate ()
69
+ ? ClassType::VISIBILITY_PRIVATE
70
+ : ($ from ->isProtected () ? ClassType::VISIBILITY_PROTECTED : ($ isInterface ? null : ClassType::VISIBILITY_PUBLIC ))
71
+ );
69
72
$ method ->setFinal ($ from ->isFinal ());
70
73
$ method ->setAbstract ($ from ->isAbstract () && !$ isInterface );
71
74
$ method ->setBody ($ from ->isAbstract () ? null : '' );
@@ -121,7 +124,10 @@ public function fromPropertyReflection(\ReflectionProperty $from): Property
121
124
$ prop = new Property ($ from ->getName ());
122
125
$ prop ->setValue ($ from ->getDeclaringClass ()->getDefaultProperties ()[$ prop ->getName ()] ?? null );
123
126
$ prop ->setStatic ($ from ->isStatic ());
124
- $ prop ->setVisibility ($ from ->isPrivate () ? 'private ' : ($ from ->isProtected () ? 'protected ' : 'public ' ));
127
+ $ prop ->setVisibility ($ from ->isPrivate ()
128
+ ? ClassType::VISIBILITY_PRIVATE
129
+ : ($ from ->isProtected () ? ClassType::VISIBILITY_PROTECTED : ClassType::VISIBILITY_PUBLIC )
130
+ );
125
131
$ prop ->setComment (Helpers::unformatDocComment ((string ) $ from ->getDocComment ()));
126
132
return $ prop ;
127
133
}
0 commit comments