Skip to content

[TypeInfo] Add CollectionType::mergeCollectionValueTypes() #59824

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
merged 1 commit into from
Feb 26, 2025

Conversation

mtarld
Copy link
Contributor

@mtarld mtarld commented Feb 21, 2025

Q A
Branch? 7.3
Bug fix? yes
New feature? yes
Deprecations? no
Issues
License MIT

At the moment, when calling the following code:

$type = Type::fromValue([new \stdClass(), new \DateTimeImmutable()]);

used to throw an exception saying: Cannot create union with both "object" and class type.. This PR fixes that, allowing the method to return the proper Type::list(Type::object()).

It also creates the CollectionType::mergeCollectionValueTypes() method to encapsulate this logic (as it'll be used in future PRs).

@mtarld mtarld force-pushed the fix/object-class-union branch 3 times, most recently from bdeef1a to 2bf88ad Compare February 21, 2025 09:38
@fabpot
Copy link
Member

fabpot commented Feb 26, 2025

Thank you @mtarld.

@fabpot fabpot merged commit 1a1f81c into symfony:7.3 Feb 26, 2025
10 of 11 checks passed
@mtarld mtarld deleted the fix/object-class-union branch February 26, 2025 07:14
GromNaN added a commit that referenced this pull request Mar 14, 2025
This PR was merged into the 7.3 branch.

Discussion
----------

[TypeInfo] Add `ArrayShapeType` class

| Q             | A
| ------------- | ---
| Branch?       | 7.3
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Issues        |
| License       | MIT

Introduces the `ArrayShapeType` that holds the exact shape of an array. Also enables the `StringTypeResolver` to parse `array{foo: int, bar?: string}` and to create the appropriate type.

This PR needs #59824 to be merged first.

Commits
-------

af1231b [TypeInfo] Add `ArrayShapeType`
symfony-splitter pushed a commit to symfony/type-info that referenced this pull request Mar 14, 2025
This PR was merged into the 7.3 branch.

Discussion
----------

[TypeInfo] Add `ArrayShapeType` class

| Q             | A
| ------------- | ---
| Branch?       | 7.3
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Issues        |
| License       | MIT

Introduces the `ArrayShapeType` that holds the exact shape of an array. Also enables the `StringTypeResolver` to parse `array{foo: int, bar?: string}` and to create the appropriate type.

This PR needs symfony/symfony#59824 to be merged first.

Commits
-------

af1231b0dd [TypeInfo] Add `ArrayShapeType`
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.

4 participants