src/lapistano/ProxyObject/Generator.php
protected static function generateProxy($originalClassName, array $methods = null, array $properties = null,
                                            $proxyClassName = '', $callAutoload = false)
    {
        $templateDir = __DIR__ . DIRECTORY_SEPARATOR . 'Generator' . DIRECTORY_SEPARATOR;
        $classTemplate = self::createTemplateObject(
            $templateDir . 'proxied_class.tpl'
        );

        $proxyClassName = self::generateProxyClassName(
            $originalClassName, $proxyClassName
        );

        if (interface_exists($proxyClassName['fullClassName'], $callAutoload)) {
            throw new GeneratorException(sprintf(
                '"%s" is an interface.', $proxyClassName['fullClassName']
            ), GeneratorException::IS_INTERFACE);
        }

        if (!class_exists($proxyClassName['fullClassName'], $callAutoload)) {
            throw new GeneratorException(sprintf(
                'Class "%s" does not exists.', $proxyClassName['fullClassName']
            ), GeneratorException::CLASS_NOT_FOUND);
        }

        $class = new \ReflectionClass($proxyClassName['fullClassName']);

        if ($class->isFinal()) {
            throw new GeneratorException(sprintf(
                'Class "%s" is declared "final". Cannot create proxy.', $proxyClassName['fullClassName']
            ), GeneratorException::CLASS_IS_FINAL);
        }

        if (!empty($proxyClassName['namespaceName'])) {
            $prologue = 'namespace ' . $proxyClassName['namespaceName'] . ";\n\n";
        }

        $classTemplate->setVar(
            array(
                'prologue' => isset($prologue) ? $prologue : '',
                'class_declaration' => $proxyClassName['proxyClassName'] . ' extends ' . $originalClassName,
                'methods' => self::getProxiedMethods($proxyClassName['fullClassName'], $class, $methods),
                'properties' => self::getProxiedProperties($proxyClassName['fullClassName'], $class, $properties),
            )
        );

        return array(
            'code' => $classTemplate->render(),
            'proxyClassName' => $proxyClassName['proxyClassName'],
            'namespaceName' => $proxyClassName['namespaceName']
        );
    }
protected static function generateProxy($originalClassName, array $methods = null, array $properties = null,
                                            $proxyClassName = '', $callAutoload = false)
    {
        $templateDir = __DIR__ . DIRECTORY_SEPARATOR . 'Generator' . DIRECTORY_SEPARATOR;
        $classTemplate = self::createTemplateObject(
            $templateDir . 'proxied_class.tpl'
        );

        $proxyClassName = self::generateProxyClassName(
            $originalClassName, $proxyClassName
        );

        if (interface_exists($proxyClassName['fullClassName'], $callAutoload)) {
            throw new GeneratorException(sprintf(
                '"%s" is an interface.', $proxyClassName['fullClassName']
            ), GeneratorException::IS_INTERFACE);
        }

        if (!class_exists($proxyClassName['fullClassName'], $callAutoload)) {
            throw new GeneratorException(sprintf(
                'Class "%s" does not exists.', $proxyClassName['fullClassName']
            ), GeneratorException::CLASS_NOT_FOUND);
        }

        $class = new \ReflectionClass($proxyClassName['fullClassName']);

        if ($class->isFinal()) {
            throw new GeneratorException(sprintf(
                'Class "%s" is declared "final". Cannot create proxy.', $proxyClassName['fullClassName']
            ), GeneratorException::CLASS_IS_FINAL);
        }

        if (!empty($proxyClassName['namespaceName'])) {
            $prologue = 'namespace ' . $proxyClassName['namespaceName'] . ";\n\n";
        }

        $classTemplate->setVar(
            array(
                'prologue' => isset($prologue) ? $prologue : '',
                'class_declaration' => $proxyClassName['proxyClassName'] . ' extends ' . $originalClassName,
                'methods' => self::getProxiedMethods($proxyClassName['fullClassName'], $class, $methods),
                'properties' => self::getProxiedProperties($proxyClassName['fullClassName'], $class, $properties),
            )
        );

        return array(
            'code' => $classTemplate->render(),
            'proxyClassName' => $proxyClassName['proxyClassName'],
            'namespaceName' => $proxyClassName['namespaceName']
        );
    }
Generates the data to be used for the actual reflection.

@static

@param string     $originalClassName Name of the class to be reflected.
@param array|null $methods           (Optional) List of methods to be exposed.
@param array|null $properties        (Optional) List of properties to be exposed.
@param string     $proxyClassName    (Optional) Name to be used for the reflected class.
@param bool       $callAutoload      (Optional) Switch to run the autoloader.

@return array The data to be used for the actual reflection.
@throws \lapistano\ProxyObject\GeneratorException