@@ -45,7 +45,7 @@ public function fromClassReflection(\ReflectionClass $from)
4545 $ class ->setProperties ($ props );
4646 foreach ($ from ->getMethods () as $ method ) {
4747 if ($ method ->getDeclaringClass ()->getName () === $ from ->getName ()) {
48- $ methods [] = $ this ->fromFunctionReflection ($ method )->setNamespace ($ class ->getNamespace ());
48+ $ methods [] = $ this ->fromMethodReflection ($ method )->setNamespace ($ class ->getNamespace ());
4949 }
5050 }
5151 $ class ->setMethods ($ methods );
@@ -56,25 +56,19 @@ public function fromClassReflection(\ReflectionClass $from)
5656 /**
5757 * @return Method
5858 */
59- public function fromFunctionReflection ( \ ReflectionFunctionAbstract $ from )
59+ public function fromMethodReflection ( \ ReflectionMethod $ from )
6060 {
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 ());
6462 $ 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 : '' );
7369 $ method ->setReturnReference ($ from ->returnsReference ());
7470 $ method ->setVariadic ($ from ->isVariadic ());
75- if (!$ from ->isClosure ()) {
76- $ method ->setComment (Helpers::unformatDocComment ($ from ->getDocComment ()));
77- }
71+ $ method ->setComment (Helpers::unformatDocComment ($ from ->getDocComment ()));
7872 if (PHP_VERSION_ID >= 70000 && $ from ->hasReturnType ()) {
7973 $ method ->setReturnType ((string ) $ from ->getReturnType ());
8074 $ method ->setReturnNullable ($ from ->getReturnType ()->allowsNull ());
@@ -83,6 +77,26 @@ public function fromFunctionReflection(\ReflectionFunctionAbstract $from)
8377 }
8478
8579
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+
86100 /**
87101 * @return Parameter
88102 */
0 commit comments