Skip to content

Commit d328a1c

Browse files
committed
phpstan updates
1 parent ce124cb commit d328a1c

File tree

6 files changed

+27
-17
lines changed

6 files changed

+27
-17
lines changed

src/Commands/ListCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ class ListCommand extends BaseCommand
1212

1313
protected $description = 'List currently available deployments';
1414

15-
public function handle()
15+
public function handle(): void
1616
{
1717
ConsoleOutput::line('');
1818
ConsoleOutput::alert('Available Deployments');
1919

20-
$deployments = AtomicDeployment::select(
20+
$deployments = AtomicDeployment::query()->select([
2121
'id',
2222
'commit_hash',
2323
'deployment_path',
2424
'deployment_link',
2525
'deployment_status',
2626
'created_at',
27-
)->get()->map(function ($deployment) {
27+
])->get()->map(function (AtomicDeployment $deployment) {
2828
$deployment->append('is_currently_deployed');
2929
$deployment->deployment_status = DeploymentStatus::getNameFromValue($deployment->deployment_status);
3030

src/Helpers/ConsoleOutput.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66

77
/**
88
* @method static void line(string $string)
9+
* @method static void warn(string $string)
910
* @method static void alert(string $string)
1011
* @method static void error(string $string)
1112
* @method static void info(string $string)
12-
* @method static void table(string $string)
13+
* @method static void table(array $titles, array $rows)
1314
*/
1415
class ConsoleOutput
1516
{

src/Interfaces/DeploymentInterface.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,10 @@ public function getLink();
2323
public function getModel();
2424

2525
public function updateStatus(int $status);
26+
27+
public function isDeployed(): bool;
28+
29+
public function getDirectoryName(): string;
30+
31+
public function createDirectory();
2632
}

src/Models/AtomicDeployment.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
*
1919
* @property-read bool $has_deployment
2020
* @property-read bool $is_currently_deployed
21+
* @property string $commit_hash
22+
* @property int $deployment_status
23+
* @property string $build_path
24+
* @property string $deployment_path
25+
* @property string $deployment_link
2126
*/
2227
class AtomicDeployment extends Model
2328
{

src/Services/AtomicDeploymentService.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace JTMcC\AtomicDeployments\Services;
66

77
use Closure;
8+
use Illuminate\Database\Eloquent\Collection;
89
use Illuminate\Support\Facades\File;
910
use Illuminate\Support\Pluralizer;
1011
use JTMcC\AtomicDeployments\Events\DeploymentFailed;
@@ -310,13 +311,15 @@ public function cleanBuilds(int $limit): void
310311
->limit($limit)
311312
->pluck('id');
312313

313-
$buildsToRemove = AtomicDeployment::whereNotIn('id', $buildIDs)->get();
314+
/* @var Collection<AtomicDeployment> $buildsToRemove */
315+
$buildsToRemove = AtomicDeployment::query()->whereNotIn('id', $buildIDs)->get();
314316

315317
$countOfBuildsToRemove = $buildsToRemove->count();
316318

317319
Output::info('Found '.$countOfBuildsToRemove.' '.Pluralizer::plural('folder', $countOfBuildsToRemove).' to be removed');
318320

319321
foreach ($buildsToRemove as $deployment) {
322+
320323
if ($deployment->is_currently_deployed) {
321324
Output::warn('Current linked path has appeared in the directory cleaning logic');
322325
Output::warn('This either means you currently have an old build deployed or there is a problem with your deployment data');
@@ -328,6 +331,7 @@ public function cleanBuilds(int $limit): void
328331
Output::info("Deleting {$deployment->commit_hash}");
329332

330333
if (! $this->isDryRun()) {
334+
// @phpstan-ignore-next-line
331335
$deployment->delete();
332336
Output::info('Deployment deleted');
333337
} else {

src/Services/Deployment.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,21 +94,15 @@ public function getCurrentPath(): string
9494
}
9595

9696
/**
97-
* @return string
98-
*
9997
* @throws ExecuteFailedException
10098
*/
101-
public function getDirectoryName()
99+
public function getDirectoryName(): string
102100
{
103-
switch ($this->directoryNaming) {
104-
case 'datetime':
105-
return Carbon::now()->format('Y-m-d_H-i-s');
106-
case 'rand':
107-
return Str::random(5).time();
108-
case 'git':
109-
default:
110-
return Exec::getGitHash();
111-
}
101+
return match ($this->directoryNaming) {
102+
'datetime' => Carbon::now()->format('Y-m-d_H-i-s'),
103+
'rand' => Str::random(5).time(),
104+
default => Exec::getGitHash(),
105+
};
112106
}
113107

114108
/**

0 commit comments

Comments
 (0)