Skip to content

[PropertyInfo] Support multiple types for collection keys & values #39020

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

Merged

Conversation

Korbeil
Copy link
Contributor

@Korbeil Korbeil commented Nov 6, 2020

Q A
Branch? 5.x
Bug fix? no
New feature? yes
Deprecations? yes
Tickets #38093
License MIT
Doc PR N/A

This PR is here to introduce multiple types for collection keys & values.
Today, we support types as following: A|B|C thanks to getTypes interface (in extractors) but we do not support union types in collection keys or values, such as array<A|B|C>. This PR will allow this.
In a next PR, we'll introduce an Extractor that will parse phpDoc in order to have union types in collection keys or values.

I tried to introduce as few depreciations as possible, we have only 2 of them here:

  • Type::getCollectionKeyType
  • Type::getCollectionValueType

@Korbeil Korbeil force-pushed the feature/property-info-collection-union-types branch 4 times, most recently from 9a93cc6 to f7b9e83 Compare November 7, 2020 21:48
@Korbeil Korbeil force-pushed the feature/property-info-collection-union-types branch 4 times, most recently from 28248c6 to 706583d Compare November 8, 2020 12:18
@nicolas-grekas nicolas-grekas added this to the 5.x milestone Nov 9, 2020
@Korbeil Korbeil force-pushed the feature/property-info-collection-union-types branch 5 times, most recently from 871c1f5 to f1ce521 Compare November 13, 2020 21:47
@Korbeil Korbeil force-pushed the feature/property-info-collection-union-types branch from 28de431 to 65aeb32 Compare November 13, 2020 23:07
@Korbeil
Copy link
Contributor Author

Korbeil commented Nov 16, 2020

ping @dunglas, if you have time to review that PR

Copy link
Member

@lyrixx lyrixx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except one little comment, I think this is OK

@Korbeil Korbeil force-pushed the feature/property-info-collection-union-types branch from 65aeb32 to 7ee15d1 Compare December 2, 2020 19:07
@Korbeil Korbeil force-pushed the feature/property-info-collection-union-types branch from 7ee15d1 to 79352da Compare December 22, 2020 22:56
@Korbeil
Copy link
Contributor Author

Korbeil commented Dec 22, 2020

@dunglas any news on this PR ?

@Korbeil Korbeil force-pushed the feature/property-info-collection-union-types branch from 79352da to 84dd178 Compare December 31, 2020 09:27
@lyrixx
Copy link
Member

lyrixx commented Dec 31, 2020

Thank you @Korbeil.

@lyrixx lyrixx merged commit 29c7bfa into symfony:5.x Dec 31, 2020
@Korbeil Korbeil deleted the feature/property-info-collection-union-types branch December 31, 2020 09:51
@fabpot fabpot mentioned this pull request Apr 18, 2021
derrabus added a commit that referenced this pull request May 31, 2021
…< 5.3 (jderusse)

This PR was merged into the 5.3 branch.

Discussion
----------

[Serializer][Validator] Add conflict with property-info < 5.3

| Q             | A
| ------------- | ---
| Branch?       | 5.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Both components uses the `getCollectionValueTypes` method from property-info that has been introduced in 5.3 in #39020

https://github.com/symfony/symfony/blob/3581145643f92dba52383c7978cfa3c03ab6c9c1/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php#L415

https://github.com/symfony/symfony/blob/3581145643f92dba52383c7978cfa3c03ab6c9c1/src/Symfony/Component/Validator/Mapping/Loader/PropertyInfoLoader.php#L122

Commits
-------

c47086e Add conflict with property-info < 5.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants