for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is a part of Woketo package.
*
* (c) Nekland <[email protected]>
* For the full license, take a look to the LICENSE file
* on the root directory of this project
*/
namespace Nekland\Woketo\Client;
use Nekland\Woketo\Message\MessageHandlerInterface;
class WebSocketClient
{
* @var int
private $port;
* @var string
private $host;
* @var array
private $config;
* @var ConnectorFactoryInterface
private $connectorFactory;
public function __construct(int $port, string $host, array $config = [], ConnectorFactoryInterface $connectorFactory = null)
$this->port = $port;
$this->host = $host;
$this->connectorFactory = $connectorFactory ?: new ConnectorFactory();
$this->setConfig($config);
}
public function start(MessageHandlerInterface $handler)
$handler
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
if ($this->config['prod'] && \extension_loaded('xdebug')) {
throw new \Exception('xdebug is enabled, it\'s a performance issue. Disable that extension or specify "prod" option to false.');
$connection = new Connection($this->connectorFactory->createConnector($this->host, $this->port));
$connection
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
Connection::__construct()
$host
$this->connectorFactory-...his->host, $this->port)
object<React\Promise\PromiseInterface>
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);
* @param array $config
* @return self
public function setConfig(array $config = [])
$this->config = array_merge([
'prod' => true
], $config);
return $this;
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.