示例#1
0
文件: PhpParameter.php 项目: hjr3/zf2
 /**
  * fromReflection()
  *
  * @param \Zend\Reflection\ReflectionParameter $reflectionParameter
  * @return \Zend\CodeGenerator\PHP\PHPParameter\Parameter
  */
 public static function fromReflection(\Zend\Reflection\ReflectionParameter $reflectionParameter)
 {
     $param = new PHPParameter();
     $param->setName($reflectionParameter->getName());
     if ($reflectionParameter->isArray()) {
         $param->setType('array');
     } else {
         $typeClass = $reflectionParameter->getClass();
         if ($typeClass !== null) {
             $param->setType($typeClass->getName());
         }
     }
     $param->setPosition($reflectionParameter->getPosition());
     if ($reflectionParameter->isOptional()) {
         $param->setDefaultValue($reflectionParameter->getDefaultValue());
     }
     $param->setPassedByReference($reflectionParameter->isPassedByReference());
     return $param;
 }
示例#2
0
文件: PhpMethod.php 项目: hjr3/zf2
 /**
  * setParameter()
  *
  * @param \Zend\CodeGenerator\PHP\Parameter\Parameter|array $parameter
  * @return \Zend\CodeGenerator\PHP\PHPMethod
  */
 public function setParameter($parameter)
 {
     if (is_array($parameter)) {
         $parameter = new PHPParameter($parameter);
         $parameterName = $parameter->getName();
     } elseif ($parameter instanceof PHPParameter) {
         $parameterName = $parameter->getName();
     } else {
         throw new Exception('setParameter() expects either an array of method options or an instance of Zend_CodeGenerator_Php_Parameter');
     }
     $this->_parameters[$parameterName] = $parameter;
     return $this;
 }