for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Cmobi\RabbitmqBundle\Rpc;
use Cmobi\RabbitmqBundle\Rpc\Exception\InvalidBodyAMQPMessageException;
use PhpAmqpLib\Message\AMQPMessage;
abstract class RpcBaseService implements RpcServiceInterface
{
private $queueName;
/** @var array */
protected $queueOptions = [
'name' => null,
'passive' => false,
'durable' => true,
'exclusive' => false,
'auto_delete' => false, //Em caso de falha no serviço a filha se mantém para que outro processe.
'nowait' => false,
'arguments' => null,
'ticket' => null
];
public function __construct(array $queueOptions, array $parameters = null)
$parameters
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
$this->queueName = $queueOptions['name'];
$this->queueOptions = array_merge($this->queueOptions, $queueOptions);
}
/**
* @return string
*/
protected abstract function buildService();
* @return \Closure
* @throws InvalidBodyAMQPMessageException
public function createCallback()
$callback = function (AMQPMessage $request) use ($this) {
$body = $this->buildService();
if (!is_string($body) || is_null($body)) {
throw new InvalidBodyAMQPMessageException('Invalid Body: Content should be string and not null.');
$message = new AMQPMessage(
$body,
['correlation_id' => $request->get('correlation_id')]
);
$request->delivery_info['channel']->basic_publish(
$message,
'',
$request->get('reply_to')
$request->delivery_info['channel']->basic_ack(
$request->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);
};
return $callback;
public function getQueueName()
return $this->queueName;
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.