Example #1
0
 /**
  * Retrieve method interface and documentation description.
  *
  * @param ReflectionMethod $method
  * @return array
  * @throws \InvalidArgumentException
  */
 public function extractMethodData(ReflectionMethod $method)
 {
     $methodData = array('documentation' => $method->getDescription(), 'interface' => array());
     $prototypes = $method->getPrototypes();
     /** Take the fullest interface that also includes optional parameters. */
     /** @var \Zend\Server\Reflection\Prototype $prototype */
     $prototype = end($prototypes);
     /** @var \Zend\Server\Reflection\ReflectionParameter $parameter */
     foreach ($prototype->getParameters() as $parameter) {
         $parameterData = array('type' => $this->_typeProcessor->process($parameter->getType()), 'required' => !$parameter->isOptional(), 'documentation' => $parameter->getDescription());
         if ($parameter->isOptional()) {
             $parameterData['default'] = $parameter->getDefaultValue();
         }
         $methodData['interface']['in']['parameters'][$parameter->getName()] = $parameterData;
     }
     if ($prototype->getReturnType() != 'void' && $prototype->getReturnType() != 'null') {
         $methodData['interface']['out']['parameters']['result'] = array('type' => $this->_typeProcessor->process($prototype->getReturnType()), 'documentation' => $prototype->getReturnValue()->getDescription(), 'required' => true);
     }
     return $methodData;
 }