Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for <any /> #560

Merged
merged 1 commit into from
Dec 19, 2024
Merged

Add support for <any /> #560

merged 1 commit into from
Dec 19, 2024

Conversation

veewee
Copy link
Contributor

@veewee veewee commented Dec 6, 2024

Add support for <any />.

Fixes #559
Fixes #533

Depends on:

This PR makes it possible to generate a property for the <any /> element. It is compatible with how PHP's internal ext-soap encoding works.

Generated code:

This PR makes the system understand <any /> elements.
https://www.w3schools.com/xml/schema_complex_any.asp

Based on minOccurs and maxOccurs the code generator will know to create a string, nullable<string> or list<string>.

Examples of generated code:

/**
 * @var string
 */
private string $any;
/**
 * @var array<int<0,2>, string>
 */
private array $any;

It is possible to overwrite this default type by using https://github.com/phpro/soap-client/blob/v4.x/docs/drivers/metadata.md#type-replacements

Encoding

You can read more about how encoding/decoding works and how you can overwrite the default behaviour here:
php-soap/encoding#29

Converts (bidirectionally) into:

^ {#1769
  +"customerName": "John Doe"
  +"customerEmail": "[email protected]"
  +"any": array:2 [
    0 => "<hello>world</hello>"
    1 => "<hello>worljohn</hello>"
  ]
}

For XML:

<x:GetCustomerDetailsResponse xmlns:x="http://example.com/customerdetails">
    <customerName>John Doe</customerName>
    <customerEmail>[email protected]</customerEmail>
    <hello>world</hello>
    <hello>worljohn</hello>
</x:GetCustomerDetailsResponse>

@veewee veewee force-pushed the any branch 7 times, most recently from 52e9ff6 to 71e2a75 Compare December 19, 2024 12:36
@veewee veewee added this to the 4.0.0 milestone Dec 19, 2024
@veewee veewee merged commit bcffb75 into phpro:v4.x Dec 19, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant