Doctrine\Common\Proxy\ProxyGenerator::generateMagicIsset PHP Метод

generateMagicIsset() приватный Метод

Generates the magic issetter invoked when lazy loaded public properties are checked against isset().
private generateMagicIsset ( Doctrine\Common\Persistence\Mapping\ClassMetadata $class ) : string
$class Doctrine\Common\Persistence\Mapping\ClassMetadata
Результат string
    private function generateMagicIsset(ClassMetadata $class)
    {
        $lazyPublicProperties = array_keys($this->getLazyLoadedPublicProperties($class));
        $hasParentIsset = $class->getReflectionClass()->hasMethod('__isset');
        if (empty($lazyPublicProperties) && !$hasParentIsset) {
            return '';
        }
        $inheritDoc = $hasParentIsset ? '{@inheritDoc}' : '';
        $magicIsset = <<<EOT
    /**
     * {$inheritDoc}
     * @param  string \$name
     * @return boolean
     */
    public function __isset(\$name)
    {

EOT;
        if (!empty($lazyPublicProperties)) {
            $magicIsset .= <<<'EOT'
        if (array_key_exists($name, $this->__getLazyProperties())) {
            $this->__initializer__ && $this->__initializer__->__invoke($this, '__isset', [$name]);

            return isset($this->$name);
        }


EOT;
        }
        if ($hasParentIsset) {
            $magicIsset .= <<<'EOT'
        $this->__initializer__ && $this->__initializer__->__invoke($this, '__isset', [$name]);

        return parent::__isset($name);

EOT;
        } else {
            $magicIsset .= "        return false;";
        }
        return $magicIsset . "\n    }";
    }