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

Override required PHP version in composer.json #304

Closed gugglegum closed 1 year ago

gugglegum commented 1 year ago

Is there a way to override default requirement for PHP minimal version? Currently it requires php >= 7.4, but I would like to make it >= 8.0 since I add additional class into generated package which uses PHP 8.0 capabilities. I tried this:

$options = GeneratorOptions::instance();
$options
    ...
    ->setOptionValue(GeneratorOptions::COMPOSER_SETTINGS, ['require' => ['php' => '>= 8.0']])
    ...

or this:

$options = GeneratorOptions::instance(/* '/path/file.yml' */);
$options
    ...
    ->setComposerSettings([
        'require.php:>=8.0',
    ])
    ...

But it produces incorrect composer.json like this:

    "require": {
        "php": [
            ">=7.4",
            ">=8.0"
        ],
    },

Is there any solution instead of modifying composer.json after generation?

mikaelcom commented 1 year ago

The Composer class is responsible of merging default composer settings with passed settings but it seems it does work perfectly.

It uses the array_merge_recursive function within it but it needs some adjustements then.

Feel free to make a PR if you feel comfortable enough, I'll work on it as soon as possible otherwise.

gugglegum commented 1 year ago

@mikaelcom Well, I made a pull-request #305 which fixes this issue. I simply replaced array_merge_recursive with array_replace_recursive. Your tests don't work, at least when I run them locally with vendor\bin\phpunit or vendor\bin\phpunit --testsuite=model I see a lot of errors (even before my change). But my own tests show that the change works fine.