-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Ban DateTime
from the codebase
#47580
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
Comments
We will probably not be able to ban it entirely. We still need to have support for working with DateTime in several places (for instance, the form and serializer components need to support them, otherwise we're not banning them from the core but from the ecosystem) |
True. We need to keep supporting them but ideally we would not generate any anymore in v7. |
i'll assume we generally don't care about tests? |
We do, the ban should be on all the codebase. |
What's your thought on |
We should use DateTimeImmutable when possible, and consider BC/FC otherwise to use DateTimeInterface or not. |
To me, when we accept an input for a date we will format, we should use DateTimeInterface. |
This is HUGE! Mutable DateTime should have been reverted from the PHP Core already in 5.5 when DateTimeImmutable was introduced to address DateTime's mutability issues. Unfortunately this did not happen and we still have it around today. |
what's PHP internals POV on the matter? I feel like preserving DateTime with new immutable methods is the fastest route, while deprecating anything mutable. if DateTime is flawed, so is DateTimeInterface IMHO |
This PR was squashed before being merged into the 6.2 branch. Discussion ---------- Ban DateTime from the codebase | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | no | New feature? | yes | Deprecations? | yes | Tickets | #47580 | License | MIT | Doc PR | symfony As discuss in this issue, the purpose of this PR is to remove DateTime from the code base in favor to DateTimeImmutable. I will process it component by component. Feel free to discuss! Commits ------- 689385a Ban DateTime from the codebase
…Mamba) This PR was merged into the 6.2 branch. Discussion ---------- [FrameworkBundle] remove DateTime from core Bundles | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | #47580 | License | MIT | Doc PR | symfony/symfony-docs Remove DateTime from all core bundles. Find also some DateTime in the SecurityBundle, but expose to BC breaks so will be treated in another PR. Commits ------- 03ea8ff remove DateTime from FrameworkBundle
Thank you for this issue. |
It has not been resolved. |
…g Doctrine (nicolas-grekas) This PR was merged into the 6.3 branch. Discussion ---------- [Messenger] Use immutable dates in the storage when using Doctrine | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | Part of #47580 | License | MIT | Doc PR | - We already started using `DateTimeImmutable` in that class but we missed these updates. Commits ------- d6563a1 [Messenger] Use immutable dates in the storage when using Doctrine
This PR was merged into the 6.4 branch. Discussion ---------- Remove unnecessary usages of DateTime | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | Part of #47580 | License | MIT | Doc PR | - Together with #50290, this PR removes `DateTime` everywhere possible. What remains is: - test cases that test both DateTime and DateTimeImmutable - legit to keep - date/time form-types and transformers in the Form component - we'd need a separate effort for them, related to #50295 - `PersistentTokenInterface::getLastUsed(): \DateTime` - separate effort also Commits ------- 8b08294 Remove unnecessary usages of DateTime
…TokenProviderInterface::updateToken()` implementations should accept `DateTimeInterface` (nicolas-grekas) This PR was merged into the 6.4 branch. Discussion ---------- [Security] Make `PersistentToken` immutable and tell `TokenProviderInterface::updateToken()` implementations should accept `DateTimeInterface` | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | Part of #47580 | License | MIT | Doc PR | - Commits ------- 3df345c [Security] Make `PersistentToken` immutable and tell `TokenProviderInterface::updateToken()` implementations should accept `DateTimeInterface`
Some occurrences remain but they're impossible to remove IIUC (until someone proves me wrong - please do ;) ) |
This PR was squashed before being merged into the 6.2 branch. Discussion ---------- Ban DateTime from the codebase | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | no | New feature? | yes | Deprecations? | yes | Tickets | symfony#47580 | License | MIT | Doc PR | symfony As discuss in this issue, the purpose of this PR is to remove DateTime from the code base in favor to DateTimeImmutable. I will process it component by component. Feel free to discuss! Commits ------- 689385a Ban DateTime from the codebase
By being mutable,
DateTime
is flawed. We should figure out a way to remove it from the codebase and have some CI check that ensures we don't add it back by mistake. I suppose we could configure psalm to do that check for us.Help welcome!
The text was updated successfully, but these errors were encountered: