コード例 #1
0
ファイル: Transformer.php プロジェクト: lanfisis/deflection
 /**
  * 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
ファイル: Generator.php プロジェクト: lanfisis/raoul
 /**
  * Add service constructor
  *
  * @param Classes $class Class
  *
  * @return \Raoul\Generator
  */
 protected function addConstructForService(Classes $class)
 {
     $docblock = new Docblock();
     $docblock->setDescription('Service contructor');
     $docblock->addParam('return', 'void');
     $docblock->addVar('wsdl', 'string', 'URI of the WSDL file');
     $docblock->addVar('options', 'array', 'An array of options');
     $function = new Functions();
     $function->setDocblock($docblock);
     $function->isPublic(true);
     $function->setName('__construct');
     $function->addParam('wsdl');
     $function->addParam('options = array()', 'array');
     $function->setContent(array('foreach ($this->classmap as $key => $value) {', array('if (!isset($options[\'classmap\'][$key])) {', array('$options[\'classmap\'][$key] = $value;'), '}'), '}', 'parent::__construct($wsdl, $options);'));
     $class->addFunction($function);
     return $this;
 }