@@ -288,6 +288,7 @@ protected function dataObjectGetterDescriptionToFieldDescription($shortDescripti
288
288
* 'type' => <string>$type,
289
289
* 'isRequired' => $isRequired,
290
290
* 'description' => $description
291
+ * 'parameterCount' => $numberOfRequiredParameters
291
292
* )</pre>
292
293
* @throws \InvalidArgumentException
293
294
*/
@@ -309,23 +310,13 @@ public function getGetterReturnType($methodReflection)
309
310
}
310
311
/** @var \Zend\Code\Reflection\DocBlock\Tag\ReturnTag $returnAnnotation */
311
312
$ 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 );
313
+ $ types = $ returnAnnotation ->getTypes ();
314
+ $ returnType = current ($ types );
315
+ $ nullable = in_array ('null ' , $ types );
316
+
326
317
return [
327
318
'type ' => $ returnType ,
328
- 'isRequired ' => !$ isNotRequired ,
319
+ 'isRequired ' => !$ nullable ,
329
320
'description ' => $ returnAnnotation ->getDescription (),
330
321
'parameterCount ' => $ methodReflection ->getNumberOfRequiredParameters ()
331
322
];
0 commit comments