setNamespace() public method

public setNamespace ( $namespace )
Esempio n. 1
0
 public function generate(Generator\ClassGenerator $class, PHPClass $type)
 {
     $class = $this->fixInterfaces($class);
     if (!($extends = $type->getExtends()) && class_exists($type->getNamespace())) {
         $extendNamespace = $type->getNamespace();
         $extendNamespace = explode('\\', $extendNamespace);
         $extendClass = array_pop($extendNamespace);
         $extendNamespace = implode('\\', $extendNamespace);
         $extends = new PHPClass();
         $extends->setName($extendClass);
         $extends->setNamespace($extendNamespace);
         $class->setExtendedClass($extends);
     }
     if ($type->getNamespace() == Enumeration::class) {
         $extendNamespace = $type->getNamespace();
         $extendNamespace = explode('\\', $extendNamespace);
         $extendClass = array_pop($extendNamespace);
         $extendNamespace = implode('\\', $extendNamespace);
         $extends = new PHPClass();
         $extends->setName($extendClass);
         $extends->setNamespace($extendNamespace);
         $class->setExtendedClass($extends);
     }
     if ($extends->getName() == "string" && $extends->getNamespace() == "" && class_exists($type->getNamespace() . '\\String')) {
         $extends->setName('String');
         $extends->setNamespace($type->getNamespace());
     } elseif ($extends->getName() == "string" && $extends->getNamespace() == "" && class_exists($type->getNamespace())) {
         $extendNamespace = $type->getNamespace();
         $extendNamespace = explode('\\', $extendNamespace);
         $extendClass = array_pop($extendNamespace);
         $extendNamespace = implode('\\', $extendNamespace);
         $extends = new PHPClass();
         $extends->setName($extendClass);
         $extends->setNamespace($extendNamespace);
         $class->setExtendedClass($extends);
     }
     $docblock = new DocBlockGenerator("Class representing " . $type->getName());
     if ($type->getDoc()) {
         $docblock->setLongDescription($type->getDoc());
     }
     $class->setNamespaceName($type->getNamespace());
     $class->setName($type->getName());
     $class->setDocblock($docblock);
     $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;
     }
 }
Esempio n. 2
0
 /**
  * @param Type $type
  * @param string $name
  * @param PHPClass $parentClass
  * @return \Goetas\Xsd\XsdToPhp\Php\Structure\PHPClass
  */
 private function visitTypeAnonymous(Type $type, $name, PHPClass $parentClass)
 {
     if (!isset($this->classes[spl_object_hash($type)])) {
         $this->classes[spl_object_hash($type)]["class"] = $class = new PHPClass();
         $class->setName($this->getNamingStrategy()->getAnonymousTypeName($type, $name));
         $class->setNamespace($parentClass->getNamespace() . "\\" . $parentClass->getName());
         $class->setDoc($type->getDoc());
         $this->visitTypeBase($class, $type);
         if ($type instanceof SimpleType) {
             $this->classes[spl_object_hash($type)]["skip"] = true;
         }
     }
     return $this->classes[spl_object_hash($type)]["class"];
 }