diff --git a/composer.json b/composer.json index 0755d44..7c5a2c7 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "authors": [ { "name": "Asmir Mustafic", - "email" : "goetas@gmail.com" + "email": "goetas@gmail.com" } ], "keywords": [ @@ -18,7 +18,7 @@ ], "license": "MIT", "require": { - "php": ">=7.2|^8.0", + "php": "^8.0", "symfony/console": "^2.7|^3.0|^4.0|^5.0|^6.0|^7.0", "symfony/dependency-injection": "^2.2|^3.0|^4.0|^5.0|^6.0|^7.0", "symfony/yaml": "^2.2|^3.0|^4.0|^5.0|^6.0|^7.0", diff --git a/src/Jms/YamlConverter.php b/src/Jms/YamlConverter.php index 98b5e2a..d0e369e 100644 --- a/src/Jms/YamlConverter.php +++ b/src/Jms/YamlConverter.php @@ -6,6 +6,7 @@ use Exception; use GoetasWebservices\XML\XSDReader\Schema\Attribute\AttributeContainer; use GoetasWebservices\XML\XSDReader\Schema\Attribute\AttributeItem; +use GoetasWebservices\XML\XSDReader\Schema\Element\Any\Any; use GoetasWebservices\XML\XSDReader\Schema\Element\Element; use GoetasWebservices\XML\XSDReader\Schema\Element\ElementContainer; use GoetasWebservices\XML\XSDReader\Schema\Element\ElementDef; @@ -444,7 +445,8 @@ public function getPropertyInHierarchy($class, $prop) if ( (isset($props['properties']) && count($props['properties']) > 0 && !isset($props['properties'][$prop])) || - (isset($props['properties']) && count($props['properties']) > 1)) { + (isset($props['properties']) && count($props['properties']) > 1) + ) { return false; } @@ -466,7 +468,9 @@ public function getPropertyInHierarchy($class, $prop) */ protected function getElementNamespace(Schema $schema, ElementItem $element) { - if ($element->getSchema()->getTargetNamespace() && + if ( + (!$element instanceof Any) && + $element->getSchema()->getTargetNamespace() && ($schema->getElementsQualification() || ($element instanceof Element && $element->isQualified()) || !$element->isLocal()) ) { return $element->getSchema()->getTargetNamespace(); @@ -482,7 +486,7 @@ protected function getElementNamespace(Schema $schema, ElementItem $element) * * @return array */ - protected function &visitElement(&$class, Schema $schema, ElementItem $element, $arrayize = true) + protected function &visitElement(&$class, Schema $schema, ElementItem|Any $element, $arrayize = true) { $property = []; $property['expose'] = true; @@ -500,6 +504,11 @@ protected function &visitElement(&$class, Schema $schema, ElementItem $element, $inflector = InflectorFactory::create()->build(); $property['accessor']['getter'] = 'get' . $inflector->classify($this->getNamingStrategy()->getPropertyName($element)); $property['accessor']['setter'] = 'set' . $inflector->classify($this->getNamingStrategy()->getPropertyName($element)); + + if ($element instanceof Any) { + return $property; + } + $t = $element->getType(); if ($arrayize) { diff --git a/src/Php/PhpConverter.php b/src/Php/PhpConverter.php index 42a8103..ef33e61 100644 --- a/src/Php/PhpConverter.php +++ b/src/Php/PhpConverter.php @@ -5,6 +5,7 @@ use Exception; use GoetasWebservices\XML\XSDReader\Schema\Attribute\AttributeItem; use GoetasWebservices\XML\XSDReader\Schema\Attribute\Group as AttributeGroup; +use GoetasWebservices\XML\XSDReader\Schema\Element\Any\Any; use GoetasWebservices\XML\XSDReader\Schema\Element\Element; use GoetasWebservices\XML\XSDReader\Schema\Element\ElementDef; use GoetasWebservices\XML\XSDReader\Schema\Element\ElementItem; @@ -298,7 +299,6 @@ public function visitType(Type $type, $force = false) } if (($this->isArrayType($type) || $this->isArrayNestedElement($type)) && !$force) { - $this->classes[spl_object_hash($type)]['skip'] = true; $this->skipByType[spl_object_hash($class)] = true; @@ -451,11 +451,16 @@ private function visitAttribute(PHPClass $class, Schema $schema, AttributeItem $ * * @return \GoetasWebservices\Xsd\XsdToPhp\Php\Structure\PHPProperty */ - private function visitElement(PHPClass $class, Schema $schema, ElementSingle $element, $arrayize = true) + private function visitElement(PHPClass $class, Schema $schema, ElementSingle|Any $element, $arrayize = true) { $property = new PHPProperty(); $property->setName($this->getNamingStrategy()->getPropertyName($element)); $property->setDoc($element->getDoc()); + + if ($element instanceof Any) { + return $property; + } + if ($element->isNil() || $element->getMin() === 0) { $property->setNullable(true); } @@ -463,9 +468,7 @@ private function visitElement(PHPClass $class, Schema $schema, ElementSingle $el $t = $element->getType(); if ($arrayize) { - if ($itemOfArray = $this->isArrayType($t)) { - if (!$itemOfArray->getName()) { if ($element instanceof ElementRef) { $refClass = $this->visitElementDef($element->getReferencedElement()); @@ -485,7 +488,6 @@ private function visitElement(PHPClass $class, Schema $schema, ElementSingle $el return $property; } elseif ($itemOfArray = $this->isArrayNestedElement($t)) { - if (!$t->getName()) { if ($element instanceof ElementRef) { $refClass = $this->visitElementDef($element->getReferencedElement());