Add phpstan level 7(#544)

This commit is contained in:
Saeed Vaziry
2025-03-12 13:31:10 +01:00
committed by GitHub
parent c22bb1fa80
commit 493cbb0849
437 changed files with 4505 additions and 2193 deletions

View File

@ -13,7 +13,7 @@
* @property int $server_id
* @property int $user_id
* @property ?int $server_log_id
* @property array $variables
* @property array<mixed> $variables
* @property string $status
* @property Carbon $created_at
* @property Carbon $updated_at
@ -24,6 +24,7 @@
*/
class CommandExecution extends AbstractModel
{
/** @use HasFactory<\Database\Factories\CommandExecutionFactory> */
use HasFactory;
protected $fillable = [
@ -43,12 +44,18 @@ class CommandExecution extends AbstractModel
'variables' => 'array',
];
/**
* @var array<string, string>
*/
public static array $statusColors = [
CommandExecutionStatus::EXECUTING => 'warning',
CommandExecutionStatus::COMPLETED => 'success',
CommandExecutionStatus::FAILED => 'danger',
];
/**
* @return BelongsTo<Command, covariant $this>
*/
public function command(): BelongsTo
{
return $this->belongsTo(Command::class);
@ -58,7 +65,7 @@ public function getContent(): string
{
$content = $this->command->command;
foreach ($this->variables as $variable => $value) {
if (is_string($value) && ! empty($value)) {
if (is_string($value) && ($value !== '' && $value !== '0')) {
$content = str_replace('${'.$variable.'}', $value, $content);
}
}
@ -66,16 +73,25 @@ public function getContent(): string
return $content;
}
/**
* @return BelongsTo<ServerLog, covariant $this>
*/
public function serverLog(): BelongsTo
{
return $this->belongsTo(ServerLog::class);
}
/**
* @return BelongsTo<Server, covariant $this>
*/
public function server(): BelongsTo
{
return $this->belongsTo(Server::class);
}
/**
* @return BelongsTo<User, covariant $this>
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);