GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — develop ( a1e45f...4cf84e )
by Baptiste
05:27
created

unwrap()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 20
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 7
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 20
ccs 7
cts 7
cp 1
crap 3
rs 10
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Immutable;
5
6
/**
7
 * @template T
8
 *
9
 * @param Set<T>|Sequence<T> $structure
10
 *
11
 * @return list<T>
0 ignored issues
show
Bug introduced by
The type Innmind\Immutable\list was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
 */
13
function unwrap($structure): array
14
{
15
    /** @psalm-suppress DocblockTypeContradiction */
16 7
    if (!$structure instanceof Set && !$structure instanceof Sequence) {
0 ignored issues
show
introduced by
$structure is always a sub-type of Innmind\Immutable\Set.
Loading history...
17 1
        $given = Type::determine($structure);
18
19 1
        throw new \TypeError("Argument 1 must be of type Set|Sequence, $given given");
20
    }
21
22
    /**
23
     * @psalm-suppress MixedAssignment
24
     *
25
     * @var list<T>
26
     */
27 6
    return $structure->reduce(
0 ignored issues
show
Bug Best Practice introduced by
The expression return $structure->reduc...ion(...) { /* ... */ }) returns the type Innmind\Immutable\R which is incompatible with the type-hinted return array.
Loading history...
28 6
        [],
0 ignored issues
show
Bug introduced by
array() of type array is incompatible with the type Innmind\Immutable\R expected by parameter $carry of Innmind\Immutable\Set::reduce(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

28
        /** @scrutinizer ignore-type */ [],
Loading history...
29
        static function(array $carry, $t): array {
30 6
            $carry[] = $t;
31
32 6
            return $carry;
33 6
        },
34
    );
35
}
36
37
/**
38
 * @throws \TypeError
39
 */
40
function assertSet(string $type, Set $set, int $position): void
41
{
42 16
    if (!$set->isOfType($type)) {
43 5
        throw new \TypeError("Argument $position must be of type Set<$type>, Set<{$set->type()}> given");
44
    }
45 12
}
46
47
/**
48
 * @throws \TypeError
49
 */
50
function assertMap(string $key, string $value, Map $map, int $position): void
51
{
52 9
    if (!$map->isOfType($key, $value)) {
53 3
        throw new \TypeError("Argument $position must be of type Map<$key, $value>, Map<{$map->keyType()}, {$map->valueType()}> given");
54
    }
55 7
}
56
57
/**
58
 * @throws \TypeError
59
 */
60
function assertSequence(string $type, Sequence $sequence, int $position): void
61
{
62 31
    if (!$sequence->isOfType($type)) {
63 4
        throw new \TypeError("Argument $position must be of type Sequence<$type>, Sequence<{$sequence->type()}> given");
64
    }
65
}
66