@@ -75,7 +75,7 @@ public function fromMethodReflection(\ReflectionMethod $from): Method
7575 $ method ->setReturnReference ($ from ->returnsReference ());
7676 $ method ->setVariadic ($ from ->isVariadic ());
7777 $ method ->setComment (Helpers::unformatDocComment ((string ) $ from ->getDocComment ()));
78- if ($ from ->hasReturnType () ) {
78+ if ($ from ->getReturnType () instanceof \ReflectionNamedType ) {
7979 $ method ->setReturnType ($ from ->getReturnType ()->getName ());
8080 $ method ->setReturnNullable ($ from ->getReturnType ()->allowsNull ());
8181 }
@@ -93,7 +93,7 @@ public function fromFunctionReflection(\ReflectionFunction $from)
9393 if (!$ from ->isClosure ()) {
9494 $ function ->setComment (Helpers::unformatDocComment ((string ) $ from ->getDocComment ()));
9595 }
96- if ($ from ->hasReturnType () ) {
96+ if ($ from ->getReturnType () instanceof \ReflectionNamedType ) {
9797 $ function ->setReturnType ($ from ->getReturnType ()->getName ());
9898 $ function ->setReturnNullable ($ from ->getReturnType ()->allowsNull ());
9999 }
@@ -105,7 +105,7 @@ public function fromParameterReflection(\ReflectionParameter $from): Parameter
105105 {
106106 $ param = new Parameter ($ from ->getName ());
107107 $ param ->setReference ($ from ->isPassedByReference ());
108- $ param ->setType ($ from ->hasType () ? $ from ->getType ()->getName () : null );
108+ $ param ->setType ($ from ->getType () instanceof \ReflectionNamedType ? $ from ->getType ()->getName () : null );
109109 $ param ->setNullable ($ from ->hasType () && $ from ->getType ()->allowsNull ());
110110 if ($ from ->isDefaultValueAvailable ()) {
111111 $ param ->setDefaultValue ($ from ->isDefaultValueConstant ()
@@ -127,9 +127,9 @@ public function fromPropertyReflection(\ReflectionProperty $from): Property
127127 ? ClassType::VISIBILITY_PRIVATE
128128 : ($ from ->isProtected () ? ClassType::VISIBILITY_PROTECTED : ClassType::VISIBILITY_PUBLIC )
129129 );
130- if (PHP_VERSION_ID >= 70400 && ($ type = $ from ->getType ())) {
131- $ prop ->setType ($ type ->getName ());
132- $ prop ->setNullable ($ type ->allowsNull ());
130+ if (PHP_VERSION_ID >= 70400 && ($ from ->getType () instanceof \ReflectionNamedType )) {
131+ $ prop ->setType ($ from -> getType () ->getName ());
132+ $ prop ->setNullable ($ from -> getType () ->allowsNull ());
133133 $ prop ->setInitialized (array_key_exists ($ prop ->getName (), $ defaults ));
134134 }
135135 $ prop ->setComment (Helpers::unformatDocComment ((string ) $ from ->getDocComment ()));
0 commit comments