public static function fromReflection(ReflectionClass $reflectionClass)
    {
        if ($reflectionClass->isInterface() !== true) {
            throw new InvalidArgumentException('The reflected class must be an interface.');
        }

        $ig = new static($reflectionClass->getShortName(), $reflectionClass->getNamespaceName());
        if ($reflectionClass->getReflectionDocComment()->isEmpty() !== true) {
            $ig->setDocumentation(DocCommentGenerator::fromReflection($reflectionClass->getReflectionDocComment()));
        }

        $extends = array();
        foreach ($reflectionClass->getOwnInterfaces() as $interface) {
            if ($interface->getNamespaceName() === $ig->getNamespace()) {
                $extends[] = $interface->getShortName();
            } else {
                $extends[] = '\\' . $interface->getName();
            }
        }
        $ig->setExtends($extends);

        foreach ($reflectionClass->getOwnConstants() as $constant) {
            $ig->addConstant(ClassConstantGenerator::fromReflection($constant));
        }

        foreach ($reflectionClass->getOwnMethods() as $method) {
            $method = MethodGenerator::fromReflection($method);
            $method->setAbstract(false);
            $ig->addMethod($method);
        }

        return $ig;
    }
public static function fromReflection(ReflectionClass $reflectionClass)
    {
        if ($reflectionClass->isInterface() !== true) {
            throw new InvalidArgumentException('The reflected class must be an interface.');
        }

        $ig = new static($reflectionClass->getShortName(), $reflectionClass->getNamespaceName());
        if ($reflectionClass->getReflectionDocComment()->isEmpty() !== true) {
            $ig->setDocumentation(DocCommentGenerator::fromReflection($reflectionClass->getReflectionDocComment()));
        }

        $extends = array();
        foreach ($reflectionClass->getOwnInterfaces() as $interface) {
            if ($interface->getNamespaceName() === $ig->getNamespace()) {
                $extends[] = $interface->getShortName();
            } else {
                $extends[] = '\\' . $interface->getName();
            }
        }
        $ig->setExtends($extends);

        foreach ($reflectionClass->getOwnConstants() as $constant) {
            $ig->addConstant(ClassConstantGenerator::fromReflection($constant));
        }

        foreach ($reflectionClass->getOwnMethods() as $method) {
            $method = MethodGenerator::fromReflection($method);
            $method->setAbstract(false);
            $ig->addMethod($method);
        }

        return $ig;
    }
public static function fromReflection ( ReflectionClass $ reflectionClass ) { if ( $ reflectionClass -> isInterface ( ) !== true ) { throw new InvalidArgumentException ( 'The reflected class must be an interface.' ) ; } $ ig = new static ( $ reflectionClass -> getShortName ( ) , $ reflectionClass -> getNamespaceName ( ) ) ; if ( $ reflectionClass -> getReflectionDocComment ( ) -> isEmpty ( ) !== true ) { $ ig -> setDocumentation ( DocCommentGenerator :: fromReflection ( $ reflectionClass -> getReflectionDocComment ( ) ) ) ; } $ extends = array ( ) ; foreach ( $ reflectionClass -> getOwnInterfaces ( ) as $ interface ) { if ( $ interface -> getNamespaceName ( ) === $ ig -> getNamespace ( ) ) { $ extends [ ] = $ interface -> getShortName ( ) ; } else { $ extends [ ] = '\\' . $ interface -> getName ( ) ; } } $ ig -> setExtends ( $ extends ) ; foreach ( $ reflectionClass -> getOwnConstants ( ) as $ constant ) { $ ig -> addConstant ( ClassConstantGenerator :: fromReflection ( $ constant ) ) ; } foreach ( $ reflectionClass -> getOwnMethods ( ) as $ method ) { $ method = MethodGenerator :: fromReflection ( $ method ) ; $ method -> setAbstract ( false ) ; $ ig -> addMethod ( $ method ) ; } return $ ig ; }
Create a new interface from reflection.

@param \Wingu\OctopusCore\Reflection\ReflectionClass $reflectionClass The reflection of the interface.
@return \Wingu\OctopusCore\CodeGenerator\PHP\OOP\InterfaceGenerator
@throws \Wingu\OctopusCore\CodeGenerator\Exceptions\InvalidArgumentException If the reflected class is not an interface.
Create a new interface from reflection .