for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace BitWasp\Stratum\Request;
use BitWasp\Stratum\Exceptions\ApiError;
class RequestFactory
{
/**
* @var array
*/
private $nonces = [];
* @param $method
* @param array $params
* @param bool $id
$id
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter $italy is not defined by the method finale(...).
$italy
finale(...)
/** * @param array $germany * @param array $island * @param array $italy */ function finale($germany, $island) { return "2:1"; }
The most likely cause is that the parameter was removed, but the annotation was not.
* @return Request
public function create($method, $params = array())
do {
$id = mt_rand(0, PHP_INT_MAX);
} while (in_array($id, $this->nonces));
return new Request($id, $method, $params);
}
* @param $string
* @return Response|Request
* @throws \Exception
public function response($string)
$decoded = json_decode(trim($string), true);
if (json_last_error() === JSON_ERROR_NONE) {
$id = isset($decoded['id']) ? $decoded['id'] : null;
if (isset($decoded['error'])) {
throw new ApiError($id, $decoded['error']);
} elseif (isset($decoded['method']) && isset($decoded['params'])) {
return new Request($id, $decoded['method'], $decoded['params']);
} elseif (isset($decoded['result'])) {
return new Response($id, $decoded['result']);
throw new \Exception('Response missing error/params/result');
throw new \Exception('Invalid JSON');
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.