I had experience with such type of time provider (with interface) and we
realized that it's very impractical. At first, it looks cool: injecting
Clock which may be frozen here and regular there (integration tests with
real DI-container, not unit tests), but clock is singleton by its nature.
Moreover, sometimes you need time in value objects, e.g. `Uuid::v1()` or
domain entities and injecting service to them looks pretty awful.
I suggest concrete class like
```
final class Clock
{
public static function setup(Closure $clock): void
{
// ...
}
public static function now(): DateTimeImmutable
{
// ...
}
}
```
Concrete class is still fixes the interoperability problem and looks more
practical.
On Saturday, October 23, 2021 at 10:31:09 PM UTC+3 [email protected] wrote:
> Hey Larry, Hey List:
>
> On 15.09.21 19:24, Larry Garfield wrote:
> > On Mon, Sep 13, 2021, at 10:15 AM, Andreas Heigl wrote:
> […]
> >>
> >> [1]
> >>
> https://andreas.heigl.org/2016/12/22/why-not-to-convert-a-datetime-to-timestamp/
> >
> > That article is the most compelling argument I've heard yet for not
> forcing the return to UTC. An abridged version of the same point should be
> included in the metadoc.
>
> Done so via https://github.com/php-fig/fig-standards/pull/1257.
>
> I'd be happy about a review and an eventual merge.
>
> Cheers
>
> Andreas
>
> --
> ,,,
> (o o)
> +---------------------------------------------------------ooO-(_)-Ooo-+
> | Andreas Heigl |
> | mailto:[email protected] N 50°22'59.5" E 08°23'58" |
> | https://andreas.heigl.org |
> +---------------------------------------------------------------------+
> | https://hei.gl/appointmentwithandreas |
> +---------------------------------------------------------------------+
>
--
You received this message because you are subscribed to the Google Groups "PHP
Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/php-fig/0d061ce2-e916-4ff7-bd72-0c7ca7699af8n%40googlegroups.com.