private function visitType(Type $type, $force = false)
{
if (!isset($this->classes[spl_object_hash($type)])) {
$this->classes[spl_object_hash($type)]["class"] = $class = new PHPClass();
if ($alias = $this->getTypeAlias($type)) {
$class->setName($alias);
$this->classes[spl_object_hash($type)]["skip"] = true;
return $class;
}
list($name, $ns) = $this->findPHPName($type);
$class->setName($name);
$class->setNamespace($ns);
$class->setDoc($type->getDoc() . PHP_EOL . "XSD Type: " . ($type->getName() ?: 'anonymous'));
$this->visitTypeBase($class, $type);
if ($type instanceof SimpleType) {
$this->classes[spl_object_hash($type)]["skip"] = true;
return $class;
}
if (($this->isArrayType($type) || $this->isArrayNestedElement($type)) && !$force) {
$this->classes[spl_object_hash($type)]["skip"] = true;
return $class;
}
$this->classes[spl_object_hash($type)]["skip"] = !!$this->getTypeAlias($type);
} elseif ($force) {
if (!$type instanceof SimpleType && !$this->getTypeAlias($type)) {
$this->classes[spl_object_hash($type)]["skip"] = false;
}
}
return $this->classes[spl_object_hash($type)]["class"];
}