private function visitSimpleType(PHPClass $class, SimpleType $type)
{
if ($restriction = $type->getRestriction()) {
$parent = $restriction->getBase();
if ($parent instanceof Type) {
$this->handleClassExtension($class, $parent);
}
foreach ($restriction->getChecks() as $typeCheck => $checks) {
foreach ($checks as $check) {
$class->addCheck('__value', $typeCheck, $check);
}
}
} elseif ($unions = $type->getUnions()) {
$types = array();
foreach ($unions as $i => $unon) {
if (!$unon->getName()) {
$types[] = $this->visitTypeAnonymous($unon, $type->getName() . $i, $class);
} else {
$types[] = $this->visitType($unon);
}
}
if ($candidato = reset($types)) {
$class->setExtends($candidato);
}
}
}