Skip to content

Commit 0bf905f

Browse files
chore!: ensure retrieved config values are of correct types and strict up types
1 parent 698b98e commit 0bf905f

24 files changed

+102
-67
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"orchestra/testbench": "^9.0",
1818
"pestphp/pest": "^3.0",
1919
"pestphp/pest-plugin-laravel": "^3.0",
20-
"carthage-software/mago": "^0.23.0"
20+
"carthage-software/mago": "1.0.0-alpha.2"
2121
},
2222
"autoload": {
2323
"psr-4": {

composer.lock

Lines changed: 10 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mago.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,17 @@ allow_dynamic_static_calls = true
1919
level = "off"
2020

2121
[[linter.rules]]
22-
name = "analysis/override-attribute"
22+
name = "best-practices/override-attribute"
2323
level = "off"
2424

2525
[[linter.rules]]
2626
name = "naming/class"
2727
level = "off"
2828

29+
[[linter.rules]]
30+
name = "best-practices/literal-named-argument"
31+
level = "off"
32+
2933
[[linter.rules]]
3034
name = "naming/interface"
3135
level = "off"
@@ -34,4 +38,3 @@ level = "off"
3438
# since we support php 8.2 we cannot use constant types
3539
name = "strictness/require-constant-type"
3640
level = "off"
37-

resources/views/backups.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55

66
@csrf
77

8-
<itiden-backup :chunk-size="{{ config('backup.chunk_size') }}" />
8+
<itiden-backup :chunk-size="{{ config()->integer('backup.chunk_size') }}" />
99

1010
@endsection

src/Backuper.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Itiden\Backup;
66

77
use Illuminate\Contracts\Auth\Authenticatable;
8+
use Illuminate\Support\Facades\Config;
89
use Illuminate\Support\Facades\File;
910
use Illuminate\Support\Facades\Pipeline;
1011
use Itiden\Backup\Contracts\Repositories\BackupRepository;
@@ -37,16 +38,17 @@ public function backup(?Authenticatable $user = null): BackupDto
3738
try {
3839
$this->stateManager->setState(State::BackupInProgress);
3940

40-
$temp_zip_path = join_paths(config('backup.temp_path'), 'temp.zip');
41+
$temp_zip_path = join_paths(Config::string('backup.temp_path'), 'temp.zip');
4142

4243
$zipper = Zipper::write($temp_zip_path);
4344

4445
Pipeline::via('backup')
4546
->send($zipper)
46-
->through(config('backup.pipeline'))
47+
->through(Config::array('backup.pipeline'))
4748
->thenReturn();
4849

49-
$password = config('backup.password');
50+
/** @var string|null */
51+
$password = Config::get('backup.password');
5052

5153
if ($password) {
5254
$zipper->encrypt($password);
@@ -108,7 +110,9 @@ public static function addMetaFromZipToBackupMeta(string $pathToZip, BackupDto $
108110
*/
109111
public function enforceMaxBackups(): void
110112
{
111-
$maxBackups = config('backup.max_backups', false);
113+
/** @var int|false */
114+
$maxBackups = Config::get('backup.max_backups', false);
115+
112116
if (!$maxBackups) {
113117
return;
114118
}

src/Console/Commands/BackupCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
*/
1717
final class BackupCommand extends Command
1818
{
19+
// @mago-expect lint:strictness/require-property-type
1920
protected $signature = 'statamic:backup';
2021

22+
// @mago-expect lint:strictness/require-property-type
2123
protected $description = 'Run the backup pipeline';
2224

2325
public function handle(): void

src/Console/Commands/ClearFilesCommand.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55
namespace Itiden\Backup\Console\Commands;
66

77
use Illuminate\Console\Command;
8+
use Illuminate\Support\Facades\Config;
89
use Illuminate\Support\Facades\File;
910

1011
use function Laravel\Prompts\info;
1112

1213
/**
1314
* Clear the backup temp directory
15+
*
16+
* @mago-expect lint:strictness/require-property-type
1417
*/
1518
final class ClearFilesCommand extends Command
1619
{
@@ -20,13 +23,15 @@ final class ClearFilesCommand extends Command
2023

2124
public function handle(): void
2225
{
23-
if (!File::exists(config('backup.temp_path'))) {
26+
$path = Config::string('backup.temp_path');
27+
28+
if (!File::exists(path: $path)) {
2429
info('Backup temp directory does not exist, no need to clear it.');
2530

2631
return;
2732
}
2833

29-
File::cleanDirectory(config('backup.temp_path'));
34+
File::cleanDirectory(directory: $path);
3035

3136
info('Backup temp directory cleared successfully');
3237
}

src/Console/Commands/RestoreCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
/**
1818
* Restore content from a directory / backup
19+
*
20+
* @mago-expect lint:strictness/require-property-type
1921
*/
2022
final class RestoreCommand extends Command
2123
{

src/DataTransferObjects/BackupDto.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Itiden\Backup\DataTransferObjects;
66

77
use Carbon\CarbonImmutable;
8+
use Illuminate\Support\Facades\Config;
89
use Illuminate\Support\Facades\Storage;
910
use Itiden\Backup\Contracts\BackupNameResolver;
1011
use Itiden\Backup\Models\Metadata;
@@ -36,7 +37,7 @@ public static function fromFile(string $path): ?static
3637
return null;
3738
}
3839

39-
$bytes = Storage::disk(config('backup.destination.disk'))->size($path);
40+
$bytes = Storage::disk(Config::string('backup.destination.disk'))->size($path);
4041

4142
return new static(
4243
id: $values->id,

src/DataTransferObjects/ChunkyUploadDto.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
final readonly class ChunkyUploadDto
1111
{
12-
// @mago-expect maintainability/excessive-parameter-list
12+
// @mago-expect lint:maintainability/excessive-parameter-list
1313
public function __construct(
1414
public string $filename,
1515
public int $totalChunks,

0 commit comments

Comments
 (0)