Post #3860080
2026-07-16 13:59 UTC
@ramsey@phpc.social
final class Duration
{
public int $microseconds { get => $this->ticks }
public function __construct(private readonly $ticks) {}
public static function zero(): self
{
static $instance = null;
$instance ??= new self(0);
return $instance;
}
}
because of the hooks I loose the readonly property on the class and "singleton" nature ... now the in-memory cache no longer works it is better to return each time a new instance
Replies (1)
-
@ramsey@phpc.social 2026-07-16 14:02
@nyamsprod@phpc.social It’s still cached in memory, but the value is mutable. Is that what you mean?