Esempio n. 1
0
 /**
  *
  * @param PHPClass $class
  * @param Schema $schema
  * @param Element $element
  * @param boolean $arrayize
  * @return \Goetas\Xsd\XsdToPhp\Structure\PHPProperty
  */
 private function visitElement(PHPClass $class, Schema $schema, ElementSingle $element, $arrayize = true)
 {
     $property = new PHPProperty();
     $property->setName($this->getNamingStrategy()->getPropertyName($element));
     $property->setDoc($element->getDoc());
     $t = $element->getType();
     $min = $element->getMin();
     $max = $element->getMax();
     $tags = array(new GenericTag('xmlname', $element->getName()), new GenericTag('xmlmin', $element->getMin() . ' '), new GenericTag('xmlmax', $max == -1 ? 'unbounded' : '' . $max . ' '), new GenericTag('xmlarray', $max == -1 || $max > $min && $min > 0 ? 'true' : 'false'), new GenericTag('xmlqualified', $element->isQualified() ? 'true' : 'false'), new GenericTag('xmlnil', $element->isNil() ? 'true' : 'false'), new GenericTag('xmlnamespace', $element->getSchema()->getTargetNamespace()), new GenericTag('xmltype', $element->getType()->getName()), new GenericTag('xmltypenamespace', $element->getType()->getSchema()->getTargetNamespace()), new GenericTag('xmlsimpletype', $t instanceof SimpleType ? 'true' : 'false'));
     $property->setTags($tags);
     if ($arrayize) {
         if ($itemOfArray = $this->isArrayType($t)) {
             if (!$itemOfArray->getName()) {
                 $classType = $this->visitTypeAnonymous($itemOfArray, $element->getName(), $class);
             } else {
                 $classType = $this->visitType($itemOfArray);
             }
             $arg = new PHPArg($this->getNamingStrategy()->getPropertyName($element));
             $arg->setType($classType);
             $property->setType(new PHPClassOf($arg));
             return $property;
         } elseif ($itemOfArray = $this->isArrayNestedElement($t)) {
             if (!$t->getName()) {
                 $classType = $this->visitTypeAnonymous($t, $element->getName(), $class);
             } else {
                 $classType = $this->visitType($t);
             }
             $elementProp = $this->visitElement($classType, $schema, $itemOfArray, false);
             $property->setType(new PHPClassOf($elementProp));
             return $property;
         } elseif ($this->isArrayElement($element)) {
             $arg = new PHPArg($this->getNamingStrategy()->getPropertyName($element));
             $arg->setType($this->findPHPClass($class, $element));
             $arg->setDefault('array()');
             $property->setType(new PHPClassOf($arg));
             return $property;
         }
     }
     $property->setType($this->findPHPClass($class, $element, true));
     return $property;
 }
Esempio n. 2
0
 /**
  *
  * @param PHPClass $class
  * @param Schema $schema
  * @param Element $element
  * @param boolean $arrayize
  * @return \Goetas\Xsd\XsdToPhp\Structure\PHPProperty
  */
 private function visitElement(PHPClass $class, Schema $schema, ElementSingle $element, $arrayize = true)
 {
     $property = new PHPProperty();
     $property->setName($this->getNamingStrategy()->getPropertyName($element));
     $property->setDoc($element->getDoc());
     $t = $element->getType();
     if ($arrayize) {
         if ($itemOfArray = $this->isArrayType($t)) {
             if (!$itemOfArray->getName()) {
                 $classType = $this->visitTypeAnonymous($itemOfArray, $element->getName(), $class);
             } else {
                 $classType = $this->visitType($itemOfArray);
             }
             $arg = new PHPArg($this->getNamingStrategy()->getPropertyName($element));
             $arg->setType($classType);
             $property->setType(new PHPClassOf($arg));
             return $property;
         } elseif ($itemOfArray = $this->isArrayNestedElement($t)) {
             if (!$t->getName()) {
                 $classType = $this->visitTypeAnonymous($t, $element->getName(), $class);
             } else {
                 $classType = $this->visitType($t);
             }
             $elementProp = $this->visitElement($classType, $schema, $itemOfArray, false);
             $property->setType(new PHPClassOf($elementProp));
             return $property;
         } elseif ($this->isArrayElement($element)) {
             $arg = new PHPArg($this->getNamingStrategy()->getPropertyName($element));
             $arg->setType($this->findPHPClass($class, $element));
             $arg->setDefault('array()');
             $property->setType(new PHPClassOf($arg));
             return $property;
         }
     }
     $property->setType($this->findPHPClass($class, $element, true));
     return $property;
 }