Pop\Code\Reflection::buildGenerator PHP Метод

buildGenerator() защищенный Метод

Build the code generator based the reflection class
protected buildGenerator ( ) : void
Результат void
    protected function buildGenerator()
    {
        // Create generator object
        $type = $this->isInterface() ? Generator::CREATE_INTERFACE : Generator::CREATE_CLASS;
        $this->generator = new Generator($this->getShortName() . '.php', $type);
        // Get the namespace
        $this->getClassNamespace();
        // Detect and set the class doc block
        $classDocBlock = $this->getDocComment();
        if (!empty($classDocBlock) && strpos($classDocBlock, '/*') !== false) {
            $this->generator->code()->setDocblock(Generator\DocblockGenerator::parse($classDocBlock));
        }
        // Detect and set if the class is abstract
        if (!$this->isInterface() && $this->isAbstract()) {
            $this->generator->code()->setAbstract(true);
        }
        // Detect and set if the class is a child class
        $parent = $this->getParentClass();
        if ($parent !== false) {
            if ($parent->inNamespace()) {
                $this->generator->getNamespace()->setUse($parent->getNamespaceName() . '\\' . $parent->getShortName());
            }
            $this->generator->code()->setParent($parent->getShortName());
        }
        // Detect and set if the class implements any interfaces
        if (!$this->isInterface()) {
            $interfaces = $this->getInterfaces();
            if ($interfaces !== false) {
                $interfacesAry = array();
                foreach ($interfaces as $interface) {
                    if ($interface->inNamespace()) {
                        $this->generator->getNamespace()->setUse($interface->getNamespaceName() . '\\' . $interface->getShortName());
                    }
                    $interfacesAry[] = $interface->getShortName();
                }
                $this->generator->code()->setInterface(implode(', ', $interfacesAry));
            }
        }
        // Detect and set constants
        $constants = $this->getConstants();
        if (count($constants) > 0) {
            foreach ($constants as $key => $value) {
                $this->generator->code()->addProperty(new Generator\PropertyGenerator($key, gettype($value), $value, 'const'));
            }
        }
        // Get properties
        $this->getClassProperties();
        // Get Methods
        $this->getClassMethods();
    }