Fix a lot of phpstan things

This commit is contained in:
James Cole
2023-11-26 12:10:42 +01:00
parent a6c355c7b8
commit 68f01d932e
53 changed files with 214 additions and 120 deletions

View File

@@ -92,6 +92,11 @@ class BudgetLimitHandler
app('log')->error($e->getMessage());
$viewRange = '1M';
}
// safety catch
if(null === $viewRange || is_array($viewRange)){
$viewRange = '1M';
}
$viewRange = (string)$viewRange;
$start = app('navigation')->startOfPeriod($budgetLimit->start_date, $viewRange);
$end = app('navigation')->startOfPeriod($budgetLimit->end_date, $viewRange);

View File

@@ -197,6 +197,9 @@ class UserEventHandler
}
$list = app('preferences')->getForUser($user, 'login_ip_history', [])->data;
if(!is_array($list)) {
$list = [];
}
/** @var array $entry */
foreach ($list as $index => $entry) {
@@ -415,7 +418,7 @@ class UserEventHandler
}
// clean up old entries (6 months)
$carbon = Carbon::createFromFormat('Y-m-d H:i:s', $preference[$index]['time']);
if ($carbon->diffInMonths(today()) > 6) {
if (false !== $carbon && $carbon->diffInMonths(today()) > 6) {
app('log')->debug(sprintf('Entry for %s is very old, remove it.', $row['ip']));
unset($preference[$index]);
}