for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace MadWeb\Initializer\Actions;
use Illuminate\Console\Command;
use Illuminate\Container\Container;
use Illuminate\Contracts\Bus\Dispatcher;
class Dispatch extends Action
{
private $job;
private $runNow;
public function __construct(Command $artisanCommand, $job, bool $runNow = false)
parent::__construct($artisanCommand);
$this->job = $job;
$this->runNow = $runNow;
}
public function title(): string
return '<comment>Dispatching job:</comment> '.get_class($this->job);
public function run(): bool
$result = null;
$result
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 ($this->runNow) {
$result = Container::getInstance()->make(Dispatcher::class)->dispatchNow($this->job);
} else {
$result = Container::getInstance()->make(Dispatcher::class)->dispatch($this->job);
$artisanCommand = $this->getArtisanCommnad();
if ($artisanCommand->getOutput()->isVerbose()) {
$artisanCommand->getOutput()->newLine();
$artisanCommand->info($result);
return ! (is_int($result) and $result > 0);
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.