xsd2php
xsd2php copied to clipboard
Wrong rendering of PHPDocs in generated classes
Hi.
First of all - thank you for this great tool. You did a good job.
I have noticed that the DocBlocks are created incorrectly. I have the following behaviour:
The XSD presents with the following:
<xs:complexType name="ExchangedDocumentType">
<xs:sequence>
<xs:element name="ID" type="udt:IDType"/>
<xs:element name="TypeCode" type="qdt:DocumentCodeType"/>
<xs:element name="IssueDateTime" type="udt:DateTimeType"/>
<xs:element name="IncludedNote" type="ram:NoteType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
In particular, I am concerned here with the element TypeCode, which is of the type DocumentCodeType.
The type DocumentCodeType is declared in the XSD as follows
<xs:complexType name="DocumentCodeType">
<xs:simpleContent>
<xs:extension base="qdt:DocumentCodeContentType"/>
</xs:simpleContent>
</xs:complexType>
The DocumentCodeContentType is declared in die XSD as follows:
<xs:simpleType name="DocumentCodeContentType">
<xs:restriction base="xs:token">
<xs:enumeration value="50"/>
<xs:enumeration value="80"/>
<xs:enumeration value="81"/>
<xs:enumeration value="82"/>
......
</xs:restriction>
</xs:simpleType>
The resulting class for ExchangedDocumentType is generated in this respect as follows:
/**
* Gets as typeCode
*
* @return string
*/
public function getTypeCode()
{
return $this->typeCode;
}
/**
* Sets a new typeCode
*
* @param string $typeCode
* @return self
*/
public function setTypeCode($typeCode)
{
$this->typeCode = $typeCode;
return $this;
}
Here you can see that the data type is assumed to be ``string''.
However, if one follows the information from the YAML file generated at the same time, then I would have expected another data type to be mentioned in the DocBlock, namely somenamespace\DocumentCodeType:
typeCode:
expose: true
access_type: public_method
serialized_name: TypeCode
xml_element:
cdata: false
namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100'
accessor:
getter: getTypeCode
setter: setTypeCode
type: somenamespace\DocumentCodeType
I would actually expect the following DocBlock at this point:
/**
* Gets as typeCode
*
* @return \somenamespace\DocumentCodeType
*/
public function getTypeCode()
{
return $this->typeCode;
}
/**
* Sets a new typeCode
*
* @param \somenamespace\DocumentCodeType $typeCode
* @return self
*/
public function setTypeCode($typeCode)
{
$this->typeCode = $typeCode;
return $this;
}
Can anyone help me with this issue?
Thank you very much.
somenamespace\DocumentCodeType in the YAML it is a bug, it should be string. In your case DocumentCodeContentType extends xs:token that is a string. The issue is somewhere in https://github.com/goetas-webservices/xsd2php/blob/5e5f02645da79bc4febfeb9a47cd4760861b2577/src/Jms/YamlConverter.php#L403C31-L403C31 but might be not trivial to debug.
Hi @goetas,
thank you for your answer... I will have an eye on it...