Пример #1
0
 /**
  *
  * @param PHPClass $class
  * @param Schema $schema
  * @param Element $element
  * @param boolean $arrayize
  * @return \GoetasWebservices\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;
 }
Пример #2
0
 private function handleProperty(Generator\ClassGenerator $class, PHPProperty $prop)
 {
     $generatedProp = new PropertyGenerator($prop->getName());
     $generatedProp->setVisibility(PropertyGenerator::VISIBILITY_PRIVATE);
     $class->addPropertyFromGenerator($generatedProp);
     if ($prop->getType() && (!$prop->getType()->getNamespace() && $prop->getType()->getName() == "array")) {
         // $generatedProp->setDefaultValue(array(), PropertyValueGenerator::TYPE_AUTO, PropertyValueGenerator::OUTPUT_SINGLE_LINE);
     }
     $docBlock = new DocBlockGenerator();
     $generatedProp->setDocBlock($docBlock);
     if ($prop->getDoc()) {
         $docBlock->setLongDescription($prop->getDoc());
     }
     $tag = new PropertyTag($prop->getName(), 'mixed');
     $type = $prop->getType();
     if ($type && $type instanceof PHPClassOf) {
         $tt = $type->getArg()->getType();
         $tag->setTypes($tt->getPhpType() . "[]");
         if ($p = $tt->isSimpleType()) {
             if ($t = $p->getType()) {
                 $tag->setTypes($t->getPhpType() . "[]");
             }
         }
     } elseif ($type) {
         if ($type->isNativeType()) {
             $tag->setTypes($type->getPhpType());
         } elseif (($p = $type->isSimpleType()) && ($t = $p->getType())) {
             $tag->setTypes($t->getPhpType());
         } else {
             $tag->setTypes($prop->getType()->getPhpType());
         }
     }
     $docBlock->setTag($tag);
 }