Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Replace phpstan suggestions
James Cole33f370359c5a
diff --git a/app/Api/V1/Controllers/Controller.php b/app/Api/V1/Controllers/Controller.phpindex ea8132335d..842d13ecc5 100644--- a/app/Api/V1/Controllers/Controller.php+++ b/app/Api/V1/Controllers/Controller.php@@ -103,7 +103,7 @@ abstract class Controller extends BaseController$obj = Carbon::parse($date);} catch (InvalidDateException | InvalidFormatException $e) {// don't care- Log::warning(sprintf('Ignored invalid date "%s" in API controller parameter check: %s', $date, $e->getMessage()));+ app('log')->warning(sprintf('Ignored invalid date "%s" in API controller parameter check: %s', $date, $e->getMessage()));}}$bag->set($field, $obj);diff --git a/app/Api/V1/Controllers/Models/Transaction/StoreController.php b/app/Api/V1/Controllers/Models/Transaction/StoreController.phpindex c00a8425c1..24d9375b77 100644--- a/app/Api/V1/Controllers/Models/Transaction/StoreController.php+++ b/app/Api/V1/Controllers/Models/Transaction/StoreController.php@@ -93,14 +93,14 @@ class StoreController extends Controllertry {$transactionGroup = $this->groupRepository->store($data);} catch (DuplicateTransactionException $e) {- Log::warning('Caught a duplicate transaction. Return error message.');+ app('log')->warning('Caught a duplicate transaction. Return error message.');$validator = Validator::make(['transactions' => [['description' => $e->getMessage()]]],['transactions.0.description' => new IsDuplicateTransaction()]);throw new ValidationException($validator, 0, $e);} catch (FireflyException $e) {- Log::warning('Caught an exception. Return error message.');+ app('log')->warning('Caught an exception. Return error message.');Log::error($e->getMessage());$message = sprintf('Internal exception: %s', $e->getMessage());$validator = Validator::make(['transactions' => [['description' => $message]]], ['transactions.0.description' => new IsDuplicateTransaction()]);diff --git a/app/Api/V1/Requests/Models/Bill/UpdateRequest.php b/app/Api/V1/Requests/Models/Bill/UpdateRequest.phpindex 1a896df108..324eba1e81 100644--- a/app/Api/V1/Requests/Models/Bill/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/Bill/UpdateRequest.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Api\V1\Requests\Models\Bill;+use FireflyIII\Models\Bill;use FireflyIII\Rules\IsBoolean;use FireflyIII\Support\Request\ChecksLogin;use FireflyIII\Support\Request\ConvertsDataTypes;@@ -75,6 +76,7 @@ class UpdateRequest extends FormRequest*/public function rules(): array{+ /** @var Bill $bill */$bill = $this->route()->parameter('bill');return [diff --git a/app/Api/V1/Requests/Models/Budget/UpdateRequest.php b/app/Api/V1/Requests/Models/Budget/UpdateRequest.phpindex 55bfe17058..c989478415 100644--- a/app/Api/V1/Requests/Models/Budget/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/Budget/UpdateRequest.php@@ -23,6 +23,7 @@ declare(strict_types=1);namespace FireflyIII\Api\V1\Requests\Models\Budget;+use FireflyIII\Models\Budget;use FireflyIII\Rules\IsBoolean;use FireflyIII\Support\Request\ChecksLogin;use FireflyIII\Support\Request\ConvertsDataTypes;@@ -80,6 +81,7 @@ class UpdateRequest extends FormRequest*/public function rules(): array{+ /** @var Budget $budget */$budget = $this->route()->parameter('budget');return [diff --git a/app/Api/V1/Requests/Models/Category/UpdateRequest.php b/app/Api/V1/Requests/Models/Category/UpdateRequest.phpindex 24a0e921fd..25d3e3d86f 100644--- a/app/Api/V1/Requests/Models/Category/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/Category/UpdateRequest.php@@ -23,6 +23,7 @@ declare(strict_types=1);namespace FireflyIII\Api\V1\Requests\Models\Category;+use FireflyIII\Models\Category;use FireflyIII\Support\Request\ChecksLogin;use FireflyIII\Support\Request\ConvertsDataTypes;use Illuminate\Foundation\Http\FormRequest;@@ -59,6 +60,7 @@ class UpdateRequest extends FormRequest*/public function rules(): array{+ /** @var Category $category */$category = $this->route()->parameter('category');return [diff --git a/app/Api/V1/Requests/Models/ObjectGroup/UpdateRequest.php b/app/Api/V1/Requests/Models/ObjectGroup/UpdateRequest.phpindex 32d95e4189..1303cf21f1 100644--- a/app/Api/V1/Requests/Models/ObjectGroup/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/ObjectGroup/UpdateRequest.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Api\V1\Requests\Models\ObjectGroup;+use FireflyIII\Models\ObjectGroup;use FireflyIII\Support\Request\ChecksLogin;use FireflyIII\Support\Request\ConvertsDataTypes;use Illuminate\Foundation\Http\FormRequest;@@ -58,6 +59,7 @@ class UpdateRequest extends FormRequest*/public function rules(): array{+ /** @var ObjectGroup $objectGroup */$objectGroup = $this->route()->parameter('objectGroup');return [diff --git a/app/Api/V1/Requests/Models/PiggyBank/UpdateRequest.php b/app/Api/V1/Requests/Models/PiggyBank/UpdateRequest.phpindex c8061fef1b..e3f41da58c 100644--- a/app/Api/V1/Requests/Models/PiggyBank/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/PiggyBank/UpdateRequest.php@@ -23,6 +23,7 @@ declare(strict_types=1);namespace FireflyIII\Api\V1\Requests\Models\PiggyBank;+use FireflyIII\Models\PiggyBank;use FireflyIII\Rules\IsAssetAccountId;use FireflyIII\Rules\LessThanPiggyTarget;use FireflyIII\Support\Request\ChecksLogin;@@ -69,6 +70,7 @@ class UpdateRequest extends FormRequest*/public function rules(): array{+ /** @var PiggyBank $piggyBank */$piggyBank = $this->route()->parameter('piggyBank');return [diff --git a/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php b/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.phpindex 0c16d29cb3..6fa38d1644 100644--- a/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php@@ -114,7 +114,7 @@ class UpdateRequest extends FormRequest}$return[] = $current;}- if (empty($return)) {+ if (0 === count($return)) {return null;}diff --git a/app/Api/V1/Requests/Models/Rule/StoreRequest.php b/app/Api/V1/Requests/Models/Rule/StoreRequest.phpindex ef1c31911b..7cc6b5c12b 100644--- a/app/Api/V1/Requests/Models/Rule/StoreRequest.php+++ b/app/Api/V1/Requests/Models/Rule/StoreRequest.php@@ -172,7 +172,7 @@ class StoreRequest extends FormRequest$data = $validator->getData();$triggers = $data['triggers'] ?? [];// need at least one trigger- if (!is_countable($triggers) || empty($triggers)) {+ if (!is_countable($triggers) || 0 === count($triggers)) {$validator->errors()->add('title', (string) trans('validation.at_least_one_trigger'));}}@@ -187,7 +187,7 @@ class StoreRequest extends FormRequest$data = $validator->getData();$actions = $data['actions'] ?? [];// need at least one trigger- if (!is_countable($actions) || empty($actions)) {+ if (!is_countable($actions) || 0 === count($actions)) {$validator->errors()->add('title', (string) trans('validation.at_least_one_action'));}}@@ -202,7 +202,7 @@ class StoreRequest extends FormRequest$data = $validator->getData();$triggers = $data['triggers'] ?? [];// need at least one trigger- if (!is_countable($triggers) || empty($triggers)) {+ if (!is_countable($triggers) || 0 === count($triggers)) {return;}$allInactive = true;@@ -231,7 +231,7 @@ class StoreRequest extends FormRequest$data = $validator->getData();$actions = $data['actions'] ?? [];// need at least one trigger- if (!is_countable($actions) || empty($actions)) {+ if (!is_countable($actions) || 0 === count($actions)) {return;}$allInactive = true;diff --git a/app/Api/V1/Requests/Models/Rule/UpdateRequest.php b/app/Api/V1/Requests/Models/Rule/UpdateRequest.phpindex 0ae4a7cda1..586cc45ad4 100644--- a/app/Api/V1/Requests/Models/Rule/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/Rule/UpdateRequest.php@@ -187,7 +187,7 @@ class UpdateRequest extends FormRequest$data = $validator->getData();$triggers = $data['triggers'] ?? null;// need at least one trigger- if (is_array($triggers) && empty($triggers)) {+ if (is_array($triggers) && 0 === count($triggers)) {$validator->errors()->add('title', (string) trans('validation.at_least_one_trigger'));}}@@ -204,7 +204,7 @@ class UpdateRequest extends FormRequest$allInactive = true;$inactiveIndex = 0;// need at least one trigger- if (is_array($triggers) && empty($triggers)) {+ if (is_array($triggers) && 0 === count($triggers)) {return;}foreach ($triggers as $index => $trigger) {@@ -231,7 +231,7 @@ class UpdateRequest extends FormRequest$data = $validator->getData();$actions = $data['actions'] ?? null;// need at least one action- if (is_array($actions) && empty($actions)) {+ if (is_array($actions) && 0 === count($actions)) {$validator->errors()->add('title', (string) trans('validation.at_least_one_action'));}}@@ -248,7 +248,7 @@ class UpdateRequest extends FormRequest$allInactive = true;$inactiveIndex = 0;// need at least one action- if (is_array($actions) && empty($actions)) {+ if (is_array($actions) && 0 === count($actions)) {return;}diff --git a/app/Api/V1/Requests/Models/RuleGroup/UpdateRequest.php b/app/Api/V1/Requests/Models/RuleGroup/UpdateRequest.phpindex 76a7e2d370..2cab0d7552 100644--- a/app/Api/V1/Requests/Models/RuleGroup/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/RuleGroup/UpdateRequest.php@@ -23,6 +23,7 @@ declare(strict_types=1);namespace FireflyIII\Api\V1\Requests\Models\RuleGroup;+use FireflyIII\Models\RuleGroup;use FireflyIII\Rules\IsBoolean;use FireflyIII\Support\Request\ChecksLogin;use FireflyIII\Support\Request\ConvertsDataTypes;@@ -62,6 +63,7 @@ class UpdateRequest extends FormRequest*/public function rules(): array{+ /** @var RuleGroup $ruleGroup */$ruleGroup = $this->route()->parameter('ruleGroup');return [diff --git a/app/Api/V1/Requests/Models/Tag/UpdateRequest.php b/app/Api/V1/Requests/Models/Tag/UpdateRequest.phpindex 89e2b21565..9783e723c0 100644--- a/app/Api/V1/Requests/Models/Tag/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/Tag/UpdateRequest.php@@ -25,6 +25,7 @@ declare(strict_types=1);namespace FireflyIII\Api\V1\Requests\Models\Tag;use FireflyIII\Models\Location;+use FireflyIII\Models\Tag;use FireflyIII\Support\Request\AppendsLocationData;use FireflyIII\Support\Request\ChecksLogin;use FireflyIII\Support\Request\ConvertsDataTypes;@@ -66,6 +67,7 @@ class UpdateRequest extends FormRequest*/public function rules(): array{+ /** @var Tag $tag */$tag = $this->route()->parameter('tagOrId');// TODO check if uniqueObjectForUser is obsolete$rules = [diff --git a/app/Api/V1/Requests/System/UpdateRequest.php b/app/Api/V1/Requests/System/UpdateRequest.phpindex 0418096d42..d5be18248c 100644--- a/app/Api/V1/Requests/System/UpdateRequest.php+++ b/app/Api/V1/Requests/System/UpdateRequest.php@@ -47,15 +47,12 @@ class UpdateRequest extends FormRequestpublic function getAll(): array{$name = $this->route()->parameter('dynamicConfigKey');- switch ($name) {- default:- break;- case 'configuration.is_demo_site':- case 'configuration.single_user_mode':- return ['value' => $this->boolean('value')];- case 'configuration.permission_update_check':- case 'configuration.last_update_check':- return ['value' => $this->convertInteger('value')];++ if ($name === 'configuration.is_demo_site' || $name === 'configuration.single_user_mode') {+ return ['value' => $this->boolean('value')];+ }+ if ($name === 'configuration.permission_update_check' || $name === 'configuration.last_update_check') {+ return ['value' => $this->convertInteger('value')];}return ['value' => $this->convertString('value')];@@ -69,16 +66,15 @@ class UpdateRequest extends FormRequestpublic function rules(): array{$name = $this->route()->parameter('configName');- switch ($name) {- default:- break;- case 'configuration.is_demo_site':- case 'configuration.single_user_mode':- return ['value' => ['required', new IsBoolean()]];- case 'configuration.permission_update_check':- return ['value' => 'required|numeric|between:-1,1'];- case 'configuration.last_update_check':- return ['value' => 'required|numeric|min:464272080'];++ if ($name === 'configuration.is_demo_site' || $name === 'configuration.single_user_mode') {+ return ['value' => ['required', new IsBoolean()]];+ }+ if ($name === 'configuration.permission_update_check') {+ return ['value' => 'required|numeric|between:-1,1'];+ }+ if ($name === 'configuration.last_update_check') {+ return ['value' => 'required|numeric|min:464272080'];}return ['value' => 'required'];diff --git a/app/Api/V1/Requests/System/UserUpdateRequest.php b/app/Api/V1/Requests/System/UserUpdateRequest.phpindex c0b88dd44e..4897c30a20 100644--- a/app/Api/V1/Requests/System/UserUpdateRequest.php+++ b/app/Api/V1/Requests/System/UserUpdateRequest.php@@ -27,6 +27,7 @@ namespace FireflyIII\Api\V1\Requests\System;use FireflyIII\Rules\IsBoolean;use FireflyIII\Support\Request\ChecksLogin;use FireflyIII\Support\Request\ConvertsDataTypes;+use FireflyIII\User;use Illuminate\Foundation\Http\FormRequest;use Illuminate\Validation\Validator;@@ -75,6 +76,7 @@ class UserUpdateRequest extends FormRequest*/public function rules(): array{+ /** @var User $user */$user = $this->route()->parameter('user');return [diff --git a/app/Api/V2/Controllers/Chart/AccountController.php b/app/Api/V2/Controllers/Chart/AccountController.phpindex 11a0b5f384..c9a44b9c1b 100644--- a/app/Api/V2/Controllers/Chart/AccountController.php+++ b/app/Api/V2/Controllers/Chart/AccountController.php@@ -75,7 +75,7 @@ class AccountController extends Controller$accounts = $this->repository->getAccountsById($frontPage->data);$chartData = [];- if (empty($frontPage->data)) {+ if (!(is_array($frontPage->data) && count($frontPage->data) > 0)) {$frontPage->data = $defaultSet;$frontPage->save();}diff --git a/app/Api/V2/Controllers/Controller.php b/app/Api/V2/Controllers/Controller.phpindex fa961ab800..77da354c9c 100644--- a/app/Api/V2/Controllers/Controller.php+++ b/app/Api/V2/Controllers/Controller.php@@ -142,7 +142,7 @@ class Controller extends BaseController$obj = Carbon::parse($date);} catch (InvalidDateException|InvalidFormatException $e) {// don't care- Log::warning(sprintf('Ignored invalid date "%s" in API v2 controller parameter check: %s', $date, $e->getMessage()));+ app('log')->warning(sprintf('Ignored invalid date "%s" in API v2 controller parameter check: %s', $date, $e->getMessage()));}}$bag->set($field, $obj);diff --git a/app/Console/Commands/Correction/CorrectOpeningBalanceCurrencies.php b/app/Console/Commands/Correction/CorrectOpeningBalanceCurrencies.phpindex 2867048078..1d0fa1e0aa 100644--- a/app/Console/Commands/Correction/CorrectOpeningBalanceCurrencies.php+++ b/app/Console/Commands/Correction/CorrectOpeningBalanceCurrencies.php@@ -101,7 +101,7 @@ class CorrectOpeningBalanceCurrencies extends Command$account = $this->getAccount($journal);if (null === $account) {$message = sprintf('Transaction journal #%d has no valid account. Cant fix this line.', $journal->id);- Log::warning($message);+ app('log')->warning($message);$this->warn($message);return 0;diff --git a/app/Console/Commands/Correction/FixUnevenAmount.php b/app/Console/Commands/Correction/FixUnevenAmount.phpindex fa3dbc5fdd..3abf92c9a5 100644--- a/app/Console/Commands/Correction/FixUnevenAmount.php+++ b/app/Console/Commands/Correction/FixUnevenAmount.php@@ -68,7 +68,7 @@ class FixUnevenAmount extends Commandif (0 !== bccomp((string)$entry->the_sum, '0')) {$message = sprintf('Sum of journal #%d is %s instead of zero.', $entry->transaction_journal_id, $entry->the_sum);$this->warn($message);- Log::warning($message);+ app('log')->warning($message);$this->fixJournal((int)$entry->transaction_journal_id);$count++;}diff --git a/app/Console/Commands/DecryptDatabase.php b/app/Console/Commands/DecryptDatabase.phpindex 8b2e10e32d..f0c82a920d 100644--- a/app/Console/Commands/DecryptDatabase.php+++ b/app/Console/Commands/DecryptDatabase.php@@ -211,9 +211,9 @@ class DecryptDatabase extends Command} catch (JsonException $e) {$message = sprintf('Could not JSON decode preference row #%d: %s. This does not have to be a problem.', $id, $e->getMessage());$this->error($message);- Log::warning($message);- Log::warning($value);- Log::warning($e->getTraceAsString());+ app('log')->warning($message);+ app('log')->warning($value);+ app('log')->warning($e->getTraceAsString());return;}diff --git a/app/Console/Commands/Integrity/RestoreOAuthKeys.php b/app/Console/Commands/Integrity/RestoreOAuthKeys.phpindex 3e50f177e3..29104ed079 100644--- a/app/Console/Commands/Integrity/RestoreOAuthKeys.php+++ b/app/Console/Commands/Integrity/RestoreOAuthKeys.php@@ -80,7 +80,7 @@ class RestoreOAuthKeys extends Commandreturn;}- Log::warning('Could not restore keys. Will create new ones.');+ app('log')->warning('Could not restore keys. Will create new ones.');$this->generateKeys();$this->storeKeysInDB();$this->line('Generated and stored new keys.');diff --git a/app/Console/Commands/Upgrade/AppendBudgetLimitPeriods.php b/app/Console/Commands/Upgrade/AppendBudgetLimitPeriods.phpindex 224bfdab3a..32d1f735f5 100644--- a/app/Console/Commands/Upgrade/AppendBudgetLimitPeriods.php+++ b/app/Console/Commands/Upgrade/AppendBudgetLimitPeriods.php@@ -111,7 +111,7 @@ class AppendBudgetLimitPeriods extends Command$limit->end_date->format('Y-m-d'));$this->warn($message);- Log::warning($message);+ app('log')->warning($message);return;}diff --git a/app/Exceptions/GracefulNotFoundHandler.php b/app/Exceptions/GracefulNotFoundHandler.phpindex 126d565d69..ae773d7b7a 100644--- a/app/Exceptions/GracefulNotFoundHandler.php+++ b/app/Exceptions/GracefulNotFoundHandler.php@@ -67,7 +67,7 @@ class GracefulNotFoundHandler extends ExceptionHandlerswitch ($name) {default:- Log::warning(sprintf('GracefulNotFoundHandler cannot handle route with name "%s"', $name));+ app('log')->warning(sprintf('GracefulNotFoundHandler cannot handle route with name "%s"', $name));return parent::render($request, $e);case 'accounts.show':diff --git a/app/Factory/AccountFactory.php b/app/Factory/AccountFactory.phpindex f547ab4afd..dd8dc16357 100644--- a/app/Factory/AccountFactory.php+++ b/app/Factory/AccountFactory.php@@ -158,7 +158,7 @@ class AccountFactory}}if (null === $result) {- Log::warning(sprintf('Found NO account type based on %d and "%s"', $accountTypeId, $accountTypeName));+ app('log')->warning(sprintf('Found NO account type based on %d and "%s"', $accountTypeId, $accountTypeName));throw new FireflyException(sprintf('AccountFactory::create() was unable to find account type #%d ("%s").', $accountTypeId, $accountTypeName));}Log::debug(sprintf('Found account type based on %d and "%s": "%s"', $accountTypeId, $accountTypeName, $result->type));diff --git a/app/Factory/TransactionCurrencyFactory.php b/app/Factory/TransactionCurrencyFactory.phpindex 30c87b92fd..414b9c62ca 100644--- a/app/Factory/TransactionCurrencyFactory.php+++ b/app/Factory/TransactionCurrencyFactory.php@@ -47,7 +47,7 @@ class TransactionCurrencyFactoryif (1 === $count) {$old = TransactionCurrency::withTrashed()->whereCode($data['code'])->first();$old->forceDelete();- Log::warning(sprintf('Force deleted old currency with ID #%d and code "%s".', $old->id, $data['code']));+ app('log')->warning(sprintf('Force deleted old currency with ID #%d and code "%s".', $old->id, $data['code']));}try {@@ -93,7 +93,7 @@ class TransactionCurrencyFactoryif (null !== $currency) {return $currency;}- Log::warning(sprintf('Currency ID is %d but found nothing!', $currencyId));+ app('log')->warning(sprintf('Currency ID is %d but found nothing!', $currencyId));}// then by code:if ('' !== $currencyCode) {@@ -101,9 +101,9 @@ class TransactionCurrencyFactoryif (null !== $currency) {return $currency;}- Log::warning(sprintf('Currency code is %d but found nothing!', $currencyCode));+ app('log')->warning(sprintf('Currency code is %d but found nothing!', $currencyCode));}- Log::warning('Found nothing for currency.');+ app('log')->warning('Found nothing for currency.');return null;}diff --git a/app/Factory/TransactionGroupFactory.php b/app/Factory/TransactionGroupFactory.phpindex 75790d36cf..93996e735a 100644--- a/app/Factory/TransactionGroupFactory.php+++ b/app/Factory/TransactionGroupFactory.php@@ -65,7 +65,7 @@ class TransactionGroupFactorytry {$collection = $this->journalFactory->create($data);} catch (DuplicateTransactionException $e) {- Log::warning('GroupFactory::create() caught journalFactory::create() with a duplicate!');+ app('log')->warning('GroupFactory::create() caught journalFactory::create() with a duplicate!');throw new DuplicateTransactionException($e->getMessage(), 0, $e);}$title = $data['group_title'] ?? null;diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.phpindex b77a646249..d78ee5fc62 100644--- a/app/Factory/TransactionJournalFactory.php+++ b/app/Factory/TransactionJournalFactory.php@@ -126,13 +126,13 @@ class TransactionJournalFactory}}} catch (DuplicateTransactionException $e) {- Log::warning('TransactionJournalFactory::create() caught a duplicate journal in createJournal()');+ app('log')->warning('TransactionJournalFactory::create() caught a duplicate journal in createJournal()');Log::error($e->getMessage());Log::error($e->getTraceAsString());$this->forceDeleteOnError($collection);throw new DuplicateTransactionException($e->getMessage(), 0, $e);} catch (FireflyException $e) {- Log::warning('TransactionJournalFactory::create() caught an exception.');+ app('log')->warning('TransactionJournalFactory::create() caught an exception.');Log::error($e->getMessage());Log::error($e->getTraceAsString());$this->forceDeleteOnError($collection);@@ -267,7 +267,7 @@ class TransactionJournalFactoryLog::error('Exception creating positive transaction.');Log::error($e->getMessage());Log::error($e->getTraceAsString());- Log::warning('Delete negative transaction.');+ app('log')->warning('Delete negative transaction.');$this->forceTrDelete($negative);$this->forceDeleteOnError(new Collection([$journal]));throw new FireflyException($e->getMessage(), 0, $e);@@ -345,7 +345,7 @@ class TransactionJournalFactory->first();}if (null !== $result) {- Log::warning(sprintf('Found a duplicate in errorIfDuplicate because hash %s is not unique!', $hash));+ app('log')->warning(sprintf('Found a duplicate in errorIfDuplicate because hash %s is not unique!', $hash));$journal = $result->transactionJournal()->withTrashed()->first();$group = $journal?->transactionGroup()->withTrashed()->first();$groupId = $group?->id;diff --git a/app/Handlers/Events/UpdatedGroupEventHandler.php b/app/Handlers/Events/UpdatedGroupEventHandler.phpindex f8cd1e16a6..320bc76fc1 100644--- a/app/Handlers/Events/UpdatedGroupEventHandler.php+++ b/app/Handlers/Events/UpdatedGroupEventHandler.php@@ -134,7 +134,7 @@ class UpdatedGroupEventHandler->first();if (null === $first) {- Log::warning(sprintf('Group #%d has no transaction journals.', $group->id));+ app('log')->warning(sprintf('Group #%d has no transaction journals.', $group->id));return;}diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.phpindex 4a92da436c..1f4b64cfcf 100644--- a/app/Http/Controllers/Auth/LoginController.php+++ b/app/Http/Controllers/Auth/LoginController.php@@ -117,7 +117,7 @@ class LoginController extends Controllerreturn $this->sendLoginResponse($request);}- Log::warning('Login attempt failed.');+ app('log')->warning('Login attempt failed.');/** Copied directly from AuthenticatesUsers, but with logging added: */// If the login attempt was unsuccessful we will increment the number of attemptsdiff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.phpindex c5dceb0820..cb01d5040a 100644--- a/app/Http/Controllers/DebugController.php+++ b/app/Http/Controllers/DebugController.php@@ -70,7 +70,7 @@ class DebugController extends ControllerLog::debug('This is a test message at the DEBUG level.');Log::info('This is a test message at the INFO level.');Log::notice('This is a test message at the NOTICE level.');- Log::warning('This is a test message at the WARNING level.');+ app('log')->warning('This is a test message at the WARNING level.');Log::error('This is a test message at the ERROR level.');Log::critical('This is a test message at the CRITICAL level.');Log::alert('This is a test message at the ALERT level.');diff --git a/app/Http/Middleware/Installer.php b/app/Http/Middleware/Installer.phpindex a8edae08ae..fdfe1a723a 100644--- a/app/Http/Middleware/Installer.php+++ b/app/Http/Middleware/Installer.php@@ -103,7 +103,7 @@ class Installer}if ($this->noTablesExist($message)) {// redirect to UpdateController- Log::warning('There are no Firefly III tables present. Redirect to migrate routine.');+ app('log')->warning('There are no Firefly III tables present. Redirect to migrate routine.');return true;}@@ -150,7 +150,7 @@ class Installer$configVersion = (int) config('firefly.db_version');$dbVersion = (int) app('fireflyconfig')->getFresh('db_version', 1)->data;if ($configVersion > $dbVersion) {- Log::warning(+ app('log')->warning(sprintf('The current configured version (%d) is older than the required version (%d). Redirect to migrate routine.',$dbVersion,@@ -177,7 +177,7 @@ class Installer$configVersion = (string) config('firefly.version');$dbVersion = (string) app('fireflyconfig')->getFresh('ff3_version', '1.0')->data;if (1 === version_compare($configVersion, $dbVersion)) {- Log::warning(+ app('log')->warning(sprintf('The current configured Firefly III version (%s) is older than the required version (%s). Redirect to migrate routine.',$dbVersion,diff --git a/app/Jobs/CreateRecurringTransactions.php b/app/Jobs/CreateRecurringTransactions.phpindex 81732cbb01..d66eee36d9 100644--- a/app/Jobs/CreateRecurringTransactions.php+++ b/app/Jobs/CreateRecurringTransactions.php@@ -377,7 +377,7 @@ class CreateRecurringTransactions implements ShouldQueue}if ($journalCount > 0 && true === $this->force) {- Log::warning(sprintf('Already created %d groups for date %s but FORCED to continue.', $journalCount, $date->format('Y-m-d')));+ app('log')->warning(sprintf('Already created %d groups for date %s but FORCED to continue.', $journalCount, $date->format('Y-m-d')));}// create transaction array and send to factory.diff --git a/app/Jobs/DownloadExchangeRates.php b/app/Jobs/DownloadExchangeRates.phpindex 64943c2ec5..98e8f74260 100644--- a/app/Jobs/DownloadExchangeRates.php+++ b/app/Jobs/DownloadExchangeRates.php@@ -114,13 +114,13 @@ class DownloadExchangeRates implements ShouldQueue$res = $client->get($url);$statusCode = $res->getStatusCode();if (200 !== $statusCode) {- Log::warning(sprintf('Trying to grab "%s" resulted in status code %d.', $url, $statusCode));+ app('log')->warning(sprintf('Trying to grab "%s" resulted in status code %d.', $url, $statusCode));return;}$body = (string) $res->getBody();$json = json_decode($body, true);if (false === $json || null === $json) {- Log::warning(sprintf('Trying to grab "%s" resulted in bad JSON.', $url));+ app('log')->warning(sprintf('Trying to grab "%s" resulted in bad JSON.', $url));return;}$date = Carbon::createFromFormat('Y-m-d', $json['date']);diff --git a/app/Models/Recurrence.php b/app/Models/Recurrence.phpindex c2c5f61e5c..0df6d7bbd3 100644--- a/app/Models/Recurrence.php+++ b/app/Models/Recurrence.php@@ -153,7 +153,7 @@ class Recurrence extends Model/*** @codeCoverageIgnore- * Get all of the notes.+ * Get all the notes.*/public function notes(): MorphMany{diff --git a/app/Repositories/TransactionGroup/TransactionGroupRepository.php b/app/Repositories/TransactionGroup/TransactionGroupRepository.phpindex 1eea5c9b20..d48696838c 100644--- a/app/Repositories/TransactionGroup/TransactionGroupRepository.php+++ b/app/Repositories/TransactionGroup/TransactionGroupRepository.php@@ -471,10 +471,10 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterfacetry {return $factory->create($data);} catch (DuplicateTransactionException $e) {- Log::warning('Group repository caught group factory with a duplicate exception!');+ app('log')->warning('Group repository caught group factory with a duplicate exception!');throw new DuplicateTransactionException($e->getMessage(), 0, $e);} catch (FireflyException $e) {- Log::warning('Group repository caught group factory with an exception!');+ app('log')->warning('Group repository caught group factory with an exception!');Log::error($e->getMessage());Log::error($e->getTraceAsString());throw new FireflyException($e->getMessage(), 0, $e);diff --git a/app/Support/Binder/BudgetList.php b/app/Support/Binder/BudgetList.phpindex 97b240fcd1..a72a89ba42 100644--- a/app/Support/Binder/BudgetList.php+++ b/app/Support/Binder/BudgetList.php@@ -55,7 +55,7 @@ class BudgetList implements BinderInterfaceif (empty($list)) {- Log::warning('Budget list count is zero, return 404.');+ app('log')->warning('Budget list count is zero, return 404.');throw new NotFoundHttpException();}@@ -75,7 +75,7 @@ class BudgetList implements BinderInterfacereturn $collection;}}- Log::warning('BudgetList fallback to 404.');+ app('log')->warning('BudgetList fallback to 404.');throw new NotFoundHttpException();}}diff --git a/app/Support/Facades/Preferences.php b/app/Support/Facades/Preferences.phpindex 049ea2f34a..56d212193b 100644--- a/app/Support/Facades/Preferences.php+++ b/app/Support/Facades/Preferences.php@@ -47,7 +47,7 @@ class Preferences extends Facade{public function __construct(){- Log::warning('Hi there');+ app('log')->warning('Hi there');}/**diff --git a/app/Support/Http/Api/ConvertsExchangeRates.php b/app/Support/Http/Api/ConvertsExchangeRates.phpindex a3cd240fa1..ac022c6908 100644--- a/app/Support/Http/Api/ConvertsExchangeRates.php+++ b/app/Support/Http/Api/ConvertsExchangeRates.php@@ -222,7 +222,7 @@ trait ConvertsExchangeRatesLog::debug(sprintf('Find rate for %s to Euro', $currency->code));$euro = TransactionCurrency::whereCode('EUR')->first();if (null === $euro) {- Log::warning('Cannot do indirect conversion without EUR.');+ app('log')->warning('Cannot do indirect conversion without EUR.');return '0';}diff --git a/app/TransactionRules/Actions/UpdatePiggybank.php b/app/TransactionRules/Actions/UpdatePiggybank.phpindex f0987283d9..5eabedafbe 100644--- a/app/TransactionRules/Actions/UpdatePiggybank.php+++ b/app/TransactionRules/Actions/UpdatePiggybank.php@@ -146,14 +146,14 @@ class UpdatePiggybank implements ActionInterface// if amount is zero, stop.if (0 === bccomp('0', $amount)) {- Log::warning('Amount left is zero, stop.');+ app('log')->warning('Amount left is zero, stop.');return;}// make sure we can remove amount:if (false === $repository->canRemoveAmount($piggyBank, $amount)) {- Log::warning(sprintf('Cannot remove %s from piggy bank.', $amount));+ app('log')->warning(sprintf('Cannot remove %s from piggy bank.', $amount));return;}@@ -185,14 +185,14 @@ class UpdatePiggybank implements ActionInterface// if amount is zero, stop.if (0 === bccomp('0', $amount)) {- Log::warning('Amount left is zero, stop.');+ app('log')->warning('Amount left is zero, stop.');return;}// make sure we can add amount:if (false === $repository->canAddAmount($piggyBank, $amount)) {- Log::warning(sprintf('Cannot add %s to piggy bank.', $amount));+ app('log')->warning(sprintf('Cannot add %s to piggy bank.', $amount));return;}diff --git a/app/Validation/Account/ReconciliationValidation.php b/app/Validation/Account/ReconciliationValidation.phpindex 55b5ff89a9..6831a92648 100644--- a/app/Validation/Account/ReconciliationValidation.php+++ b/app/Validation/Account/ReconciliationValidation.php@@ -61,7 +61,7 @@ trait ReconciliationValidation$search = $this->findExistingAccount($validTypes, $array);if (null === $search) {$this->sourceError = (string) trans('validation.reconciliation_source_bad_data', ['id' => $accountId, 'name' => $accountName]);- Log::warning('Not a valid source. Cant find it.', $validTypes);+ app('log')->warning('Not a valid source. Cant find it.', $validTypes);return false;}@@ -98,7 +98,7 @@ trait ReconciliationValidation$search = $this->findExistingAccount($validTypes, $array);if (null === $search) {$this->sourceError = (string) trans('validation.reconciliation_source_bad_data', ['id' => $accountId, 'name' => $accountName]);- Log::warning('Not a valid source. Cant find it.', $validTypes);+ app('log')->warning('Not a valid source. Cant find it.', $validTypes);return false;}diff --git a/app/Validation/Account/TransferValidation.php b/app/Validation/Account/TransferValidation.phpindex 06e49a8665..0c186dcb5a 100644--- a/app/Validation/Account/TransferValidation.php+++ b/app/Validation/Account/TransferValidation.php@@ -103,7 +103,7 @@ trait TransferValidation// if both values are NULL we return false,// because the source of a withdrawal can't be created.$this->sourceError = (string) trans('validation.transfer_source_need_data');- Log::warning('Not a valid source, need more data.');+ app('log')->warning('Not a valid source, need more data.');return false;}@@ -112,7 +112,7 @@ trait TransferValidation$search = $this->findExistingAccount($validTypes, $array);if (null === $search) {$this->sourceError = (string) trans('validation.transfer_source_bad_data', ['id' => $accountId, 'name' => $accountName]);- Log::warning('Not a valid source, cant find it.', $validTypes);+ app('log')->warning('Not a valid source, cant find it.', $validTypes);return false;}diff --git a/app/Validation/Account/WithdrawalValidation.php b/app/Validation/Account/WithdrawalValidation.phpindex 5200b16e7c..de11ac8cf3 100644--- a/app/Validation/Account/WithdrawalValidation.php+++ b/app/Validation/Account/WithdrawalValidation.php@@ -63,7 +63,7 @@ trait WithdrawalValidation// if both values are NULL we return TRUE// because we assume the user doesnt want to submit / change anything.$this->sourceError = (string) trans('validation.withdrawal_source_need_data');- Log::warning('[a] Not a valid source. Need more data.');+ app('log')->warning('[a] Not a valid source. Need more data.');return false;}@@ -72,7 +72,7 @@ trait WithdrawalValidation$search = $this->findExistingAccount($validTypes, $array);if (null === $search) {$this->sourceError = (string) trans('validation.withdrawal_source_bad_data', ['id' => $accountId, 'name' => $accountName]);- Log::warning('Not a valid source. Cant find it.', $validTypes);+ app('log')->warning('Not a valid source. Cant find it.', $validTypes);return false;}@@ -137,7 +137,7 @@ trait WithdrawalValidation// if both values are NULL we return false,// because the source of a withdrawal can't be created.$this->sourceError = (string) trans('validation.withdrawal_source_need_data');- Log::warning('[b] Not a valid source. Need more data.');+ app('log')->warning('[b] Not a valid source. Need more data.');return false;}@@ -146,7 +146,7 @@ trait WithdrawalValidation$search = $this->findExistingAccount($validTypes, $array);if (null === $search) {$this->sourceError = (string) trans('validation.withdrawal_source_bad_data', ['id' => $accountId, 'name' => $accountName]);- Log::warning('Not a valid source. Cant find it.', $validTypes);+ app('log')->warning('Not a valid source. Cant find it.', $validTypes);return false;}diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.phpindex 45af8719e7..d075158734 100644--- a/app/Validation/FireflyValidator.php+++ b/app/Validation/FireflyValidator.php@@ -609,7 +609,7 @@ class FireflyValidator extends Validator}$type = $this->data['objectType'] ?? 'unknown';if ('expense' !== $type && 'revenue' !== $type) {- Log::warning(sprintf('Account number "%s" is not unique and account type "%s" cannot share its account number.', $value, $type));+ app('log')->warning(sprintf('Account number "%s" is not unique and account type "%s" cannot share its account number.', $value, $type));return false;}Log::debug(sprintf('Account number "%s" is not unique but account type "%s" may share its account number.', $value, $type));diff --git a/app/Validation/GroupValidation.php b/app/Validation/GroupValidation.phpindex 7ae55d6c6a..c7b63bbcff 100644--- a/app/Validation/GroupValidation.php+++ b/app/Validation/GroupValidation.php@@ -167,8 +167,8 @@ trait GroupValidation}$count = $transactionGroup->transactionJournals()->where('transaction_journals.id', $journalId)->count();if (null === $journalId || 0 === $count) {- Log::warning(sprintf('Transaction group #%d has %d journals with ID %d', $transactionGroup->id, $count, $journalId));- Log::warning('Invalid submission: Each split must have transaction_journal_id (either valid ID or 0).');+ app('log')->warning(sprintf('Transaction group #%d has %d journals with ID %d', $transactionGroup->id, $count, $journalId));+ app('log')->warning('Invalid submission: Each split must have transaction_journal_id (either valid ID or 0).');$validator->errors()->add(sprintf('transactions.%d.source_name', $index), (string) trans('validation.need_id_in_edit'));}}diff --git a/app/Validation/RecurrenceValidation.php b/app/Validation/RecurrenceValidation.phpindex cc359e592e..c0166a8c31 100644--- a/app/Validation/RecurrenceValidation.php+++ b/app/Validation/RecurrenceValidation.php@@ -66,7 +66,7 @@ trait RecurrenceValidationLog::debug(sprintf('Determined type to be %s.', $transactionType));}if (null === $first) {- Log::warning('Just going to assume type is a withdrawal.');+ app('log')->warning('Just going to assume type is a withdrawal.');$transactionType = 'withdrawal';}}diff --git a/app/Validation/TransactionValidation.php b/app/Validation/TransactionValidation.phpindex 407e66dbde..8ee4d110da 100644--- a/app/Validation/TransactionValidation.php+++ b/app/Validation/TransactionValidation.php@@ -230,7 +230,7 @@ trait TransactionValidation// do something with result:if (false === $validSource) {- Log::warning('Looks like the source account is not valid so complain to the user about it.');+ app('log')->warning('Looks like the source account is not valid so complain to the user about it.');$validator->errors()->add(sprintf('transactions.%d.source_id', $index), $accountValidator->sourceError);$validator->errors()->add(sprintf('transactions.%d.source_name', $index), $accountValidator->sourceError);@@ -258,7 +258,7 @@ trait TransactionValidation$validDestination = $accountValidator->validateDestination($array);// do something with result:if (false === $validDestination) {- Log::warning('Looks like the destination account is not valid so complain to the user about it.');+ app('log')->warning('Looks like the destination account is not valid so complain to the user about it.');$validator->errors()->add(sprintf('transactions.%d.destination_id', $index), $accountValidator->destError);$validator->errors()->add(sprintf('transactions.%d.destination_name', $index), $accountValidator->destError);}@@ -395,7 +395,7 @@ trait TransactionValidation}$unique = array_unique($types);if (count($unique) > 1) {- Log::warning('Add error for mismatch transaction types.');+ app('log')->warning('Add error for mismatch transaction types.');$validator->errors()->add('transactions.0.type', (string) trans('validation.transaction_types_equal'));return;@@ -498,7 +498,7 @@ trait TransactionValidation$validator->errors()->add('transactions.0.source_id', (string) trans('validation.all_accounts_equal'));$validator->errors()->add('transactions.0.destination_id', (string) trans('validation.all_accounts_equal'));}- Log::warning('Add error about equal accounts.');+ app('log')->warning('Add error about equal accounts.');return;}