|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types = 1); |
|
3
|
|
|
|
|
4
|
|
|
namespace Innmind\AMQP\Transport\Protocol\v091; |
|
5
|
|
|
|
|
6
|
|
|
use Innmind\AMQP\{ |
|
7
|
|
|
Transport\Protocol as ProtocolInterface, |
|
8
|
|
|
Transport\Protocol\Version, |
|
9
|
|
|
Transport\Protocol\Connection as ConnectionInterface, |
|
10
|
|
|
Transport\Protocol\Channel as ChannelInterface, |
|
11
|
|
|
Transport\Protocol\Exchange as ExchangeInterface, |
|
12
|
|
|
Transport\Protocol\Queue as QueueInterface, |
|
13
|
|
|
Transport\Protocol\Basic as BasicInterface, |
|
14
|
|
|
Transport\Protocol\Transaction as TransactionInterface, |
|
15
|
|
|
Transport\Frame\Method, |
|
16
|
|
|
Exception\VersionNotUsable |
|
17
|
|
|
}; |
|
18
|
|
|
use Innmind\Immutable\{ |
|
19
|
|
|
Str, |
|
20
|
|
|
StreamInterface |
|
21
|
|
|
}; |
|
22
|
|
|
|
|
23
|
|
|
final class Protocol implements ProtocolInterface |
|
24
|
|
|
{ |
|
25
|
|
|
private $version; |
|
26
|
|
|
private $read; |
|
27
|
|
|
private $connection; |
|
28
|
|
|
private $channel; |
|
29
|
|
|
private $exchange; |
|
30
|
|
|
private $queue; |
|
31
|
|
|
private $basic; |
|
32
|
|
|
private $transaction; |
|
33
|
|
|
|
|
34
|
63 |
|
public function __construct() |
|
35
|
|
|
{ |
|
36
|
63 |
|
$this->version = new Version(0, 9, 1); |
|
37
|
63 |
|
$this->read = new Reader; |
|
38
|
63 |
|
$this->connection = new Connection; |
|
39
|
63 |
|
$this->channel = new Channel; |
|
40
|
63 |
|
$this->exchange = new Exchange; |
|
41
|
63 |
|
$this->queue = new Queue; |
|
42
|
63 |
|
$this->basic = new Basic; |
|
43
|
63 |
|
$this->transaction = new Transaction; |
|
44
|
63 |
|
} |
|
45
|
|
|
|
|
46
|
3 |
|
public function version(): Version |
|
47
|
|
|
{ |
|
48
|
3 |
|
return $this->version; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
5 |
|
public function use(Version $version): ProtocolInterface |
|
52
|
|
|
{ |
|
53
|
5 |
|
if (!$version->compatibleWith($this->version)) { |
|
|
|
|
|
|
54
|
2 |
|
throw new VersionNotUsable($version); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
3 |
|
return $this; |
|
|
|
|
|
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* {@inheritdoc} |
|
62
|
|
|
*/ |
|
63
|
3 |
|
public function read(Method $method, Str $arguments): StreamInterface |
|
64
|
|
|
{ |
|
65
|
3 |
|
return ($this->read)($method, $arguments); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
55 |
|
public function method(string $name): Method |
|
69
|
|
|
{ |
|
70
|
55 |
|
return Methods::get($name); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
3 |
|
public function connection(): ConnectionInterface |
|
74
|
|
|
{ |
|
75
|
3 |
|
return $this->connection; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
3 |
|
public function channel(): ChannelInterface |
|
79
|
|
|
{ |
|
80
|
3 |
|
return $this->channel; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
1 |
|
public function exchange(): ExchangeInterface |
|
84
|
|
|
{ |
|
85
|
1 |
|
return $this->exchange; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
1 |
|
public function queue(): QueueInterface |
|
89
|
|
|
{ |
|
90
|
1 |
|
return $this->queue; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
1 |
|
public function basic(): BasicInterface |
|
94
|
|
|
{ |
|
95
|
1 |
|
return $this->basic; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
1 |
|
public function transaction(): TransactionInterface |
|
99
|
|
|
{ |
|
100
|
1 |
|
return $this->transaction; |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
|
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: