1 | <?php |
||
25 | class PhpAmqpLibDriver implements Driver |
||
26 | { |
||
27 | const DELIVERY_MODE = 'delivery_mode'; |
||
28 | const CONTENT_TYPE = 'content_type'; |
||
29 | const APPLICATION_HEADERS = 'application_headers'; |
||
30 | const CORRELATION_ID = 'correlation_id'; |
||
31 | const REPLY_TO = 'reply_to'; |
||
32 | |||
33 | /** @var AbstractConnection */ |
||
34 | private $connection; |
||
35 | |||
36 | /** @var AMQPChannel */ |
||
37 | private $channel; |
||
38 | |||
39 | /** @var bool */ |
||
40 | private $stop = false; |
||
41 | /** @var bool */ |
||
42 | private $retryPublish = false; |
||
43 | |||
44 | /** |
||
45 | * PhpAmqpLibDriver constructor. |
||
46 | * |
||
47 | * @param AbstractConnection $connection |
||
48 | */ |
||
49 | public function __construct(AbstractConnection $connection) |
||
53 | |||
54 | /** |
||
55 | * Declare a persistent queue |
||
56 | * |
||
57 | * @param string $queueName |
||
58 | * @param string $type |
||
59 | * |
||
60 | * @return string |
||
61 | */ |
||
62 | public function declareSimpleQueue($queueName = '', $type = self::QUEUE_DURABLE) |
||
71 | |||
72 | /** |
||
73 | * Declare an exchange |
||
74 | * |
||
75 | * @param string $exchangeName |
||
76 | * @param string $type |
||
77 | * |
||
78 | * @return string |
||
79 | */ |
||
80 | public function declareExchange($exchangeName = '', $type = self::EXCHANGE_TYPE_FANOUT) |
||
86 | |||
87 | /** |
||
88 | * Bind an existing queue to an exchange |
||
89 | * |
||
90 | * @param string $exchange |
||
91 | * @param string $queueName |
||
92 | * @param string $routingKey |
||
93 | * @return void |
||
94 | */ |
||
95 | public function bindQueue($exchange, $queueName, $routingKey = '') |
||
99 | |||
100 | /** |
||
101 | * Create a persisting queue and bind it to an exchange |
||
102 | * |
||
103 | * @param string $exchange |
||
104 | * @param string $queueName |
||
105 | * @param string $routingKey |
||
106 | * @return void |
||
107 | */ |
||
108 | public function declareAndBindQueue($exchange, $queueName, $routingKey = '') |
||
113 | |||
114 | /** |
||
115 | * Delete a queue |
||
116 | * |
||
117 | * @param string $queueName |
||
118 | * @return void |
||
119 | */ |
||
120 | public function deleteQueue($queueName) |
||
124 | |||
125 | /** |
||
126 | * Delete an exchange |
||
127 | * |
||
128 | * @param string $exchangeName |
||
129 | * @return void |
||
130 | */ |
||
131 | public function deleteExchange($exchangeName) |
||
135 | |||
136 | /** |
||
137 | * Publish a message in the exchange |
||
138 | * |
||
139 | * @param string $exchangeName |
||
140 | * @param Message $message |
||
141 | * |
||
142 | * @return void |
||
143 | */ |
||
144 | public function publish($exchangeName, Message $message) |
||
157 | |||
158 | /** |
||
159 | * Consume the queue |
||
160 | * |
||
161 | * @param string $queueName |
||
162 | * @param callable $callback |
||
163 | * @param int $timeout |
||
164 | * @param bool $autoAck |
||
165 | * |
||
166 | * @return void |
||
167 | * @throws AssertionFailedException |
||
168 | * @throws \OutOfBoundsException |
||
169 | * @throws \InvalidArgumentException |
||
170 | * @throws Exception |
||
171 | */ |
||
172 | public function consume($queueName, callable $callback, $timeout = 0, $autoAck = true) |
||
204 | |||
205 | /** |
||
206 | * Acknowledge the reception of the message |
||
207 | * |
||
208 | * @param Message $message |
||
209 | * |
||
210 | * @return void |
||
211 | */ |
||
212 | public function ack(Message $message) |
||
216 | |||
217 | /** |
||
218 | * Aknowledge an error during the consumption of the message |
||
219 | * |
||
220 | * @param Message $message |
||
221 | * @param bool $requeue |
||
222 | * |
||
223 | * @return void |
||
224 | */ |
||
225 | public function nack(Message $message, $requeue = true) |
||
229 | |||
230 | /** |
||
231 | * Close the connection |
||
232 | * |
||
233 | * @return void |
||
234 | */ |
||
235 | public function close() |
||
242 | |||
243 | /** |
||
244 | * @return AMQPChannel |
||
245 | */ |
||
246 | private function getChannel() |
||
254 | |||
255 | /** |
||
256 | * @param $timeout |
||
257 | * |
||
258 | * @throws Exception |
||
259 | */ |
||
260 | private function wait($timeout) |
||
275 | |||
276 | /** |
||
277 | * Returns the message parameters |
||
278 | * |
||
279 | * @param Message $message |
||
280 | * |
||
281 | * @return array |
||
282 | */ |
||
283 | private static function getMessageProperties(Message $message) |
||
301 | |||
302 | /** |
||
303 | * @param AMQPMessage $message |
||
304 | * |
||
305 | * @return array |
||
306 | * |
||
307 | * @throws \OutOfBoundsException |
||
308 | */ |
||
309 | private static function getHeaders(AMQPMessage $message) |
||
314 | |||
315 | /** |
||
316 | * @param AMQPMessage $message |
||
317 | * |
||
318 | * @return string |
||
319 | * |
||
320 | * @throws \OutOfBoundsException |
||
321 | */ |
||
322 | private static function getCorrelationId(AMQPMessage $message) |
||
327 | |||
328 | /** |
||
329 | * @param AMQPMessage $message |
||
330 | * |
||
331 | * @return string |
||
332 | * |
||
333 | * @throws \OutOfBoundsException |
||
334 | */ |
||
335 | private static function getReplyTo(AMQPMessage $message) |
||
340 | |||
341 | private function retryPublish($exchangeName, Message $message) |
||
349 | |||
350 | private function checkIfWeShouldRetry(Exception $exception) |
||
361 | } |
||
362 |
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: