fix: Choice(multiple: true) warning with string[] and type_info#2690
Merged
DjordyKoert merged 1 commit intoFeb 20, 2026
Merged
Conversation
When using Choice constraint with multiple: true and @var string[] annotation with type_info enabled, swagger-php emitted a warning: "@OA\Items() parent type must be array". The constraint handler created an OA\Items child on the property schema before the type describer had set type='array'. With string[] and type_info=true, the TypeInfo component treated the type as ambiguous (list or dictionary), creating a oneOf structure that left the Items orphaned on a schema without type='array'. Fix: set type='array' on the property in applyEnumFromChoiceConstraint when multiple is true, before creating the Items child. This is semantically correct since Choice(multiple: true) implies an array. Fixes nelmio#2664
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 5.x #2690 +/- ##
=======================================
Coverage 95.58% 95.58%
=======================================
Files 94 94
Lines 3035 3036 +1
=======================================
+ Hits 2901 2902 +1
Misses 134 134 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
DjordyKoert
pushed a commit
that referenced
this pull request
Feb 20, 2026
🤖 I have created a release *beep* *boop* --- ## [5.9.4](v5.9.3...v5.9.4) (2026-02-20) ### Bug Fixes * `#[MapRequestPayload]` & `#[MapUploadedFile]` combined on same route ([#2689](#2689)) ([4ff48e7](4ff48e7)) * Choice(multiple: true) warning with string[] and type_info ([#2690](#2690)) ([1c608db](1c608db)) * Count constraint uses minProperties/maxProperties for maps ([#2688](#2688)) ([e8196ef](e8196ef)) * LegacyType deprecation warning in Configuration ([#2687](#2687)) ([3c06392](3c06392)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2664
When using
#[Assert\Choice(multiple: true)]with/** @var string[] */andtype_info: true, swagger-php emits:Root cause: The constraint handler (
applyEnumFromChoiceConstraint) creates anOA\Itemschild on the property schema before the type describer runs. Withstring[]+type_info: true, TypeInfo treats the type as ambiguous (list or dictionary) and creates aoneOfstructure — leaving theItemsorphaned on a schema withouttype='array'.Fix: Set
type='array'on the property inapplyEnumFromChoiceConstraintwhenmultipleis true, before creating theItemschild. This is semantically correct sinceChoice(multiple: true)implies the value is an array.