From 1b1a45c1ea5cbfab4f6708a08773632704cc9f52 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 6 Mar 2023 10:02:20 +0100 Subject: [PATCH] feat(developer): Document PSR-20 implementation of ITimeFactory Signed-off-by: Joas Schilling --- developer_manual/digging_deeper/psr.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/developer_manual/digging_deeper/psr.rst b/developer_manual/digging_deeper/psr.rst index c70ba36e4..7601974da 100644 --- a/developer_manual/digging_deeper/psr.rst +++ b/developer_manual/digging_deeper/psr.rst @@ -45,7 +45,17 @@ PSR-11: Container Interface The dependency injection container follows the `PSR-11`_ container interface, so you may type-hint ``\Psr\Container\ContainerInterface`` whenever you want an instance of a container and use ``has($id)`` to check for existence and ``get($id)`` to retrieve an instance of a service. See the :ref:`dependency injection docs ` for details. +.. _psr20: + +PSR-20: Clock +------------- + +.. versionadded:: 27 + +The ``\OCP\AppFramework\Utility\ITimeFactory`` class follows the `PSR-20`_ clock interface, so you may type-hint ``\PSR\Clock\ClockInterface`` and then use the ``now()`` method whenever you want to get the current time. You can also change the timezone for the to be returned ``\DateTimeImmutable`` instance, by getting a new ``ITimeFactory`` from ``ITimeFactory::withTimeZone()``. + .. _`PSR-0`: https://www.php-fig.org/psr/psr-0/ .. _`PSR-3`: https://www.php-fig.org/psr/psr-3/ .. _`PSR-4`: https://www.php-fig.org/psr/psr-4/ .. _`PSR-11`: https://www.php-fig.org/psr/psr-11/ +.. _`PSR-20`: https://www.php-fig.org/psr/psr-20/