Esempio n. 1
0
 public function testRender()
 {
     $p = new Parameter('param');
     $r = $this->realizer;
     $this->assertEquals('$param', $r->realize($p), 'Simple parameter');
     $p->setDefaultValue('def');
     $this->assertEquals('$param = mockedDefValue', $r->realize($p), 'Parameter with string default value');
     $p->setByRef(true);
     $this->assertEquals('&$param = mockedDefValue', $r->realize($p), 'Parameter with string default value and passed by ref');
     $p = new Parameter('param');
     $p->setTypeHint('stdClass');
     $this->assertEquals('stdClass $param', $r->realize($p), 'Parameter with Type Hinting');
 }
Esempio n. 2
0
 /**
  * @param \ReflectionParameter $parameter
  * @return Parameter
  */
 public function parameter(\ReflectionParameter $parameter)
 {
     $phpyParam = new Parameter($parameter->getName());
     if ($parameter->isArray()) {
         $phpyParam->setTypeHint('array');
     } elseif ($class = $parameter->getClass()) {
         $phpyParam->setTypeHint('\\' . $class->getName());
     }
     if ($parameter->isDefaultValueAvailable()) {
         $phpyParam->setDefaultValue($parameter->getDefaultValue());
     }
     $phpyParam->setByRef($parameter->isPassedByReference());
     return $phpyParam;
 }
Esempio n. 3
0
 /**
  * @param Parameter $parameter
  * @return array
  */
 private function getTmplVars(Parameter $parameter)
 {
     return array('typeHint' => $parameter->getTypeHint(), 'passByRef' => $parameter->isByRef() ? '&' : '', 'paramName' => $parameter->getName(), 'defValue' => $parameter->hasDefaultValue() ? ' = ' . $this->renderDefaultValue($parameter->getDefaultValue()) : '');
 }
Esempio n. 4
0
 /**
  * @covers Parameter::setTypeHint
  */
 public function testSetAndGetTypeHint()
 {
     $this->parameter->setTypeHint('ahia');
     $this->assertEquals('ahia', $this->parameter->getTypeHint());
 }