8000 [TypeInfo] Add `TypeFactoryTrait::fromValue` method by mtarld · Pull Request #59368 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[TypeInfo] Add TypeFactoryTrait::fromValue method #59368

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
Jan 17, 2025

Conversation

mtarld
Copy link
Contributor
@mtarld mtarld commented Jan 6, 2025
Q A
Branch? 7.3
Bug fix? no
New feature? yes
Deprecations? no
Issues
License MIT

Add TypeFactoryTrait::fromValue method that will create a Type instance from a given value as precisely as possible.

@mtarld mtarld force-pushed the feat/create-type-from-value branch from 7b09bed to cc740e1 Compare January 6, 2025 11:47
@nicolas-grekas
Copy link
Member

What's the use case? When do we not know the type ahead of time and need a value?

@mtarld
Copy link
Contributor Author
mtarld commented Jan 6, 2025

IMO, this could be used within Serializer's normalizers, especially in their supports method to introspect the value and know if it could be normalized, WDYT?

Copy link
Member
@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

Works for me then, if there's a use case :)

@fabpot
Copy link
Member
fabpot commented Jan 17, 2025

Thank you @mtarld.

@fabpot fabpot merged commit 073cbf1 into symfony:7.3 Jan 17, 2025
11 checks passed
@mtarld mtarld deleted the feat/create-type-from-value branch January 17, 2025 07:19
@fabpot fabpot mentioned this pull request May 2, 2025
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
0