Skip to content

Commit 790aa4a

Browse files
committed
grammar/spelling/trailing-spaces;
1 parent 13290ae commit 790aa4a

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

proposed/clock-meta.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44

55
Getting the current time in applications is typically achieved using the `time()` or `microtime` functions, or by using a `new \DateTimeImmutable()` class.
66

7-
Due to the nature of time progression these methods cannot be used when predictable results are needed, such as during testing.
7+
Due to the nature of time progression, these methods cannot be used when predictable results are needed, such as during testing.
88

9-
This `ClockInterface` aims to provide a standard way to consume time that allows interoperability not only when consuming the "real" time but also when predictable results need to be available. This avoids the need to use PHP extensions for testing or redeclare the `time()` function in a local namespace.
9+
This `ClockInterface` aims to provide a standard way to consume time that allows interoperability, not only when consuming the "real" time, but also when predictable results need to be available. This avoids the need to use PHP extensions for testing or redeclaring the `time()` function in a local namespace.
1010

1111
## 2. Why Bother?
1212

13-
There are currently a few libraries that provide this functionality, however there is no interopability between these different libraries, as they ship with their own clock interfaces.
13+
There are currently a few libraries that provide this functionality. However, there is no interoperability between these different libraries, as they ship with their own clock interfaces.
1414

15-
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.
15+
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

1717
`Carbon\Carbon`, and its fork `Cake\Chronos\Chronos`, do provide mocking via a static `setTestNow()` method, but this provides no isolation and must be called again to stop mocking.
1818

1919
Pros:
2020

2121
* Consistent interface to get the current time;
22-
* Easy to mock the wall clock time for repeatablility.
22+
* Easy to mock the wall clock time for repeatability.
2323

2424
Cons:
2525

@@ -45,7 +45,7 @@ calling `time()` or `date()`.
4545

4646
### 4.1 Chosen Approach
4747

48-
We have decided to formalize the existing practices used by several other packages. Some popular packages providing this functionality are:
48+
We have decided to formalize the existing practices used by several other packages. Some popular packages providing this functionality are:
4949

5050
* [`lcobucci/clock`](https://packagist.org/packages/lcobucci/clock)
5151
* [`kreait/clock`](https://packagist.org/packages/kreait/clock)
@@ -57,15 +57,15 @@ We have decided to formalize the existing practices used by several other packag
5757
Some of these provide interfaces and some rely on extending a clock class to mock the
5858
current time.
5959

60-
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.
60+
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.
6161

6262
### 4.2 Timezones
6363

64-
Time by now is defined by interaction of electromagnetic radiation with the excited states of certain atoms where the SI defines one second as the duration of 9192631770 cycles of radiation corresponding to the transition between two energy levels of the ground state of the caesium-133 atom at 0K. This means that retrieving the current time will always return the same time, no matter where it is observed. While the timezone defines *where* the time was observed it does not modify the actual "slice" of time.
64+
Time by now is defined by interaction of electromagnetic radiation with the excited states of certain atoms, where the SI defines one second as the duration of 9192631770 cycles of radiation corresponding to the transition between two energy levels of the ground state of the caesium-133 atom at 0K. This means that retrieving the current time will always return the same time, no matter where it is observed. While the timezone defines *where* the time was observed, it does not modify the actual "slice" of time.
6565

66-
This means that for the sake of this PSR the timezone is considered an implementation detail of the interface.
66+
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 can 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 actions are not defined in this interface.
7171

@@ -135,5 +135,5 @@ final class FrozenClock implements \Psr\Clock\ClockInterface
135135

136136
This document stems from the work of many people in previous years, we recognize their effort:
137137

138-
*
138+
*
139139
_**Note:** Order descending chronologically._

0 commit comments

Comments
 (0)