/** * fromReflection() * * @param Zend_Reflection_Method $reflectionMethod * @return Zend_CodeGenerator_Php_Method */ public static function fromReflection(Zend_Reflection_Method $reflectionMethod) { $method = new self(); $method->setSourceContent($reflectionMethod->getContents(false)); $method->setSourceDirty(false); if ($reflectionMethod->getDocComment() != '') { $method->setDocblock(Zend_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(Zend_CodeGenerator_Php_Parameter::fromReflection($reflectionParameter)); } $method->setBody($reflectionMethod->getBody()); return $method; }
public static function fromReflection(Zend_Reflection_Method $reflectionMethod) { $method = new self(); $method->setSourceContent($reflectionMethod->getContents(false)); $method->setSourceDirty(false); if ($reflectionMethod->getDocComment() != '') { $method->setDocblock(Zend_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(Zend_CodeGenerator_Php_Parameter::fromReflection($reflectionParameter)); } $body = $reflectionMethod->getBody(); $body2 = str_replace("\n\n", "\n", $body); $body2 = preg_replace("|^\n\\s{4}|muU", "\n", $body2); $body2 = preg_replace("|^\\s{4}|muU", "", $body2); // $body2 = str_replace(' ', '.', $body2); //dmDebug::kill($body, "\n".$body2); $method->setBody($body2); return $method; }