Пример #1
0
 /**
  * Returns well formated header with descriptions, param, return, ...
  *
  * @param array $definition Header definition
  *
  * @return Deflection\Element\Docblock
  */
 public function arrayToDocblockElement(array $definition)
 {
     $docblock = new Docblock();
     if (isset($definition['description'])) {
         $docblock->setDescription($definition['description']);
     }
     if (isset($definition['params'])) {
         foreach ($definition['params'] as $param => $infos) {
             $type = isset($infos['type']) ? $infos['type'] : '';
             $description = isset($infos['description']) ? $infos['description'] : '';
             $docblock->addVar($param, $type, $description);
         }
     }
     if (isset($definition['return'])) {
         $docblock->addParam('return', $definition['return']);
     }
     if (isset($definition['infos'])) {
         foreach ($definition['infos'] as $name => $value) {
             $docblock->addParam($name, $value);
         }
     }
     return $docblock;
 }
Пример #2
0
 /**
  * Add all param to class with public scope to be fill by php SOAPClient
  *
  * @param Deflection\Element\Classes $class      Current class
  * @param array                      $definition Param definition
  *
  * @return \Raoul\Generator
  */
 protected function addParamsFromDefinition(Classes $class, $definition)
 {
     if (!isset($definition['all'])) {
         return $this;
     }
     $allSimple = true;
     $params = array();
     foreach ($definition['all'] as $name => $infos) {
         $param = new Param();
         $docblock = new Docblock();
         $description = ucfirst($name);
         if ($infos['nullable'] === true) {
             $param->setValue('null');
         }
         if ($infos['collection'] === true) {
             $description = $description . ' collection';
             $param->setValue('array()');
         }
         $type = $this->getType($infos['type'], $class->getNamespace());
         $docblock->setDescription($description);
         $docblock->addParam('var', $type);
         $param->setName($name);
         $param->isPublic();
         $param->setDocblock($docblock);
         $class->addParam($param);
         if (!$this->isSImpleType($type)) {
             $allSimple = false;
         } else {
             $params[$name] = $type;
         }
     }
     if ($allSimple) {
         $this->simpleTypeCLass[$class->getName()] = $params;
     }
     return $this;
 }