Skip to content

fix: Choice(multiple: true) warning with string[] and type_info#2690

Merged
DjordyKoert merged 1 commit into
nelmio:5.xfrom
lacatoire:fix/choice-multiple-items-parent-type
Feb 20, 2026
Merged

fix: Choice(multiple: true) warning with string[] and type_info#2690
DjordyKoert merged 1 commit into
nelmio:5.xfrom
lacatoire:fix/choice-multiple-items-parent-type

Conversation

@lacatoire

@lacatoire lacatoire commented Feb 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #2664

When using #[Assert\Choice(multiple: true)] with /** @var string[] */ and type_info: true, swagger-php emits:

User Warning: @OA\Items() parent type must be "array"

Root cause: The constraint handler (applyEnumFromChoiceConstraint) creates an OA\Items child on the property schema before the type describer runs. With string[] + type_info: true, TypeInfo treats the type as ambiguous (list or dictionary) and creates a oneOf structure — leaving 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 the value is an array.

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

codecov Bot commented Feb 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.58%. Comparing base (b1661c9) to head (1a1ce7f).
⚠️ Report is 1 commits behind head on 5.x.
✅ All tests successful. No failed tests found.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DjordyKoert DjordyKoert merged commit 1c608db into nelmio:5.x Feb 20, 2026
42 checks passed
@lacatoire lacatoire deleted the fix/choice-multiple-items-parent-type branch February 20, 2026 14:38
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>
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.

[Bug]: @OA\Items() parent type must be "array" when using Choice assert with multiple: true

2 participants