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 }";
}