コード例 #1
0
 public function setUpFixtures()
 {
     // function with undocumented parameter $t that has default value 'foo'
     $function = new ezcReflectionFunction('mmm');
     $this->actual['mmm'] = $function->getParameters();
     // function with three parameters that have type annotations but no type hints
     //        $this->expectedFunctionM1 = new ReflectionFunction( 'm1' );
     //        $this->expected['m1'] = $this->expectedFunctionM1->getParameters();
     $this->actualFunctionM1 = new ezcReflectionFunction('m1');
     $this->actualParamsOfM1 = $this->actualFunctionM1->getParameters();
     // method with one undocumented parameter
     //        $this->expectedMethod_TestMethods_m3
     //            = new ReflectionMethod( 'TestMethods', 'm3' );
     //        $this->expected['TestMethods::m3']
     //            = $this->expectedMethod_TestMethods_m3->getParameters();
     $this->actualMethod_TestMethods_m3 = new ezcReflectionMethod('TestMethods', 'm3');
     $this->actualParamsOf_TestMethods_m3 = $this->actualMethod_TestMethods_m3->getParameters();
     // method with parameter that has type hint
     //        $expMethod
     //            = new ReflectionMethod( 'ezcReflection', 'setReflectionTypeFactory' );
     //        $this->expected['ezcReflection::setReflectionTypeFactory']
     //            = $expMethod->getParameters();
     $this->actualMethod_ezcReflection_setReflectionTypeFactory = new ezcReflectionMethod('ezcReflection', 'setReflectionTypeFactory');
     $this->actualParamsOf_ezcReflection_setReflectionTypeFactory = $this->actualMethod_ezcReflection_setReflectionTypeFactory->getParameters();
     // function with parameter that has type hint only
     //        $expFunction = new ReflectionFunction( 'functionWithTypeHint' );
     //        $this->expected['functionWithTypeHint'] = $expFunction->getParameters();
     $this->actualFunction_functionWithTypeHint = new ezcReflectionFunction('functionWithTypeHint');
     $this->actualParamsOf_functionWithTypeHint = $this->actualFunction_functionWithTypeHint->getParameters();
     unset($this->expectedFunctionM1, $this->expectedMethod_TestMethods_m3, $this->expectedMethod_ezcReflection_setReflectionTypeFactory, $this->expectedFunction_functionWithTypeHint, $this->actualFunctionM1, $this->actualMethod_TestMethods_m3, $this->actualMethod_ezcReflection_setReflectionTypeFactory, $this->actualFunction_functionWithTypeHint);
 }
コード例 #2
0
ファイル: parser_test.php プロジェクト: naderman/pflow
 public function testGetParamAnnotations()
 {
     $parser = ezcReflection::getDocCommentParser();
     $parser->parse(self::$docs[0]);
     $annotations = $parser->getParamAnnotations();
     self::assertEquals(0, count($annotations));
     $parser = ezcReflection::getDocCommentParser();
     $parser->parse(self::$docs[3]);
     $annotations = $parser->getParamAnnotations();
     self::assertEquals(1, count($annotations));
     $parser = ezcReflection::getDocCommentParser();
     $parser->parse(self::$docs[6]);
     $annotations = $parser->getParamAnnotations();
     self::assertEquals(3, count($annotations));
     self::assertEquals('test', $annotations[0]->getParamName());
     self::assertEquals('string', $annotations[0]->getTypeName());
     self::assertEquals('test3', $annotations[2]->getParamName());
     self::assertEquals('NonExistingType', $annotations[2]->getTypeName());
     $parser = ezcReflection::getDocCommentParser();
     $m2 = new ezcReflectionFunction('m2');
     $parser->parse($m2->getDocComment());
     $annotations = $parser->getParamAnnotations();
     self::assertEquals(2, count($annotations));
     self::assertEquals('DocuFlaw', $annotations[0]->getParamName());
     self::assertEquals('NULL', $annotations[0]->getTypeName());
     self::assertEquals(array('NULL', 'DocuFlaw'), $annotations[0]->getParams());
     // testAddDescriptionLine
     $originalDescription = $annotations[0]->getDescription();
     $additionalDescriptionLine = 'This is an additional line of description.';
     $annotations[0]->addDescriptionLine($additionalDescriptionLine);
     self::assertEquals($originalDescription . "\n" . $additionalDescriptionLine, $annotations[0]->getDescription());
     self::assertNull($annotations[1]->getParamName());
     self::assertEquals('boolean', $annotations[1]->getTypeName());
     self::assertEquals(array('boolean'), $annotations[1]->getParams());
 }
コード例 #3
0
 public function testExport()
 {
     self::assertEquals(ReflectionFunction::export('m1', true), ezcReflectionFunction::export('m1', true));
     self::assertEquals(ReflectionFunction::export('m2', true), ezcReflectionFunction::export('m2', true));
     self::assertEquals(ReflectionFunction::export('m3', true), ezcReflectionFunction::export('m3', true));
 }