goetas-webservices / xsd2php

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

Uncaught TypeError issue after upgrading to 0.4.11 #163

Closed pribeirojtm closed 8 months ago

pribeirojtm commented 8 months ago

Hello @goetas,

I'm using the following software versions: xsd2php: 0.4.11 Composer version: 2.2.21 PHP version: 8.2.8

And when executing: php -d memory_limit=-1 vendor/bin/xsd2php convert config/config_xsd2php.yml file.xsd

I got: `PHP Fatal error: Uncaught TypeError: GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter::visitElement(): Argument #3 ($element) must be of type GoetasWebservices\XML\XSDReader\Schema\Element\ElementSingle, GoetasWebservices\XML\XSDReader\Schema\Element\Choice given, called in /var/www/oldjtm/JTM/portal-jtm/vendor/goetas-webservices/xsd2php/src/Php/PhpConverter.php on line 310 and defined in /var/www/oldjtm/JTM/portal-jtm/vendor/goetas-webservices/xsd2php/src/Php/PhpConverter.php:410 Stack trace:

0 /var/www/oldjtm/JTM/portal-jtm/vendor/goetas-webservices/xsd2php/src/Php/PhpConverter.php(310): GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter->visitElement()

1 /var/www/oldjtm/JTM/portal-jtm/vendor/goetas-webservices/xsd2php/src/Php/PhpConverter.php(117): GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter->visitComplexType()

2 /var/www/oldjtm/JTM/portal-jtm/vendor/goetas-webservices/xsd2php/src/Php/PhpConverter.php(251): GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter->visitTypeBase()

3 /var/www/oldjtm/JTM/portal-jtm/vendor/goetas-webservices/xsd2php/src/Php/PhpConverter.php(93): GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter->visitType()

4 /var/www/oldjtm/JTM/portal-jtm/vendor/goetas-webservices/xsd2php/src/Php/PhpConverter.php(61): GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter->navigate()

5 /var/www/oldjtm/JTM/portal-jtm/vendor/goetas-webservices/xsd2php/src/Command/Convert.php(62): GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter->convert()

6 /var/www/oldjtm/JTM/portal-jtm/vendor/symfony/console/Command/Command.php(312): GoetasWebservices\Xsd\XsdToPhp\Command\Convert->execute()

7 /var/www/oldjtm/JTM/portal-jtm/vendor/symfony/console/Application.php(1022): Symfony\Component\Console\Command\Command->run()

8 /var/www/oldjtm/JTM/portal-jtm/vendor/symfony/console/Application.php(314): Symfony\Component\Console\Application->doRunCommand()

9 /var/www/oldjtm/JTM/portal-jtm/vendor/symfony/console/Application.php(168): Symfony\Component\Console\Application->doRun()

10 /var/www/oldjtm/JTM/portal-jtm/vendor/goetas-webservices/xsd2php/bin/xsd2php(26): Symfony\Component\Console\Application->run()

11 /var/www/oldjtm/JTM/portal-jtm/vendor/bin/xsd2php(120): include('...')

12 {main}

thrown in /var/www/oldjtm/JTM/portal-jtm/vendor/goetas-webservices/xsd2php/src/Php/PhpConverter.php on line 410`

Do you have any clue why this is happening?

When I used older php version 7.2 and old xsd2php 0.3.9 I had no problems executing the xsd2php convert

Thanks

Vitexus commented 8 months ago

The same issue:

PHP Fatal error:  Uncaught TypeError: GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter::visitElement(): Argument #3 ($element) must be of type GoetasWebservices\XML\XSDReader\Schema\Element\ElementSingle, GoetasWebservices\XML\XSDReader\Schema\Element\Choice given, called in /home/vitex/Projects/VitexSoftware/php-vitexsoftware-pohoda-connector/vendor/goetas-webservices/xsd2php/src/Php/PhpConverter.php on line 310 and defined in /home/vitex/Projects/VitexSoftware/php-vitexsoftware-pohoda-connector/vendor/goetas-webservices/xsd2php/src/Php/PhpConverter.php:410
Stack trace:
#0 /home/vitex/Projects/VitexSoftware/php-vitexsoftware-pohoda-connector/vendor/goetas-webservices/xsd2php/src/Php/PhpConverter.php(310): GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter->visitElement()
#1 /home/vitex/Projects/VitexSoftware/php-vitexsoftware-pohoda-connector/vendor/goetas-webservices/xsd2php/src/Php/PhpConverter.php(117): GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter->visitComplexType()
#2 /home/vitex/Projects/VitexSoftware/php-vitexsoftware-pohoda-connector/vendor/goetas-webservices/xsd2php/src/Php/PhpConverter.php(251): GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter->visitTypeBase()
#3 /home/vitex/Projects/VitexSoftware/php-vitexsoftware-pohoda-connector/vendor/goetas-webservices/xsd2php/src/Php/PhpConverter.php(488): GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter->visitType()
#4 /home/vitex/Projects/VitexSoftware/php-vitexsoftware-pohoda-connector/vendor/goetas-webservices/xsd2php/src/Php/PhpConverter.php(537): GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter->findPHPClass()
#5 /home/vitex/Projects/VitexSoftware/php-vitexsoftware-pohoda-connector/vendor/goetas-webservices/xsd2php/src/Php/PhpConverter.php(472): GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter->findPHPElementClassName()
#6 /home/vitex/Projects/VitexSoftware/php-vitexsoftware-pohoda-connector/vendor/goetas-webservices/xsd2php/src/Php/PhpConverter.php(310): GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter->visitElement()
#7 /home/vitex/Projects/VitexSoftware/php-vitexsoftware-pohoda-connector/vendor/goetas-webservices/xsd2php/src/Php/PhpConverter.php(117): GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter->visitComplexType()
#8 /home/vitex/Projects/VitexSoftware/php-vitexsoftware-pohoda-connector/vendor/goetas-webservices/xsd2php/src/Php/PhpConverter.php(251): GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter->visitTypeBase()
#9 /home/vitex/Projects/VitexSoftware/php-vitexsoftware-pohoda-connector/vendor/goetas-webservices/xsd2php/src/Php/PhpConverter.php(93): GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter->visitType()
#10 /home/vitex/Projects/VitexSoftware/php-vitexsoftware-pohoda-connector/vendor/goetas-webservices/xsd2php/src/Php/PhpConverter.php(101): GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter->navigate()
#11 /home/vitex/Projects/VitexSoftware/php-vitexsoftware-pohoda-connector/vendor/goetas-webservices/xsd2php/src/Php/PhpConverter.php(61): GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter->navigate()
#12 /home/vitex/Projects/VitexSoftware/php-vitexsoftware-pohoda-connector/vendor/goetas-webservices/xsd2php/src/Command/Convert.php(62): GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter->convert()
#13 /home/vitex/Projects/VitexSoftware/php-vitexsoftware-pohoda-connector/vendor/symfony/console/Command/Command.php(326): GoetasWebservices\Xsd\XsdToPhp\Command\Convert->execute()
#14 /home/vitex/Projects/VitexSoftware/php-vitexsoftware-pohoda-connector/vendor/symfony/console/Application.php(1063): Symfony\Component\Console\Command\Command->run()
#15 /home/vitex/Projects/VitexSoftware/php-vitexsoftware-pohoda-connector/vendor/symfony/console/Application.php(320): Symfony\Component\Console\Application->doRunCommand()
#16 /home/vitex/Projects/VitexSoftware/php-vitexsoftware-pohoda-connector/vendor/symfony/console/Application.php(174): Symfony\Component\Console\Application->doRun()
#17 /home/vitex/Projects/VitexSoftware/php-vitexsoftware-pohoda-connector/vendor/goetas-webservices/xsd2php/bin/xsd2php(26): Symfony\Component\Console\Application->run()
#18 /home/vitex/Projects/VitexSoftware/php-vitexsoftware-pohoda-connector/vendor/bin/xsd2php(120): include('...')
#19 {main}
  thrown in /home/vitex/Projects/VitexSoftware/php-vitexsoftware-pohoda-connector/vendor/goetas-webservices/xsd2php/src/Php/PhpConverter.php on line 410

With: https://www.stormware.cz/xml/schema/all_schema_ver2.zip

The problem is in http://www.stormware.cz/schema/version_2/type.xsd :

  <xsd:complexType name="actionTypeItem">
    <xsd:choice>
        <xsd:element name="add" type="xsd:string">
            <xsd:annotation>
                <xsd:documentation>Vložení nového záznamu. Výchozí hodnota.</xsd:documentation>
            </xsd:annotation>
        </xsd:element>
        <xsd:element name="update" type="ftr:requestItemType">
            <xsd:annotation>
                <xsd:documentation>Aktualizace záznamu.</xsd:documentation>
            </xsd:annotation>
        </xsd:element>
        <xsd:element name="delete" type="ftr:requestItemType">
            <xsd:annotation>
                <xsd:documentation>Odstranění záznamu.</xsd:documentation>
            </xsd:annotation>
        </xsd:element>
    </xsd:choice>
</xsd:complexType>