From 91b7d20f9b08ba77f1c7793922225e86e35d9d0a Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 29 Oct 2023 06:31:13 +0100 Subject: [PATCH] Remove static references --- .../Commands/Upgrade/UpgradeLiabilitiesEight.php | 2 +- app/Handlers/Events/APIEventHandler.php | 4 ++-- app/Handlers/Events/AdminEventHandler.php | 12 ++++++------ app/Handlers/Events/AutomationHandler.php | 4 ++-- app/Handlers/Events/BillEventHandler.php | 4 ++-- app/Handlers/Events/Model/BudgetLimitHandler.php | 6 +++--- .../Events/Model/PiggyBankEventHandler.php | 2 +- app/Handlers/Events/UserEventHandler.php | 16 ++++++++-------- app/Http/Controllers/DebugController.php | 4 ++-- app/Http/Middleware/Authenticate.php | 4 ++-- app/Jobs/MailError.php | 4 ++-- .../Support/CreditRecalculateService.php | 2 +- .../Internal/Update/RecurrenceUpdateService.php | 2 +- app/Support/Navigation.php | 2 +- app/Validation/RecurrenceValidation.php | 10 +++++----- 15 files changed, 39 insertions(+), 39 deletions(-) diff --git a/app/Console/Commands/Upgrade/UpgradeLiabilitiesEight.php b/app/Console/Commands/Upgrade/UpgradeLiabilitiesEight.php index ccd8e4721b..0309e53898 100644 --- a/app/Console/Commands/Upgrade/UpgradeLiabilitiesEight.php +++ b/app/Console/Commands/Upgrade/UpgradeLiabilitiesEight.php @@ -216,7 +216,7 @@ class UpgradeLiabilitiesEight extends Command return; } - Log::warning('Did not find opening balance.'); + app('log')->warning('Did not find opening balance.'); } /** diff --git a/app/Handlers/Events/APIEventHandler.php b/app/Handlers/Events/APIEventHandler.php index c1d78be08e..2938bdc1f5 100644 --- a/app/Handlers/Events/APIEventHandler.php +++ b/app/Handlers/Events/APIEventHandler.php @@ -54,11 +54,11 @@ class APIEventHandler } catch (Exception $e) { $message = $e->getMessage(); if (str_contains($message, 'Bcc')) { - Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); + app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); return; } if (str_contains($message, 'RFC 2822')) { - Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); + app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); return; } Log::error($e->getMessage()); diff --git a/app/Handlers/Events/AdminEventHandler.php b/app/Handlers/Events/AdminEventHandler.php index acf73ff5a4..0bcb9b264a 100644 --- a/app/Handlers/Events/AdminEventHandler.php +++ b/app/Handlers/Events/AdminEventHandler.php @@ -62,11 +62,11 @@ class AdminEventHandler } catch (Exception $e) { $message = $e->getMessage(); if (str_contains($message, 'Bcc')) { - Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); + app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); return; } if (str_contains($message, 'RFC 2822')) { - Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); + app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); return; } Log::error($e->getMessage()); @@ -100,11 +100,11 @@ class AdminEventHandler } catch (Exception $e) { $message = $e->getMessage(); if (str_contains($message, 'Bcc')) { - Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); + app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); return; } if (str_contains($message, 'RFC 2822')) { - Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); + app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); return; } Log::error($e->getMessage()); @@ -134,11 +134,11 @@ class AdminEventHandler } catch (Exception $e) { $message = $e->getMessage(); if (str_contains($message, 'Bcc')) { - Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); + app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); return; } if (str_contains($message, 'RFC 2822')) { - Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); + app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); return; } Log::error($e->getMessage()); diff --git a/app/Handlers/Events/AutomationHandler.php b/app/Handlers/Events/AutomationHandler.php index defb50f90f..4b761f92a7 100644 --- a/app/Handlers/Events/AutomationHandler.php +++ b/app/Handlers/Events/AutomationHandler.php @@ -78,11 +78,11 @@ class AutomationHandler } catch (Exception $e) { $message = $e->getMessage(); if (str_contains($message, 'Bcc')) { - Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); + app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); return; } if (str_contains($message, 'RFC 2822')) { - Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); + app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); return; } Log::error($e->getMessage()); diff --git a/app/Handlers/Events/BillEventHandler.php b/app/Handlers/Events/BillEventHandler.php index a7b58a4102..d3e5f99017 100644 --- a/app/Handlers/Events/BillEventHandler.php +++ b/app/Handlers/Events/BillEventHandler.php @@ -56,11 +56,11 @@ class BillEventHandler } catch (Exception $e) { $message = $e->getMessage(); if (str_contains($message, 'Bcc')) { - Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); + app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); return; } if (str_contains($message, 'RFC 2822')) { - Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); + app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); return; } Log::error($e->getMessage()); diff --git a/app/Handlers/Events/Model/BudgetLimitHandler.php b/app/Handlers/Events/Model/BudgetLimitHandler.php index 8abe31998a..7bf72ba2fe 100644 --- a/app/Handlers/Events/Model/BudgetLimitHandler.php +++ b/app/Handlers/Events/Model/BudgetLimitHandler.php @@ -65,11 +65,11 @@ class BudgetLimitHandler Log::debug(sprintf('Now in updateAvailableBudget(#%d)', $budgetLimit->id)); $budget = Budget::find($budgetLimit->budget_id); if (null === $budget) { - Log::warning('Budget is null, probably deleted, find deleted version.'); + app('log')->warning('Budget is null, probably deleted, find deleted version.'); $budget = Budget::withTrashed()->find($budgetLimit->budget_id); } if (null === $budget) { - Log::warning('Budget is still null, cannot continue, will delete budget limit.'); + app('log')->warning('Budget is still null, cannot continue, will delete budget limit.'); $budgetLimit->forceDelete(); return; } @@ -77,7 +77,7 @@ class BudgetLimitHandler // sanity check. It happens when the budget has been deleted so the original user is unknown. if (null === $user) { - Log::warning('User is null, cannot continue.'); + app('log')->warning('User is null, cannot continue.'); $budgetLimit->forceDelete(); return; } diff --git a/app/Handlers/Events/Model/PiggyBankEventHandler.php b/app/Handlers/Events/Model/PiggyBankEventHandler.php index 5eca00f652..fa1ec5a4c4 100644 --- a/app/Handlers/Events/Model/PiggyBankEventHandler.php +++ b/app/Handlers/Events/Model/PiggyBankEventHandler.php @@ -52,7 +52,7 @@ class PiggyBankEventHandler ->where('transaction_journal_id', $journal->id) ->exists(); if ($exists) { - Log::warning('Already have event for this journal and piggy, will not create another.'); + app('log')->warning('Already have event for this journal and piggy, will not create another.'); return; } } diff --git a/app/Handlers/Events/UserEventHandler.php b/app/Handlers/Events/UserEventHandler.php index 6f534d04a1..79beb3405f 100644 --- a/app/Handlers/Events/UserEventHandler.php +++ b/app/Handlers/Events/UserEventHandler.php @@ -207,11 +207,11 @@ class UserEventHandler } catch (Exception $e) { $message = $e->getMessage(); if (str_contains($message, 'Bcc')) { - Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); + app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); return; } if (str_contains($message, 'RFC 2822')) { - Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); + app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); return; } Log::error($e->getMessage()); @@ -241,11 +241,11 @@ class UserEventHandler } catch (Exception $e) { $message = $e->getMessage(); if (str_contains($message, 'Bcc')) { - Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); + app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); return; } if (str_contains($message, 'RFC 2822')) { - Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); + app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); return; } Log::error($e->getMessage()); @@ -318,11 +318,11 @@ class UserEventHandler } catch (Exception $e) { $message = $e->getMessage(); if (str_contains($message, 'Bcc')) { - Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); + app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); return; } if (str_contains($message, 'RFC 2822')) { - Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); + app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); return; } Log::error($e->getMessage()); @@ -366,11 +366,11 @@ class UserEventHandler } catch (Exception $e) { $message = $e->getMessage(); if (str_contains($message, 'Bcc')) { - Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); + app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); return; } if (str_contains($message, 'RFC 2822')) { - Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); + app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); return; } Log::error($e->getMessage()); diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.php index c4fc690fe1..ee03dab98e 100644 --- a/app/Http/Controllers/DebugController.php +++ b/app/Http/Controllers/DebugController.php @@ -203,7 +203,7 @@ class DebugController extends Controller } } catch (Exception $e) { // generic catch for open basedir. Log::debug('Could not check build counter, but thats ok.'); - Log::warning($e->getMessage()); + app('log')->warning($e->getMessage()); } try { if (file_exists('/var/www/build-date-main.txt')) { @@ -211,7 +211,7 @@ class DebugController extends Controller } } catch (Exception $e) { // generic catch for open basedir. Log::debug('Could not check build date, but thats ok.'); - Log::warning($e->getMessage()); + app('log')->warning($e->getMessage()); } if ('' !== (string)env('BASE_IMAGE_BUILD')) { $return['base_build'] = env('BASE_IMAGE_BUILD'); diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index 476ceabe80..b0e3e4f743 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -128,7 +128,7 @@ class Authenticate private function validateBlockedUser(?User $user, array $guards): void { if (null === $user) { - Log::warning('User is null, throw exception?'); + app('log')->warning('User is null, throw exception?'); } if (null !== $user) { // Log::debug(get_class($user)); @@ -137,7 +137,7 @@ class Authenticate if ('email_changed' === $user->blocked_code) { $message = (string)trans('firefly.email_changed_logout'); } - Log::warning('User is blocked, cannot use authentication method.'); + app('log')->warning('User is blocked, cannot use authentication method.'); app('session')->flash('logoutMessage', $message); /** @noinspection PhpUndefinedMethodInspection */ $this->auth->logout(); // @phpstan-ignore-line (thinks function is undefined) diff --git a/app/Jobs/MailError.php b/app/Jobs/MailError.php index bb4b916b7d..4f235ea29e 100644 --- a/app/Jobs/MailError.php +++ b/app/Jobs/MailError.php @@ -95,11 +95,11 @@ class MailError extends Job implements ShouldQueue } catch (Exception | TransportException $e) { // intentional generic exception $message = $e->getMessage(); if (str_contains($message, 'Bcc')) { - Log::warning('[Bcc] Could not email or log the error. Please validate your email settings, use the .env.example file as a guide.'); + app('log')->warning('[Bcc] Could not email or log the error. Please validate your email settings, use the .env.example file as a guide.'); return; } if (str_contains($message, 'RFC 2822')) { - Log::warning('[RFC] Could not email or log the error. Please validate your email settings, use the .env.example file as a guide.'); + app('log')->warning('[RFC] Could not email or log the error. Please validate your email settings, use the .env.example file as a guide.'); return; } Log::error($e->getMessage()); diff --git a/app/Services/Internal/Support/CreditRecalculateService.php b/app/Services/Internal/Support/CreditRecalculateService.php index c221ab4131..58f81795e2 100644 --- a/app/Services/Internal/Support/CreditRecalculateService.php +++ b/app/Services/Internal/Support/CreditRecalculateService.php @@ -433,7 +433,7 @@ class CreditRecalculateService return $result; } - Log::warning(sprintf('[-1] Catch-all, should not happen. Left of debt = %s', app('steam')->bcround($leftOfDebt, $decimals))); + app('log')->warning(sprintf('[-1] Catch-all, should not happen. Left of debt = %s', app('steam')->bcround($leftOfDebt, $decimals))); return $leftOfDebt; } diff --git a/app/Services/Internal/Update/RecurrenceUpdateService.php b/app/Services/Internal/Update/RecurrenceUpdateService.php index 559f333fd3..926882e621 100644 --- a/app/Services/Internal/Update/RecurrenceUpdateService.php +++ b/app/Services/Internal/Update/RecurrenceUpdateService.php @@ -224,7 +224,7 @@ class RecurrenceUpdateService Log::debug(sprintf('Original count is %d', $originalCount)); if (0 === count($transactions)) { // won't drop transactions, rather avoid. - Log::warning('No transactions to update, too scared to continue!'); + app('log')->warning('No transactions to update, too scared to continue!'); return; } $combinations = []; diff --git a/app/Support/Navigation.php b/app/Support/Navigation.php index fbd3e3a0ab..77b451691f 100644 --- a/app/Support/Navigation.php +++ b/app/Support/Navigation.php @@ -111,7 +111,7 @@ class Navigation try { return $this->calculator->nextDateByInterval($epoch, $periodicity, $skipInterval); } catch (IntervalException $exception) { - Log::warning($exception->getMessage(), ['exception' => $exception]); + app('log')->warning($exception->getMessage(), ['exception' => $exception]); } catch (Throwable $exception) { Log::error($exception->getMessage(), ['exception' => $exception]); } diff --git a/app/Validation/RecurrenceValidation.php b/app/Validation/RecurrenceValidation.php index 6dabcbf60d..d87a7656be 100644 --- a/app/Validation/RecurrenceValidation.php +++ b/app/Validation/RecurrenceValidation.php @@ -340,12 +340,12 @@ trait RecurrenceValidation //$recurrence = $validator->get if (null === $transactions) { - Log::warning('[a] User submitted no transactions.'); + app('log')->warning('[a] User submitted no transactions.'); $validator->errors()->add('transactions', (string)trans('validation.at_least_one_transaction')); return; } if (0 === $submittedTrCount) { - Log::warning('[b] User submitted no transactions.'); + app('log')->warning('[b] User submitted no transactions.'); $validator->errors()->add('transactions', (string)trans('validation.at_least_one_transaction')); return; } @@ -393,12 +393,12 @@ trait RecurrenceValidation foreach ($transactions as $index => $transaction) { Log::debug(sprintf('Now at %d/%d', $index + 1, $submittedTrCount)); if (!is_array($transaction)) { - Log::warning('Not an array. Give error.'); + app('log')->warning('Not an array. Give error.'); $validator->errors()->add(sprintf('transactions.%d.id', $index), (string)trans('validation.at_least_one_transaction')); return; } if (!array_key_exists('id', $transaction) && $idsMandatory) { - Log::warning('ID is mandatory but array has no ID.'); + app('log')->warning('ID is mandatory but array has no ID.'); $validator->errors()->add(sprintf('transactions.%d.id', $index), (string)trans('validation.need_id_to_match')); return; } @@ -419,7 +419,7 @@ trait RecurrenceValidation $maxUnmatched = max(1, $submittedTrCount - $originalTrCount); Log::debug(sprintf('Submitted: %d. Original: %d. User can submit %d unmatched transactions.', $submittedTrCount, $originalTrCount, $maxUnmatched)); if ($unmatchedIds > $maxUnmatched) { - Log::warning(sprintf('Too many unmatched transactions (%d).', $unmatchedIds)); + app('log')->warning(sprintf('Too many unmatched transactions (%d).', $unmatchedIds)); $validator->errors()->add('transactions.0.id', (string)trans('validation.too_many_unmatched')); return; }