for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Mouf\AmqpClient\Objects;
use Mouf\AmqpClient\Client;
class ExchangeTest extends \PHPUnit_Framework_TestCase
{
public function testExchange()
global $rabbitmq_host;
global
Instead of relying on global state, we recommend one of these alternatives:
function myFunction($a, $b) { // Do something }
class MyClass { private $a; private $b; public function __construct($a, $b) { $this->a = $a; $this->b = $b; } public function myFunction() { // Do something } }
global $rabbitmq_port;
global $rabbitmq_user;
global $rabbitmq_password;
$client = new Client($rabbitmq_host, $rabbitmq_port, $rabbitmq_user, $rabbitmq_password);
$client->setPrefetchCount(1);
$exchange = new Exchange('test_exchange', 'fanout');
Exchange::__construct()
$type
This check looks for function calls that miss required arguments.
'test_exchange'
string
object<Mouf\AmqpClient\Client>
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);
$exchange
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
$myVar = 'Value'; $higher = false; if (rand(1, 6) > 3) { $higher = true; } else { $higher = false; }
Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.
$myVar
$higher
}
Instead of relying on
global
state, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state