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 ( 638f88...e189ab )
by Baptiste
01:40
created

Connection::openOk()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
crap 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\AMQP\Transport\Protocol\v091\Reader;
5
6
use Innmind\AMQP\{
7
    Transport\Frame\Method,
8
    Transport\Frame\Visitor\Arguments,
9
    Transport\Frame\Value\LongString,
10
    Transport\Frame\Value\ShortString,
11
    Transport\Frame\Value\Table,
12
    Transport\Frame\Value\UnsignedLongInteger,
13
    Transport\Frame\Value\UnsignedOctet,
14
    Transport\Frame\Value\UnsignedShortInteger,
15
    Transport\Protocol\v091\Methods,
16
    Exception\UnknownMethod
17
};
18
use Innmind\Immutable\{
19
    Str,
20
    StreamInterface
21
};
22
23
final class Connection
24
{
25
    /**
26
     * @return StreamInterface<Value>
0 ignored issues
show
Documentation introduced by
The doc-type StreamInterface<Value> could not be parsed: Expected "|" or "end of type", but got "<" at position 15. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
27
     */
28 13
    public function __invoke(Method $method, Str $arguments): StreamInterface
29
    {
30
        switch (true) {
31 13
            case Methods::get('connection.start')->equals($method):
1 ignored issue
show
Documentation introduced by
$method is of type object<Innmind\AMQP\Transport\Frame\Method>, but the function expects a object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
32 2
                $visit = $this->start();
33 2
                break;
34
35 11
            case Methods::get('connection.secure')->equals($method):
1 ignored issue
show
Documentation introduced by
$method is of type object<Innmind\AMQP\Transport\Frame\Method>, but the function expects a object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
36 2
                $visit = $this->secure();
37 2
                break;
38
39 9
            case Methods::get('connection.tune')->equals($method):
1 ignored issue
show
Documentation introduced by
$method is of type object<Innmind\AMQP\Transport\Frame\Method>, but the function expects a object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
40 2
                $visit = $this->tune();
41 2
                break;
42
43 7
            case Methods::get('connection.open-ok')->equals($method):
1 ignored issue
show
Documentation introduced by
$method is of type object<Innmind\AMQP\Transport\Frame\Method>, but the function expects a object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
44 2
                $visit = $this->openOk();
45 2
                break;
46
47 5
            case Methods::get('connection.close')->equals($method):
1 ignored issue
show
Documentation introduced by
$method is of type object<Innmind\AMQP\Transport\Frame\Method>, but the function expects a object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
48 2
                $visit = $this->close();
49 2
                break;
50
51 3
            case Methods::get('connection.close-ok')->equals($method):
1 ignored issue
show
Documentation introduced by
$method is of type object<Innmind\AMQP\Transport\Frame\Method>, but the function expects a object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
52 2
                $visit = $this->closeOk();
53 2
                break;
54
55
            default:
56 1
                throw new UnknownMethod($method);
57
        }
58
59 12
        return $visit($arguments);
60
    }
61
62 2
    private function start(): Arguments
63
    {
64 2
        return new Arguments(
65 2
            UnsignedOctet::class, //major version
66 2
            UnsignedOctet::class, //minor version
67 2
            Table::class, //server properties
68 2
            LongString::class, //mechanisms
69 2
            LongString::class //locales
70
        );
71
    }
72
73 2
    private function secure(): Arguments
74
    {
75 2
        return new Arguments(
76 2
            LongString::class //challenge
77
        );
78
    }
79
80 2
    private function tune(): Arguments
81
    {
82 2
        return new Arguments(
83 2
            UnsignedShortInteger::class, //max channels
84 2
            UnsignedLongInteger::class, //max frame size
85 2
            UnsignedShortInteger::class //heartbeat delay
86
        );
87
    }
88
89 2
    private function openOk(): Arguments
90
    {
91 2
        return new Arguments(
92 2
            ShortString::class //known hosts
93
        );
94
    }
95
96 2
    private function close(): Arguments
97
    {
98 2
        return new Arguments(
99 2
            UnsignedShortInteger::class, //reply code
100 2
            ShortString::class, //reply text
101 2
            UnsignedShortInteger::class, //failing class id
102 2
            UnsignedShortInteger::class //failing method id
103
        );
104
    }
105
106 2
    private function closeOk(): Arguments
107
    {
108 2
        return new Arguments; // no arguments
109
    }
110
}
111