Skip to content
This repository has been archived by the owner on Jan 7, 2023. It is now read-only.

Commit

Permalink
Merge pull request #119 from goetas/official-serializer
Browse files Browse the repository at this point in the history
Official JMS serializer
  • Loading branch information
goetas authored Aug 3, 2016
2 parents b3dce9a + f45fa22 commit af667d7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 31 deletions.
19 changes: 5 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------
Expand All @@ -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
-----

Expand Down Expand Up @@ -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",
}
```

Expand Down
12 changes: 3 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down
9 changes: 5 additions & 4 deletions lib/Jms/YamlConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'>";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions tests/Converter/JMS/Xsd2JmsElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down Expand Up @@ -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',
),
),

Expand Down
5 changes: 3 additions & 2 deletions tests/Converter/JMS/Xsd2JmsGroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
)
)
Expand Down Expand Up @@ -508,4 +509,4 @@ public function testGeneralParts()
)
), $classes['Example\\Element1']);
}
}
}

0 comments on commit af667d7

Please sign in to comment.