-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Serializer] Remove datetime serializer #48982
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
Conversation
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
What if people uses |
@@ -148,7 +148,8 @@ | |||
"symfony/security-acl": "~2.8|~3.0", | |||
"twig/cssinliner-extra": "^2.12|^3", | |||
"twig/inky-extra": "^2.12|^3", | |||
"twig/markdown-extra": "^2.12|^3" | |||
"twig/markdown-extra": "^2.12|^3", | |||
"vimeo/psalm": "^5.0@dev" |
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.
you shouldn't change composer.json, not the scope of this PR. BTW, what was your intention by adding psalm?
self::TIMEZONE_KEY => null, | ||
]; | ||
|
||
private const SUPPORTED_TYPES = [ | ||
\DateTimeInterface::class => true, | ||
\DateTimeImmutable::class => true, | ||
\DateTime::class => true, |
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.
Are you sure to drop support of normalization of \DateTime
?
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.
This part is a no-go. We must still support normalizing DateTime
objects. Otherwise, we force dropping usages of DateTime in all projects instead (and this is a BC break)
@@ -195,7 +190,6 @@ public function testDenormalizeUsingFormatPassedInContext() | |||
{ | |||
$this->assertEquals(new \DateTimeImmutable('2016/01/01'), $this->normalizer->denormalize('2016.01.01', \DateTimeInterface::class, null, [DateTimeNormalizer::FORMAT_KEY => 'Y.m.d|'])); | |||
$this->assertEquals(new \DateTimeImmutable('2016/01/01'), $this->normalizer->denormalize('2016.01.01', \DateTimeImmutable::class, null, [DateTimeNormalizer::FORMAT_KEY => 'Y.m.d|'])); | |||
$this->assertEquals(new \DateTime('2016/01/01'), $this->normalizer->denormalize('2016.01.01', \DateTime::class, null, [DateTimeNormalizer::FORMAT_KEY => 'Y.m.d|'])); |
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.
As normalization of \DateTime
should be still supported, you should restore this test.
$this->assertEquals(new \DateTime('2016/01/01', new \DateTimeZone('UTC')), $this->normalizer->denormalize('2016-01-01T00:00:00+00:00', \DateTime::class)); | ||
$this->assertEquals(new \DateTime('2016/01/01', new \DateTimeZone('UTC')), $this->normalizer->denormalize(' 2016-01-01T00:00:00+00:00 ', \DateTime::class)); |
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.
As normalization of \DateTime
should be still supported, you should restore this test.
@@ -88,29 +87,29 @@ public function denormalize(mixed $data, string $type, string $format = null, ar | |||
} | |||
|
|||
if (null !== $dateTimeFormat) { | |||
$object = \DateTime::class === $type ? \DateTime::createFromFormat($dateTimeFormat, $data, $timezone) : \DateTimeImmutable::createFromFormat($dateTimeFormat, $data, $timezone); |
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.
As $type
is an argument, be careful to still support this way for users to decide of final normalization.
self::TIMEZONE_KEY => null, | ||
]; | ||
|
||
private const SUPPORTED_TYPES = [ | ||
\DateTimeInterface::class => true, | ||
\DateTimeImmutable::class => true, | ||
\DateTime::class => true, |
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.
This part is a no-go. We must still support normalizing DateTime
objects. Otherwise, we force dropping usages of DateTime in all projects instead (and this is a BC break)
@Marion-Valls what is the state of this PR ? Will you work on fixing the feedback ? |
Closing as there is no more activity here. Thanks for trying |
Remove DateTime from all core bundles.