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.
Passed
Push — develop ( 7af216...ebf010 )
by Baptiste
13:17
created

testThrowWhenJoiningOnNonStringSet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace Tests\Innmind\Immutable;
5
6
use function Innmind\Immutable\{
7
    assertSet,
0 ignored issues
show
Bug introduced by
The type Innmind\Immutable\assertSet 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...
8
    assertSequence,
0 ignored issues
show
Bug introduced by
The type Innmind\Immutable\assertSequence 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...
9
    assertMap,
0 ignored issues
show
Bug introduced by
The type Innmind\Immutable\assertMap 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...
10
    unwrap,
0 ignored issues
show
Bug introduced by
The type Innmind\Immutable\unwrap 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...
11
    join,
0 ignored issues
show
Bug introduced by
The type Innmind\Immutable\join 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
    first,
0 ignored issues
show
Bug introduced by
The type Innmind\Immutable\first 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...
13
};
14
use Innmind\Immutable\{
15
    Set,
16
    Sequence,
17
    Map,
18
    Str,
19
    Exception\EmptySet,
20
};
21
use PHPUnit\Framework\TestCase;
22
23
class FunctionsTest extends TestCase
24
{
25
    public function testAssertSet()
26
    {
27
        $this->assertNull(assertSet('string', Set::of('string'), 42));
0 ignored issues
show
Bug introduced by
Are you sure the usage of assertSet('string', Innm...\Set::of('string'), 42) is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
28
29
        $this->expectException(\TypeError::class);
30
        $this->expectExceptionMessage('Argument 42 must be of type Set<string>, Set<int> given');
31
32
        assertSet('string', Set::of('int'), 42);
33
    }
34
35
    public function testAssertSequence()
36
    {
37
        $this->assertNull(assertSequence('string', Sequence::of('string'), 42));
0 ignored issues
show
Bug introduced by
Are you sure the usage of assertSequence('string',...ence::of('string'), 42) is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
38
39
        $this->expectException(\TypeError::class);
40
        $this->expectExceptionMessage('Argument 42 must be of type Sequence<string>, Sequence<int> given');
41
42
        assertSequence('string', Sequence::of('int'), 42);
43
    }
44
45
    public function testAssertMap()
46
    {
47
        $this->assertNull(assertMap('string', 'int', Map::of('string', 'int'), 42));
0 ignored issues
show
Bug introduced by
Are you sure the usage of assertMap('string', 'int...f('string', 'int'), 42) is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
48
49
        $this->expectException(\TypeError::class);
50
        $this->expectExceptionMessage('Argument 42 must be of type Map<string, int>, Map<string, string> given');
51
52
        assertMap('string', 'int', Map::of('string', 'string'), 42);
53
    }
54
55
    public function testUnwrapSet()
56
    {
57
        $this->assertSame(
58
            [1, 2, 3],
59
            unwrap(Set::ints(1, 2, 3)),
60
        );
61
    }
62
63
    public function testUnwrapSequence()
64
    {
65
        $this->assertSame(
66
            [1, 2, 3],
67
            unwrap(Sequence::ints(1, 2, 3)),
0 ignored issues
show
Bug introduced by
Innmind\Immutable\Sequence::ints(1, 2, 3) of type Innmind\Immutable\Sequence is incompatible with the type Innmind\Immutable\Set expected by parameter $structure of Innmind\Immutable\unwrap(). ( Ignorable by Annotation )

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

67
            unwrap(/** @scrutinizer ignore-type */ Sequence::ints(1, 2, 3)),
Loading history...
68
        );
69
    }
70
71
    public function testThrowWhenUnwrappingNotOfExpectedType()
72
    {
73
        $this->expectException(\TypeError::class);
74
        $this->expectExceptionMessage('Argument 1 must be of type Set|Sequence, stdClass given');
75
76
        unwrap(new \stdClass);
0 ignored issues
show
Bug introduced by
new stdClass() of type stdClass is incompatible with the type Innmind\Immutable\Set expected by parameter $structure of Innmind\Immutable\unwrap(). ( Ignorable by Annotation )

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

76
        unwrap(/** @scrutinizer ignore-type */ new \stdClass);
Loading history...
77
    }
78
79
    public function testThrowWhenJoiningNotOfExpectedType()
80
    {
81
        $this->expectException(\TypeError::class);
82
        $this->expectExceptionMessage('Argument 2 must be of type Set|Sequence, stdClass given');
83
84
        join('|', new \stdClass);
0 ignored issues
show
Bug introduced by
new stdClass() of type stdClass is incompatible with the type Innmind\Immutable\Set expected by parameter $structure of Innmind\Immutable\join(). ( Ignorable by Annotation )

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

84
        join('|', /** @scrutinizer ignore-type */ new \stdClass);
Loading history...
85
    }
86
87
    public function testThrowWhenJoiningOnNonStringSet()
88
    {
89
        $this->expectException(\TypeError::class);
90
        $this->expectExceptionMessage('Argument 2 must be of type Set<string>, Set<int> given');
91
92
        join('|', Set::of('int'));
93
    }
94
95
    public function testThrowWhenJoiningOnNonStringSequence()
96
    {
97
        $this->expectException(\TypeError::class);
98
        $this->expectExceptionMessage('Argument 2 must be of type Sequence<string>, Sequence<int> given');
99
100
        join('|', Sequence::of('int'));
0 ignored issues
show
Bug introduced by
Innmind\Immutable\Sequence::of('int') of type Innmind\Immutable\Sequence is incompatible with the type Innmind\Immutable\Set expected by parameter $structure of Innmind\Immutable\join(). ( Ignorable by Annotation )

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

100
        join('|', /** @scrutinizer ignore-type */ Sequence::of('int'));
Loading history...
101
    }
102
103
    public function testJoinSet()
104
    {
105
        $str = join('|', Set::of('string', '1', '2', '3'));
106
107
        $this->assertInstanceOf(Str::class, $str);
108
        $this->assertSame('1|2|3', $str->toString());
109
    }
110
111
    public function testJoinSequence()
112
    {
113
        $str = join('|', Sequence::of('string', '1', '2', '3'));
0 ignored issues
show
Bug introduced by
Innmind\Immutable\Sequen...string', '1', '2', '3') of type Innmind\Immutable\Sequence is incompatible with the type Innmind\Immutable\Set expected by parameter $structure of Innmind\Immutable\join(). ( Ignorable by Annotation )

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

113
        $str = join('|', /** @scrutinizer ignore-type */ Sequence::of('string', '1', '2', '3'));
Loading history...
114
115
        $this->assertInstanceOf(Str::class, $str);
116
        $this->assertSame('1|2|3', $str->toString());
117
    }
118
119
    public function testThrowWhenTryingToAccessFirstValueOfAnEmptySet()
120
    {
121
        $this->expectException(EmptySet::class);
122
123
        first(Set::of('int'));
124
    }
125
126
    public function testAccessFirstValueOfASet()
127
    {
128
        $this->assertSame(null, first(Set::mixed(null, 1, '')));
129
        $this->assertSame('', first(Set::mixed('', 1, null)));
130
        $this->assertSame(false, first(Set::mixed(false, 1, null)));
131
        $this->assertSame(0, first(Set::mixed(0, 1, null)));
132
        $this->assertSame(42, first(Set::mixed(42, 1, null)));
133
    }
134
}
135