Exemple #1
0
 public function testStartLine()
 {
     $reflectionMethod = new ZendL_Reflection_Method('ZendL_Reflection_TestSampleClass5', 'doSomething');
     $this->assertEquals($reflectionMethod->getStartLine(), 105);
     $this->assertEquals($reflectionMethod->getStartLine(true), 89);
 }
Exemple #2
0
 public static function fromReflection(ZendL_Reflection_Method $reflectionMethod)
 {
     $method = new self();
     $method->setSourceContent($reflectionMethod->getContents(false));
     $method->setSourceDirty(false);
     if ($reflectionMethod->getDocComment() != '') {
         $method->setDocblock(ZendL_Tool_CodeGenerator_Php_Docblock::fromReflection($reflectionMethod->getDocblock()));
     }
     $method->setFinal($reflectionMethod->isFinal());
     if ($reflectionMethod->isPrivate()) {
         $method->setVisibility(self::VISIBILITY_PRIVATE);
     } elseif ($reflectionMethod->isProtected()) {
         $method->setVisibility(self::VISIBILITY_PROTECTED);
     } else {
         $method->setVisibility(self::VISIBILITY_PUBLIC);
     }
     $method->setStatic($reflectionMethod->isStatic());
     $method->setName($reflectionMethod->getName());
     foreach ($reflectionMethod->getParameters() as $reflectionParameter) {
         $method->setParameter(ZendL_Tool_CodeGenerator_Php_Parameter::fromReflection($reflectionParameter));
     }
     $method->setBody($reflectionMethod->getBody());
     return $method;
 }