Skip to content

Commit 4a38ab2

Browse files
committed
Fix some issues
Thanks to @kylekatarnis for spotting them!
1 parent afc73a3 commit 4a38ab2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

proposed/clock-meta.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ There are currently a few libraries that provide this functionality, however the
1414

1515
Symfony provides a package called `symfony/phpunit-bridge` that has a `Symfony\Bridge\PhpUnit\ClockMock` class, which allows mocking PHP's built-in time and date functions, however this does not solve mocking calls to `new \DateTimeImmutable()`. It also does not fully mock time when called from other libraries that rely on the system time.
1616

17-
`Cake\Chronos\Chronos` does provide mocking via a static `setTestNow()` method, but this has its own pitfalls as it provides no isolation and must be called again to stop mocking.
17+
`Carbon\Carbon` – and being forked from that also `Cake\Chronos\Chronos` – do provide mocking via a static `setTestNow()` method, but this has its own pitfalls as it provides no isolation and must be called again to stop mocking.
1818

1919
Pros:
2020

@@ -54,7 +54,7 @@ We have decided to formalize the existing practices, used by several other packa
5454

5555
(This list is not exhaustive!)
5656

57-
interfaces, and some relying on overloading (extending) the Clock class to mock the
57+
Some of these providing interfaces, and some relying on overloading (extending) the Clock class to mock the
5858
current time.
5959

6060
These implementations all provide a `now()` method which returns a `DateTimeImmutable` object. As the `DateTimeImmutable` object allows retrieving the Unix timestamp, by calling `getTimestamp()` or `format('u.U')`, this interface does not define any special methods to retrieve a Unix timestamp or any other time information that is not available from a `DateTimeImmutable` object.
@@ -65,7 +65,7 @@ Time by now is defined by interaction of electromagnetic radiation with the exci
6565

6666
This means that for the sake of this PSR the timezone is considered an implementation detail of the interface.
6767

68-
It is up to the implementation to make sure that the timezone is handled according to the business logic of the application. That is either by making sure that a call to `now()` will only return a `DateTimeImmutable` object with a known timezone (implicit contract) or by explicitly changing the timezone to be correct for the application. This an be done by calling `setTimezone()` to create a new `DateTimeImmutable` object with the given timezone.
68+
It is up to the implementation to make sure that the timezone is handled according to the business logic of the application. That is either by making sure that a call to `now()` will only return a `DateTimeImmutable` object with a known timezone (implicit contract) or by explicitly changing the timezone to be correct for the application. This can be done by calling `setTimezone()` to create a new `DateTimeImmutable` object with the given timezone.
6969

7070
These are though actions that are not part of the contract which this interface defines.
7171

0 commit comments

Comments
 (0)