Replace phpstan suggestions

This commit is contained in:
James Cole 2022-10-30 14:44:49 +01:00
parent c032ffd4f9
commit 33f370359c
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
45 changed files with 99 additions and 87 deletions

View File

@ -103,7 +103,7 @@ abstract class Controller extends BaseController
$obj = Carbon::parse($date); $obj = Carbon::parse($date);
} catch (InvalidDateException | InvalidFormatException $e) { } catch (InvalidDateException | InvalidFormatException $e) {
// don't care // 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); $bag->set($field, $obj);

View File

@ -93,14 +93,14 @@ class StoreController extends Controller
try { try {
$transactionGroup = $this->groupRepository->store($data); $transactionGroup = $this->groupRepository->store($data);
} catch (DuplicateTransactionException $e) { } 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( $validator = Validator::make(
['transactions' => [['description' => $e->getMessage()]]], ['transactions' => [['description' => $e->getMessage()]]],
['transactions.0.description' => new IsDuplicateTransaction()] ['transactions.0.description' => new IsDuplicateTransaction()]
); );
throw new ValidationException($validator, 0, $e); throw new ValidationException($validator, 0, $e);
} catch (FireflyException $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()); Log::error($e->getMessage());
$message = sprintf('Internal exception: %s', $e->getMessage()); $message = sprintf('Internal exception: %s', $e->getMessage());
$validator = Validator::make(['transactions' => [['description' => $message]]], ['transactions.0.description' => new IsDuplicateTransaction()]); $validator = Validator::make(['transactions' => [['description' => $message]]], ['transactions.0.description' => new IsDuplicateTransaction()]);

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\Bill; namespace FireflyIII\Api\V1\Requests\Models\Bill;
use FireflyIII\Models\Bill;
use FireflyIII\Rules\IsBoolean; use FireflyIII\Rules\IsBoolean;
use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\ConvertsDataTypes;
@ -75,6 +76,7 @@ class UpdateRequest extends FormRequest
*/ */
public function rules(): array public function rules(): array
{ {
/** @var Bill $bill */
$bill = $this->route()->parameter('bill'); $bill = $this->route()->parameter('bill');
return [ return [

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\Budget; namespace FireflyIII\Api\V1\Requests\Models\Budget;
use FireflyIII\Models\Budget;
use FireflyIII\Rules\IsBoolean; use FireflyIII\Rules\IsBoolean;
use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\ConvertsDataTypes;
@ -80,6 +81,7 @@ class UpdateRequest extends FormRequest
*/ */
public function rules(): array public function rules(): array
{ {
/** @var Budget $budget */
$budget = $this->route()->parameter('budget'); $budget = $this->route()->parameter('budget');
return [ return [

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\Category; namespace FireflyIII\Api\V1\Requests\Models\Category;
use FireflyIII\Models\Category;
use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
@ -59,6 +60,7 @@ class UpdateRequest extends FormRequest
*/ */
public function rules(): array public function rules(): array
{ {
/** @var Category $category */
$category = $this->route()->parameter('category'); $category = $this->route()->parameter('category');
return [ return [

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\ObjectGroup; namespace FireflyIII\Api\V1\Requests\Models\ObjectGroup;
use FireflyIII\Models\ObjectGroup;
use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
@ -58,6 +59,7 @@ class UpdateRequest extends FormRequest
*/ */
public function rules(): array public function rules(): array
{ {
/** @var ObjectGroup $objectGroup */
$objectGroup = $this->route()->parameter('objectGroup'); $objectGroup = $this->route()->parameter('objectGroup');
return [ return [

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\PiggyBank; namespace FireflyIII\Api\V1\Requests\Models\PiggyBank;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Rules\IsAssetAccountId; use FireflyIII\Rules\IsAssetAccountId;
use FireflyIII\Rules\LessThanPiggyTarget; use FireflyIII\Rules\LessThanPiggyTarget;
use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ChecksLogin;
@ -69,6 +70,7 @@ class UpdateRequest extends FormRequest
*/ */
public function rules(): array public function rules(): array
{ {
/** @var PiggyBank $piggyBank */
$piggyBank = $this->route()->parameter('piggyBank'); $piggyBank = $this->route()->parameter('piggyBank');
return [ return [

View File

@ -114,7 +114,7 @@ class UpdateRequest extends FormRequest
} }
$return[] = $current; $return[] = $current;
} }
if (empty($return)) { if (0 === count($return)) {
return null; return null;
} }

View File

@ -172,7 +172,7 @@ class StoreRequest extends FormRequest
$data = $validator->getData(); $data = $validator->getData();
$triggers = $data['triggers'] ?? []; $triggers = $data['triggers'] ?? [];
// need at least one trigger // 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')); $validator->errors()->add('title', (string) trans('validation.at_least_one_trigger'));
} }
} }
@ -187,7 +187,7 @@ class StoreRequest extends FormRequest
$data = $validator->getData(); $data = $validator->getData();
$actions = $data['actions'] ?? []; $actions = $data['actions'] ?? [];
// need at least one trigger // 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')); $validator->errors()->add('title', (string) trans('validation.at_least_one_action'));
} }
} }
@ -202,7 +202,7 @@ class StoreRequest extends FormRequest
$data = $validator->getData(); $data = $validator->getData();
$triggers = $data['triggers'] ?? []; $triggers = $data['triggers'] ?? [];
// need at least one trigger // need at least one trigger
if (!is_countable($triggers) || empty($triggers)) { if (!is_countable($triggers) || 0 === count($triggers)) {
return; return;
} }
$allInactive = true; $allInactive = true;
@ -231,7 +231,7 @@ class StoreRequest extends FormRequest
$data = $validator->getData(); $data = $validator->getData();
$actions = $data['actions'] ?? []; $actions = $data['actions'] ?? [];
// need at least one trigger // need at least one trigger
if (!is_countable($actions) || empty($actions)) { if (!is_countable($actions) || 0 === count($actions)) {
return; return;
} }
$allInactive = true; $allInactive = true;

View File

@ -187,7 +187,7 @@ class UpdateRequest extends FormRequest
$data = $validator->getData(); $data = $validator->getData();
$triggers = $data['triggers'] ?? null; $triggers = $data['triggers'] ?? null;
// need at least one trigger // 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')); $validator->errors()->add('title', (string) trans('validation.at_least_one_trigger'));
} }
} }
@ -204,7 +204,7 @@ class UpdateRequest extends FormRequest
$allInactive = true; $allInactive = true;
$inactiveIndex = 0; $inactiveIndex = 0;
// need at least one trigger // need at least one trigger
if (is_array($triggers) && empty($triggers)) { if (is_array($triggers) && 0 === count($triggers)) {
return; return;
} }
foreach ($triggers as $index => $trigger) { foreach ($triggers as $index => $trigger) {
@ -231,7 +231,7 @@ class UpdateRequest extends FormRequest
$data = $validator->getData(); $data = $validator->getData();
$actions = $data['actions'] ?? null; $actions = $data['actions'] ?? null;
// need at least one action // 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')); $validator->errors()->add('title', (string) trans('validation.at_least_one_action'));
} }
} }
@ -248,7 +248,7 @@ class UpdateRequest extends FormRequest
$allInactive = true; $allInactive = true;
$inactiveIndex = 0; $inactiveIndex = 0;
// need at least one action // need at least one action
if (is_array($actions) && empty($actions)) { if (is_array($actions) && 0 === count($actions)) {
return; return;
} }

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\RuleGroup; namespace FireflyIII\Api\V1\Requests\Models\RuleGroup;
use FireflyIII\Models\RuleGroup;
use FireflyIII\Rules\IsBoolean; use FireflyIII\Rules\IsBoolean;
use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\ConvertsDataTypes;
@ -62,6 +63,7 @@ class UpdateRequest extends FormRequest
*/ */
public function rules(): array public function rules(): array
{ {
/** @var RuleGroup $ruleGroup */
$ruleGroup = $this->route()->parameter('ruleGroup'); $ruleGroup = $this->route()->parameter('ruleGroup');
return [ return [

View File

@ -25,6 +25,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\Tag; namespace FireflyIII\Api\V1\Requests\Models\Tag;
use FireflyIII\Models\Location; use FireflyIII\Models\Location;
use FireflyIII\Models\Tag;
use FireflyIII\Support\Request\AppendsLocationData; use FireflyIII\Support\Request\AppendsLocationData;
use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\ConvertsDataTypes;
@ -66,6 +67,7 @@ class UpdateRequest extends FormRequest
*/ */
public function rules(): array public function rules(): array
{ {
/** @var Tag $tag */
$tag = $this->route()->parameter('tagOrId'); $tag = $this->route()->parameter('tagOrId');
// TODO check if uniqueObjectForUser is obsolete // TODO check if uniqueObjectForUser is obsolete
$rules = [ $rules = [

View File

@ -47,15 +47,12 @@ class UpdateRequest extends FormRequest
public function getAll(): array public function getAll(): array
{ {
$name = $this->route()->parameter('dynamicConfigKey'); $name = $this->route()->parameter('dynamicConfigKey');
switch ($name) {
default: if ($name === 'configuration.is_demo_site' || $name === 'configuration.single_user_mode') {
break; return ['value' => $this->boolean('value')];
case 'configuration.is_demo_site': }
case 'configuration.single_user_mode': if ($name === 'configuration.permission_update_check' || $name === 'configuration.last_update_check') {
return ['value' => $this->boolean('value')]; return ['value' => $this->convertInteger('value')];
case 'configuration.permission_update_check':
case 'configuration.last_update_check':
return ['value' => $this->convertInteger('value')];
} }
return ['value' => $this->convertString('value')]; return ['value' => $this->convertString('value')];
@ -69,16 +66,15 @@ class UpdateRequest extends FormRequest
public function rules(): array public function rules(): array
{ {
$name = $this->route()->parameter('configName'); $name = $this->route()->parameter('configName');
switch ($name) {
default: if ($name === 'configuration.is_demo_site' || $name === 'configuration.single_user_mode') {
break; return ['value' => ['required', new IsBoolean()]];
case 'configuration.is_demo_site': }
case 'configuration.single_user_mode': if ($name === 'configuration.permission_update_check') {
return ['value' => ['required', new IsBoolean()]]; return ['value' => 'required|numeric|between:-1,1'];
case 'configuration.permission_update_check': }
return ['value' => 'required|numeric|between:-1,1']; if ($name === 'configuration.last_update_check') {
case 'configuration.last_update_check': return ['value' => 'required|numeric|min:464272080'];
return ['value' => 'required|numeric|min:464272080'];
} }
return ['value' => 'required']; return ['value' => 'required'];

View File

@ -27,6 +27,7 @@ namespace FireflyIII\Api\V1\Requests\System;
use FireflyIII\Rules\IsBoolean; use FireflyIII\Rules\IsBoolean;
use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\ConvertsDataTypes;
use FireflyIII\User;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Validator; use Illuminate\Validation\Validator;
@ -75,6 +76,7 @@ class UserUpdateRequest extends FormRequest
*/ */
public function rules(): array public function rules(): array
{ {
/** @var User $user */
$user = $this->route()->parameter('user'); $user = $this->route()->parameter('user');
return [ return [

View File

@ -75,7 +75,7 @@ class AccountController extends Controller
$accounts = $this->repository->getAccountsById($frontPage->data); $accounts = $this->repository->getAccountsById($frontPage->data);
$chartData = []; $chartData = [];
if (empty($frontPage->data)) { if (!(is_array($frontPage->data) && count($frontPage->data) > 0)) {
$frontPage->data = $defaultSet; $frontPage->data = $defaultSet;
$frontPage->save(); $frontPage->save();
} }

View File

@ -142,7 +142,7 @@ class Controller extends BaseController
$obj = Carbon::parse($date); $obj = Carbon::parse($date);
} catch (InvalidDateException|InvalidFormatException $e) { } catch (InvalidDateException|InvalidFormatException $e) {
// don't care // 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); $bag->set($field, $obj);

View File

@ -101,7 +101,7 @@ class CorrectOpeningBalanceCurrencies extends Command
$account = $this->getAccount($journal); $account = $this->getAccount($journal);
if (null === $account) { if (null === $account) {
$message = sprintf('Transaction journal #%d has no valid account. Cant fix this line.', $journal->id); $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); $this->warn($message);
return 0; return 0;

View File

@ -68,7 +68,7 @@ class FixUnevenAmount extends Command
if (0 !== bccomp((string)$entry->the_sum, '0')) { if (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); $message = sprintf('Sum of journal #%d is %s instead of zero.', $entry->transaction_journal_id, $entry->the_sum);
$this->warn($message); $this->warn($message);
Log::warning($message); app('log')->warning($message);
$this->fixJournal((int)$entry->transaction_journal_id); $this->fixJournal((int)$entry->transaction_journal_id);
$count++; $count++;
} }

View File

@ -211,9 +211,9 @@ class DecryptDatabase extends Command
} catch (JsonException $e) { } catch (JsonException $e) {
$message = sprintf('Could not JSON decode preference row #%d: %s. This does not have to be a problem.', $id, $e->getMessage()); $message = sprintf('Could not JSON decode preference row #%d: %s. This does not have to be a problem.', $id, $e->getMessage());
$this->error($message); $this->error($message);
Log::warning($message); app('log')->warning($message);
Log::warning($value); app('log')->warning($value);
Log::warning($e->getTraceAsString()); app('log')->warning($e->getTraceAsString());
return; return;
} }

View File

@ -80,7 +80,7 @@ class RestoreOAuthKeys extends Command
return; return;
} }
Log::warning('Could not restore keys. Will create new ones.'); app('log')->warning('Could not restore keys. Will create new ones.');
$this->generateKeys(); $this->generateKeys();
$this->storeKeysInDB(); $this->storeKeysInDB();
$this->line('Generated and stored new keys.'); $this->line('Generated and stored new keys.');

View File

@ -111,7 +111,7 @@ class AppendBudgetLimitPeriods extends Command
$limit->end_date->format('Y-m-d') $limit->end_date->format('Y-m-d')
); );
$this->warn($message); $this->warn($message);
Log::warning($message); app('log')->warning($message);
return; return;
} }

View File

@ -67,7 +67,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
switch ($name) { switch ($name) {
default: 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); return parent::render($request, $e);
case 'accounts.show': case 'accounts.show':

View File

@ -158,7 +158,7 @@ class AccountFactory
} }
} }
if (null === $result) { 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)); 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)); Log::debug(sprintf('Found account type based on %d and "%s": "%s"', $accountTypeId, $accountTypeName, $result->type));

View File

@ -47,7 +47,7 @@ class TransactionCurrencyFactory
if (1 === $count) { if (1 === $count) {
$old = TransactionCurrency::withTrashed()->whereCode($data['code'])->first(); $old = TransactionCurrency::withTrashed()->whereCode($data['code'])->first();
$old->forceDelete(); $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 { try {
@ -93,7 +93,7 @@ class TransactionCurrencyFactory
if (null !== $currency) { if (null !== $currency) {
return $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: // then by code:
if ('' !== $currencyCode) { if ('' !== $currencyCode) {
@ -101,9 +101,9 @@ class TransactionCurrencyFactory
if (null !== $currency) { if (null !== $currency) {
return $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; return null;
} }

View File

@ -65,7 +65,7 @@ class TransactionGroupFactory
try { try {
$collection = $this->journalFactory->create($data); $collection = $this->journalFactory->create($data);
} catch (DuplicateTransactionException $e) { } 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); throw new DuplicateTransactionException($e->getMessage(), 0, $e);
} }
$title = $data['group_title'] ?? null; $title = $data['group_title'] ?? null;

View File

@ -126,13 +126,13 @@ class TransactionJournalFactory
} }
} }
} catch (DuplicateTransactionException $e) { } 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->getMessage());
Log::error($e->getTraceAsString()); Log::error($e->getTraceAsString());
$this->forceDeleteOnError($collection); $this->forceDeleteOnError($collection);
throw new DuplicateTransactionException($e->getMessage(), 0, $e); throw new DuplicateTransactionException($e->getMessage(), 0, $e);
} catch (FireflyException $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->getMessage());
Log::error($e->getTraceAsString()); Log::error($e->getTraceAsString());
$this->forceDeleteOnError($collection); $this->forceDeleteOnError($collection);
@ -267,7 +267,7 @@ class TransactionJournalFactory
Log::error('Exception creating positive transaction.'); Log::error('Exception creating positive transaction.');
Log::error($e->getMessage()); Log::error($e->getMessage());
Log::error($e->getTraceAsString()); Log::error($e->getTraceAsString());
Log::warning('Delete negative transaction.'); app('log')->warning('Delete negative transaction.');
$this->forceTrDelete($negative); $this->forceTrDelete($negative);
$this->forceDeleteOnError(new Collection([$journal])); $this->forceDeleteOnError(new Collection([$journal]));
throw new FireflyException($e->getMessage(), 0, $e); throw new FireflyException($e->getMessage(), 0, $e);
@ -345,7 +345,7 @@ class TransactionJournalFactory
->first(); ->first();
} }
if (null !== $result) { 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(); $journal = $result->transactionJournal()->withTrashed()->first();
$group = $journal?->transactionGroup()->withTrashed()->first(); $group = $journal?->transactionGroup()->withTrashed()->first();
$groupId = $group?->id; $groupId = $group?->id;

View File

@ -134,7 +134,7 @@ class UpdatedGroupEventHandler
->first(); ->first();
if (null === $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; return;
} }

View File

@ -117,7 +117,7 @@ class LoginController extends Controller
return $this->sendLoginResponse($request); return $this->sendLoginResponse($request);
} }
Log::warning('Login attempt failed.'); app('log')->warning('Login attempt failed.');
/** Copied directly from AuthenticatesUsers, but with logging added: */ /** Copied directly from AuthenticatesUsers, but with logging added: */
// If the login attempt was unsuccessful we will increment the number of attempts // If the login attempt was unsuccessful we will increment the number of attempts

View File

@ -70,7 +70,7 @@ class DebugController extends Controller
Log::debug('This is a test message at the DEBUG level.'); Log::debug('This is a test message at the DEBUG level.');
Log::info('This is a test message at the INFO level.'); Log::info('This is a test message at the INFO level.');
Log::notice('This is a test message at the NOTICE 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::error('This is a test message at the ERROR level.');
Log::critical('This is a test message at the CRITICAL level.'); Log::critical('This is a test message at the CRITICAL level.');
Log::alert('This is a test message at the ALERT level.'); Log::alert('This is a test message at the ALERT level.');

View File

@ -103,7 +103,7 @@ class Installer
} }
if ($this->noTablesExist($message)) { if ($this->noTablesExist($message)) {
// redirect to UpdateController // 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; return true;
} }
@ -150,7 +150,7 @@ class Installer
$configVersion = (int) config('firefly.db_version'); $configVersion = (int) config('firefly.db_version');
$dbVersion = (int) app('fireflyconfig')->getFresh('db_version', 1)->data; $dbVersion = (int) app('fireflyconfig')->getFresh('db_version', 1)->data;
if ($configVersion > $dbVersion) { if ($configVersion > $dbVersion) {
Log::warning( app('log')->warning(
sprintf( sprintf(
'The current configured version (%d) is older than the required version (%d). Redirect to migrate routine.', 'The current configured version (%d) is older than the required version (%d). Redirect to migrate routine.',
$dbVersion, $dbVersion,
@ -177,7 +177,7 @@ class Installer
$configVersion = (string) config('firefly.version'); $configVersion = (string) config('firefly.version');
$dbVersion = (string) app('fireflyconfig')->getFresh('ff3_version', '1.0')->data; $dbVersion = (string) app('fireflyconfig')->getFresh('ff3_version', '1.0')->data;
if (1 === version_compare($configVersion, $dbVersion)) { if (1 === version_compare($configVersion, $dbVersion)) {
Log::warning( app('log')->warning(
sprintf( sprintf(
'The current configured Firefly III version (%s) is older than the required version (%s). Redirect to migrate routine.', 'The current configured Firefly III version (%s) is older than the required version (%s). Redirect to migrate routine.',
$dbVersion, $dbVersion,

View File

@ -377,7 +377,7 @@ class CreateRecurringTransactions implements ShouldQueue
} }
if ($journalCount > 0 && true === $this->force) { 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. // create transaction array and send to factory.

View File

@ -114,13 +114,13 @@ class DownloadExchangeRates implements ShouldQueue
$res = $client->get($url); $res = $client->get($url);
$statusCode = $res->getStatusCode(); $statusCode = $res->getStatusCode();
if (200 !== $statusCode) { 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; return;
} }
$body = (string) $res->getBody(); $body = (string) $res->getBody();
$json = json_decode($body, true); $json = json_decode($body, true);
if (false === $json || null === $json) { 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; return;
} }
$date = Carbon::createFromFormat('Y-m-d', $json['date']); $date = Carbon::createFromFormat('Y-m-d', $json['date']);

View File

@ -153,7 +153,7 @@ class Recurrence extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* Get all of the notes. * Get all the notes.
*/ */
public function notes(): MorphMany public function notes(): MorphMany
{ {

View File

@ -471,10 +471,10 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
try { try {
return $factory->create($data); return $factory->create($data);
} catch (DuplicateTransactionException $e) { } 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); throw new DuplicateTransactionException($e->getMessage(), 0, $e);
} catch (FireflyException $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->getMessage());
Log::error($e->getTraceAsString()); Log::error($e->getTraceAsString());
throw new FireflyException($e->getMessage(), 0, $e); throw new FireflyException($e->getMessage(), 0, $e);

View File

@ -55,7 +55,7 @@ class BudgetList implements BinderInterface
if (empty($list)) { if (empty($list)) {
Log::warning('Budget list count is zero, return 404.'); app('log')->warning('Budget list count is zero, return 404.');
throw new NotFoundHttpException(); throw new NotFoundHttpException();
} }
@ -75,7 +75,7 @@ class BudgetList implements BinderInterface
return $collection; return $collection;
} }
} }
Log::warning('BudgetList fallback to 404.'); app('log')->warning('BudgetList fallback to 404.');
throw new NotFoundHttpException(); throw new NotFoundHttpException();
} }
} }

View File

@ -47,7 +47,7 @@ class Preferences extends Facade
{ {
public function __construct() public function __construct()
{ {
Log::warning('Hi there'); app('log')->warning('Hi there');
} }
/** /**

View File

@ -222,7 +222,7 @@ trait ConvertsExchangeRates
Log::debug(sprintf('Find rate for %s to Euro', $currency->code)); Log::debug(sprintf('Find rate for %s to Euro', $currency->code));
$euro = TransactionCurrency::whereCode('EUR')->first(); $euro = TransactionCurrency::whereCode('EUR')->first();
if (null === $euro) { if (null === $euro) {
Log::warning('Cannot do indirect conversion without EUR.'); app('log')->warning('Cannot do indirect conversion without EUR.');
return '0'; return '0';
} }

View File

@ -146,14 +146,14 @@ class UpdatePiggybank implements ActionInterface
// if amount is zero, stop. // if amount is zero, stop.
if (0 === bccomp('0', $amount)) { if (0 === bccomp('0', $amount)) {
Log::warning('Amount left is zero, stop.'); app('log')->warning('Amount left is zero, stop.');
return; return;
} }
// make sure we can remove amount: // make sure we can remove amount:
if (false === $repository->canRemoveAmount($piggyBank, $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; return;
} }
@ -185,14 +185,14 @@ class UpdatePiggybank implements ActionInterface
// if amount is zero, stop. // if amount is zero, stop.
if (0 === bccomp('0', $amount)) { if (0 === bccomp('0', $amount)) {
Log::warning('Amount left is zero, stop.'); app('log')->warning('Amount left is zero, stop.');
return; return;
} }
// make sure we can add amount: // make sure we can add amount:
if (false === $repository->canAddAmount($piggyBank, $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; return;
} }

View File

@ -61,7 +61,7 @@ trait ReconciliationValidation
$search = $this->findExistingAccount($validTypes, $array); $search = $this->findExistingAccount($validTypes, $array);
if (null === $search) { if (null === $search) {
$this->sourceError = (string) trans('validation.reconciliation_source_bad_data', ['id' => $accountId, 'name' => $accountName]); $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; return false;
} }
@ -98,7 +98,7 @@ trait ReconciliationValidation
$search = $this->findExistingAccount($validTypes, $array); $search = $this->findExistingAccount($validTypes, $array);
if (null === $search) { if (null === $search) {
$this->sourceError = (string) trans('validation.reconciliation_source_bad_data', ['id' => $accountId, 'name' => $accountName]); $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; return false;
} }

View File

@ -103,7 +103,7 @@ trait TransferValidation
// if both values are NULL we return false, // if both values are NULL we return false,
// because the source of a withdrawal can't be created. // because the source of a withdrawal can't be created.
$this->sourceError = (string) trans('validation.transfer_source_need_data'); $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; return false;
} }
@ -112,7 +112,7 @@ trait TransferValidation
$search = $this->findExistingAccount($validTypes, $array); $search = $this->findExistingAccount($validTypes, $array);
if (null === $search) { if (null === $search) {
$this->sourceError = (string) trans('validation.transfer_source_bad_data', ['id' => $accountId, 'name' => $accountName]); $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; return false;
} }

View File

@ -63,7 +63,7 @@ trait WithdrawalValidation
// if both values are NULL we return TRUE // if both values are NULL we return TRUE
// because we assume the user doesnt want to submit / change anything. // because we assume the user doesnt want to submit / change anything.
$this->sourceError = (string) trans('validation.withdrawal_source_need_data'); $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; return false;
} }
@ -72,7 +72,7 @@ trait WithdrawalValidation
$search = $this->findExistingAccount($validTypes, $array); $search = $this->findExistingAccount($validTypes, $array);
if (null === $search) { if (null === $search) {
$this->sourceError = (string) trans('validation.withdrawal_source_bad_data', ['id' => $accountId, 'name' => $accountName]); $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; return false;
} }
@ -137,7 +137,7 @@ trait WithdrawalValidation
// if both values are NULL we return false, // if both values are NULL we return false,
// because the source of a withdrawal can't be created. // because the source of a withdrawal can't be created.
$this->sourceError = (string) trans('validation.withdrawal_source_need_data'); $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; return false;
} }
@ -146,7 +146,7 @@ trait WithdrawalValidation
$search = $this->findExistingAccount($validTypes, $array); $search = $this->findExistingAccount($validTypes, $array);
if (null === $search) { if (null === $search) {
$this->sourceError = (string) trans('validation.withdrawal_source_bad_data', ['id' => $accountId, 'name' => $accountName]); $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; return false;
} }

View File

@ -609,7 +609,7 @@ class FireflyValidator extends Validator
} }
$type = $this->data['objectType'] ?? 'unknown'; $type = $this->data['objectType'] ?? 'unknown';
if ('expense' !== $type && 'revenue' !== $type) { 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; return false;
} }
Log::debug(sprintf('Account number "%s" is not unique but account type "%s" may share its account number.', $value, $type)); Log::debug(sprintf('Account number "%s" is not unique but account type "%s" may share its account number.', $value, $type));

View File

@ -167,8 +167,8 @@ trait GroupValidation
} }
$count = $transactionGroup->transactionJournals()->where('transaction_journals.id', $journalId)->count(); $count = $transactionGroup->transactionJournals()->where('transaction_journals.id', $journalId)->count();
if (null === $journalId || 0 === $count) { if (null === $journalId || 0 === $count) {
Log::warning(sprintf('Transaction group #%d has %d journals with ID %d', $transactionGroup->id, $count, $journalId)); app('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('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')); $validator->errors()->add(sprintf('transactions.%d.source_name', $index), (string) trans('validation.need_id_in_edit'));
} }
} }

View File

@ -66,7 +66,7 @@ trait RecurrenceValidation
Log::debug(sprintf('Determined type to be %s.', $transactionType)); Log::debug(sprintf('Determined type to be %s.', $transactionType));
} }
if (null === $first) { 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'; $transactionType = 'withdrawal';
} }
} }

View File

@ -230,7 +230,7 @@ trait TransactionValidation
// do something with result: // do something with result:
if (false === $validSource) { 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_id', $index), $accountValidator->sourceError);
$validator->errors()->add(sprintf('transactions.%d.source_name', $index), $accountValidator->sourceError); $validator->errors()->add(sprintf('transactions.%d.source_name', $index), $accountValidator->sourceError);
@ -258,7 +258,7 @@ trait TransactionValidation
$validDestination = $accountValidator->validateDestination($array); $validDestination = $accountValidator->validateDestination($array);
// do something with result: // do something with result:
if (false === $validDestination) { 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_id', $index), $accountValidator->destError);
$validator->errors()->add(sprintf('transactions.%d.destination_name', $index), $accountValidator->destError); $validator->errors()->add(sprintf('transactions.%d.destination_name', $index), $accountValidator->destError);
} }
@ -395,7 +395,7 @@ trait TransactionValidation
} }
$unique = array_unique($types); $unique = array_unique($types);
if (count($unique) > 1) { 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')); $validator->errors()->add('transactions.0.type', (string) trans('validation.transaction_types_equal'));
return; 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.source_id', (string) trans('validation.all_accounts_equal'));
$validator->errors()->add('transactions.0.destination_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; return;
} }