Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phpstan 2.x #408

Draft
wants to merge 4 commits into
base: 2.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ jobs:

- name: Run test suite
run: php artisan test

- name: Run Phpstan
run: ./vendor/bin/phpstan analyze --no-progress
1 change: 0 additions & 1 deletion app/Actions/FirewallRule/CreateRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public function create(Server $server, array $input): FirewallRule
'mask' => $input['mask'] ?? null,
]);

/** @var Firewall $firewallHandler */
$firewallHandler = $server->firewall()->handler();
$firewallHandler->addRule(
$rule->type,
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/NotificationChannels/AddChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static function rules(array $input): array
'label' => 'required',
];

return array_merge($rules, static::providerRules($input));
return array_merge($rules, self::providerRules($input));
}

private static function providerRules(array $input): array
Expand Down
6 changes: 3 additions & 3 deletions app/Actions/ServerProvider/CreateServerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CreateServerProvider
*/
public function create(User $user, Project $project, array $input): ServerProvider
{
$provider = static::getProvider($input['provider']);
$provider = self::getProvider($input['provider']);

try {
$provider->connect($input);
Expand Down Expand Up @@ -60,7 +60,7 @@ public static function rules(array $input): array
],
];

return array_merge($rules, static::providerRules($input));
return array_merge($rules, self::providerRules($input));
}

private static function providerRules(array $input): array
Expand All @@ -69,6 +69,6 @@ private static function providerRules(array $input): array
return [];
}

return static::getProvider($input['provider'])->credentialValidationRules($input);
return self::getProvider($input['provider'])->credentialValidationRules($input);
}
}
2 changes: 1 addition & 1 deletion app/Actions/SourceControl/ConnectSourceControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static function rules(array $input): array
],
];

return array_merge($rules, static::providerRules($input));
return array_merge($rules, self::providerRules($input));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/SourceControl/EditSourceControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static function rules(SourceControl $sourceControl, array $input): array
],
];

return array_merge($rules, static::providerRules($sourceControl, $input));
return array_merge($rules, self::providerRules($sourceControl, $input));
}

/**
Expand Down
12 changes: 6 additions & 6 deletions app/Facades/FTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
use Illuminate\Support\Facades\Facade;

/**
* @method static bool|Connection connect(string $host, string $port, bool $ssl = false)
* @method static bool login(string $username, string $password, bool|Connection $connection)
* @method static void close(bool|Connection $connection)
* @method static bool passive(bool|Connection $connection, bool $passive)
* @method static bool delete(bool|Connection $connection, string $path)
* @method static void assertConnected(string $host)
* @ method static bool|Connection connect(string $host, string $port, bool $ssl = false)
* @ method static bool login(string $username, string $password, bool|Connection $connection)
* @ method static void close(bool|Connection $connection)
* @ method static bool passive(bool|Connection $connection, bool $passive)
* @ method static bool delete(bool|Connection $connection, string $path)
* @ method static void assertConnected(string $host)
*/
class FTP extends Facade
{
Expand Down
18 changes: 9 additions & 9 deletions app/Facades/SSH.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
/**
* Class SSH
*
* @method static init(Server $server, string $asUser = null)
* @method static setLog(?ServerLog $log)
* @method static connect()
* @method static string exec(string $command, string $log = '', int $siteId = null, ?bool $stream = false, callable $streamCallback = null)
* @method static string assertExecuted(array|string $commands)
* @method static string assertExecutedContains(string $command)
* @method static string assertFileUploaded(string $toPath, ?string $content = null)
* @method static string getUploadedLocalPath()
* @method static disconnect()
* @ method static \App\Helpers\SSH init(Server $server, string $asUser = null)
* @ method static \App\Helpers\SSH setLog(?ServerLog $log)
* @ method static void connect()
* @ method static string exec(string $command, string $log = '', int $siteId = null, ?bool $stream = false, callable $streamCallback = null)
* @ method static string assertExecuted(array|string $commands)
* @ method static string assertExecutedContains(string $command)
* @ method static string assertFileUploaded(string $toPath, ?string $content = null)
* @ method static string getUploadedLocalPath()
* @ method static void disconnect()
*/
class SSH extends FacadeAlias
{
Expand Down
28 changes: 15 additions & 13 deletions app/Models/Backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,6 @@
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;

/**
* @property string $type
* @property int $server_id
* @property int $storage_id
* @property int $database_id
* @property string $interval
* @property int $keep_backups
* @property string $status
* @property Server $server
* @property StorageProvider $storage
* @property Database $database
* @property BackupFile[] $files
*/
class Backup extends AbstractModel
{
use HasFactory;
Expand Down Expand Up @@ -58,26 +45,41 @@ public static function boot(): void
BackupStatus::FAILED => 'danger',
];

/**
* @return BelongsTo<Server, $this>
*/
public function server(): BelongsTo
{
return $this->belongsTo(Server::class);
}

/**
* @return BelongsTo<StorageProvider, $this>
*/
public function storage(): BelongsTo
{
return $this->belongsTo(StorageProvider::class, 'storage_id');
}

/**
* @return BelongsTo<Database, $this>
*/
public function database(): BelongsTo
{
return $this->belongsTo(Database::class)->withTrashed();
}

/**
* @return HasMany<BackupFile, $this>
*/
public function files(): HasMany
{
return $this->hasMany(BackupFile::class, 'backup_id');
}

/**
* @return HasOne<BackupFile, $this>
*/
public function lastFile(): HasOne
{
return $this->hasOne(BackupFile::class, 'backup_id')->latest();
Expand Down
14 changes: 4 additions & 10 deletions app/Models/BackupFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
* @property int $backup_id
* @property string $name
* @property int $size
* @property string $status
* @property string $restored_to
* @property Carbon $restored_at
* @property Backup $backup
*/
class BackupFile extends AbstractModel
{
use HasFactory;
Expand All @@ -39,7 +30,7 @@ protected static function booted(): void
static::created(function (BackupFile $backupFile) {
$keep = $backupFile->backup->keep_backups;
if ($backupFile->backup->files()->count() > $keep) {
/* @var BackupFile $lastFileToKeep */
/** @var BackupFile $lastFileToKeep */
$lastFileToKeep = $backupFile->backup->files()->orderByDesc('id')->skip($keep)->first();
if ($lastFileToKeep) {
$files = $backupFile->backup->files()
Expand Down Expand Up @@ -71,6 +62,9 @@ protected static function booted(): void
BackupFileStatus::RESTORE_FAILED => 'danger',
];

/**
* @return BelongsTo<Backup, $this>
*/
public function backup(): BelongsTo
{
return $this->belongsTo(Backup::class);
Expand Down
13 changes: 3 additions & 10 deletions app/Models/CronJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
* @property int $server_id
* @property string $command
* @property string $user
* @property string $frequency
* @property bool $hidden
* @property string $status
* @property string $crontab
* @property Server $server
*/
class CronJob extends AbstractModel
{
use HasFactory;
Expand Down Expand Up @@ -43,6 +33,9 @@ class CronJob extends AbstractModel
CronjobStatus::DISABLED => 'gray',
];

/**
* @return BelongsTo<Server, $this>
*/
public function server(): BelongsTo
{
return $this->belongsTo(Server::class);
Expand Down
14 changes: 6 additions & 8 deletions app/Models/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
* @property int $server_id
* @property string $name
* @property string $status
* @property Server $server
* @property Backup[] $backups
* @property Carbon $deleted_at
*/
class Database extends AbstractModel
{
use HasFactory;
Expand Down Expand Up @@ -55,11 +47,17 @@ public static function boot(): void
DatabaseStatus::FAILED => 'danger',
];

/**
* @return BelongsTo<Server, $this>
*/
public function server(): BelongsTo
{
return $this->belongsTo(Server::class);
}

/**
* @return HasMany<Backup, $this>
*/
public function backups(): HasMany
{
return $this->hasMany(Backup::class)->where('type', 'database');
Expand Down
12 changes: 3 additions & 9 deletions app/Models/DatabaseUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
* @property int $server_id
* @property string $username
* @property string $password
* @property array $databases
* @property string $host
* @property string $status
* @property Server $server
*/
class DatabaseUser extends AbstractModel
{
use HasFactory;
Expand All @@ -38,6 +29,9 @@ class DatabaseUser extends AbstractModel
'password',
];

/**
* @return BelongsTo<Server, $this>
*/
public function server(): BelongsTo
{
return $this->belongsTo(Server::class);
Expand Down
21 changes: 9 additions & 12 deletions app/Models/Deployment.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,6 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
* @property int $site_id
* @property int $deployment_script_id
* @property int $log_id
* @property string $commit_id
* @property string $commit_id_short
* @property array $commit_data
* @property string $status
* @property Site $site
* @property DeploymentScript $deploymentScript
* @property ServerLog $log
*/
class Deployment extends AbstractModel
{
use HasFactory;
Expand All @@ -44,16 +32,25 @@ class Deployment extends AbstractModel
DeploymentStatus::FAILED => 'danger',
];

/**
* @return BelongsTo<Site, $this>
*/
public function site(): BelongsTo
{
return $this->belongsTo(Site::class);
}

/**
* @return BelongsTo<DeploymentScript, $this>
*/
public function deploymentScript(): BelongsTo
{
return $this->belongsTo(DeploymentScript::class);
}

/**
* @return BelongsTo<ServerLog, $this>
*/
public function log(): BelongsTo
{
return $this->belongsTo(ServerLog::class, 'log_id');
Expand Down
9 changes: 3 additions & 6 deletions app/Models/DeploymentScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
* @property int $site_id
* @property string $name
* @property string $content
* @property Site $site
*/
class DeploymentScript extends AbstractModel
{
use HasFactory;
Expand All @@ -25,6 +19,9 @@ class DeploymentScript extends AbstractModel
'site_id' => 'integer',
];

/**
* @return BelongsTo<Site, $this>
*/
public function site(): BelongsTo
{
return $this->belongsTo(Site::class);
Expand Down
14 changes: 3 additions & 11 deletions app/Models/FirewallRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,6 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
* @property int $server_id
* @property string $type
* @property string $protocol
* @property int $port
* @property string $source
* @property ?string $mask
* @property string $note
* @property string $status
* @property Server $server
*/
class FirewallRule extends AbstractModel
{
use HasFactory;
Expand All @@ -36,6 +25,9 @@ class FirewallRule extends AbstractModel
'port' => 'integer',
];

/**
* @return BelongsTo<Server, $this>
*/
public function server(): BelongsTo
{
return $this->belongsTo(Server::class);
Expand Down
Loading