for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Scaffolder\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
class ClearCacheCommand extends Command
{
protected $signature = 'scaffolder:clear {what=all}';
protected $description = 'Clear generated files like cache, json, drafts';
/**
* Execute the Command.
*/
public function handle()
switch ($this->argument('what')) {
case 'cache':
$this->handleCache();
break;
case 'drafts':
$this->handleBlade();
handleBlade()
Scaffolder\Commands\ClearCacheCommand
handle()
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.
default:
$this->handleDrafts();
}
* Execute the command for compiled cache files.
public function handleCache()
// Get the compiled files
$compiledFiles = File::glob(base_path('scaffolder-config/cache/*.scf'));
// Start progress bar
$this->output->progressStart(count($compiledFiles));
foreach ($compiledFiles as $compiledFile)
File::delete($compiledFile);
// Advance progress
$this->output->progressAdvance();
// Finish progress
$this->output->progressFinish();
$this->info('Cache cleared');
* Execute the command for drafts files and folder.
public function handleDrafts()
$success = File::cleanDirectory(base_path('drafts'));
$success
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('Drafts cleared');
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.