Skip to content

Commit 226f9ff

Browse files
committed
always use namespacer;
1 parent 648df80 commit 226f9ff

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

proposed/clock-meta.md

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

33
## 1. Summary
44

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

77
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 redeclaring 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

@@ -24,7 +24,7 @@ Pros:
2424
Cons:
2525

2626
* Extra overhead and developer effort to get the current time;
27-
* Not as simple as calling `time()` or `date()`.
27+
* Not as simple as calling `\time()` or `\date()`.
2828

2929
## 3. Scope
3030

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

5555
Some of these provide interfaces and some rely on extending a clock class to mock the current time.
5656

57-
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.
57+
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.
5858

5959
### 4.2 Timezones
6060

6161
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.
6262

6363
This means that, for the sake of this PSR, the timezone is considered an implementation detail of the interface.
6464

65-
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.
65+
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.
6666

6767
These actions are not defined in this interface.
6868

proposed/clock.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ interfaces/functionality first.
2020
Creating a standard way of accessing the clock would allow interoperability
2121
during testing, when testing behavior that has timing-based side effects.
2222
Common ways to get the current time include calling `\time()` or
23-
`new DateTimeImmutable('now')`. However, this makes mocking the current time
23+
`new \DateTimeImmutable('now')`. However, this makes mocking the current time
2424
impossible in some situations.
2525

2626
## 1.2 Definitions

0 commit comments

Comments
 (0)