Exemplo n.º 1
0
 public function testGenerateIsCorrect()
 {
     $this->_parameter->setType('Foo');
     $this->_parameter->setName('bar');
     $this->_parameter->setDefaultValue(15);
     $this->assertEquals('Foo $bar = 15', $this->_parameter->generate());
     $this->_parameter->setDefaultValue('foo');
     $this->assertEquals('Foo $bar = \'foo\'', $this->_parameter->generate());
 }
Exemplo n.º 2
0
 /**
  * fromReflection()
  *
  * @param Zend_Reflection_Parameter $reflectionParameter
  * @return Zend_CodeGenerator_Php_Parameter
  */
 public static function fromReflection(Zend_Reflection_Parameter $reflectionParameter)
 {
     $param = new Zend_CodeGenerator_Php_Parameter();
     $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;
 }