function testFunctions()
 {
     $functions = $this->class->getFunctions();
     $this->assertNotEmpty($functions);
     $this->assertEquals('Description of a*a', $functions[0]->getDescription());
     $this->assertEquals(false, $functions[0]->isDeprecated());
     $this->assertEquals('funcA', $functions[0]->getName());
     $this->assertEquals('void', $functions[0]->getReturnType());
     $this->assertEquals('public', $functions[0]->getVisibility());
     $this->assertEquals('Description of b', $functions[1]->getDescription());
     $this->assertEquals(false, $functions[1]->isDeprecated());
     $this->assertEquals('funcB', $functions[1]->getName());
     $this->assertEquals('void', $functions[1]->getReturnType());
     $this->assertEquals('public', $functions[1]->getVisibility());
     $this->assertEquals('', $functions[2]->getDescription());
     $this->assertEquals('funcD', $functions[2]->getName());
     $this->assertEquals('void', $functions[2]->getReturnType());
     $this->assertEquals('public', $functions[2]->getVisibility());
     $this->assertEquals(false, $functions[2]->isDeprecated());
     // These function does not declare return type but the return
     // type should be guessable
     $this->assertEquals('mixed', $functions[3]->getReturnType());
     $this->assertEquals('bool', $functions[4]->getReturnType());
     $this->assertEquals('bool', $functions[5]->getReturnType());
     $this->assertTrue($functions[5]->isAbstract());
     $this->assertTrue($this->class->isAbstract());
     // Protected function have been put last
     $this->assertEquals('Description of c', $functions[6]->getDescription());
     $this->assertEquals(true, $functions[6]->isDeprecated());
     $this->assertEquals('This one is deprecated', $functions[6]->getDeprecationMessage());
     $this->assertEquals('funcC', $functions[6]->getName());
     $this->assertEquals('\\Acme\\ExampleClass', $functions[6]->getReturnType());
     $this->assertEquals('protected', $functions[6]->getVisibility());
     $this->assertTrue(empty($functions[7]));
     // Should be skipped since tagged with @ignore */
 }
Exemple #2
0
 /**
  * @param FunctionEntity $func
  * @param ClassEntity $class
  * @return FunctionEntity
  */
 private function findInheritedFunctionDeclaration(FunctionEntity $func, ClassEntity $class)
 {
     $funcName = $func->getName();
     $inheritedFuncDeclaration = $this->functionFinder->find($funcName, $class->getExtends());
     if (!$inheritedFuncDeclaration) {
         $inheritedFuncDeclaration = $this->functionFinder->findInClasses($funcName, $class->getInterfaces());
         if (!$inheritedFuncDeclaration) {
             throw new \RuntimeException('Function ' . $funcName . ' tries to inherit docs but no parent method is found');
         }
     }
     if (!$func->isAbstract() && !$class->isAbstract() && $inheritedFuncDeclaration->isAbstract()) {
         $inheritedFuncDeclaration->isAbstract(false);
     }
     return $inheritedFuncDeclaration;
 }