for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace WebStream\IO;
/**
* ConsoleOutputStream
* @author Ryuichi TANAKA.
* @since 2016/02/27
* @version 0.7
*/
class ConsoleOutputStream extends OutputStream
{
* constructor
public function __construct()
parent::__construct("");
}
* {@inheritdoc}
public function write($buf, int $off = null, int $len = null)
$data = null;
$data
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
if ($off === null && $len === null) {
$data = $buf;
} elseif ($off !== null && $len === null) {
$data = substr($buf, $off);
} elseif ($off === null && $len !== null) {
$data = substr($buf, 0, $len);
} else {
$data = substr($buf, $off, $len);
$this->stream .= $data;
public function close()
$this->stream = null;
public function flush()
echo $this->stream;
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
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.