for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Created by PhpStorm.
* User: quimmanrique
* Date: 13/02/17
* Time: 19:13
*/
namespace Cmp\Queues\Infrastructure\AmqpLib\v26\RabbitMQ\Queue;
use Cmp\Queues\Domain\Queue\JSONMessageFactory;
use PhpAmqpLib\Message\AMQPMessage;
use Psr\Log\LoggerInterface;
class MessageHandler
{
* @var JSONMessageFactory
private $jsonMessageFactory;
* @var callable
private $callback;
* MessageHandler constructor.
* @param JSONMessageFactory $jsonMessageFactory
public function __construct(JSONMessageFactory $jsonMessageFactory)
$this->jsonMessageFactory = $jsonMessageFactory;
}
* @param AMQPMessage $message
* @throws \Exception
public function handleMessage(AMQPMessage $message)
try {
$task = $this->jsonMessageFactory->create($message->body);
call_user_func_array($this->callback, [$task]);
$message->delivery_info['channel']->basic_ack($message->delivery_info['delivery_tag']);
$message->delivery_info['delivery_tag']
object<PhpAmqpLib\Channel\AMQPChannel>
string
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);
} catch (\Exception $e) {
throw $e;
public function setCallback(callable $callback)
$this->callback = $callback;
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: