Skip to content
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

[3.0 proposal] Deprecate mutable DateTime-based types #2975

Open
Majkl578 opened this issue Jan 11, 2018 · 1 comment
Open

[3.0 proposal] Deprecate mutable DateTime-based types #2975

Majkl578 opened this issue Jan 11, 2018 · 1 comment

Comments

@Majkl578
Copy link
Contributor

Majkl578 commented Jan 11, 2018

I'd like to deprecate DateTimeType, DateTimeTzType, DateType, TimeType and VarDateTimeType in favor of their immutable siblings. Possibly also alias the names in 3.0 so datetime uses immutable by default.
Using mutable DateTime is generally discouraged as of DateTimeImmutable addition in PHP 5.5. It leads to many WTF effects due to methods like modify() that modify itself, but also is not supported i.e. in ORM which does object identity comparison (so modify() will not be persisted, see ORM gotcha). Docs should be updated in 2.x to suggest immutables as well.

@Ocramius
Copy link
Member

This is not a bug for DBAL, but rather for ORM.

DBAL doesn't touch the DateTime instances, so we're safe in this library.

What we can (and probably should) do in ORM is triggering deprecation warnings during metadata validation.

I fully agree with the fact that DateTime is obsolete and inadequate these days, but we provide a functionally pure API for type conversion, so the mutability is not an issue for DBAL itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants