getNamespace() 공개 메소드

public getNamespace ( )
예제 #1
0
 public function getPath(PHPClass $php)
 {
     foreach ($this->namespaces as $namespace => $dir) {
         if (strpos(trim($php->getNamespace()) . "\\", $namespace) === 0) {
             $d = strtr(substr($php->getNamespace(), strlen($namespace)), "\\", "/");
             $dir = rtrim($dir, "/") . "/" . $d;
             if (!is_dir($dir) && !mkdir($dir, 0777, true)) {
                 throw new PathGeneratorException("Can't create the '{$dir}' directory");
             }
             return rtrim($dir, "/") . "/" . $php->getName() . ".php";
         }
     }
     throw new PathGeneratorException("Can't find a defined location where save '{$php}' object");
 }
예제 #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"];
 }
예제 #3
0
 protected function isNativeType(PHPClass $class)
 {
     return !$class->getNamespace() && in_array($class->getName(), ['string', 'int', 'float', 'integer', 'boolean', 'array', 'mixed', 'callable']);
 }
예제 #4
0
 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;
     }
 }