fix(php): keep model namespace for allOf-wrapped $ref in items and params

PR
3d ago
+89-0

Fixes #25354.

A single-member allOf around a model reference can lose the PHP namespace when used as an array item or query parameter. The generated declaration becomes \PhpModelError[] instead of \php\Model\Error[].

toAllOfName() returns a type declaration that already contains namespace separators. Passing it through toModelName() again removes those separators. This change resolves a single-member allOf through its member, or resolves an explicit x-all-of-name as a qualified model name.

The regression test covers array items, query parameters, and the named override.

Validation Correction

I checked the build and sample-generation box too early. The earlier sample run reused an older CLI JAR, so its zero-diff result did not verify this patch.

Fresh verification of commit 2760f0a8ca2c02aac8d13ea2cba08aec2460921b, in an isolated checkout with JDK 11.0.27:

  • Focused CLI reactor package build passed with tests skipped. The PHP generator class in the CLI JAR matches the class compiled by that build.
  • PHP unit package: 71 tests passed, with zero failures, errors, or skips. This includes the new namespace regression.
  • The rebuilt CLI generated the issue fixture with matching fully qualified wrapped and direct reference types. The named override remains CustomError.
  • PHP 8.1 syntax checks passed for the generated Result, DefaultApi, Error, and SortDir files.
  • All 15 PHP sample configurations regenerated successfully with zero tracked changes.
  • Documentation export for the 9 affected PHP generator names completed with zero tracked changes.

The full clean package build and all-language sample and documentation generation were not run. These are PHP-scoped results.

PR Checklist

  • Read the contribution guidelines.
  • Complete the full build, sample, and documentation checklist. The PHP-scoped checks listed here do not establish that the full checklist passed.
  • Mention the PHP technical committee in the original description.

AI assisted the implementation and test execution.