WsdlToPhp / PackageGenerator

Generates a PHP SDK based on a WSDL, simple and powerful, WSDL to PHP
https://providr.io
MIT License
428 stars 73 forks source link

Wrong autoload/psr-4 in composer.json #306

Open gugglegum opened 1 year ago

gugglegum commented 1 year ago

Describe the bug

For some reason, autoload.psr-4 section is generated wrong when used custom namespace.

To Reproduce

Here's the generating code:

$options = GeneratorOptions::instance();
$options->setOrigin('https://**********.com/test/wsdl/inventory2.0.0RC4/InventoryService.wsdl')
    ->setDestination(__DIR__ . '/../test-wsdl-driver')
    ->setSrcDirname('src')
    ->setNamespace('My\Specific\Namespace\Wsdl')
    ->setNamespaceDictatesDirectories(false)
    ->setComposerName('test/test-wsdl-driver');
// Generator instantiation
$generator = new Generator($options);
// Package generation
$generator->generatePackage();

For some reason autoload section in composer.json contains a namespace after src folder:

    "autoload": {
        "psr-4": {
            "My\\Specific\\Namespace\\Wsdl\\": "./src\\My\\Specific\\Namespace\\Wsdl"
        }
    }

Expected behavior

I expect that according to setNamespaceDictatesDirectories(false) the root of WSDL code will be placed in the src folder and autoload section will look like:

    "autoload": {
        "psr-4": {
            "My\\Specific\\Namespace\\Wsdl\\": "src/"
        }
    }

Additional context

It would also be great if I could specify setSrcDirname('src/Inventory') and setNamespace('My\Specific\Namespace\Wsdl\Inventory'), but autoload.psr-4 would still be "My\\Specific\\Namespace\\Wsdl\\": "src/". This can be useful if I want to group multiple WSDL libraries in one composer package. Each actual WSDL library will be placed in a separate subfolder within src folder, but with a common root namespace.