Closed kiler129 closed 4 years ago
Looks like a good idea to me.
I had a doubt about when the DateTimeInterface
was introduced, so I checked : https://www.php.net/manual/fr/class.datetimeinterface.php
>=5.5
should be enough.
Thanks for the idea btw ;)
@yann-eugone I did a PR for that change: https://github.com/prestaconcept/PrestaSitemapBundle/pull/202
It simply bumps the PHP version to 5.5.0 and replaces DateTime
with DateTimeInterface
@yann-eugone Poke :yum:
Sorry I'm late.
I don't understand why don't you just did the thing you were saying you will in the issue ? That solution look better to me, the issue was the version checking, as immutable dates were not introduced in PHP 7.
Could you stick to this, cancel your changes on the composer.json, and add NEXT_MAJOR methods comments everywhere ?
This has been done and released in v2.0.0
Problem
Running the bundle on 7.3 I discovered that last update date cannot be set to an instance of
\DateTimeImmutable
. The problem is caused by the typehint onUrlConcrete
:https://github.com/prestaconcept/PrestaSitemapBundle/blob/5ec8028a16c63c97ab328f7acf456eac571916bc/Sitemap/Url/UrlConcrete.php#L89-L94
Solution
The proper typehint would be
\DateTimeInterface
, but since the bundle supports PHP 5 I suggest that the setter is changed to manually trigger the same messages as native typehint:Backward compatibility
To compare the behavior:
That way there is no difference in behavior of invalid arguments, but on PHP 7.3 it's possible to pass
\DateTimeImmutable
.WDYT about such change? It will greatly simplify our workflow (so we don't have to convert the dates for every link).