goetas-webservices / xsd2php

Convert XSD into PHP classes and JMS serializer definitions
MIT License
234 stars 88 forks source link

Not escaping */ in php comments #165

Open tredvermtraud opened 7 months ago

tredvermtraud commented 7 months ago

While using this amazing tool I noticed that Comments are parsed from xsd to php without escaping slashes ( / ). Thus resulting in a broken class (which can easily be fixed by escaping the slash with a backslash ( \ ) ).

The following XSD:

<xs:element name="uuidUrsprungsnachricht" minOccurs="0" type="bdt:UUID">
  <xs:annotation>
    <xs:documentation>[...] xga:satz/xga:*/xga:uuid [...]</xs:documentation>
  </xs:annotation>
</xs:element>

Results in the following PHP:

  /**
   * [...] xga:satz/xga:*/xga:uuid [...].
   *
   * @var string $uuidUrsprungsnachricht
   */
  private $uuidUrsprungsnachricht = null;

It could be fixable by just adding a backslash before the slash

  /**
   * [...] xga:satz\/xga:*\/xga:uuid [...]
   *
   * @var string $uuidUrsprungsnachricht
   */
  private $uuidUrsprungsnachricht = null;

I have shortened the commentary and replaced it with [...] to prevent unnecessary bloating. I assume a simple search and replace could be all that is needed to prevent this in the future?