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\Rfc6455\Handshake;
use Nekland\Woketo\Exception\RuntimeException;
use Nekland\Woketo\Http\Request;
use Nekland\Woketo\Http\Response;
class ClientHandshake implements HandshakeInterface
{
public function sign($request, Response $response = null)
if ($response !== null) {
throw new RuntimeException('You cannot give a Response as the client should create the key.');
}
if (!$request instanceof Request) {
throw new RuntimeException(sprintf('Expected request at first argument but got %s', gettype($request)));
$key = '';
for ($i = 0; $i < 16; $i++) {
$key .= chr(mt_rand(0,255));
$key = base64_encode($key);
$request->setKey($key);
return $key;
public function verify($request)
// TODO: Implement verify() method.
public function createRequest(string $uri)
$uri
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
$request = Request::create('');
$request
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
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.