@@ -45,7 +45,7 @@ public function fromClassReflection(\ReflectionClass $from)
45
45
$ class ->setProperties ($ props );
46
46
foreach ($ from ->getMethods () as $ method ) {
47
47
if ($ method ->getDeclaringClass ()->getName () === $ from ->getName ()) {
48
- $ methods [] = $ this ->fromFunctionReflection ($ method )->setNamespace ($ class ->getNamespace ());
48
+ $ methods [] = $ this ->fromMethodReflection ($ method )->setNamespace ($ class ->getNamespace ());
49
49
}
50
50
}
51
51
$ class ->setMethods ($ methods );
@@ -56,25 +56,19 @@ public function fromClassReflection(\ReflectionClass $from)
56
56
/**
57
57
* @return Method
58
58
*/
59
- public function fromFunctionReflection ( \ ReflectionFunctionAbstract $ from )
59
+ public function fromMethodReflection ( \ ReflectionMethod $ from )
60
60
{
61
- $ method = $ from instanceof \ReflectionMethod
62
- ? new Method ($ from ->getName ())
63
- : ($ from ->isClosure () ? new Closure : new GlobalFunction ($ from ->getName ()));
61
+ $ method = new Method ($ from ->getName ());
64
62
$ method ->setParameters (array_map ([$ this , 'fromParameterReflection ' ], $ from ->getParameters ()));
65
- if ($ from instanceof \ReflectionMethod) {
66
- $ isInterface = $ from ->getDeclaringClass ()->isInterface ();
67
- $ method ->setStatic ($ from ->isStatic ());
68
- $ method ->setVisibility ($ from ->isPrivate () ? 'private ' : ($ from ->isProtected () ? 'protected ' : ($ isInterface ? NULL : 'public ' )));
69
- $ method ->setFinal ($ from ->isFinal ());
70
- $ method ->setAbstract ($ from ->isAbstract () && !$ isInterface );
71
- $ method ->setBody ($ from ->isAbstract () ? FALSE : '' );
72
- }
63
+ $ method ->setStatic ($ from ->isStatic ());
64
+ $ isInterface = $ from ->getDeclaringClass ()->isInterface ();
65
+ $ method ->setVisibility ($ from ->isPrivate () ? 'private ' : ($ from ->isProtected () ? 'protected ' : ($ isInterface ? NULL : 'public ' )));
66
+ $ method ->setFinal ($ from ->isFinal ());
67
+ $ method ->setAbstract ($ from ->isAbstract () && !$ isInterface );
68
+ $ method ->setBody ($ from ->isAbstract () ? FALSE : '' );
73
69
$ method ->setReturnReference ($ from ->returnsReference ());
74
70
$ method ->setVariadic ($ from ->isVariadic ());
75
- if (!$ from ->isClosure ()) {
76
- $ method ->setComment (Helpers::unformatDocComment ($ from ->getDocComment ()));
77
- }
71
+ $ method ->setComment (Helpers::unformatDocComment ($ from ->getDocComment ()));
78
72
if (PHP_VERSION_ID >= 70000 && $ from ->hasReturnType ()) {
79
73
$ method ->setReturnType ((string ) $ from ->getReturnType ());
80
74
$ method ->setReturnNullable ($ from ->getReturnType ()->allowsNull ());
@@ -83,6 +77,26 @@ public function fromFunctionReflection(\ReflectionFunctionAbstract $from)
83
77
}
84
78
85
79
80
+ /**
81
+ * @return GlobalFunction|Closure
82
+ */
83
+ public function fromFunctionReflection (\ReflectionFunction $ from )
84
+ {
85
+ $ function = $ from ->isClosure () ? new Closure : new GlobalFunction ($ from ->getName ());
86
+ $ function ->setParameters (array_map ([$ this , 'fromParameterReflection ' ], $ from ->getParameters ()));
87
+ $ function ->setReturnReference ($ from ->returnsReference ());
88
+ $ function ->setVariadic ($ from ->isVariadic ());
89
+ if (!$ from ->isClosure ()) {
90
+ $ function ->setComment (Helpers::unformatDocComment ($ from ->getDocComment ()));
91
+ }
92
+ if (PHP_VERSION_ID >= 70000 && $ from ->hasReturnType ()) {
93
+ $ function ->setReturnType ((string ) $ from ->getReturnType ());
94
+ $ function ->setReturnNullable ($ from ->getReturnType ()->allowsNull ());
95
+ }
96
+ return $ function ;
97
+ }
98
+
99
+
86
100
/**
87
101
* @return Parameter
88
102
*/
0 commit comments