Skip to content

Commit

Permalink
chore: add strict_types throughout codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
lewislarsen committed Jun 24, 2024
1 parent 73257fb commit e829503
Show file tree
Hide file tree
Showing 105 changed files with 276 additions and 17 deletions.
2 changes: 2 additions & 0 deletions app/Actions/BackupDestinations/CheckS3Connection.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Actions\BackupDestinations;

use App\Events\BackupDestinationConnectionCheck;
Expand Down
9 changes: 6 additions & 3 deletions app/Actions/RemoteServer/CheckRemoteServerConnection.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<?php

declare(strict_types=1);

namespace App\Actions\RemoteServer;

use App\Events\RemoteServerConnectivityStatusChanged;
use App\Models\RemoteServer;
use Exception;
use Illuminate\Support\Facades\Log;
use phpseclib3\Crypt\Common\PrivateKey;
use phpseclib3\Crypt\PublicKeyLoader;
use phpseclib3\Net\SSH2;
use RuntimeException;
Expand Down Expand Up @@ -56,7 +59,7 @@ private function checkServerConnection(array $data, ?RemoteServer $remoteServer
}

try {
// Load the private key
/** @var PrivateKey $key */
$key = PublicKeyLoader::load(get_ssh_private_key(), config('app.ssh.passphrase'));

$ssh = new SSH2($data['host'], $data['port']);
Expand All @@ -81,7 +84,7 @@ private function checkServerConnection(array $data, ?RemoteServer $remoteServer

Log::debug('[Server Connection Check] Successfully connected to remote server');

if ($remoteServer) {
if ($remoteServer instanceof \App\Models\RemoteServer) {
Log::debug('[Server Connection Check] Dispatching RemoteServerConnectivityStatusChanged event (result: ' . $remoteServer->connectivity_status . ')', ['remote_server' => $remoteServer]);
RemoteServerConnectivityStatusChanged::dispatch($remoteServer, $remoteServer->connectivity_status);
}
Expand All @@ -97,7 +100,7 @@ private function checkServerConnection(array $data, ?RemoteServer $remoteServer
'connectivity_status' => RemoteServer::STATUS_OFFLINE,
]);

if ($remoteServer) {
if ($remoteServer instanceof \App\Models\RemoteServer) {
Log::debug('[Server Connection Check] Dispatching RemoteServerConnectivityStatusChanged event (result: ' . $remoteServer->connectivity_status . ')', ['remote_server' => $remoteServer]);
RemoteServerConnectivityStatusChanged::dispatch($remoteServer, $remoteServer->connectivity_status);
}
Expand Down
4 changes: 4 additions & 0 deletions app/Actions/RemoteServer/RemoveSSHKey.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<?php

declare(strict_types=1);

namespace App\Actions\RemoteServer;

use App\Mail\RemoteServers\FailedToRemoveKey;
use App\Mail\RemoteServers\SuccessfullyRemovedKey;
use App\Models\RemoteServer;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
use phpseclib3\Crypt\Common\PrivateKey;
use phpseclib3\Crypt\PublicKeyLoader;
use phpseclib3\Net\SSH2;
use RuntimeException;
Expand All @@ -17,6 +20,7 @@ public function handle(RemoteServer $remoteServer): void
{
Log::info('Removing SSH key from server.', ['server_id' => $remoteServer->id]);

/** @var PrivateKey $key */
$key = PublicKeyLoader::load(get_ssh_private_key(), config('app.ssh.passphrase'));

try {
Expand Down
2 changes: 2 additions & 0 deletions app/Console/Commands/CheckVersion.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Console\Commands;

use Exception;
Expand Down
2 changes: 2 additions & 0 deletions app/Console/Commands/EncryptDatabasePasswordsCommand.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Console\Commands;

use App\Models\RemoteServer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Console\Commands;

use App\Jobs\CheckBackupDestinationsS3ConnectionJob;
Expand Down
2 changes: 2 additions & 0 deletions app/Console/Commands/ExecuteScheduledBackupTasksCommand.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Console\Commands;

use App\Models\BackupTask;
Expand Down
2 changes: 2 additions & 0 deletions app/Console/Commands/GenerateSSHKeyCommand.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Console\Commands;

use Illuminate\Console\Command;
Expand Down
2 changes: 2 additions & 0 deletions app/Console/Commands/ResetInoperativeBackupTasksCommand.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Console\Commands;

use App\Models\BackupTask;
Expand Down
2 changes: 2 additions & 0 deletions app/Console/Commands/ValidateS3ConnectionCommand.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Console\Commands;

use App\Actions\BackupDestinations\CheckS3Connection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Console\Commands;

use App\Jobs\CheckRemoteServerConnectionJob;
Expand Down
2 changes: 2 additions & 0 deletions app/Events/BackupDestinationConnectionCheck.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Events;

use App\Models\BackupDestination;
Expand Down
2 changes: 2 additions & 0 deletions app/Events/BackupTaskStatusChanged.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Events;

use App\Models\BackupTask;
Expand Down
2 changes: 2 additions & 0 deletions app/Events/CreatedBackupTaskLog.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Events;

use App\Models\BackupTask;
Expand Down
2 changes: 2 additions & 0 deletions app/Events/RemoteServerConnectivityStatusChanged.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Events;

use App\Models\RemoteServer;
Expand Down
2 changes: 2 additions & 0 deletions app/Events/StreamBackupTaskLogEvent.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Events;

use App\Models\BackupTask;
Expand Down
2 changes: 2 additions & 0 deletions app/Exceptions/BackupTaskRuntimeException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Exceptions;

use Exception;
Expand Down
2 changes: 2 additions & 0 deletions app/Exceptions/BackupTaskZipException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Exceptions;

use Exception;
Expand Down
2 changes: 2 additions & 0 deletions app/Exceptions/DatabaseDumpException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Exceptions;

use Exception;
Expand Down
2 changes: 2 additions & 0 deletions app/Exceptions/S3ConnectionException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Exceptions;

use Exception;
Expand Down
2 changes: 2 additions & 0 deletions app/Exceptions/SFTPConnectionException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Exceptions;

use Exception;
Expand Down
2 changes: 2 additions & 0 deletions app/Exceptions/TaskBackupFileRotationException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Exceptions;

use Exception;
Expand Down
2 changes: 2 additions & 0 deletions app/Facades/Greeting.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Facades;

use App\Services\GreetingService;
Expand Down
6 changes: 4 additions & 2 deletions app/Http/Controllers/Auth/GitHubSocialiteController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
Expand Down Expand Up @@ -39,11 +41,11 @@ public function handleProviderCallback(): RedirectResponse
try {
$githubUser = Socialite::driver('github')->user();

if ($user = $this->findUserByGitHubId($githubUser->getId())) {
if (($user = $this->findUserByGitHubId($githubUser->getId())) instanceof \App\Models\User) {
return $this->loginAndRedirect($user, 'Found GH ID associated with this user, logging them in.');
}

if ($user = $this->findUserByEmailAndUpdateGitHubId($githubUser)) {
if (($user = $this->findUserByEmailAndUpdateGitHubId($githubUser)) instanceof \App\Models\User) {
return $this->loginAndRedirect($user, 'Adding the user\'s GH ID to their account.');
}

Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/Auth/VerifyEmailController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/BackupDestinations/EditController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Http\Controllers\BackupDestinations;

use App\Http\Controllers\Controller;
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/BackupTasks/EditController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Http\Controllers\BackupTasks;

use App\Http\Controllers\Controller;
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Http\Controllers;

abstract class Controller
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/OverviewController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Http\Controllers;

use App\Models\BackupTask;
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/RemoteServers/EditController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Http\Controllers\RemoteServers;

use App\Http\Controllers\Controller;
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/Tags/EditController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Http\Controllers\Tags;

use App\Http\Controllers\Controller;
Expand Down
2 changes: 2 additions & 0 deletions app/Jobs/BackupTasks/SendDiscordNotificationJob.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Jobs\BackupTasks;

use App\Models\BackupTask;
Expand Down
2 changes: 2 additions & 0 deletions app/Jobs/BackupTasks/SendSlackNotificationJob.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Jobs\BackupTasks;

use App\Models\BackupTask;
Expand Down
2 changes: 2 additions & 0 deletions app/Jobs/CheckBackupDestinationsS3ConnectionJob.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Jobs;

use App\Actions\BackupDestinations\CheckS3Connection;
Expand Down
2 changes: 2 additions & 0 deletions app/Jobs/CheckRemoteServerConnectionJob.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Jobs;

use App\Actions\RemoteServer\CheckRemoteServerConnection;
Expand Down
2 changes: 2 additions & 0 deletions app/Jobs/RemoteServers/RemoveSSHKeyJob.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Jobs\RemoteServers;

use App\Actions\RemoteServer\RemoveSSHKey;
Expand Down
2 changes: 2 additions & 0 deletions app/Jobs/RemoteServers/RemoveServerJob.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Jobs\RemoteServers;

use App\Models\RemoteServer;
Expand Down
2 changes: 2 additions & 0 deletions app/Jobs/RunDatabaseBackupTaskJob.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Jobs;

use App\Services\Backup\Tasks\DatabaseBackup;
Expand Down
2 changes: 2 additions & 0 deletions app/Jobs/RunFileBackupTaskJob.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Jobs;

use App\Services\Backup\Tasks\FileBackup;
Expand Down
2 changes: 2 additions & 0 deletions app/Livewire/Actions/Logout.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Livewire\Actions;

use Illuminate\Support\Facades\Auth;
Expand Down
2 changes: 2 additions & 0 deletions app/Livewire/BackupDestinations/CheckConnectionButton.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Livewire\BackupDestinations;

use App\Models\BackupDestination;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Livewire\BackupDestinations;

use App\Models\BackupDestination;
Expand Down
Loading

0 comments on commit e829503

Please sign in to comment.