Beispiel #1
0
    /**
     * fromReflection()
     *
     * @param \Zend\Reflection\ReflectionMethod $reflectionMethod
     * @return \Zend\CodeGenerator\Php\PhpMethod
     */
    public static function fromReflection(\Zend\Reflection\ReflectionMethod $reflectionMethod)
    {
        $method = new self();

        $method->setSourceContent($reflectionMethod->getContents(false));
        $method->setSourceDirty(false);

        if ($reflectionMethod->getDocComment() != '') {
            $method->setDocblock(PhpDocblock::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(PhpParameter::fromReflection($reflectionParameter));
        }

        $method->setBody($reflectionMethod->getBody());

        return $method;
    }
Beispiel #2
0
 /**
  * Get parameter annotations from docblock
  * 
  * @return array
  */
 protected function getParameterAnnotations()
 {
     if (null !== $this->parameterAnnotations) {
         return $this->parameterAnnotations;
     }
     $rDocblock = $this->reflection->getDocblock();
     $params = $rDocblock->getTags('param');
     $this->parameterAnnotations = $params;
     return $this->parameterAnnotations;
 }
 public function testGetContentsReturnsCorrectContent()
 {
     $reflectionMethod = new Reflection\ReflectionMethod('ZendTest\\Reflection\\TestAsset\\TestSampleClass5', 'doSomething');
     $this->assertEquals("    {\n\n        return 'mixedValue';\n\n    }\n", $reflectionMethod->getContents(false));
 }