diff --git a/README.md b/README.md index 6d73e81..a87fd82 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Convert XSD into PHP classes. With `goetas/xsd2php` you can convert any XSD/WSDL definition into PHP classes. -XSD2PHP can also generate [JMS Serializer](http://jmsyst.com/libs/serializer) compatible metadata that can be used to serialize/unserialize the object instances. +**XSD2PHP can also generate [JMS Serializer](http://jmsyst.com/libs/serializer) compatible metadata that can be used to serialize/unserialize the object instances**. Installation ----------- @@ -20,22 +20,13 @@ There is one recommended way to install xsd2php via [Composer](https://getcompos * adding the dependency to your ``composer.json`` file: ```js - "require": { + "require-dev": { .. - "goetas/xsd2php":"^2.0", - "jms/serializer": "serializer-master-dev as 1.0", + "goetas/xsd2php":"^2.1", .. - }, - "repositories": [{ - "type": "vcs", - "url": "https://github.com/goetas/serializer.git" - }], + } ``` -This package requires a patched version of JMS Serializer. -In the last year the activity of JMS serializer was very low and some features -required by this project was rejected or not yet reviewed ( [#222](https://github.com/schmittjoh/serializer/pull/222) ) - Usage ----- @@ -111,7 +102,7 @@ All reference to this type are replaced with the `Vendor/Project/CustomDateClass ```js "require" : { - "goetas-webservices/xsd2php-runtime":"^0.1", + "goetas-webservices/xsd2php-runtime":"^0.2.2", } ``` diff --git a/composer.json b/composer.json index c1f6d6b..6733cbb 100644 --- a/composer.json +++ b/composer.json @@ -20,21 +20,15 @@ "php": ">=5.5", "symfony/console": "^2.1|^3.0", "symfony/yaml": "^2.1|^3.0", - "goetas-webservices/xsd-reader": "^0.1", + "goetas-webservices/xsd-reader": "^0.1.2", "doctrine/inflector": "^1.0", "zendframework/zend-code": "~2.3" }, "require-dev": { "phpunit/phpunit": "^4.8|^5.0", - "jms/serializer": "serializer-master-dev as 1.0", - "goetas-webservices/xsd2php-runtime": "^0.1" + "jms/serializer": "^1.2", + "goetas-webservices/xsd2php-runtime": "^0.2.2" }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/goetas/serializer.git" - } - ], "autoload": { "psr-4": { "Goetas\\Xsd\\XsdToPhp\\": "lib/" diff --git a/lib/Jms/YamlConverter.php b/lib/Jms/YamlConverter.php index dcff69f..0c82da0 100644 --- a/lib/Jms/YamlConverter.php +++ b/lib/Jms/YamlConverter.php @@ -29,10 +29,10 @@ public function __construct(NamingStrategy $namingStrategy) parent::__construct($namingStrategy); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "dateTime", function (Type $type) { - return "Goetas\Xsd\XsdToPhp\XMLSchema\DateTime"; + return 'GoetasWebservices\Xsd\XsdToPhp\XMLSchema\DateTime'; }); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "time", function (Type $type) { - return "Goetas\Xsd\XsdToPhp\XMLSchema\Time"; + return 'GoetasWebservices\Xsd\XsdToPhp\XMLSchema\Time'; }); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "date", function (Type $type) { return "DateTime<'Y-m-d'>"; @@ -351,9 +351,9 @@ private function visitAttribute(&$class, Schema $schema, AttributeItem $attribut } elseif ($itemOfArray = $this->isArrayType($attribute->getType())) { if ($valueProp = $this->typeHasValue($itemOfArray, $class, 'xx')) { - $property["type"] = "Goetas\Xsd\XsdToPhp\Jms\SimpleListOf<" . $valueProp . ">"; + $property["type"] = "GoetasWebservices\Xsd\XsdToPhp\Jms\SimpleListOf<" . $valueProp . ">"; } else { - $property["type"] = "Goetas\Xsd\XsdToPhp\Jms\SimpleListOf<" . $this->findPHPName($itemOfArray) . ">"; + $property["type"] = "GoetasWebservices\Xsd\XsdToPhp\Jms\SimpleListOf<" . $this->findPHPName($itemOfArray) . ">"; } $property["xml_list"]["inline"] = false; @@ -426,6 +426,7 @@ private function visitElement(&$class, Schema $schema, ElementItem $element, $ar $property["type"] = "array<" . $visited["type"] . ">"; $property["xml_list"]["inline"] = false; + $property["xml_list"]["skip_when_empty"] = $element->getMin() === 0; $property["xml_list"]["entry_name"] = $itemOfArray->getName(); if ($schema->getTargetNamespace()) { $property["xml_list"]["namespace"] = $schema->getTargetNamespace(); diff --git a/tests/Converter/JMS/Xsd2JmsElementTest.php b/tests/Converter/JMS/Xsd2JmsElementTest.php index a1b8426..d0a9970 100644 --- a/tests/Converter/JMS/Xsd2JmsElementTest.php +++ b/tests/Converter/JMS/Xsd2JmsElementTest.php @@ -111,7 +111,7 @@ public function testElementOfBaseType($xsType, $phpName) 'getter' => 'value', 'setter' => 'value', ), - 'type' => 'Goetas\\Xsd\\XsdToPhp\\XMLSchema\\DateTime', + 'type' => 'GoetasWebservices\Xsd\XsdToPhp\XMLSchema\DateTime', ), )) ), $classes['Example\ElementOne']); @@ -151,7 +151,7 @@ public function testElementOfBaseTypeAnon($xsType, $phpName) 'getter' => 'value', 'setter' => 'value', ), - 'type' => 'Goetas\\Xsd\\XsdToPhp\\XMLSchema\\DateTime', + 'type' => 'GoetasWebservices\Xsd\XsdToPhp\XMLSchema\DateTime', ), ), diff --git a/tests/Converter/JMS/Xsd2JmsGroupTest.php b/tests/Converter/JMS/Xsd2JmsGroupTest.php index fe3b91e..a48b9ff 100644 --- a/tests/Converter/JMS/Xsd2JmsGroupTest.php +++ b/tests/Converter/JMS/Xsd2JmsGroupTest.php @@ -290,7 +290,8 @@ public function testArray() 'xml_list' => array( 'inline' => false, 'entry_name' => 'string', - 'namespace' => 'http://www.example.com' + 'namespace' => 'http://www.example.com', + 'skip_when_empty' => false ) ) ) @@ -508,4 +509,4 @@ public function testGeneralParts() ) ), $classes['Example\\Element1']); } -} \ No newline at end of file +}