From 5b672713283703a74c629ccd67b1d77eb57e24b9 Mon Sep 17 00:00:00 2001 From: freekmurze Date: Wed, 7 Aug 2024 11:07:52 +0000 Subject: [PATCH] Fix styling --- src/BackupDestination/BackupCollection.php | 2 +- src/BackupDestination/BackupDestination.php | 2 +- src/BackupServiceProvider.php | 2 +- src/Commands/ListCommand.php | 8 +++--- src/Commands/MonitorCommand.php | 2 +- src/Events/BackupHasFailed.php | 3 +-- src/Events/BackupManifestWasCreated.php | 3 +-- src/Events/BackupWasSuccessful.php | 3 +-- src/Events/BackupZipWasCreated.php | 3 +-- src/Events/CleanupHasFailed.php | 3 +-- src/Events/CleanupWasSuccessful.php | 3 +-- src/Events/DumpingDatabase.php | 3 +-- src/Events/HealthyBackupWasFound.php | 3 +-- src/Events/UnhealthyBackupWasFound.php | 3 +-- src/Exceptions/CannotCreateDbDumper.php | 2 +- src/Helpers/ConsoleOutput.php | 1 + src/Helpers/File.php | 2 +- src/Listeners/EncryptBackupArchive.php | 2 +- .../Channels/Discord/DiscordMessage.php | 6 +++-- src/Notifications/EventHandler.php | 5 ++-- src/Notifications/Notifiable.php | 2 +- .../BackupHasFailedNotification.php | 9 +++---- .../BackupWasSuccessfulNotification.php | 9 +++---- .../CleanupHasFailedNotification.php | 9 +++---- .../CleanupWasSuccessfulNotification.php | 9 +++---- .../HealthyBackupWasFoundNotification.php | 11 ++++---- .../UnhealthyBackupWasFoundNotification.php | 9 +++---- src/Tasks/Backup/BackupJob.php | 27 +++++++++---------- src/Tasks/Backup/BackupJobFactory.php | 2 +- src/Tasks/Backup/DbDumperFactory.php | 10 +++---- src/Tasks/Backup/FileSelection.php | 14 +++++----- src/Tasks/Backup/Manifest.php | 4 +-- src/Tasks/Backup/Zip.php | 10 +++---- src/Tasks/Cleanup/CleanupStrategy.php | 3 +-- src/Tasks/Cleanup/Period.php | 3 +-- src/Tasks/Monitor/BackupDestinationStatus.php | 7 +++-- .../BackupDestinationStatusFactory.php | 4 +-- src/Tasks/Monitor/HealthCheckFailure.php | 3 +-- .../Monitor/HealthChecks/MaximumAgeInDays.php | 3 +-- .../MaximumStorageInMegabytes.php | 3 +-- src/Traits/Retryable.php | 6 ++--- tests/Commands/BackupCommandTest.php | 14 +++++----- tests/Commands/ListCommandTest.php | 2 +- tests/Commands/MonitorCommandTest.php | 2 +- tests/DbDumperFactoryTest.php | 3 +-- tests/Events/UnhealthyBackupWasFoundTest.php | 4 +-- tests/FileSelectionTest.php | 9 +++---- tests/FormatTest.php | 1 - tests/Listeners/EncryptBackupArchiveTest.php | 8 +++--- tests/ManifestTest.php | 1 - tests/Notifications/EventHandlerTest.php | 4 +-- tests/Pest.php | 4 +-- tests/TestCase.php | 12 ++++----- 53 files changed, 126 insertions(+), 156 deletions(-) diff --git a/src/BackupDestination/BackupCollection.php b/src/BackupDestination/BackupCollection.php index 514c1bfa..c2f8c034 100644 --- a/src/BackupDestination/BackupCollection.php +++ b/src/BackupDestination/BackupCollection.php @@ -13,7 +13,7 @@ class BackupCollection extends Collection public static function createFromFiles(?FileSystem $disk, array $files): self { return (new static($files)) - ->filter(fn (string $path) => (new File())->isZipFile($disk, $path)) + ->filter(fn (string $path) => (new File)->isZipFile($disk, $path)) ->map(fn (string $path) => new Backup($disk, $path)) ->sortByDesc(fn (Backup $backup) => $backup->date()->timestamp) ->values(); diff --git a/src/BackupDestination/BackupDestination.php b/src/BackupDestination/BackupDestination.php index 9c689f6a..1542f98a 100644 --- a/src/BackupDestination/BackupDestination.php +++ b/src/BackupDestination/BackupDestination.php @@ -20,7 +20,7 @@ class BackupDestination protected ?BackupCollection $backupCollectionCache = null; - public function __construct(Filesystem $disk = null, string $backupName, string $diskName) + public function __construct(?Filesystem $disk, string $backupName, string $diskName) { $this->disk = $disk; diff --git a/src/BackupServiceProvider.php b/src/BackupServiceProvider.php index 64e4c663..b16219d1 100644 --- a/src/BackupServiceProvider.php +++ b/src/BackupServiceProvider.php @@ -56,7 +56,7 @@ protected function registerDiscordChannel() { Notification::resolved(function (ChannelManager $service) { $service->extend('discord', function ($app) { - return new DiscordChannel(); + return new DiscordChannel; }); }); } diff --git a/src/Commands/ListCommand.php b/src/Commands/ListCommand.php index ac9cada7..a89a4d12 100644 --- a/src/Commands/ListCommand.php +++ b/src/Commands/ListCommand.php @@ -20,7 +20,7 @@ class ListCommand extends BaseCommand public function handle(): int { if (config()->has('backup.monitorBackups')) { - $this->warn("Warning! Your config file still uses the old monitorBackups key. Update it to monitor_backups."); + $this->warn('Warning! Your config file still uses the old monitorBackups key. Update it to monitor_backups.'); } $statuses = BackupDestinationStatusFactory::createForMonitorConfig(config('backup.monitor_backups')); @@ -39,8 +39,8 @@ protected function displayOverview(Collection $backupDestinationStatuses) }); $this->table($headers, $rows, 'default', [ - 4 => new RightAlignedTableStyle(), - 6 => new RightAlignedTableStyle(), + 4 => new RightAlignedTableStyle, + 6 => new RightAlignedTableStyle, ]); return $this; @@ -98,7 +98,7 @@ protected function displayFailures(Collection $backupDestinationStatuses) return $this; } - protected function getFormattedBackupDate(Backup $backup = null) + protected function getFormattedBackupDate(?Backup $backup = null) { return is_null($backup) ? 'No backups present' diff --git a/src/Commands/MonitorCommand.php b/src/Commands/MonitorCommand.php index f68040bf..652cda42 100644 --- a/src/Commands/MonitorCommand.php +++ b/src/Commands/MonitorCommand.php @@ -18,7 +18,7 @@ class MonitorCommand extends BaseCommand implements Isolatable public function handle(): int { if (config()->has('backup.monitorBackups')) { - $this->warn("Warning! Your config file still uses the old monitorBackups key. Update it to monitor_backups."); + $this->warn('Warning! Your config file still uses the old monitorBackups key. Update it to monitor_backups.'); } $hasError = false; diff --git a/src/Events/BackupHasFailed.php b/src/Events/BackupHasFailed.php index 66454cf8..8bf68229 100644 --- a/src/Events/BackupHasFailed.php +++ b/src/Events/BackupHasFailed.php @@ -10,6 +10,5 @@ class BackupHasFailed public function __construct( public Exception $exception, public ?BackupDestination $backupDestination = null, - ) { - } + ) {} } diff --git a/src/Events/BackupManifestWasCreated.php b/src/Events/BackupManifestWasCreated.php index 5d45aa2f..3cb8aec0 100644 --- a/src/Events/BackupManifestWasCreated.php +++ b/src/Events/BackupManifestWasCreated.php @@ -8,6 +8,5 @@ class BackupManifestWasCreated { public function __construct( public Manifest $manifest, - ) { - } + ) {} } diff --git a/src/Events/BackupWasSuccessful.php b/src/Events/BackupWasSuccessful.php index de686fa6..8b562be2 100644 --- a/src/Events/BackupWasSuccessful.php +++ b/src/Events/BackupWasSuccessful.php @@ -8,6 +8,5 @@ class BackupWasSuccessful { public function __construct( public BackupDestination $backupDestination, - ) { - } + ) {} } diff --git a/src/Events/BackupZipWasCreated.php b/src/Events/BackupZipWasCreated.php index 211730d9..4106311f 100644 --- a/src/Events/BackupZipWasCreated.php +++ b/src/Events/BackupZipWasCreated.php @@ -6,6 +6,5 @@ class BackupZipWasCreated { public function __construct( public string $pathToZip, - ) { - } + ) {} } diff --git a/src/Events/CleanupHasFailed.php b/src/Events/CleanupHasFailed.php index 709cb299..6d97ecc5 100644 --- a/src/Events/CleanupHasFailed.php +++ b/src/Events/CleanupHasFailed.php @@ -10,6 +10,5 @@ class CleanupHasFailed public function __construct( public Exception $exception, public ?BackupDestination $backupDestination = null, - ) { - } + ) {} } diff --git a/src/Events/CleanupWasSuccessful.php b/src/Events/CleanupWasSuccessful.php index 4306284c..a9bd8ebe 100644 --- a/src/Events/CleanupWasSuccessful.php +++ b/src/Events/CleanupWasSuccessful.php @@ -8,6 +8,5 @@ class CleanupWasSuccessful { public function __construct( public BackupDestination $backupDestination, - ) { - } + ) {} } diff --git a/src/Events/DumpingDatabase.php b/src/Events/DumpingDatabase.php index a66afe89..98faf17f 100644 --- a/src/Events/DumpingDatabase.php +++ b/src/Events/DumpingDatabase.php @@ -8,6 +8,5 @@ class DumpingDatabase { public function __construct( public DbDumper $dbDumper - ) { - } + ) {} } diff --git a/src/Events/HealthyBackupWasFound.php b/src/Events/HealthyBackupWasFound.php index 75d89cfa..0d76759c 100644 --- a/src/Events/HealthyBackupWasFound.php +++ b/src/Events/HealthyBackupWasFound.php @@ -8,6 +8,5 @@ class HealthyBackupWasFound { public function __construct( public BackupDestinationStatus $backupDestinationStatus, - ) { - } + ) {} } diff --git a/src/Events/UnhealthyBackupWasFound.php b/src/Events/UnhealthyBackupWasFound.php index 77d698e7..503945b1 100644 --- a/src/Events/UnhealthyBackupWasFound.php +++ b/src/Events/UnhealthyBackupWasFound.php @@ -8,6 +8,5 @@ class UnhealthyBackupWasFound { public function __construct( public BackupDestinationStatus $backupDestinationStatus - ) { - } + ) {} } diff --git a/src/Exceptions/CannotCreateDbDumper.php b/src/Exceptions/CannotCreateDbDumper.php index dca0e6bf..9680b20b 100644 --- a/src/Exceptions/CannotCreateDbDumper.php +++ b/src/Exceptions/CannotCreateDbDumper.php @@ -8,7 +8,7 @@ class CannotCreateDbDumper extends Exception { public static function unsupportedDriver(string $driver): self { - $supportedDrivers = collect(config("database.connections"))->keys(); + $supportedDrivers = collect(config('database.connections'))->keys(); $formattedSupportedDrivers = $supportedDrivers ->map(fn (string $supportedDriver) => "`$supportedDriver`") diff --git a/src/Helpers/ConsoleOutput.php b/src/Helpers/ConsoleOutput.php index dbe2728f..72107288 100644 --- a/src/Helpers/ConsoleOutput.php +++ b/src/Helpers/ConsoleOutput.php @@ -6,6 +6,7 @@ /** * @phpstan-ignore-next-line + * * @mixin \Illuminate\Console\Concerns\InteractsWithIO */ class ConsoleOutput diff --git a/src/Helpers/File.php b/src/Helpers/File.php index c1f6b2d8..bcf7a2fe 100644 --- a/src/Helpers/File.php +++ b/src/Helpers/File.php @@ -32,7 +32,7 @@ protected function hasAllowedMimeType(?Filesystem $disk, string $path): bool return in_array($this->mimeType($disk, $path), self::$allowedMimeTypes); } - protected function mimeType(?Filesystem $disk, string $path): bool | string + protected function mimeType(?Filesystem $disk, string $path): bool|string { try { if ($disk && method_exists($disk, 'mimeType')) { diff --git a/src/Listeners/EncryptBackupArchive.php b/src/Listeners/EncryptBackupArchive.php index 35d62b1d..2277e7e2 100644 --- a/src/Listeners/EncryptBackupArchive.php +++ b/src/Listeners/EncryptBackupArchive.php @@ -13,7 +13,7 @@ public function handle(BackupZipWasCreated $event): void return; } - $zip = new ZipArchive(); + $zip = new ZipArchive; $zip->open($event->pathToZip); diff --git a/src/Notifications/Channels/Discord/DiscordMessage.php b/src/Notifications/Channels/Discord/DiscordMessage.php index 873655f7..66eb4ea7 100644 --- a/src/Notifications/Channels/Discord/DiscordMessage.php +++ b/src/Notifications/Channels/Discord/DiscordMessage.php @@ -7,7 +7,9 @@ class DiscordMessage { public const COLOR_SUCCESS = '0b6623'; + public const COLOR_WARNING = 'fD6a02'; + public const COLOR_ERROR = 'e32929'; protected string $username = 'Laravel Backup'; @@ -28,7 +30,7 @@ class DiscordMessage protected string $url = ''; - public function from(string $username, string $avatarUrl = null): self + public function from(string $username, ?string $avatarUrl = null): self { $this->username = $username; @@ -128,7 +130,7 @@ public function toArray(): array ], ]; - if (!empty($this->username)) { + if (! empty($this->username)) { $data['username'] = $this->username; } diff --git a/src/Notifications/EventHandler.php b/src/Notifications/EventHandler.php index 5feb46e0..55279337 100644 --- a/src/Notifications/EventHandler.php +++ b/src/Notifications/EventHandler.php @@ -17,8 +17,7 @@ class EventHandler { public function __construct( protected Repository $config - ) { - } + ) {} public function subscribe(Dispatcher $events): void { @@ -40,7 +39,7 @@ protected function determineNotifiable() protected function determineNotification($event): Notification { - $lookingForNotificationClass = class_basename($event) . "Notification"; + $lookingForNotificationClass = class_basename($event).'Notification'; $notificationClass = collect($this->config->get('backup.notifications.notifications')) ->keys() diff --git a/src/Notifications/Notifiable.php b/src/Notifications/Notifiable.php index f20549a2..13e30475 100644 --- a/src/Notifications/Notifiable.php +++ b/src/Notifications/Notifiable.php @@ -8,7 +8,7 @@ class Notifiable { use NotifiableTrait; - public function routeNotificationForMail(): string | array + public function routeNotificationForMail(): string|array { return config('backup.notifications.mail.to'); } diff --git a/src/Notifications/Notifications/BackupHasFailedNotification.php b/src/Notifications/Notifications/BackupHasFailedNotification.php index 64d99bd8..98faf6a0 100644 --- a/src/Notifications/Notifications/BackupHasFailedNotification.php +++ b/src/Notifications/Notifications/BackupHasFailedNotification.php @@ -13,12 +13,11 @@ class BackupHasFailedNotification extends BaseNotification { public function __construct( public BackupHasFailed $event, - ) { - } + ) {} public function toMail(): MailMessage { - $mailMessage = (new MailMessage()) + $mailMessage = (new MailMessage) ->error() ->from(config('backup.notifications.mail.from.address', config('mail.from.address')), config('backup.notifications.mail.from.name', config('mail.from.name'))) ->subject(trans('backup::notifications.backup_failed_subject', ['application_name' => $this->applicationName()])) @@ -33,7 +32,7 @@ public function toMail(): MailMessage public function toSlack(): SlackMessage { - return (new SlackMessage()) + return (new SlackMessage) ->error() ->from(config('backup.notifications.slack.username'), config('backup.notifications.slack.icon')) ->to(config('backup.notifications.slack.channel')) @@ -55,7 +54,7 @@ public function toSlack(): SlackMessage public function toDiscord(): DiscordMessage { - return (new DiscordMessage()) + return (new DiscordMessage) ->error() ->from(config('backup.notifications.discord.username'), config('backup.notifications.discord.avatar_url')) ->title(trans('backup::notifications.backup_failed_subject', ['application_name' => $this->applicationName()])) diff --git a/src/Notifications/Notifications/BackupWasSuccessfulNotification.php b/src/Notifications/Notifications/BackupWasSuccessfulNotification.php index 013bafc9..bc734706 100644 --- a/src/Notifications/Notifications/BackupWasSuccessfulNotification.php +++ b/src/Notifications/Notifications/BackupWasSuccessfulNotification.php @@ -13,12 +13,11 @@ class BackupWasSuccessfulNotification extends BaseNotification { public function __construct( public BackupWasSuccessful $event, - ) { - } + ) {} public function toMail(): MailMessage { - $mailMessage = (new MailMessage()) + $mailMessage = (new MailMessage) ->from(config('backup.notifications.mail.from.address', config('mail.from.address')), config('backup.notifications.mail.from.name', config('mail.from.name'))) ->subject(trans('backup::notifications.backup_successful_subject', ['application_name' => $this->applicationName()])) ->line(trans('backup::notifications.backup_successful_body', ['application_name' => $this->applicationName(), 'disk_name' => $this->diskName()])); @@ -32,7 +31,7 @@ public function toMail(): MailMessage public function toSlack(): SlackMessage { - return (new SlackMessage()) + return (new SlackMessage) ->success() ->from(config('backup.notifications.slack.username'), config('backup.notifications.slack.icon')) ->to(config('backup.notifications.slack.channel')) @@ -44,7 +43,7 @@ public function toSlack(): SlackMessage public function toDiscord(): DiscordMessage { - return (new DiscordMessage()) + return (new DiscordMessage) ->success() ->from(config('backup.notifications.discord.username'), config('backup.notifications.discord.avatar_url')) ->title(trans('backup::notifications.backup_successful_subject_title')) diff --git a/src/Notifications/Notifications/CleanupHasFailedNotification.php b/src/Notifications/Notifications/CleanupHasFailedNotification.php index 42cf2383..0fce4acb 100644 --- a/src/Notifications/Notifications/CleanupHasFailedNotification.php +++ b/src/Notifications/Notifications/CleanupHasFailedNotification.php @@ -13,12 +13,11 @@ class CleanupHasFailedNotification extends BaseNotification { public function __construct( public CleanupHasFailed $event, - ) { - } + ) {} public function toMail(): MailMessage { - $mailMessage = (new MailMessage()) + $mailMessage = (new MailMessage) ->error() ->from(config('backup.notifications.mail.from.address', config('mail.from.address')), config('backup.notifications.mail.from.name', config('mail.from.name'))) ->subject(trans('backup::notifications.cleanup_failed_subject', ['application_name' => $this->applicationName()])) @@ -35,7 +34,7 @@ public function toMail(): MailMessage public function toSlack(): SlackMessage { - return (new SlackMessage()) + return (new SlackMessage) ->error() ->from(config('backup.notifications.slack.username'), config('backup.notifications.slack.icon')) ->to(config('backup.notifications.slack.channel')) @@ -57,7 +56,7 @@ public function toSlack(): SlackMessage public function toDiscord(): DiscordMessage { - return (new DiscordMessage()) + return (new DiscordMessage) ->error() ->from(config('backup.notifications.discord.username'), config('backup.notifications.discord.avatar_url')) ->title( diff --git a/src/Notifications/Notifications/CleanupWasSuccessfulNotification.php b/src/Notifications/Notifications/CleanupWasSuccessfulNotification.php index b554be0d..caa39f97 100644 --- a/src/Notifications/Notifications/CleanupWasSuccessfulNotification.php +++ b/src/Notifications/Notifications/CleanupWasSuccessfulNotification.php @@ -13,12 +13,11 @@ class CleanupWasSuccessfulNotification extends BaseNotification { public function __construct( public CleanupWasSuccessful $event, - ) { - } + ) {} public function toMail(): MailMessage { - $mailMessage = (new MailMessage()) + $mailMessage = (new MailMessage) ->from(config('backup.notifications.mail.from.address', config('mail.from.address')), config('backup.notifications.mail.from.name', config('mail.from.name'))) ->subject(trans('backup::notifications.cleanup_successful_subject', ['application_name' => $this->applicationName()])) ->line(trans('backup::notifications.cleanup_successful_body', ['application_name' => $this->applicationName(), 'disk_name' => $this->diskName()])); @@ -32,7 +31,7 @@ public function toMail(): MailMessage public function toSlack(): SlackMessage { - return (new SlackMessage()) + return (new SlackMessage) ->success() ->from(config('backup.notifications.slack.username'), config('backup.notifications.slack.icon')) ->to(config('backup.notifications.slack.channel')) @@ -44,7 +43,7 @@ public function toSlack(): SlackMessage public function toDiscord(): DiscordMessage { - return (new DiscordMessage()) + return (new DiscordMessage) ->success() ->from(config('backup.notifications.discord.username'), config('backup.notifications.discord.avatar_url')) ->title(trans('backup::notifications.cleanup_successful_subject_title')) diff --git a/src/Notifications/Notifications/HealthyBackupWasFoundNotification.php b/src/Notifications/Notifications/HealthyBackupWasFoundNotification.php index 6ed4a9e8..43777ab0 100644 --- a/src/Notifications/Notifications/HealthyBackupWasFoundNotification.php +++ b/src/Notifications/Notifications/HealthyBackupWasFoundNotification.php @@ -13,12 +13,11 @@ class HealthyBackupWasFoundNotification extends BaseNotification { public function __construct( public HealthyBackupWasFound $event, - ) { - } + ) {} public function toMail(): MailMessage { - $mailMessage = (new MailMessage()) + $mailMessage = (new MailMessage) ->from(config('backup.notifications.mail.from.address', config('mail.from.address')), config('backup.notifications.mail.from.name', config('mail.from.name'))) ->subject(trans('backup::notifications.healthy_backup_found_subject', ['application_name' => $this->applicationName(), 'disk_name' => $this->diskName()])) ->line(trans('backup::notifications.healthy_backup_found_body', ['application_name' => $this->applicationName()])); @@ -32,7 +31,7 @@ public function toMail(): MailMessage public function toSlack(): SlackMessage { - return (new SlackMessage()) + return (new SlackMessage) ->success() ->from(config('backup.notifications.slack.username'), config('backup.notifications.slack.icon')) ->to(config('backup.notifications.slack.channel')) @@ -44,12 +43,12 @@ public function toSlack(): SlackMessage public function toDiscord(): DiscordMessage { - return (new DiscordMessage()) + return (new DiscordMessage) ->success() ->from(config('backup.notifications.discord.username'), config('backup.notifications.discord.avatar_url')) ->title( trans('backup::notifications.healthy_backup_found_subject_title', [ - 'application_name' => $this->applicationName(), + 'application_name' => $this->applicationName(), ]) )->fields($this->backupDestinationProperties()->toArray()); } diff --git a/src/Notifications/Notifications/UnhealthyBackupWasFoundNotification.php b/src/Notifications/Notifications/UnhealthyBackupWasFoundNotification.php index 4e7570f8..03892819 100644 --- a/src/Notifications/Notifications/UnhealthyBackupWasFoundNotification.php +++ b/src/Notifications/Notifications/UnhealthyBackupWasFoundNotification.php @@ -14,12 +14,11 @@ class UnhealthyBackupWasFoundNotification extends BaseNotification { public function __construct( public UnhealthyBackupWasFound $event, - ) { - } + ) {} public function toMail(): MailMessage { - $mailMessage = (new MailMessage()) + $mailMessage = (new MailMessage) ->error() ->from(config('backup.notifications.mail.from.address', config('mail.from.address')), config('backup.notifications.mail.from.name', config('mail.from.name'))) ->subject(trans('backup::notifications.unhealthy_backup_found_subject', ['application_name' => $this->applicationName()])) @@ -42,7 +41,7 @@ public function toMail(): MailMessage public function toSlack(): SlackMessage { - $slackMessage = (new SlackMessage()) + $slackMessage = (new SlackMessage) ->error() ->from(config('backup.notifications.slack.username'), config('backup.notifications.slack.icon')) ->to(config('backup.notifications.slack.channel')) @@ -75,7 +74,7 @@ public function toSlack(): SlackMessage public function toDiscord(): DiscordMessage { - $discordMessage = (new DiscordMessage()) + $discordMessage = (new DiscordMessage) ->error() ->from(config('backup.notifications.discord.username'), config('backup.notifications.discord.avatar_url')) ->title( diff --git a/src/Tasks/Backup/BackupJob.php b/src/Tasks/Backup/BackupJob.php index 952cb57e..2a242b85 100644 --- a/src/Tasks/Backup/BackupJob.php +++ b/src/Tasks/Backup/BackupJob.php @@ -46,7 +46,7 @@ public function __construct() ->dontBackupDatabases() ->setDefaultFilename(); - $this->backupDestinations = new Collection(); + $this->backupDestinations = new Collection; } public function dontBackupFilesystem(): self @@ -67,7 +67,7 @@ public function onlyDbName(array $allowedDbNames): self public function dontBackupDatabases(): self { - $this->dbDumpers = new Collection(); + $this->dbDumpers = new Collection; return $this; } @@ -170,7 +170,7 @@ public function run(): void $this->copyToBackupDestinations($zipFile); } catch (Exception $exception) { - consoleOutput()->error("Backup failed because: {$exception->getMessage()}." . PHP_EOL . $exception->getTraceAsString()); + consoleOutput()->error("Backup failed because: {$exception->getMessage()}.".PHP_EOL.$exception->getTraceAsString()); $this->temporaryDirectory->delete(); @@ -211,7 +211,7 @@ protected function directoriesUsedByBackupJob(): array return $this->backupDestinations ->filter(fn (BackupDestination $backupDestination) => $backupDestination->filesystemType() === 'localfilesystemadapter') ->map( - fn (BackupDestination $backupDestination) => $backupDestination->disk()->path('') . $backupDestination->backupName() + fn (BackupDestination $backupDestination) => $backupDestination->disk()->path('').$backupDestination->backupName() ) ->each(fn (string $backupDestinationDirectory) => $this->fileSelection->excludeFilesFrom($backupDestinationDirectory)) ->push($this->temporaryDirectory->path()) @@ -222,7 +222,7 @@ protected function createZipContainingEveryFileInManifest(Manifest $manifest): s { consoleOutput()->info("Zipping {$manifest->count()} files and directories..."); - $pathToZip = $this->temporaryDirectory->path(config('backup.backup.destination.filename_prefix') . $this->filename); + $pathToZip = $this->temporaryDirectory->path(config('backup.backup.destination.filename_prefix').$this->filename); $zip = Zip::createForManifest($manifest, $pathToZip); @@ -240,8 +240,6 @@ protected function createZipContainingEveryFileInManifest(Manifest $manifest): s /** * Dumps the databases to the given directory. * Returns an array with paths to the dump files. - * - * @return array */ protected function dumpDatabases(): array { @@ -251,33 +249,32 @@ protected function dumpDatabases(): array $dbType = mb_strtolower(basename(str_replace('\\', '/', get_class($dbDumper)))); - if (config('backup.backup.database_dump_filename_base') === 'connection') { $dbName = $key; } elseif ($dbDumper instanceof Sqlite) { - $dbName = $key . '-database'; + $dbName = $key.'-database'; } else { $dbName = $dbDumper->getDbName(); } $timeStamp = ''; if ($timeStampFormat = config('backup.backup.database_dump_file_timestamp_format')) { - $timeStamp = '-' . Carbon::now()->format($timeStampFormat); + $timeStamp = '-'.Carbon::now()->format($timeStampFormat); } $fileName = "{$dbType}-{$dbName}{$timeStamp}.{$this->getExtension($dbDumper)}"; if (config('backup.backup.gzip_database_dump')) { - $dbDumper->useCompressor(new GzipCompressor()); - $fileName .= '.' . $dbDumper->getCompressorExtension(); + $dbDumper->useCompressor(new GzipCompressor); + $fileName .= '.'.$dbDumper->getCompressorExtension(); } if ($compressor = config('backup.backup.database_dump_compressor')) { - $dbDumper->useCompressor(new $compressor()); - $fileName .= '.' . $dbDumper->getCompressorExtension(); + $dbDumper->useCompressor(new $compressor); + $fileName .= '.'.$dbDumper->getCompressorExtension(); } - $temporaryFilePath = $this->temporaryDirectory->path('db-dumps' . DIRECTORY_SEPARATOR . $fileName); + $temporaryFilePath = $this->temporaryDirectory->path('db-dumps'.DIRECTORY_SEPARATOR.$fileName); event(new DumpingDatabase($dbDumper)); diff --git a/src/Tasks/Backup/BackupJobFactory.php b/src/Tasks/Backup/BackupJobFactory.php index f9cfddfe..b950003c 100644 --- a/src/Tasks/Backup/BackupJobFactory.php +++ b/src/Tasks/Backup/BackupJobFactory.php @@ -10,7 +10,7 @@ class BackupJobFactory { public static function createFromArray(array $config): BackupJob { - return (new BackupJob()) + return (new BackupJob) ->setFileSelection(static::createFileSelection($config['backup']['source']['files'])) ->setDbDumpers(static::createDbDumpers($config['backup']['source']['databases'])) ->setBackupDestinations(BackupDestinationFactory::createFromArray($config['backup'])); diff --git a/src/Tasks/Backup/DbDumperFactory.php b/src/Tasks/Backup/DbDumperFactory.php index d62ff378..c568b564 100644 --- a/src/Tasks/Backup/DbDumperFactory.php +++ b/src/Tasks/Backup/DbDumperFactory.php @@ -19,7 +19,7 @@ class DbDumperFactory public static function createFromConnection(string $dbConnectionName): DbDumper { - $parser = new ConfigurationUrlParser(); + $parser = new ConfigurationUrlParser; if (config("database.connections.{$dbConnectionName}") === null) { throw CannotCreateDbDumper::unsupportedDriver($dbConnectionName); @@ -83,10 +83,10 @@ protected static function forDriver($dbDriver): DbDumper } return match ($driver) { - 'mysql', 'mariadb' => new MySql(), - 'pgsql' => new PostgreSql(), - 'sqlite' => new Sqlite(), - 'mongodb' => new MongoDb(), + 'mysql', 'mariadb' => new MySql, + 'pgsql' => new PostgreSql, + 'sqlite' => new Sqlite, + 'mongodb' => new MongoDb, default => throw CannotCreateDbDumper::unsupportedDriver($driver), }; } diff --git a/src/Tasks/Backup/FileSelection.php b/src/Tasks/Backup/FileSelection.php index 93a03958..dd011878 100644 --- a/src/Tasks/Backup/FileSelection.php +++ b/src/Tasks/Backup/FileSelection.php @@ -17,19 +17,19 @@ class FileSelection protected bool $shouldIgnoreUnreadableDirs = false; - public static function create(array | string $includeFilesAndDirectories = []): self + public static function create(array|string $includeFilesAndDirectories = []): self { return new static($includeFilesAndDirectories); } - public function __construct(array | string $includeFilesAndDirectories = []) + public function __construct(array|string $includeFilesAndDirectories = []) { $this->includeFilesAndDirectories = collect($includeFilesAndDirectories); $this->excludeFilesAndDirectories = collect(); } - public function excludeFilesFrom(array | string $excludeFilesAndDirectories): self + public function excludeFilesFrom(array|string $excludeFilesAndDirectories): self { $this->excludeFilesAndDirectories = $this->excludeFilesAndDirectories->merge($this->sanitize($excludeFilesAndDirectories)); @@ -50,13 +50,13 @@ public function shouldIgnoreUnreadableDirs(bool $ignoreUnreadableDirs): self return $this; } - public function selectedFiles(): Generator | array + public function selectedFiles(): Generator|array { if ($this->includeFilesAndDirectories->isEmpty()) { return []; } - $finder = (new Finder()) + $finder = (new Finder) ->ignoreDotFiles(false) ->ignoreVCS(false); @@ -105,7 +105,7 @@ protected function shouldExclude(string $path): bool { $path = realpath($path); if (is_dir($path)) { - $path .= DIRECTORY_SEPARATOR ; + $path .= DIRECTORY_SEPARATOR; } foreach ($this->excludeFilesAndDirectories as $excludedPath) { if (Str::startsWith($path, $excludedPath.(is_dir($excludedPath) ? DIRECTORY_SEPARATOR : ''))) { @@ -120,7 +120,7 @@ protected function shouldExclude(string $path): bool return false; } - protected function sanitize(string | array $paths): Collection + protected function sanitize(string|array $paths): Collection { return collect($paths) ->reject(fn ($path) => $path === '') diff --git a/src/Tasks/Backup/Manifest.php b/src/Tasks/Backup/Manifest.php index 69894cfe..be61d93b 100644 --- a/src/Tasks/Backup/Manifest.php +++ b/src/Tasks/Backup/Manifest.php @@ -27,7 +27,7 @@ public function path(): string return $this->manifestPath; } - public function addFiles(array | string | Generator $filePaths): self + public function addFiles(array|string|Generator $filePaths): self { if (is_string($filePaths)) { $filePaths = [$filePaths]; @@ -42,7 +42,7 @@ public function addFiles(array | string | Generator $filePaths): self return $this; } - public function files(): Generator | array + public function files(): Generator|array { $file = new SplFileObject($this->path()); diff --git a/src/Tasks/Backup/Zip.php b/src/Tasks/Backup/Zip.php index 3dbcbf1f..c45927f9 100644 --- a/src/Tasks/Backup/Zip.php +++ b/src/Tasks/Backup/Zip.php @@ -17,7 +17,7 @@ class Zip public static function createForManifest(Manifest $manifest, string $pathToZip): self { $relativePath = config('backup.backup.source.files.relative_path') ? - rtrim(config('backup.backup.source.files.relative_path'), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR : false; + rtrim(config('backup.backup.source.files.relative_path'), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR : false; $zip = new static($pathToZip); @@ -34,9 +34,9 @@ public static function createForManifest(Manifest $manifest, string $pathToZip): protected static function determineNameOfFileInZip(string $pathToFile, string $pathToZip, string $relativePath) { - $fileDirectory = pathinfo($pathToFile, PATHINFO_DIRNAME) . DIRECTORY_SEPARATOR; + $fileDirectory = pathinfo($pathToFile, PATHINFO_DIRNAME).DIRECTORY_SEPARATOR; - $zipDirectory = pathinfo($pathToZip, PATHINFO_DIRNAME) . DIRECTORY_SEPARATOR; + $zipDirectory = pathinfo($pathToZip, PATHINFO_DIRNAME).DIRECTORY_SEPARATOR; if (Str::startsWith($fileDirectory, $zipDirectory)) { return substr($pathToFile, strlen($zipDirectory)); @@ -51,7 +51,7 @@ protected static function determineNameOfFileInZip(string $pathToFile, string $p public function __construct(string $pathToZip) { - $this->zipFile = new ZipArchive(); + $this->zipFile = new ZipArchive; $this->pathToZip = $pathToZip; @@ -87,7 +87,7 @@ public function close(): void $this->zipFile->close(); } - public function add(string | iterable $files, string $nameInZip = null): self + public function add(string|iterable $files, ?string $nameInZip = null): self { if (is_array($files)) { $nameInZip = null; diff --git a/src/Tasks/Cleanup/CleanupStrategy.php b/src/Tasks/Cleanup/CleanupStrategy.php index 49bf3438..35dc8972 100644 --- a/src/Tasks/Cleanup/CleanupStrategy.php +++ b/src/Tasks/Cleanup/CleanupStrategy.php @@ -12,8 +12,7 @@ abstract class CleanupStrategy public function __construct( protected Repository $config, - ) { - } + ) {} abstract public function deleteOldBackups(BackupCollection $backups); diff --git a/src/Tasks/Cleanup/Period.php b/src/Tasks/Cleanup/Period.php index 6019413e..d00bcb32 100644 --- a/src/Tasks/Cleanup/Period.php +++ b/src/Tasks/Cleanup/Period.php @@ -9,8 +9,7 @@ class Period public function __construct( protected Carbon $startDate, protected Carbon $endDate - ) { - } + ) {} public function startDate(): Carbon { diff --git a/src/Tasks/Monitor/BackupDestinationStatus.php b/src/Tasks/Monitor/BackupDestinationStatus.php index e63e8900..105fe436 100644 --- a/src/Tasks/Monitor/BackupDestinationStatus.php +++ b/src/Tasks/Monitor/BackupDestinationStatus.php @@ -14,15 +14,14 @@ class BackupDestinationStatus public function __construct( protected BackupDestination $backupDestination, protected array $healthChecks = [] - ) { - } + ) {} public function backupDestination(): BackupDestination { return $this->backupDestination; } - public function check(HealthCheck $check): bool | HealthCheckFailure + public function check(HealthCheck $check): bool|HealthCheckFailure { try { $check->checkHealth($this->backupDestination()); @@ -35,7 +34,7 @@ public function check(HealthCheck $check): bool | HealthCheckFailure public function getHealthChecks(): Collection { - return collect($this->healthChecks)->prepend(new IsReachable()); + return collect($this->healthChecks)->prepend(new IsReachable); } public function getHealthCheckFailure(): ?HealthCheckFailure diff --git a/src/Tasks/Monitor/BackupDestinationStatusFactory.php b/src/Tasks/Monitor/BackupDestinationStatusFactory.php index 061b3132..81036302 100644 --- a/src/Tasks/Monitor/BackupDestinationStatusFactory.php +++ b/src/Tasks/Monitor/BackupDestinationStatusFactory.php @@ -12,7 +12,7 @@ public static function createForMonitorConfig(array $monitorConfiguration): Coll { return collect($monitorConfiguration) ->flatMap(fn (array $monitorProperties) => self::createForSingleMonitor($monitorProperties)) - ->sortBy(fn (BackupDestinationStatus $backupDestinationStatus) => $backupDestinationStatus->backupDestination()->backupName() . '-' . + ->sortBy(fn (BackupDestinationStatus $backupDestinationStatus) => $backupDestinationStatus->backupDestination()->backupName().'-'. $backupDestinationStatus->backupDestination()->diskName()); } @@ -39,7 +39,7 @@ protected static function buildHealthChecks($monitorConfig): array })->toArray(); } - protected static function buildHealthCheck(string $class, string | array $options): HealthCheck + protected static function buildHealthCheck(string $class, string|array $options): HealthCheck { if (! is_array($options)) { return new $class($options); diff --git a/src/Tasks/Monitor/HealthCheckFailure.php b/src/Tasks/Monitor/HealthCheckFailure.php index ca97fa6a..94d1b0ce 100644 --- a/src/Tasks/Monitor/HealthCheckFailure.php +++ b/src/Tasks/Monitor/HealthCheckFailure.php @@ -10,8 +10,7 @@ class HealthCheckFailure public function __construct( protected HealthCheck $healthCheck, protected Exception $exception - ) { - } + ) {} public function healthCheck(): HealthCheck { diff --git a/src/Tasks/Monitor/HealthChecks/MaximumAgeInDays.php b/src/Tasks/Monitor/HealthChecks/MaximumAgeInDays.php index c25d97bd..0bd33824 100644 --- a/src/Tasks/Monitor/HealthChecks/MaximumAgeInDays.php +++ b/src/Tasks/Monitor/HealthChecks/MaximumAgeInDays.php @@ -10,8 +10,7 @@ class MaximumAgeInDays extends HealthCheck { public function __construct( protected int $days = 1 - ) { - } + ) {} public function checkHealth(BackupDestination $backupDestination): void { diff --git a/src/Tasks/Monitor/HealthChecks/MaximumStorageInMegabytes.php b/src/Tasks/Monitor/HealthChecks/MaximumStorageInMegabytes.php index 2335808a..9a119ed3 100644 --- a/src/Tasks/Monitor/HealthChecks/MaximumStorageInMegabytes.php +++ b/src/Tasks/Monitor/HealthChecks/MaximumStorageInMegabytes.php @@ -10,8 +10,7 @@ class MaximumStorageInMegabytes extends HealthCheck { public function __construct( protected int $maximumSizeInMegaBytes = 5000 - ) { - } + ) {} public function checkHealth(BackupDestination $backupDestination): void { diff --git a/src/Traits/Retryable.php b/src/Traits/Retryable.php index b0ef0fb6..69a973c2 100644 --- a/src/Traits/Retryable.php +++ b/src/Traits/Retryable.php @@ -32,16 +32,16 @@ protected function sleepFor(int $seconds = 0) protected function setTries(string $type) { if ($this->option('tries')) { - $this->tries = (int)$this->option('tries'); + $this->tries = (int) $this->option('tries'); return; } - $this->tries = (int)config('backup.' . $type . '.tries', 1); + $this->tries = (int) config('backup.'.$type.'.tries', 1); } protected function getRetryDelay(string $type) { - return (int)config('backup.' . $type . '.retry_delay', 0); + return (int) config('backup.'.$type.'.retry_delay', 0); } } diff --git a/tests/Commands/BackupCommandTest.php b/tests/Commands/BackupCommandTest.php index 446af30b..c25089ad 100644 --- a/tests/Commands/BackupCommandTest.php +++ b/tests/Commands/BackupCommandTest.php @@ -97,7 +97,7 @@ $this->artisan('backup:run --only-files')->assertExitCode(0); $zipFiles = []; - $zip = new ZipArchive(); + $zip = new ZipArchive; $zip->open(Storage::disk('local')->path($this->expectedZipPath)); foreach (range(0, $zip->numFiles - 1) as $i) { $zipFiles[] = $zip->statIndex($i)['name']; @@ -116,7 +116,7 @@ $this->artisan('backup:run --only-files')->assertExitCode(0); $zipFile = ''; - $zip = new ZipArchive(); + $zip = new ZipArchive; $zip->open(Storage::disk('local')->path($this->expectedZipPath)); if ($zip->numFiles) { $zipFile = $zip->statIndex(0)['name']; @@ -365,7 +365,7 @@ $this->artisan('backup:run --disable-notifications --only-db --db-name=db1 --only-to-disk=local')->assertExitCode(0); Storage::disk('local')->assertExists($this->expectedZipPath); - $zip = new ZipArchive(); + $zip = new ZipArchive; $zip->open(Storage::disk('local')->path($this->expectedZipPath)); expect($zip->numFiles)->toBe(1); expect($zip->statIndex(0)['encryption_method'])->toBe(ZipArchive::EM_AES_256); @@ -380,33 +380,31 @@ // by default (with no destination.compression_method specified), the ZipArchive::CM_DEFLATE is used $this->artisan('backup:run --only-db')->assertExitCode(0); - $zip = new ZipArchive(); + $zip = new ZipArchive; $zip->open(Storage::disk('local')->path($this->expectedZipPath)); expect($zip->numFiles)->toBe(1); expect($zip->statIndex(0)['comp_method'])->toBe(ZipArchive::CM_DEFLATE); $zip->close(); - // check no compression with ZipArchive::CM_STORE method config()->set('backup.backup.destination.compression_method', ZipArchive::CM_STORE); config()->set('backup.backup.destination.compression_level', 0); $this->artisan('backup:run --only-db')->assertExitCode(0); - $zip = new ZipArchive(); + $zip = new ZipArchive; $zip->open(Storage::disk('local')->path($this->expectedZipPath)); expect($zip->numFiles)->toBe(1); expect($zip->statIndex(0)['comp_method'])->toBe(ZipArchive::CM_STORE); $zip->close(); - // check ZipArchive::CM_DEFLATE method with custom compression level config()->set('backup.backup.destination.compression_method', ZipArchive::CM_DEFLATE); config()->set('backup.backup.destination.compression_level', 2); $this->artisan('backup:run --only-db')->assertExitCode(0); - $zip = new ZipArchive(); + $zip = new ZipArchive; $zip->open(Storage::disk('local')->path($this->expectedZipPath)); expect($zip->numFiles)->toBe(1); expect($zip->statIndex(0)['comp_method'])->toBe(ZipArchive::CM_DEFLATE); diff --git a/tests/Commands/ListCommandTest.php b/tests/Commands/ListCommandTest.php index 35657b57..e3c12903 100644 --- a/tests/Commands/ListCommandTest.php +++ b/tests/Commands/ListCommandTest.php @@ -15,5 +15,5 @@ config(['backup.monitorBackups' => config('backup.monitor_backups')]); $this->artisan('backup:list') - ->expectsOutput("Warning! Your config file still uses the old monitorBackups key. Update it to monitor_backups."); + ->expectsOutput('Warning! Your config file still uses the old monitorBackups key. Update it to monitor_backups.'); }); diff --git a/tests/Commands/MonitorCommandTest.php b/tests/Commands/MonitorCommandTest.php index a43b7c32..4e7861ca 100644 --- a/tests/Commands/MonitorCommandTest.php +++ b/tests/Commands/MonitorCommandTest.php @@ -15,6 +15,6 @@ public function it_warns_the_user_about_the_old_style_config_keys() config(['backup.monitorBackups' => config('backup.monitor_backups')]); $this->artisan('backup:monitor') - ->expectsOutput("Warning! Your config file still uses the old monitorBackups key. Update it to monitor_backups."); + ->expectsOutput('Warning! Your config file still uses the old monitorBackups key. Update it to monitor_backups.'); } } diff --git a/tests/DbDumperFactoryTest.php b/tests/DbDumperFactoryTest.php index d93c82ee..55f7a92e 100644 --- a/tests/DbDumperFactoryTest.php +++ b/tests/DbDumperFactoryTest.php @@ -168,13 +168,12 @@ it('can create instances of custom dumpers', function () { DbDumperFactory::extend('mysql', function () { - return new MongoDb(); + return new MongoDb; }); expect(DbDumperFactory::createFromConnection('mysql'))->toBeInstanceOf(MongoDb::class); }); - function getDumpCommand(): string { $dumpFile = ''; diff --git a/tests/Events/UnhealthyBackupWasFoundTest.php b/tests/Events/UnhealthyBackupWasFoundTest.php index 0c15533d..cd7aee9c 100644 --- a/tests/Events/UnhealthyBackupWasFoundTest.php +++ b/tests/Events/UnhealthyBackupWasFoundTest.php @@ -28,7 +28,7 @@ ->artisan('backup:monitor')->assertExitCode(1); Notification::assertSentTo( - new Notifiable(), + new Notifiable, UnhealthyBackupWasFoundNotification::class, function (UnhealthyBackupWasFoundNotification $notification) use ($msg) { $slack = $notification->toSlack(); @@ -57,7 +57,7 @@ function (UnhealthyBackupWasFoundNotification $notification) use ($msg) { ->artisan('backup:monitor') ->assertExitCode(1); - Notification::assertSentTo(new Notifiable(), UnhealthyBackupWasFoundNotification::class, function (UnhealthyBackupWasFoundNotification $notification) { + Notification::assertSentTo(new Notifiable, UnhealthyBackupWasFoundNotification::class, function (UnhealthyBackupWasFoundNotification $notification) { $slack = $notification->toSlack(); expect($slack->content)->toContain(trans('backup::notifications.unhealthy_backup_found_unknown')); $this->assertNotNull(collect($slack->attachments)->firstWhere('title', 'Health check')); diff --git a/tests/FileSelectionTest.php b/tests/FileSelectionTest.php index 4c5b9eeb..bea0a09d 100644 --- a/tests/FileSelectionTest.php +++ b/tests/FileSelectionTest.php @@ -37,7 +37,7 @@ it('can exclude files from a given subdirectory', function () { $fileSelection = (new FileSelection($this->sourceDirectory)) - ->excludeFilesFrom("{$this->sourceDirectory}/directory1"); + ->excludeFilesFrom("{$this->sourceDirectory}/directory1"); $testFiles = getTestFiles([ '.dot', @@ -62,8 +62,8 @@ it('can exclude files with wildcards from a given subdirectory', function () { $fileSelection = (new FileSelection($this->sourceDirectory)) ->excludeFilesFrom(getTestFiles([ - "*/file1.txt", - "*/directory1", + '*/file1.txt', + '*/directory1', ])); $testFiles = getTestFiles([ @@ -129,7 +129,7 @@ }); it('returns an empty array when not specifying any directories', function () { - $fileSelection = new FileSelection(); + $fileSelection = new FileSelection; expect(iterator_to_array($fileSelection->selectedFiles()))->toBeEmpty(); }); @@ -160,7 +160,6 @@ expect($fileSelection)->toBeInstanceOf(FileSelection::class); }); - function assertSameArrayContent($expected, $actual, $message = '') { test()->assertCount(count($expected), array_intersect($expected, $actual), $message); diff --git a/tests/FormatTest.php b/tests/FormatTest.php index dd4bb4e0..0ac356a3 100644 --- a/tests/FormatTest.php +++ b/tests/FormatTest.php @@ -1,7 +1,6 @@ open($path); assertEncryptionMethod($zip, ZipArchive::EM_NONE); @@ -23,14 +23,14 @@ }); /** - * @param int $algorithm + * @param int $algorithm */ it('encrypts archive with password', function (int $algorithm) { config()->set('backup.backup.encryption', $algorithm); $path = zip(); - $zip = new ZipArchive(); + $zip = new ZipArchive; $zip->open($path); assertEncryptionMethod($zip, $algorithm); @@ -49,7 +49,7 @@ it('can not open encrypted archive without password', function () { $path = zip(); - $zip = new ZipArchive(); + $zip = new ZipArchive; $zip->open($path); assertEncryptionMethod($zip, ZipArchive::EM_AES_256); diff --git a/tests/ManifestTest.php b/tests/ManifestTest.php index 52f372b7..85ab2f86 100644 --- a/tests/ManifestTest.php +++ b/tests/ManifestTest.php @@ -67,7 +67,6 @@ } }); - function getManifestTestFiles(): array { return collect(range(1, 3)) diff --git a/tests/Notifications/EventHandlerTest.php b/tests/Notifications/EventHandlerTest.php index b001bc39..74f87751 100644 --- a/tests/Notifications/EventHandlerTest.php +++ b/tests/Notifications/EventHandlerTest.php @@ -13,7 +13,7 @@ it('will send a notification by default when a backup has failed', function () { fireBackupHasFailedEvent(); - Notification::assertSentTo(new Notifiable(), BackupHasFailedNotification::class); + Notification::assertSentTo(new Notifiable, BackupHasFailedNotification::class); }); it('will send a notification via the configured notification channels', function (array $expectedChannels) { @@ -21,7 +21,7 @@ fireBackupHasFailedEvent(); - Notification::assertSentTo(new Notifiable(), BackupHasFailedNotification::class, function ($notification, $usedChannels) use ($expectedChannels) { + Notification::assertSentTo(new Notifiable, BackupHasFailedNotification::class, function ($notification, $usedChannels) use ($expectedChannels) { return $expectedChannels == $usedChannels; }); })->with([ diff --git a/tests/Pest.php b/tests/Pest.php index 0819fb64..43d20332 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -1,9 +1,9 @@ in(__DIR__); expect()->extend('hasItemContaining', function (string $searchString) { diff --git a/tests/TestCase.php b/tests/TestCase.php index 27f4ce42..aa9193c1 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -19,9 +19,7 @@ abstract class TestCase extends Orchestra { /** - * @param \Illuminate\Foundation\Application $app - * - * @return array + * @param \Illuminate\Foundation\Application $app */ protected function getPackageProviders($app): array { @@ -31,7 +29,7 @@ protected function getPackageProviders($app): array } /** - * @param \Illuminate\Foundation\Application $app + * @param \Illuminate\Foundation\Application $app */ protected function getEnvironmentSetUp($app) { @@ -107,7 +105,7 @@ protected function assertFileDoesntExistsInZip(string $diskName, string $zipPath protected function fileExistsInZip(string $diskName, string $zipPath, string $fileName): bool { - $zip = new ZipArchive(); + $zip = new ZipArchive; if ($zip->open($this->getFullDiskPath($diskName, $zipPath)) === true) { return $zip->locateName($fileName, ZipArchive::FL_NODIR) !== false; @@ -126,7 +124,7 @@ protected function assertExactPathExistsInZip(string $diskName, string $zipPath, protected function exactPathExistsInZip(string $diskName, string $zipPath, string $fullPath): bool { - $zip = new ZipArchive(); + $zip = new ZipArchive; if ($zip->open($this->getFullDiskPath($diskName, $zipPath)) === true) { foreach (range(0, $zip->numFiles - 1) as $i) { @@ -236,7 +234,7 @@ public function fakeBackup(): self return $this; } - public function makeHealthCheckFail(Exception $customException = null): self + public function makeHealthCheckFail(?Exception $customException = null): self { FakeFailingHealthCheck::$reason = $customException;