8000 #2794 revert bc break preventing `DateTimeImmutable` conversion by Ocramius · Pull Request #2795 · doctrine/dbal · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

#2794 revert bc break preventing DateTimeImmutable conversion #2795

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

Ocramius
Copy link
Member

Reverts the unintentional BC break reported in #2794

Ocramius added 2 commits July 27, 2017 19:54
…ld STILL work, even if unintentionally
…le date types - reverts unintentional BC break
Copy link
Member
@alcaeus alcaeus left a comment

Choose a reason for hiding this comment

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

Looks good, as mentioned: we could check for DateTimeInterface unless you explicitly don't want to cover any possible future implementations of it.

@@ -53,7 +53,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)
return $value;
}

if ($value instanceof \DateTime) {
if ($value instanceof \DateTime || $value instanceof \DateTimeImmutable) {
Copy link
Member

Choose a reason for hiding this comment

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

Why not just use DateTimeInterface as #2678 suggested?

Copy link
Member
@lcobucci lcobucci Jul 27, 2017

Choose a reason for hiding this comment

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

As far as I know (and experienced) the interface is quite safe to be used here. I've bothered @derickr also on Twitter to help us. Because we all know that it's easier to get people's attention by being annoying HAHAHA 😜

@Ocramius
Copy link
Member Author
Ocramius commented Jul 27, 2017 via email

@alcaeus
Copy link
Member
alcaeus commented Jul 27, 2017

Because according to @derickr it cannot be relied upon

IIRC, there was something about it not being a true interface in the sense of "you can typehint against it but we don't want you to implement it" (see note in docs). Doesn't matter, fix looks good as is, was just wondering.

@Majkl578
Copy link
Contributor

As far as I know, DateTimeInterface exists just for this purpose, I don't really understand why it would be a good idea to use it. Actually typehinting is the only way it's good for - it can't be implemented in user-land anyway. And official documentation nods:

DateTimeInterface is meant so that both DateTime and DateTimeImmutable can be type hinted for. It is not possible to implement this interface with userland classes.

Copy link
Member
@lcobucci lcobucci left a comment

Choose a reason for hiding this comment

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

Patch LGTM but I'd really prefer to have the interface there.

@Ocramius Ocramius merged commit 912b2b8 into master Jul 28, 2017
@Ocramius Ocramius deleted the fix/#2794-revert-bc-break-preventing-datetimeimmutable-conversion branch July 28, 2017 10:35
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0