for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Nip\Router\Console;
use ByTIC\Console\Command;
use Exception;
/**
* Class CacheCommand
* @package Nip\Config\Console
*/
class CacheCommand extends Command
{
protected function configure()
parent::configure();
$this->setName('router:cache');
$this->setDescription('Create a route cache file for faster route registration');
}
* @inheritDoc
* @throws Exception
protected function handle()
$this->call('router:clear');
$app = $this->getByticApp();
$configPath = $app->getCachedRoutesPath();
$router = $this->getFromContainer('router');
$router->setOption('cache_dir', $configPath);
$matcher = $router->getMatcher();
$matcher
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->info('Routes cached successfully!');
return 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.