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

Frame::values()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\AMQP\Transport;
5
6
use Innmind\AMQP\Transport\Frame\{
7
    Type,
8
    Channel,
9
    Method,
10
    Value,
11
    Value\UnsignedOctet,
12
    Value\UnsignedShortInteger,
13
    Value\UnsignedLongInteger
14
};
15
use Innmind\Math\Algebra\Integer;
16
use Innmind\Immutable\{
17
    Sequence,
18
    Stream,
19
    StreamInterface
20
};
21
22
final class Frame
23
{
24
    private $type;
25
    private $channel;
26
    private $method;
27
    private $values;
28
    private $string;
29
30 1
    public function __construct(
31
        Type $type,
32
        Channel $channel,
33
        Method $method,
34
        Value ...$values
35
    ) {
36 1
        $this->type = $type;
37 1
        $this->channel = $channel;
38 1
        $this->method = $method;
39 1
        $values = new Sequence(...$values);
40 1
        $payload = $values->join('')->toEncoding('ASCII');
41 1
        $frame = new Sequence(
42 1
            new UnsignedOctet(new Integer($type->toInt())),
43 1
            new UnsignedShortInteger(new Integer($channel->toInt())),
44 1
            new UnsignedLongInteger(
45 1
                new Integer($payload->length() + 4) // 4 is the size for the method
46
            ),
47 1
            new UnsignedShortInteger(new Integer($method->class())),
48 1
            new UnsignedShortInteger(new Integer($method->method())),
49 1
            $payload,
50 1
            new UnsignedOctet(new Integer(0xCE))
51
        );
52 1
        $this->values = $values->reduce(
53 1
            new Stream(Value::class),
54 1
            static function(Stream $stream, Value $value): Stream {
55 1
                return $stream->add($value);
1 ignored issue
show
Documentation introduced by
$value is of type object<Innmind\AMQP\Transport\Frame\Value>, but the function expects a object<Innmind\Immutable\T>.

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...
56 1
            }
57
        );
58 1
        $this->string = (string) $frame->join('');
59 1
    }
60
61 1
    public function type(): Type
62
    {
63 1
        return $this->type;
64
    }
65
66 1
    public function channel(): Channel
67
    {
68 1
        return $this->channel;
69
    }
70
71 1
    public function method(): Method
72
    {
73 1
        return $this->method;
74
    }
75
76
    /**
77
     * @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...
78
     */
79 1
    public function values(): StreamInterface
80
    {
81 1
        return $this->values;
82
    }
83
84 1
    public function __toString(): string
85
    {
86 1
        return $this->string;
87
    }
88
}
89