for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace TBolier\RethinkQL\Query;
use TBolier\RethinkQL\Connection\ConnectionInterface;
use TBolier\RethinkQL\Response\ResponseInterface;
use TBolier\RethinkQL\Types\Response\ResponseType;
class Cursor implements \Iterator
{
/**
* @var ConnectionInterface
*/
private $connection;
* @var int
private $token;
* @param ConnectionInterface $connection
* @param int $token
* @param ResponseInterface $response
public function __construct(ConnectionInterface $connection, int $token, ResponseInterface $response)
$this->connection = $connection;
$this->token = $token;
$this->setBatch($response);
}
private function setBatch($response)
$this->isComplete = $response['t'] === ResponseType::SUCCESS_SEQUENCE;
isComplete
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
$this->currentIndex = 0;
currentIndex
$this->currentSize = \count($response['r']);
currentSize
$this->currentData = array();
currentData
foreach ($response['r'] as $row) {
$this->currentData[] = $datum = $row;
$datum
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
* @inheritdoc
public function current()
// TODO: Implement current() method.
public function next()
// TODO: Implement next() method.
public function key()
// TODO: Implement key() method.
public function valid()
// TODO: Implement valid() method.
public function rewind()
// TODO: Implement rewind() method.
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: