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

azjezz / psl / 17871212902

19 Sep 2025 10:29PM UTC coverage: 98.497%. Remained the same
17871212902

push

github

web-flow
refactor: remove redundant `@var` tags from constants (#533)

This commit removes a large number of `@var` docblocks from constants throughout the `Psl\DateTime` and `Psl\Math` namespaces.

These annotations were often redundant, too wide (e.g., `@var int` for a specific literal value), or in some cases, incorrect. modern static analyzers can infer the precise literal types of these constants directly from their values.

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

5506 of 5590 relevant lines covered (98.5%)

52.29 hits per line

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

87.5
/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
 * @mago-expect lint:best-practices/no-else-clause
21
 * @mago-expect lint:strictness/no-shorthand-ternary
22
 */
23
function high_resolution_time(): array
24
{
25
    /**
26
     * @var null|list{int, int} $offset
27
     */
28
    static $offset = null;
3✔
29

30
    if ($offset === null) {
3✔
31
        $offset = hrtime() ?: null;
1✔
32

33
        Psl\invariant(null !== $offset, 'The system does not provide a monotonic timer.');
1✔
34

35
        $time = system_time();
1✔
36

37
        $offset = [
1✔
38
            $time[0] - $offset[0],
1✔
39
            $time[1] - $offset[1],
1✔
40
        ];
1✔
41
    }
42

43
    [$seconds_offset, $nanoseconds_offset] = $offset;
3✔
44
    $high_resolution_time = hrtime();
3✔
45
    if (false === $high_resolution_time) {
3✔
46
        throw new Psl\Exception\InvariantViolationException('The system does not provide a monotonic timer.');
×
47
    }
48

49
    [$seconds, $nanoseconds] = $high_resolution_time;
3✔
50

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

60
    $seconds += $seconds_offset;
3✔
61
    $nanoseconds = $nanoseconds_adjusted;
3✔
62

63
    return [$seconds, $nanoseconds];
3✔
64
}
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