public static function fromReflection(ReflectionMethod $reflectionMethod)
    {
        $method = new static($reflectionMethod->getName());
        foreach ($reflectionMethod->getParameters() as $parameter) {
            $method->addParameter(ParameterGenerator::fromReflection($parameter));
        }

        $method->setFinal($reflectionMethod->isFinal());
        $method->setAbstract($reflectionMethod->isAbstract());

        if ($reflectionMethod->isStatic() === true) {
            $method->setStatic(true);
        }

        if ($reflectionMethod->isPrivate() === true) {
            $method->setVisibility(Modifiers::VISIBILITY_PRIVATE);
        } elseif ($reflectionMethod->isProtected() === true) {
            $method->setVisibility(Modifiers::VISIBILITY_PROTECTED);
        } else {
            $method->setVisibility(Modifiers::VISIBILITY_PUBLIC);
        }

        if ($reflectionMethod->getReflectionDocComment()->isEmpty() !== true) {
            $method->setDocumentation(
                DocCommentGenerator::fromReflection($reflectionMethod->getReflectionDocComment())
            );
        }

        if ($reflectionMethod->isAbstract() !== true) {
            $body = trim($reflectionMethod->getBody());
            if ($body !== '') {
                $method->setBody($body);
            }
        }

        return $method;
    }
public static function fromReflection(ReflectionMethod $reflectionMethod)
    {
        $method = new static($reflectionMethod->getName());
        foreach ($reflectionMethod->getParameters() as $parameter) {
            $method->addParameter(ParameterGenerator::fromReflection($parameter));
        }

        $method->setFinal($reflectionMethod->isFinal());
        $method->setAbstract($reflectionMethod->isAbstract());

        if ($reflectionMethod->isStatic() === true) {
            $method->setStatic(true);
        }

        if ($reflectionMethod->isPrivate() === true) {
            $method->setVisibility(Modifiers::VISIBILITY_PRIVATE);
        } elseif ($reflectionMethod->isProtected() === true) {
            $method->setVisibility(Modifiers::VISIBILITY_PROTECTED);
        } else {
            $method->setVisibility(Modifiers::VISIBILITY_PUBLIC);
        }

        if ($reflectionMethod->getReflectionDocComment()->isEmpty() !== true) {
            $method->setDocumentation(
                DocCommentGenerator::fromReflection($reflectionMethod->getReflectionDocComment())
            );
        }

        if ($reflectionMethod->isAbstract() !== true) {
            $body = trim($reflectionMethod->getBody());
            if ($body !== '') {
                $method->setBody($body);
            }
        }

        return $method;
    }
public static function fromReflection ( ReflectionMethod $ reflectionMethod ) { $ method = new static ( $ reflectionMethod -> getName ( ) ) ; foreach ( $ reflectionMethod -> getParameters ( ) as $ parameter ) { $ method -> addParameter ( ParameterGenerator :: fromReflection ( $ parameter ) ) ; } $ method -> setFinal ( $ reflectionMethod -> isFinal ( ) ) ; $ method -> setAbstract ( $ reflectionMethod -> isAbstract ( ) ) ; if ( $ reflectionMethod -> isStatic ( ) === true ) { $ method -> setStatic ( true ) ; } if ( $ reflectionMethod -> isPrivate ( ) === true ) { $ method -> setVisibility ( Modifiers :: VISIBILITY_PRIVATE ) ; } elseif ( $ reflectionMethod -> isProtected ( ) === true ) { $ method -> setVisibility ( Modifiers :: VISIBILITY_PROTECTED ) ; } else { $ method -> setVisibility ( Modifiers :: VISIBILITY_PUBLIC ) ; } if ( $ reflectionMethod -> getReflectionDocComment ( ) -> isEmpty ( ) !== true ) { $ method -> setDocumentation ( DocCommentGenerator :: fromReflection ( $ reflectionMethod -> getReflectionDocComment ( ) ) ) ; } if ( $ reflectionMethod -> isAbstract ( ) !== true ) { $ body = trim ( $ reflectionMethod -> getBody ( ) ) ; if ( $ body !== '' ) { $ method -> setBody ( $ body ) ; } } return $ method ; }
Create a new method from reflection.

@param \Wingu\OctopusCore\Reflection\ReflectionMethod $reflectionMethod The reflection of the method.
@return \Wingu\OctopusCore\CodeGenerator\PHP\OOP\MethodGenerator
Create a new method from reflection .