for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Spatie\EventProjector\Console\Snapshots;
use Illuminate\Console\Command;
class DeleteSnapshotCommand extends Command
{
protected $signature = 'event-projector:delete-snapshot';
protected $description = 'Delete snapshots';
public function handle()
$titles = ['Number', 'Projector', 'Last processed event id', 'Created at', 'Name'];
$rows = $this->snapshotRepository->get()->map(function (Snapshot $snapshot) {
snapshotRepository
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;
static $number = 0;
return [
$number++,
$snapshot->projectorName(),
$snapshot->lastProcessedEventId(),
$snapshot->createdAt(),
$snapshot->name(),
];
});
$this->table($titles, $rows);
$snapshotNumber = $this->ask('Which snapshot would you like to delete?');
$snapshotNumber
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
}
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: