protected function isOneType(PHPClass $type, $onlyParent = false) { if ($onlyParent) { $e = $type->getExtends(); if ($e) { if ($e->hasProperty('__value')) { return $e->getProperty('__value'); } } } else { if ($type->hasPropertyInHierarchy('__value') && count($type->getPropertiesInHierarchy()) === 1) { return $type->getPropertyInHierarchy("__value"); } } }
public function generate(Generator\ClassGenerator $class, PHPClass $type) { $docblock = new DocBlockGenerator("Class representing " . $type->getName()); if ($type->getDoc()) { $docblock->setLongDescription($type->getDoc()); } $class->setNamespaceName($type->getNamespace() ?: NULL); $class->setName($type->getName()); $class->setDocblock($docblock); if ($extends = $type->getExtends()) { if ($p = $this->isOneType($extends)) { $this->handleProperty($class, $p); $this->handleValueMethod($class, $p, $extends); } else { $class->setExtendedClass($extends->getName()); if ($extends->getNamespace() != $type->getNamespace()) { if ($extends->getName() == $type->getName()) { $class->addUse($type->getExtends()->getFullName(), $extends->getName() . "Base"); $class->setExtendedClass($extends->getName() . "Base"); } else { $class->addUse($extends->getFullName()); } } } } if ($this->handleBody($class, $type)) { return true; } }