$arguments = [];
foreach ($this->arguments as $k => $v) {
if (is_array($v)) {
$arguments[$k] = ['A', $v];
} elseif (is_int($v)) {
$arguments[$k] = ['I', $v];
} elseif (is_bool($v)) {
$arguments[$k] = ['t', $v];
} elseif (is_string($v)) {
$arguments[$k] = ['S', $v];
} else {
throw new Exception\InvalidArgumentException('Unknown argument type ' . gettype($v));
}
}
For those who cannot directly change $channel->exchange_declare() call, like, people who use RabbitMQ Symfony bundle, you can solve it like that:
Instead of providing
['foo' => 'bar']
as argument, provide
['foo' => [ARGUMENT_TYPE, 'bar']]
Where ARGUMENT_TYPE is one of \PhpAmqpLib\Wire\AMQPAbstractCollection type constants.
List or available argument types:
private static $_types_091 = array(
self::T_INT_SHORTSHORT => 'b',
self::T_INT_SHORTSHORT_U => 'B',
self::T_INT_SHORT => 'U',
self::T_INT_SHORT_U => 'u',
self::T_INT_LONG => 'I',
self::T_INT_LONG_U => 'i',
self::T_INT_LONGLONG => 'L',
self::T_INT_LONGLONG_U => 'l',
self::T_DECIMAL => 'D',
self::T_TIMESTAMP => 'T',
self::T_VOID => 'V',
self::T_BOOL => 't',
self::T_STRING_SHORT => 's',
self::T_STRING_LONG => 'S',
self::T_ARRAY => 'A',
self::T_TABLE => 'F'
);
and
private static $_types_080 = array(
self::T_INT_LONG => 'I',
self::T_DECIMAL => 'D',
self::T_TIMESTAMP => 'T',
self::T_STRING_LONG => 'S',
self::T_TABLE => 'F'
);
有话要说