-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
DateInterval
no longer respects start/end class types
#18057
Comments
It seems that this issue has been fixed in the 8.4 version during the subtle comparison. In fact, when calling this code in PHP versions lower than 8.4, you can avoid this issue by adding the third parameter DatePeriod::INCLUDE_END_DATE |
No, it is clearly not fixed: |
For me, it appears that DatePeriod is broken since 8.4.1. Before, the end date is not included by default. Starting from 8.4.1, it is. |
Well that's just great... That change is not in the changelog either... |
got it ,I seem to understand what you mean. The official explanation for this issue can be found in #9401. You can take a look |
So basically they broke it permanently, but in a weird way, and with no changelog. How could they not include these changes in the changelog? Makes no sense, they're BC breaks!
Both DateTime and DateTimeImmutable have the same constructor signature, they should have thought of that when they added the interface. Carbon does not implement its own constructor, Chronos (which I use) extends it and calls the parent constructor. I'm sure almost all custom extensions of |
DateInterval
iterated types no longer mirror parameter typeshttps://3v4l.org/VIQbo#v7.4.33 // TestClass
https://3v4l.org/VIQbo#v8.0.30 // DateTimeImmutable
This used to be consistent in PHP7.4 and below,
start
,end
AND iterated values were all of the same class,but since PHP 8.0, they are no longer consistent for some reason, and it's weird, because there should be no issue with compatibility having it the way it used to be. It used to be objectively better.
I only noticed it now because I had to update a legacy project from 7.3 to 8.3. Now I will also have to manually wrap any code that iterates over
DatePeriod
.PHP Version
PHP 8.0+
Operating System
No response
The text was updated successfully, but these errors were encountered: