1 | <?php |
||
40 | class RpcServer extends BaseConsumer |
||
41 | { |
||
42 | /** |
||
43 | * Initialize Server. |
||
44 | * |
||
45 | * @param string $name Server name |
||
46 | */ |
||
47 | 30 | public function initServer($name) |
|
54 | |||
55 | /** |
||
56 | * Start server. |
||
57 | */ |
||
58 | 25 | public function start() |
|
66 | |||
67 | /** |
||
68 | * Process message. |
||
69 | * |
||
70 | * @param AMQPMessage $message |
||
71 | * @throws \OutOfBoundsException |
||
72 | * @throws \PhpAmqpLib\Exception\AMQPInvalidArgumentException |
||
73 | */ |
||
74 | 15 | public function processMessage(AMQPMessage $message) |
|
75 | { |
||
76 | try { |
||
77 | 15 | $message->delivery_info['channel'] |
|
78 | 15 | ->basic_ack($message->delivery_info['delivery_tag']); |
|
|
|||
79 | 15 | $result = call_user_func($this->callback, $message->body); |
|
80 | 15 | $this->sendReply($result, $message->get('reply_to'), $message->get('correlation_id')); |
|
81 | 14 | } catch (AMQPRuntimeException $exception) { |
|
82 | 5 | $this->sendReply( |
|
83 | 5 | 'error: ' . $exception->getMessage(), |
|
84 | 5 | $message->get('reply_to'), |
|
85 | 5 | $message->get('correlation_id') |
|
86 | 4 | ); |
|
87 | 9 | } catch (AMQPInvalidArgumentException $exception) { |
|
88 | 5 | $this->sendReply( |
|
89 | 5 | 'error: ' . $exception->getMessage(), |
|
90 | 5 | $message->get('reply_to'), |
|
91 | 5 | $message->get('correlation_id') |
|
92 | 4 | ); |
|
93 | } |
||
94 | 15 | } |
|
95 | |||
96 | /** |
||
97 | * Send reply. |
||
98 | * |
||
99 | * @param string $result |
||
100 | * @param string $client |
||
101 | * @param string $correlationId |
||
102 | * @throws \PhpAmqpLib\Exception\AMQPInvalidArgumentException |
||
103 | */ |
||
104 | 15 | protected function sendReply($result, $client, $correlationId) |
|
116 | } |
||
117 |
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: