[php-nextgen] Add anyof Support

Merged
CK
4mo ago
+2452-170

Follow up to #23985
This PR adds support for anyOf models with and without discriminators. It copies the implementation from the oneOf model and updates some of the naming/logic to refer to Composed instead of oneOf or anyOf specifically.

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@jebentier (2017/07), @dkarlovi (2017/07), @mandrean (2017/08), @jfastnacht (2017/09), @ybelenko (2018/07), @renepardon (2018/12)


Summary by cubic

Adds anyOf support to the PHP Nextgen generator by introducing AnyOfInterface and generated dispatcher models, and updates ObjectSerializer to reliably dispatch oneOf/anyOf with safer JSON decoding. Samples, docs, and tests are regenerated, including new petstore anyOf models.

  • New Features

    • Generate anyOf dispatcher models via model_anyof.mustache; add AnyOfInterface and register it in PhpNextgenClientCodegen.
    • Add deserializeAnyOf() and dispatch for both OneOfInterface and AnyOfInterface in ObjectSerializer; dispatch runs after json_decode and before array-to-object casting.
    • Update model docs to list anyOf members and discriminator selection; skip per-property test stubs for composed models; add petstore Reptile, Smoothie, Lizard, Snake; regenerate echo and petstore samples; add anyOf polymorphism tests.
  • Bug Fixes

    • Preserve original strings when JSON decode fails (including the "null" literal); catch Throwable during deserialization; tighten composed-type validation.