Skip to content

Commit 680440f

Browse files
committed
cs fixes
1 parent 8dcd6e4 commit 680440f

File tree

7 files changed

+35
-11
lines changed

7 files changed

+35
-11
lines changed

app/Console/Commands/PerformSiteHealthCheck.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ class PerformSiteHealthCheck extends Command
2727
*/
2828
public function handle(): int
2929
{
30-
CheckSiteHealth::dispatchSync(
31-
Site::findOrFail($this->input->getArgument('siteId'))
32-
);
30+
/** @var Site $site */
31+
$site = Site::findOrFail($this->input->getArgument('siteId'));
32+
33+
CheckSiteHealth::dispatchSync($site);
3334

3435
return Command::SUCCESS;
3536
}

app/Console/Commands/QueueHealthChecks.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ public function handle(): int
3434
$this->output->writeln('Pushing pending health checks');
3535

3636
Site::query()
37-
->whereDate('last_seen', '<', Carbon::now()->subHours(env('HEALTH_CHECK_INTERVAL', 24)))
37+
->whereDate(
38+
'last_seen',
39+
'<',
40+
Carbon::now()->subHours((int) config('autoupdates.healthcheck_interval')) // @phpstan-ignore-line
41+
)
3842
->chunkById(
3943
100,
4044
function (Collection $chunk) {
@@ -44,7 +48,7 @@ function (Collection $chunk) {
4448
$this->totalPushed += $chunk->count();
4549

4650
// Push each site check to queue
47-
$chunk->each(fn($site) => CheckSiteHealth::dispatch($site));
51+
$chunk->each(fn ($site) => CheckSiteHealth::dispatch($site));
4852
}
4953
);
5054

app/Jobs/CheckSiteHealth.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public function handle(): void
4444
])->toArray()
4545
);
4646

47+
// @phpstan-ignore-next-line
4748
$this->site->last_seen = Carbon::now();
4849
$this->site->save();
4950
}

app/Services/SiteConnectionService.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,23 @@ protected function performHttpRequest(
9595
);
9696
}
9797

98-
// Return decoded body
99-
return json_decode(
98+
// Decode body
99+
$return = json_decode(
100100
(string) $response->getBody(),
101101
true,
102102
512,
103103
JSON_THROW_ON_ERROR
104104
);
105+
106+
// Make sure it's an array
107+
if (!is_array($return)) {
108+
throw new RequestException(
109+
"Invalid JSON body",
110+
$request,
111+
$response
112+
);
113+
}
114+
115+
return $return;
105116
}
106117
}

config/app.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,5 @@
121121
'maintenance' => [
122122
'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
123123
'store' => env('APP_MAINTENANCE_STORE', 'database'),
124-
],
125-
124+
]
126125
];

config/autoupdates.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
return [
4+
'healthcheck_interval' => env('HEALTH_CHECK_INTERVAL', 24)
5+
];

phpstan.neon.dist

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@ parameters:
77
paths:
88
- app/
99

10-
# Level 9 is the highest level
11-
level: 5
10+
level: 9
11+
12+
ignoreErrors:
13+
- '#Method .* return type has no value type specified in iterable type array.#'
14+
- '#Method .* has parameter .* with no value type specified in iterable type array.#'

0 commit comments

Comments
 (0)