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

azjezz / psl / 8560673219

04 Apr 2024 08:09PM UTC coverage: 98.781% (-0.1%) from 98.91%
8560673219

push

github

web-flow
feat(types): Memoize simple types without arguments (#457)

63 of 63 new or added lines in 25 files covered. (100.0%)

6 existing lines in 3 files now uncovered.

4377 of 4431 relevant lines covered (98.78%)

58.3 hits per line

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

88.89
/src/Psl/Type/Internal/ArrayKeyType.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Psl\Type\Internal;
6

7
use function is_int;
8
use function is_string;
9

10
/**
11
 * @extends UnionType<string, int>
12
 *
13
 * @internal
14
 */
15
final class ArrayKeyType extends UnionType
16
{
17
    public function __construct()
18
    {
19
        /** @psalm-suppress MissingThrowsDocblock */
UNCOV
20
        parent::__construct(new StringType(), new IntType());
×
21
    }
22

23
    public function matches(mixed $value): bool
24
    {
25
        return is_string($value) || is_int($value);
75✔
26
    }
27

28
    public function assert(mixed $value): mixed
29
    {
30
        // happy path performance optimization:
31
        if (is_string($value) || is_int($value)) {
80✔
32
            return $value;
54✔
33
        }
34

35
        return parent::assert($value);
26✔
36
    }
37

38
    public function coerce(mixed $value): mixed
39
    {
40
        // happy path performance optimization:
41
        if (is_string($value) || is_int($value)) {
32✔
42
            return $value;
18✔
43
        }
44

45
        return parent::coerce($value);
16✔
46
    }
47

48
    public function toString(): string
49
    {
50
        return 'array-key';
60✔
51
    }
52
}
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