• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

azjezz / psl / 13662276056

04 Mar 2025 08:24PM UTC coverage: 98.505% (+0.005%) from 98.5%
13662276056

push

github

web-flow
chore: update mago to version 0.16.0 (#516)

* chore: update mago to version 0.16.0

Signed-off-by: azjezz <azjezz@protonmail.com>

* chore: re-format the codebase using the latest mago

Signed-off-by: azjezz <azjezz@protonmail.com>

---------

Signed-off-by: azjezz <azjezz@protonmail.com>

35 of 35 new or added lines in 7 files covered. (100.0%)

2 existing lines in 1 file now uncovered.

5470 of 5553 relevant lines covered (98.51%)

52.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.48
/src/Psl/DateTime/Internal/high_resolution_time.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Psl\DateTime\Internal;
6

7
use Psl;
8

9
use function hrtime;
10

11
use const Psl\DateTime\NANOSECONDS_PER_SECOND;
12

13
/**
14
 * @throws Psl\Exception\InvariantViolationException
15
 *
16
 * @return array{int, int}
17
 *
18
 * @internal
19
 *
20
 * @psalm-mutation-free
21
 *
22
 * @psalm-suppress ImpureStaticVariable - We ignore the internal mutation, as is simply a static initializer.
23
 * @psalm-suppress ImpureFunctionCall - `hrtime()` it is mutation-free, as it performs a read-only operation from the systems clock,
24
 *  and does not alter anything.
25
 *
26
 * @mago-expect best-practices/no-boolean-literal-comparison
27
 * @mago-expect best-practices/no-else-clause
28
 */
29
function high_resolution_time(): array
30
{
31
    /**
32
     * @var null|array{int, int} $offset
33
     */
34
    static $offset = null;
3✔
35

36
    if ($offset === null) {
3✔
37
        $offset = hrtime();
1✔
38

39
        /** @psalm-suppress RedundantCondition - This is not redundant, hrtime can return false. */
40
        Psl\invariant(false !== $offset, 'The system does not provide a monotonic timer.');
1✔
41

42
        $time = system_time();
1✔
43

44
        $offset = [
1✔
45
            $time[0] - $offset[0],
1✔
46
            $time[1] - $offset[1],
1✔
47
        ];
1✔
48
    }
49

50
    [$seconds_offset, $nanoseconds_offset] = $offset;
3✔
51
    [$seconds, $nanoseconds] = hrtime();
3✔
52

53
    $nanoseconds_adjusted = $nanoseconds + $nanoseconds_offset;
3✔
54
    if ($nanoseconds_adjusted >= NANOSECONDS_PER_SECOND) {
3✔
55
        ++$seconds;
2✔
56
        $nanoseconds_adjusted -= NANOSECONDS_PER_SECOND;
2✔
57
    } elseif ($nanoseconds_adjusted < 0) {
2✔
UNCOV
58
        --$seconds;
×
UNCOV
59
        $nanoseconds_adjusted += NANOSECONDS_PER_SECOND;
×
60
    }
61

62
    $seconds += $seconds_offset;
3✔
63
    $nanoseconds = $nanoseconds_adjusted;
3✔
64

65
    return [$seconds, $nanoseconds];
3✔
66
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc