Skip to content

issue #324 - fix how composer settings are created in the GeneratorOptions class#336

Merged
mikaelcom merged 8 commits into
WsdlToPhp:developfrom
ajoh504:feature/issue-324
Apr 6, 2026
Merged

issue #324 - fix how composer settings are created in the GeneratorOptions class#336
mikaelcom merged 8 commits into
WsdlToPhp:developfrom
ajoh504:feature/issue-324

Conversation

@ajoh504

@ajoh504 ajoh504 commented Feb 28, 2026

Copy link
Copy Markdown
Contributor

The GeneratorOptions::setOptionValue method contains a new condtion to check if the current input contains composer settings, and internally calls setComposerSettings if so. The unit tests attempt to test the following possibilites:

  1. Composer settings are sent via command line
  2. Composer settings are sent via a PHP project script

This fixes issue #324 where, when adding composer settings via the command line, the composer.json file was written as this:

"0": "config.disable-tls:true",
"1": "autoload.psr-4.Custom\\SoapClient\\:./Custom/SoapClient/"

instead of this:

"autoload": {
    "psr-4": {
        "Custom\\SoapClient\\": "./Custom/SoapClient/"
    }
},
"config": {
  "disable-tls": true
}

- Used internally by the class to determine if the setComposerSettings method has been called already
- When set to true, this property ensures 'setComposerSettings' is not called infinitely
- the condition checks if the input contains composer settings, then calls 'setComposerSettings' if so
- updating 'calledSetComposerSettings' to true before calling 'setComposerSettings' is required to prevent an infinite call chain
- this fixes issue WsdlToPhp#324 where the composer settings are incorrectly written to the composer.json file
- the goal is to test writing composer settings both from the command line and from a PHP array
- this is to ensure that the caller can successfully create composer settings from both the command line and from a WsdlToPHP project script
@mikaelcom

Copy link
Copy Markdown
Member

Thanks for you work @ajoh504 , could you add at least one test in the WsdlToPhp\PackageGenerator\Tests\File\ComposerTest to see an actual composer.json result?

- this test also adds additional composer settings via `setOptionComposerSettings`
@ajoh504

ajoh504 commented Mar 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for you work @ajoh504 , could you add at least one test in the WsdlToPhp\PackageGenerator\Tests\File\ComposerTest to see an actual composer.json result?

Hi @mikaelcom, my pleasure. I've added an additional test to assertJson, however I don't believe this properly covers the code changes since the primary change was in GeneratorOptions::setOptionValue.

I considered creating an instance of GeneratorOptionsTest inside the ComposerTest, but I did not see anywhere in the Test suite where test classes referenced other test classes. Please let me know if you have additional recommendations for code test coverage.

Comment thread tests/File/ComposerTest.php Outdated
Comment thread src/ConfigurationReader/GeneratorOptions.php Outdated

@mikaelcom mikaelcom left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be adapted 😉

Comment thread src/ConfigurationReader/GeneratorOptions.php Outdated
Comment thread src/ConfigurationReader/GeneratorOptions.php Outdated
Comment thread src/ConfigurationReader/GeneratorOptions.php Outdated
Comment thread src/ConfigurationReader/GeneratorOptions.php Outdated
- Order the key/value pairs to appropriately match the expected values and actual values
@ajoh504

ajoh504 commented Mar 15, 2026

Copy link
Copy Markdown
Contributor Author

I'm finding some failures with the PHP Unit tests for the ComposerTest class. One example is that the expected value does not have an "author" entry but the actual value does. Another example has to do with Windows vs. *nix path separators. Should I create a separate issue for this? I could work on this issue next.

@mikaelcom

Copy link
Copy Markdown
Member

I'm finding some failures with the PHP Unit tests for the ComposerTest class. One example is that the expected value does not have an "author" entry but the actual value does. Another example has to do with Windows vs. *nix path separators. Should I create a separate issue for this? I could work on this issue next.

Feel free to create a new issue then 😉

Comment thread tests/resources/generated/ValidBingComposerSettingsAdditionalOptions.json Outdated
Co-authored-by: Mikaël DELSOL <contact@mikael-delsol.fr>

@mikaelcom mikaelcom left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me know if you can't merge by yourself

@ajoh504 ajoh504 closed this Apr 4, 2026
@ajoh504 ajoh504 reopened this Apr 4, 2026
@ajoh504

ajoh504 commented Apr 4, 2026

Copy link
Copy Markdown
Contributor Author

It looks like I only have the option to "Close with comment."

@mikaelcom mikaelcom merged commit 22d2cec into WsdlToPhp:develop Apr 6, 2026
2 of 4 checks passed
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

Successfully merging this pull request may close these issues.

Composer Settings Are Incorrectly Created With A Numeric Index In The Composer JSON File

2 participants