Example #1
0
 /**
  * Tests that export creates the expected string representation of a
  * function parameter.
  *
  * @return void
  * @group pdepend
  * @group pdepend::code
  * @group unittest
  */
 public function testParameterExportsExistingFunction()
 {
     self::assertFalse(function_exists(__FUNCTION__));
     function testParameterExportsExistingFunction($foo)
     {
     }
     self::assertSame('Parameter #0 [ <required> $foo ]', PHP_Depend_Code_Parameter::export(__FUNCTION__, 'foo', true));
 }
Example #2
0
 /**
  * This method will initialize the <b>$_parameters</b> property.
  *
  * @return void
  * @since 0.9.6
  */
 private function _initParameters()
 {
     $parameters = array();
     $formalParameters = $this->getFirstChildOfType(PHP_Depend_Code_ASTFormalParameters::CLAZZ);
     $formalParameters = $formalParameters->findChildrenOfType(PHP_Depend_Code_ASTFormalParameter::CLAZZ);
     foreach ($formalParameters as $formalParameter) {
         $parameter = new PHP_Depend_Code_Parameter($formalParameter);
         $parameter->setDeclaringFunction($this);
         $parameter->setPosition(count($parameters));
         $parameters[] = $parameter;
     }
     $optional = true;
     foreach (array_reverse($parameters) as $parameter) {
         if ($parameter->isDefaultValueAvailable() === false) {
             $optional = false;
         }
         $parameter->setOptional($optional);
     }
     $this->_parameters = new PHP_Depend_Code_NodeIterator($parameters);
 }