Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong rendering of PHPDocs in generated classes #160

Open
horstoeko opened this issue Oct 4, 2023 · 2 comments
Open

Wrong rendering of PHPDocs in generated classes #160

horstoeko opened this issue Oct 4, 2023 · 2 comments

Comments

@horstoeko
Copy link

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.

@goetas
Copy link
Member

goetas commented Oct 5, 2023

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.

@horstoeko
Copy link
Author

Hi @goetas,

thank you for your answer... I will have an eye on it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants