/** * 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; }
/** * 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; }