Skip to content

Commit

Permalink
Add Phpstan Baseline, increase Level to 5 and "fix" some errors (#68)
Browse files Browse the repository at this point in the history
* Phpstan Fixes

* Add phpstan-baseline
  • Loading branch information
stefanzweifel authored Mar 26, 2024
1 parent a2d61a2 commit 6d8f956
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
31 changes: 31 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
parameters:
ignoreErrors:
-
message: "#^Unsafe usage of new static\\(\\)\\.$#"
count: 2
path: src/Exceptions/CannotCreateDbImporter.php

-
message: "#^Unsafe usage of new static\\(\\)\\.$#"
count: 1
path: src/Exceptions/CliNotFound.php

-
message: "#^Unsafe usage of new static\\(\\)\\.$#"
count: 1
path: src/Exceptions/DecompressionFailed.php

-
message: "#^Unsafe usage of new static\\(\\)\\.$#"
count: 2
path: src/Exceptions/ImportFailed.php

-
message: "#^Unsafe usage of new static\\(\\)\\.$#"
count: 1
path: src/Exceptions/NoBackupsFound.php

-
message: "#^Unsafe usage of new static\\(\\)\\.$#"
count: 1
path: src/Exceptions/NoDatabaseDumpsFound.php
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ includes:
- phpstan-baseline.neon

parameters:
level: 4
level: 5
paths:
- src
- config
Expand Down
4 changes: 1 addition & 3 deletions src/Commands/RestoreCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ private function getBackupToRestore(string $disk): string
->filter(fn ($file) => Str::endsWith($file, '.zip'));

if ($listOfBackups->count() === 0) {
if (isset($disk)) {
error("No backups found on {$disk}.");
}
error("No backups found on {$disk}.");
throw NoBackupsFound::onDisk($disk);
}

Expand Down
1 change: 1 addition & 0 deletions src/HealthChecks/Checks/DatabaseHasTables.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function run(PendingRestore $pendingRestore): Result
$tables = $schemaBuilder->getTables();
} else {
// `getAllTables()` has been removed in Laravel 11.
/** @phpstan-ignore-next-line */
$tables = $schemaBuilder->getAllTables();
}

Expand Down
1 change: 1 addition & 0 deletions src/PendingRestore.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static function make(...$attributes): PendingRestore
{
$restoreName = now()->format('Y-m-d-h-i-s').'-'.Str::uuid();

/** @phpstan-ignore-next-line */
return new self(
...$attributes,
restoreName: $restoreName,
Expand Down

0 comments on commit 6d8f956

Please sign in to comment.