-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Serializer] Add DateTimeNormalizer::CAST_KEY
context option
#53056
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
[Serializer] Add DateTimeNormalizer::CAST_KEY
context option
#53056
Conversation
d45ef9a
to
fb671a2
Compare
src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Context/Normalizer/DateTimeNormalizerContextBuilder.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Context/Normalizer/DateTimeNormalizerContextBuilder.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php
Outdated
Show resolved
Hide resolved
fb671a2
to
f2e8ba2
Compare
@mtarld I've updated, is this what you had in mind with deprecation? |
39809e2
to
aa8cf48
Compare
src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php
Outdated
Show resolved
Hide resolved
dc03538
to
b3d55df
Compare
b3d55df
to
bae7e35
Compare
Should I skip those test cases on 32bit systems when value is > PHP_INT_MAX? |
src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php
Outdated
Show resolved
Hide resolved
Either that or skip the int cast on those systems. |
969e59b
to
0c85461
Compare
DateTimeNormalizer::CAST_KEY
context option
Anybody to review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good to me. But I'm wondering that maybe we can add a check to make sure that the cast value is consistent with the format? So that it won't be possible to cast d/m/Y
to an int
for example. WDYT?
But then we would go back to format guessing, which derrabus wanted to avoid :) |
Oh yeah, I missed that part... Thanks, LGTM then! |
0c85461
to
e5e925e
Compare
Thank you @norkunas. |
…ontext option (SzymonKaminski) This PR was merged into the 7.1 branch. Discussion ---------- [Serializer] Document `DateTimeNormalizer::CAST_KEY` context option PR documents new context option `CAST_KEY` of `DateTimeNormalizer` that allows to cast objects to integers or floats. Resolves #19485 Feature PR: symfony/symfony#53056 Commits ------- 5495c1d [Serializer] Document DateTimeNormalizer::CAST_KEY context option
This adds
DateTimeNormalizer::CAST_KEY
context option allowing to cast the formatted result toint
orfloat
.