@@ -309,23 +309,13 @@ public function getGetterReturnType($methodReflection)
309
309
}
310
310
/** @var \Zend\Code\Reflection\DocBlock\Tag\ReturnTag $returnAnnotation */
311
311
$ returnAnnotation = current ($ returnAnnotations );
312
- // $returnType = $returnAnnotation->getType();
313
- /*
314
- * Adding this code as a workaround since \Zend\Code\Reflection\DocBlock\Tag\ReturnTag::initialize does not
315
- * detect and return correct type for array of objects in annotation.
316
- * eg @return \Magento\Webapi\Service\Entity\SimpleData[] is returned with type
317
- * \Magento\Webapi\Service\Entity\SimpleData instead of \Magento\Webapi\Service\Entity\SimpleData[]
318
- */
319
- $ escapedReturnType = str_replace ('[] ' , '\[\] ' , $ returnType );
320
- $ escapedReturnType = str_replace ('\\' , '\\\\' , $ escapedReturnType );
321
-
322
- if (preg_match ("/.* \\@return \\s+( {$ escapedReturnType }).*/i " , $ methodDocBlock ->getContents (), $ matches )) {
323
- $ returnType = $ matches [1 ];
324
- }
325
- $ isNotRequired = (bool )preg_match ("/.*\@return\s+\S+\|null.*/i " , $ methodDocBlock ->getContents (), $ matches );
312
+ $ types = $ returnAnnotation ->getTypes ();
313
+ $ returnType = current ($ types );
314
+ $ nullable = in_array ('null ' , $ types );
315
+
326
316
return [
327
317
'type ' => $ returnType ,
328
- 'isRequired ' => !$ isNotRequired ,
318
+ 'isRequired ' => !$ nullable ,
329
319
'description ' => $ returnAnnotation ->getDescription (),
330
320
'parameterCount ' => $ methodReflection ->getNumberOfRequiredParameters ()
331
321
];
0 commit comments