goetas/xsd2php — pull request #51 by das-peter (2014-12-02 10:44:10+00:00)
Title: Adjustment for YamlConverter to specify SimpleType / ComplexTypeSimpleCo...

# Issue
I try to convert the xsd files provided for the [VDV EKAP 431](https://www.vdv.de/ip-kom-oev.aspx) ([xsd archive](https://www.vdv.de/trias-xsd-v1.0.zipx?forced=true)) service using xsd2php.
This seems to work pretty well but when creating the JMS YAML metadata the output seems to be inconsistent to the generated classes.

Here's an example:
Generated class Trias\LocationRefStructureType types stopPointRef clearly as string:
```php
/**
* Class representing LocationRefStructureType
*
* Reference to a stop, address, POI, locality
* XSD Type: LocationRefStructure
*/
class LocationRefStructureType
{

/**
* @property string $stopPointRef
*/
private $stopPointRef = null;

/**
* Sets a new stopPointRef
*
* @param string $stopPointRef
* @return self
*/
public function setStopPointRef($stopPointRef)
{
$this->stopPointRef = $stopPointRef;
return $this;
}
```

Generated metadata Trias/LocationRefStructureType.yaml types stopPointRef clearly as Trias\StopPointRef:
```yaml
Trias\LocationRefStructureType:
properties:
stopPointRef:
expose: true
access_type: public_method
serialized_name: StopPointRef
xml_element:
namespace: trias
accessor:
getter: getStopPointRef
setter: setStopPointRef
type: Trias\StopPointRef
```

Used code to generate code:
```
php vendor/goetas/xsd2php/bin/xsd2php.php convert:php trias-xsd-v1.0/Trias.xsd \
--ns-map='trias;Trias/' \
--ns-dest='Trias/;src/Trias' \
--ns-map='http://www.siri.org.uk/siri;Siri/' \
--ns-dest='Siri/;src/Siri' \
--ns-map='http://www.ifopt.org.uk/ifopt;Ifopt/' \
--ns-dest='Ifopt/;src/Ifopt' \
--ns-map='http://www.ifopt.org.uk/acsb;Ifopt/Acsb/' \
--ns-dest='Ifopt/Acsb/;src/Ifopt/Acsb' \
--ns-map='http://datex2.eu/schema/1_0/1_0;Datex2/' \
--ns-dest='Datex2/;src/Datex2'
```

Used code to generate metadata:
```
php vendor/goetas/xsd2php/bin/xsd2php.php convert:jms-yaml trias-xsd-v1.0/Trias.xsd \
--ns-map='trias;Trias/' \
--ns-dest='Trias/;src/Trias' \
--ns-map='http://www.siri.org.uk/siri;Siri/' \
--ns-dest='Siri/;src/Siri' \
--ns-map='http://www.ifopt.org.uk/ifopt;Ifopt/' \
--ns-dest='Ifopt/;src/Ifopt' \
--ns-map='http://www.ifopt.org.uk/acsb;Ifopt/Acsb/' \
--ns-dest='Ifopt/Acsb/;src/Ifopt/Acsb' \
--ns-map='http://datex2.eu/schema/1_0/1_0;Datex2/' \
--ns-dest='Datex2/;src/Datex2' \
--alias-map='http://www.w3.org/2001/XMLSchema;anyType;Drupal\clients_vdv\Jms\Handler\VdvAnyType' \
--alias-map='http://www.w3.org/2001/XMLSchema;anySimpleType;Drupal\clients_vdv\Jms\Handler\VdvAnySimpleType'
```

# Solution proposal

I think the both types should match and since I think it's desirable to keep the nesting as low as possible the metadata should follow the generated classes and accept the simple type.
The changes I made check if the element is an instance of SimpleType / ComplexTypeSimpleContent and if so uses the inner type for the YAML type.
The example case now outputs this JMS YAML metadata:
```yaml
Trias\LocationRefStructureType:
properties:
stopPointRef:
expose: true
access_type: public_method
serialized_name: StopPointRef
xml_element:
namespace: trias
accessor:
getter: getStopPointRef
setter: setStopPointRef
type: string
```