Commit c2db99f
Align Time\Duration with the native implementation
Runs the phpt tests of php-src (php/php-src#23073) unmodified against the
polyfill, and fixes the divergences that are left:
* use the native ZPP wording for the multiplyBy()/divideBy() argument errors,
and reject a negative divisor with ValueError instead of DivisionByZeroError
* detect the nanoseconds overflow of multiplyBy(), which turned into
"TypeError: ... must be of type int, float given"
* reject "PT1HS" and "PTS", which the native parser does not accept
* validate $nanoseconds before the range of $seconds in fromSeconds()
* report the native range error in fromMinutes()/fromHours()/fromMicroseconds()/
fromMilliseconds() and when parsing an ISO-8601 duration
* forbid dynamic properties, as the native readonly class does
The range and the sign of zero durations are now enforced in a single place,
so that no operation can return a Duration that breaks the class invariants.
On the test side, the phpt files are byte-identical to php-src, except
helper.inc which cannot use the syntax of PHP >= 8.5, and new.phpt which is
covered by DurationTest since a userland class cannot reject
ReflectionClass::newInstanceWithoutConstructor(). DurationTest now runs on
PHP >= 8.6 too, so its expectations are checked against the native class.
Also adds the subtree split, moves the classmap entry next to the other 8.6
polyfills and ignores the temporary files written by PhptTest.1 parent 16ed7cf commit c2db99f
10 files changed
Lines changed: 402 additions & 418 deletions
File tree
- src/Time
- Resources/stubs/Time
- tests/Time
- phpt
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
| 177 | + | |
177 | 178 | | |
178 | 179 | | |
179 | | - | |
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
80 | | - | |
81 | | - | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
9 | 20 | | |
10 | 21 | | |
11 | 22 | | |
| |||
0 commit comments