Reformat various code.

This commit is contained in:
James Cole
2022-03-29 14:59:58 +02:00
parent 29bed2547c
commit d1a09ff33b
115 changed files with 2700 additions and 2699 deletions

View File

@@ -46,7 +46,7 @@ class UpdateRequest implements UpdateRequestInterface
Log::debug(sprintf('Now in getUpdateInformation(%s)', $channel));
$information = [
'level' => 'error',
'message' => (string)trans('firefly.unknown_error'),
'message' => (string) trans('firefly.unknown_error'),
];
// try get array from update server:
@@ -76,7 +76,7 @@ class UpdateRequest implements UpdateRequestInterface
'version' => config('firefly.version'),
'date' => Carbon::today()->startOfDay(),
'level' => 'error',
'message' => (string)trans('firefly.unknown_error'),
'message' => (string) trans('firefly.unknown_error'),
];
$uri = config('firefly.update_endpoint');
@@ -101,12 +101,12 @@ class UpdateRequest implements UpdateRequestInterface
if (200 !== $res->getStatusCode()) {
Log::error(sprintf('Response status from server is %d.', $res->getStatusCode()));
Log::error((string)$res->getBody());
Log::error((string) $res->getBody());
$return['message'] = sprintf('Error: %d', $res->getStatusCode());
return $return;
}
$body = (string)$res->getBody();
$body = (string) $res->getBody();
try {
$json = json_decode($body, true, 512, JSON_THROW_ON_ERROR);
@@ -144,7 +144,7 @@ class UpdateRequest implements UpdateRequestInterface
Log::debug('Now in parseResult()', $information);
$return = [
'level' => 'error',
'message' => (string)trans('firefly.unknown_error'),
'message' => (string) trans('firefly.unknown_error'),
];
$current = config('firefly.version');
$latest = $information['version'];
@@ -155,7 +155,7 @@ class UpdateRequest implements UpdateRequestInterface
// -1: you're running a newer version:
if (-1 === $compare) {
$return['level'] = 'info';
$return['message'] = (string)trans('firefly.update_newer_version_alert', ['your_version' => $current, 'new_version' => $latest]);
$return['message'] = (string) trans('firefly.update_newer_version_alert', ['your_version' => $current, 'new_version' => $latest]);
Log::debug('User is running a newer version', $return);
return $return;
@@ -163,7 +163,7 @@ class UpdateRequest implements UpdateRequestInterface
// running the current version:
if (0 === $compare) {
$return['level'] = 'info';
$return['message'] = (string)trans('firefly.update_current_version_alert', ['version' => $current]);
$return['message'] = (string) trans('firefly.update_current_version_alert', ['version' => $current]);
Log::debug('User is the current version.', $return);
return $return;
@@ -177,10 +177,10 @@ class UpdateRequest implements UpdateRequestInterface
// it's still very fresh, and user wants a stable release:
if ($diff <= $expectedDiff) {
$return['level'] = 'info';
$return['message'] = (string)trans(
$return['message'] = (string) trans(
'firefly.just_new_release',
['version' => $latest,
'date' => $released->isoFormat((string)trans('config.month_and_day_js')),
'date' => $released->isoFormat((string) trans('config.month_and_day_js')),
'days' => $expectedDiff,
]
);
@@ -191,12 +191,12 @@ class UpdateRequest implements UpdateRequestInterface
// its been around for a while:
$return['level'] = 'success';
$return['message'] = (string)trans(
$return['message'] = (string) trans(
'firefly.update_new_version_alert',
[
'your_version' => $current,
'new_version' => $latest,
'date' => $released->isoFormat((string)trans('config.month_and_day_js'))]
'date' => $released->isoFormat((string) trans('config.month_and_day_js'))]
);
Log::debug('New release is old enough.');

View File

@@ -41,7 +41,7 @@ use stdClass;
class AccountDestroyService
{
/**
* @param Account $account
* @param Account $account
* @param Account|null $moveTo
*
* @return void
@@ -87,7 +87,7 @@ class AccountDestroyService
->where('transaction_types.type', TransactionType::OPENING_BALANCE)
->get(['transactions.transaction_journal_id']);
if ($set->count() > 0) {
$journalId = (int)$set->first()->transaction_journal_id;
$journalId = (int) $set->first()->transaction_journal_id;
Log::debug(sprintf('Found opening balance journal with ID #%d', $journalId));
// get transactions with this journal (should be just one):
@@ -133,8 +133,8 @@ class AccountDestroyService
$user = $account->user;
/** @var stdClass $row */
foreach ($collection as $row) {
if ((int)$row->the_count > 1) {
$journalId = (int)$row->transaction_journal_id;
if ((int) $row->the_count > 1) {
$journalId = (int) $row->transaction_journal_id;
$journal = $user->transactionJournals()->find($journalId);
if (null !== $journal) {
Log::debug(sprintf('Deleted journal #%d because it has the same source as destination.', $journal->id));
@@ -192,7 +192,7 @@ class AccountDestroyService
/** @var RecurrenceDestroyService $destroyService */
$destroyService = app(RecurrenceDestroyService::class);
foreach ($recurrences as $recurrenceId) {
$destroyService->destroyById((int)$recurrenceId);
$destroyService->destroyById((int) $recurrenceId);
}
}

View File

@@ -52,10 +52,10 @@ class BudgetDestroyService
}
// also delete all relations between categories and transaction journals:
DB::table('budget_transaction_journal')->where('budget_id', (int)$budget->id)->delete();
DB::table('budget_transaction_journal')->where('budget_id', (int) $budget->id)->delete();
// also delete all relations between categories and transactions:
DB::table('budget_transaction')->where('budget_id', (int)$budget->id)->delete();
DB::table('budget_transaction')->where('budget_id', (int) $budget->id)->delete();
// also delete all budget limits
$budget->budgetlimits()->delete();

View File

@@ -46,9 +46,9 @@ class CategoryDestroyService
}
// also delete all relations between categories and transaction journals:
DB::table('category_transaction_journal')->where('category_id', (int)$category->id)->delete();
DB::table('category_transaction_journal')->where('category_id', (int) $category->id)->delete();
// also delete all relations between categories and transactions:
DB::table('category_transaction')->where('category_id', (int)$category->id)->delete();
DB::table('category_transaction')->where('category_id', (int) $category->id)->delete();
}
}

View File

@@ -146,7 +146,7 @@ trait AccountServiceTrait
$data[$field] = 1;
}
$factory->crud($account, $field, (string)$data[$field]);
$factory->crud($account, $field, (string) $data[$field]);
}
}
}
@@ -192,7 +192,7 @@ trait AccountServiceTrait
*/
public function validOBData(array $data): bool
{
$data['opening_balance'] = (string)($data['opening_balance'] ?? '');
$data['opening_balance'] = (string) ($data['opening_balance'] ?? '');
if ('' !== $data['opening_balance'] && 0 === bccomp($data['opening_balance'], '0')) {
$data['opening_balance'] = '';
}
@@ -512,6 +512,63 @@ trait AccountServiceTrait
return $group;
}
/**
* See reference nr. 99
*
* @param TransactionGroup $group
*
* @return TransactionJournal
* @throws FireflyException
*/
private function getObJournal(TransactionGroup $group): TransactionJournal
{
/** @var TransactionJournal $journal */
$journal = $group->transactionJournals()->first();
if (null === $journal) {
throw new FireflyException(sprintf('Group #%d has no OB journal', $group->id));
}
return $journal;
}
/**
* See reference nr. 98
*
* @param TransactionJournal $journal
* @param Account $account
*
* @return Transaction
* @throws FireflyException
*/
private function getOBTransaction(TransactionJournal $journal, Account $account): Transaction
{
/** @var Transaction $transaction */
$transaction = $journal->transactions()->where('account_id', '!=', $account->id)->first();
if (null === $transaction) {
throw new FireflyException(sprintf('Could not get OB transaction for journal #%d', $journal->id));
}
return $transaction;
}
/**
* @param TransactionJournal $journal
* @param Account $account
*
* @return Transaction
* @throws FireflyException
*/
private function getNotOBTransaction(TransactionJournal $journal, Account $account): Transaction
{
/** @var Transaction $transaction */
$transaction = $journal->transactions()->where('account_id', $account->id)->first();
if (null === $transaction) {
throw new FireflyException(sprintf('Could not get non-OB transaction for journal #%d', $journal->id));
}
return $transaction;
}
/**
* Update or create the opening balance group.
* Since opening balance and date can still be empty strings, it may fail.
@@ -667,61 +724,4 @@ trait AccountServiceTrait
return $group;
}
/**
* See reference nr. 99
*
* @param TransactionGroup $group
*
* @return TransactionJournal
* @throws FireflyException
*/
private function getObJournal(TransactionGroup $group): TransactionJournal
{
/** @var TransactionJournal $journal */
$journal = $group->transactionJournals()->first();
if (null === $journal) {
throw new FireflyException(sprintf('Group #%d has no OB journal', $group->id));
}
return $journal;
}
/**
* See reference nr. 98
*
* @param TransactionJournal $journal
* @param Account $account
*
* @return Transaction
* @throws FireflyException
*/
private function getOBTransaction(TransactionJournal $journal, Account $account): Transaction
{
/** @var Transaction $transaction */
$transaction = $journal->transactions()->where('account_id', '!=', $account->id)->first();
if (null === $transaction) {
throw new FireflyException(sprintf('Could not get OB transaction for journal #%d', $journal->id));
}
return $transaction;
}
/**
* @param TransactionJournal $journal
* @param Account $account
*
* @return Transaction
* @throws FireflyException
*/
private function getNotOBTransaction(TransactionJournal $journal, Account $account): Transaction
{
/** @var Transaction $transaction */
$transaction = $journal->transactions()->where('account_id', $account->id)->first();
if (null === $transaction) {
throw new FireflyException(sprintf('Could not get non-OB transaction for journal #%d', $journal->id));
}
return $transaction;
}
}

View File

@@ -205,7 +205,7 @@ class CreditRecalculateService
$factory->crud($account, 'start_of_debt', $startOfDebt);
// get direction of liability:
$direction = (string)$this->repository->getMetaValue($account, 'liability_direction');
$direction = (string) $this->repository->getMetaValue($account, 'liability_direction');
// now loop all transactions (except opening balance and credit thing)
$transactions = $account->transactions()->get();
@@ -246,7 +246,7 @@ class CreditRecalculateService
// to a credit-liability doesn't increase the amount (yet)
if (
$type === TransactionType::WITHDRAWAL
&& (int)$account->id === (int)$transaction->account_id
&& (int) $account->id === (int) $transaction->account_id
&& 1 === bccomp($transaction->amount, '0')
&& 'credit' === $direction
) {
@@ -258,7 +258,7 @@ class CreditRecalculateService
// likewise deposit into a credit debt does not change the amount
if (
$type === TransactionType::DEPOSIT
&& (int)$account->id === (int)$transaction->account_id
&& (int) $account->id === (int) $transaction->account_id
&& -1 === bccomp($transaction->amount, '0')
&& 'credit' === $direction
) {

View File

@@ -98,7 +98,7 @@ trait JournalServiceTrait
$search = null;
// first attempt, find by ID.
if (null !== $data['id']) {
$search = $this->accountRepository->find((int)$data['id']);
$search = $this->accountRepository->find((int) $data['id']);
if (null !== $search && in_array($search->accountType->type, $types, true)) {
Log::debug(
sprintf('Found "account_id" object: #%d, "%s" of type %s', $search->id, $search->name, $search->accountType->type)
@@ -109,32 +109,6 @@ trait JournalServiceTrait
return $search;
}
/**
* @param Account|null $account
* @param array $data
* @param array $types
*
* @return Account|null
*/
private function findAccountByName(?Account $account, array $data, array $types): ?Account
{
// second attempt, find by name.
if (null === $account && null !== $data['name']) {
// find by preferred type.
$source = $this->accountRepository->findByName($data['name'], [$types[0]]);
// or any expected type.
$source = $source ?? $this->accountRepository->findByName($data['name'], $types);
if (null !== $source) {
Log::debug(sprintf('Found "account_name" object: #%d, %s', $source->id, $source->name));
$account = $source;
}
}
return $account;
}
/**
* @param Account|null $account
* @param array $data
@@ -175,10 +149,10 @@ trait JournalServiceTrait
if (null === $account && null !== $data['number'] && '' !== (string) $data['number']) {
Log::debug(sprintf('Searching for account number "%s".', $data['number']));
// find by preferred type.
$source = $this->accountRepository->findByAccountNumber((string)$data['number'], [$types[0]]);
$source = $this->accountRepository->findByAccountNumber((string) $data['number'], [$types[0]]);
// or any expected type.
$source = $source ?? $this->accountRepository->findByAccountNumber((string)$data['number'], $types);
$source = $source ?? $this->accountRepository->findByAccountNumber((string) $data['number'], $types);
if (null !== $source) {
Log::debug(sprintf('Found account: #%d, %s', $source->id, $source->name));
@@ -190,6 +164,32 @@ trait JournalServiceTrait
return $account;
}
/**
* @param Account|null $account
* @param array $data
* @param array $types
*
* @return Account|null
*/
private function findAccountByName(?Account $account, array $data, array $types): ?Account
{
// second attempt, find by name.
if (null === $account && null !== $data['name']) {
// find by preferred type.
$source = $this->accountRepository->findByName($data['name'], [$types[0]]);
// or any expected type.
$source = $source ?? $this->accountRepository->findByName($data['name'], $types);
if (null !== $source) {
Log::debug(sprintf('Found "account_name" object: #%d, %s', $source->id, $source->name));
$account = $source;
}
}
return $account;
}
/**
* @param Account|null $account
* @param array $data
@@ -218,12 +218,12 @@ trait JournalServiceTrait
throw new FireflyException(sprintf('TransactionFactory: Cannot create asset account with these values: %s', json_encode($data)));
}
// fix name of account if only IBAN is given:
if ('' === (string)$data['name'] && '' !== (string)$data['iban']) {
if ('' === (string) $data['name'] && '' !== (string) $data['iban']) {
Log::debug(sprintf('Account name is now IBAN ("%s")', $data['iban']));
$data['name'] = $data['iban'];
}
// fix name of account if only number is given:
if ('' === (string)$data['name'] && '' !== (string)$data['number']) {
if ('' === (string) $data['name'] && '' !== (string) $data['number']) {
Log::debug(sprintf('Account name is now account number ("%s")', $data['number']));
$data['name'] = $data['number'];
}
@@ -379,7 +379,7 @@ trait JournalServiceTrait
*/
protected function storeNotes(TransactionJournal $journal, ?string $notes): void
{
$notes = (string)$notes;
$notes = (string) $notes;
$note = $journal->notes()->first();
if ('' !== $notes) {
if (null === $note) {
@@ -422,7 +422,7 @@ trait JournalServiceTrait
}
Log::debug('Start of loop.');
foreach ($tags as $string) {
$string = (string)$string;
$string = (string) $string;
Log::debug(sprintf('Now at tag "%s"', $string));
if ('' !== $string) {
$tag = $this->tagFactory->findOrCreate($string);

View File

@@ -144,7 +144,7 @@ trait RecurringTransactionTrait
if (!$validator->validateDestination(['id' => $destination->id])) {
throw new FireflyException(sprintf('Destination invalid: %s', $validator->destError));
}
if (array_key_exists('foreign_amount', $array) && '' === (string)$array['foreign_amount']) {
if (array_key_exists('foreign_amount', $array) && '' === (string) $array['foreign_amount']) {
unset($array['foreign_amount']);
}
// See reference nr. 100
@@ -156,25 +156,25 @@ trait RecurringTransactionTrait
'source_id' => $source->id,
'destination_id' => $destination->id,
'amount' => $array['amount'],
'foreign_amount' => array_key_exists('foreign_amount', $array) ? (string)$array['foreign_amount'] : null,
'foreign_amount' => array_key_exists('foreign_amount', $array) ? (string) $array['foreign_amount'] : null,
'description' => $array['description'],
]
);
$transaction->save();
if (array_key_exists('budget_id', $array)) {
$this->setBudget($transaction, (int)$array['budget_id']);
$this->setBudget($transaction, (int) $array['budget_id']);
}
if (array_key_exists('bill_id', $array)) {
$this->setBill($transaction, (int)$array['bill_id']);
$this->setBill($transaction, (int) $array['bill_id']);
}
if (array_key_exists('category_id', $array)) {
$this->setCategory($transaction, (int)$array['category_id']);
$this->setCategory($transaction, (int) $array['category_id']);
}
// same for piggy bank
if (array_key_exists('piggy_bank_id', $array)) {
$this->updatePiggyBank($transaction, (int)$array['piggy_bank_id']);
$this->updatePiggyBank($transaction, (int) $array['piggy_bank_id']);
}
if (array_key_exists('tags', $array) && is_array($array['tags'])) {
@@ -194,14 +194,14 @@ trait RecurringTransactionTrait
protected function findAccount(array $expectedTypes, ?int $accountId, ?string $accountName): Account
{
$result = null;
$accountId = (int)$accountId;
$accountName = (string)$accountName;
$accountId = (int) $accountId;
$accountName = (string) $accountName;
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
$repository->setUser($this->user);
// if user has submitted an account ID, search for it.
$result = $repository->find((int)$accountId);
$result = $repository->find((int) $accountId);
if (null !== $result) {
return $result;
}

View File

@@ -89,7 +89,7 @@ class AccountUpdateService
// find currency, or use default currency instead.
if (array_key_exists('currency_id', $data) || array_key_exists('currency_code', $data)) {
$currency = $this->getCurrency((int)($data['currency_id'] ?? null), (string)($data['currency_code'] ?? null));
$currency = $this->getCurrency((int) ($data['currency_id'] ?? null), (string) ($data['currency_code'] ?? null));
unset($data['currency_code'], $data['currency_id']);
$data['currency_id'] = $currency->id;
}
@@ -108,7 +108,7 @@ class AccountUpdateService
// update note:
if (array_key_exists('notes', $data) && null !== $data['notes']) {
$this->updateNote($account, (string)$data['notes']);
$this->updateNote($account, (string) $data['notes']);
}
// update preferences if inactive:
@@ -135,7 +135,7 @@ class AccountUpdateService
$account->active = $data['active'];
}
if (array_key_exists('iban', $data)) {
$account->iban = app('steam')->filterSpaces((string)$data['iban']);
$account->iban = app('steam')->filterSpaces((string) $data['iban']);
}
// set liability, but account must already be a liability.
@@ -149,7 +149,7 @@ class AccountUpdateService
// set liability, alternative method used in v1 layout:
if ($this->isLiability($account) && array_key_exists('account_type_id', $data)) {
$type = AccountType::find((int)$data['account_type_id']);
$type = AccountType::find((int) $data['account_type_id']);
if (null !== $type && in_array($type->type, config('firefly.valid_liabilities'), true)) {
$account->account_type_id = $type->id;
@@ -210,7 +210,7 @@ class AccountUpdateService
return $account;
}
// get account type ID's because a join and an update is hard:
$oldOrder = (int)$account->order;
$oldOrder = (int) $account->order;
$newOrder = $data['order'];
Log::debug(sprintf('Order is set to be updated from %s to %s', $oldOrder, $newOrder));
$list = $this->getTypeIds([AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT]);
@@ -248,7 +248,7 @@ class AccountUpdateService
foreach ($array as $type) {
/** @var AccountType $type */
$type = AccountType::whereType($type)->first();
$return[] = (int)$type->id;
$return[] = (int) $type->id;
}
return $return;
@@ -357,12 +357,12 @@ class AccountUpdateService
$array = $preference->data;
Log::debug('Old array is: ', $array);
Log::debug(sprintf('Must remove : %d', $account->id));
$removeAccountId = (int)$account->id;
$removeAccountId = (int) $account->id;
$new = [];
foreach ($array as $value) {
if ((int)$value !== $removeAccountId) {
if ((int) $value !== $removeAccountId) {
Log::debug(sprintf('Will include: %d', $value));
$new[] = (int)$value;
$new[] = (int) $value;
}
}
Log::debug('Final new array is', $new);

View File

@@ -56,7 +56,7 @@ class BillUpdateService
if (array_key_exists('currency_id', $data) || array_key_exists('currency_code', $data)) {
$factory = app(TransactionCurrencyFactory::class);
$currency = $factory->find((int)($data['currency_id'] ?? null), $data['currency_code'] ?? null) ??
$currency = $factory->find((int) ($data['currency_id'] ?? null), $data['currency_code'] ?? null) ??
app('amount')->getDefaultCurrencyByUser($bill->user);
// enable the currency if it isn't.
@@ -78,14 +78,14 @@ class BillUpdateService
];
// update note:
if (array_key_exists('notes', $data)) {
$this->updateNote($bill, (string)$data['notes']);
$this->updateNote($bill, (string) $data['notes']);
}
// update order.
if (array_key_exists('order', $data)) {
// update the order of the piggy bank:
$oldOrder = (int)$bill->order;
$newOrder = (int)($data['order'] ?? $oldOrder);
$oldOrder = (int) $bill->order;
$newOrder = (int) ($data['order'] ?? $oldOrder);
if ($oldOrder !== $newOrder) {
$this->updateOrder($bill, $oldOrder, $newOrder);
}
@@ -117,7 +117,7 @@ class BillUpdateService
}
if (array_key_exists('object_group_id', $data)) {
// try also with ID:
$objectGroupId = (int)($data['object_group_id'] ?? 0);
$objectGroupId = (int) ($data['object_group_id'] ?? 0);
if (0 !== $objectGroupId) {
$objectGroup = $this->findObjectGroupById($objectGroupId);
if (null !== $objectGroup) {
@@ -144,20 +144,20 @@ class BillUpdateService
*/
private function updateBillProperties(Bill $bill, array $data): Bill
{
if (array_key_exists('name', $data) && '' !== (string)$data['name']) {
if (array_key_exists('name', $data) && '' !== (string) $data['name']) {
$bill->name = $data['name'];
}
if (array_key_exists('amount_min', $data) && '' !== (string)$data['amount_min']) {
if (array_key_exists('amount_min', $data) && '' !== (string) $data['amount_min']) {
$bill->amount_min = $data['amount_min'];
}
if (array_key_exists('amount_max', $data) && '' !== (string)$data['amount_max']) {
if (array_key_exists('amount_max', $data) && '' !== (string) $data['amount_max']) {
$bill->amount_max = $data['amount_max'];
}
if (array_key_exists('date', $data) && '' !== (string)$data['date']) {
if (array_key_exists('date', $data) && '' !== (string) $data['date']) {
$bill->date = $data['date'];
}
if (array_key_exists('repeat_freq', $data) && '' !== (string)$data['repeat_freq']) {
if (array_key_exists('repeat_freq', $data) && '' !== (string) $data['repeat_freq']) {
$bill->repeat_freq = $data['repeat_freq'];
}
if (array_key_exists('skip', $data)) {
@@ -166,10 +166,10 @@ class BillUpdateService
if (array_key_exists('active', $data)) {
$bill->active = $data['active'];
}
if(array_key_exists('end_date', $data)) {
if (array_key_exists('end_date', $data)) {
$bill->end_date = $data['end_date'];
}
if(array_key_exists('extension_date', $data)) {
if (array_key_exists('extension_date', $data)) {
$bill->extension_date = $data['extension_date'];
}

View File

@@ -40,15 +40,15 @@ class CurrencyUpdateService
*/
public function update(TransactionCurrency $currency, array $data): TransactionCurrency
{
if (array_key_exists('code', $data) && '' !== (string)$data['code']) {
if (array_key_exists('code', $data) && '' !== (string) $data['code']) {
$currency->code = $data['code'];
}
if (array_key_exists('symbol', $data) && '' !== (string)$data['symbol']) {
if (array_key_exists('symbol', $data) && '' !== (string) $data['symbol']) {
$currency->symbol = $data['symbol'];
}
if (array_key_exists('name', $data) && '' !== (string)$data['name']) {
if (array_key_exists('name', $data) && '' !== (string) $data['name']) {
$currency->name = $data['name'];
}

View File

@@ -48,7 +48,7 @@ class GroupCloneService
$newGroup = $group->replicate();
$newGroup->save();
foreach ($group->transactionJournals as $journal) {
$this->cloneJournal($journal, $newGroup, (int)$group->id);
$this->cloneJournal($journal, $newGroup, (int) $group->id);
}
return $newGroup;

View File

@@ -215,7 +215,7 @@ class JournalUpdateService
$validator->setTransactionType($expectedType);
$validator->setUser($this->transactionJournal->user);
$result = $validator->validateSource(['id' =>$sourceId]);
$result = $validator->validateSource(['id' => $sourceId]);
Log::debug(sprintf('hasValidSourceAccount(%d, "%s") will return %s', $sourceId, $sourceName, var_export($result, true)));
// See reference nr. 95
@@ -359,7 +359,7 @@ class JournalUpdateService
}
$sourceInfo = [
'id' => (int)($this->data['source_id'] ?? null),
'id' => (int) ($this->data['source_id'] ?? null),
'name' => $this->data['source_name'] ?? null,
'iban' => $this->data['source_iban'] ?? null,
'number' => $this->data['source_number'] ?? null,
@@ -424,7 +424,7 @@ class JournalUpdateService
}
$destInfo = [
'id' => (int)($this->data['destination_id'] ?? null),
'id' => (int) ($this->data['destination_id'] ?? null),
'name' => $this->data['destination_name'] ?? null,
'iban' => $this->data['destination_iban'] ?? null,
'number' => $this->data['destination_number'] ?? null,
@@ -487,8 +487,8 @@ class JournalUpdateService
)
&& TransactionType::WITHDRAWAL === $type
) {
$billId = (int)($this->data['bill_id'] ?? 0);
$billName = (string)($this->data['bill_name'] ?? '');
$billId = (int) ($this->data['bill_id'] ?? 0);
$billName = (string) ($this->data['bill_name'] ?? '');
$bill = $this->billRepository->findBill($billId, $billName);
$this->transactionJournal->bill_id = $bill?->id;
Log::debug('Updated bill ID');
@@ -502,7 +502,7 @@ class JournalUpdateService
*/
private function updateField(string $fieldName): void
{
if (array_key_exists($fieldName, $this->data) && '' !== (string)$this->data[$fieldName]) {
if (array_key_exists($fieldName, $this->data) && '' !== (string) $this->data[$fieldName]) {
$value = $this->data[$fieldName];
if ('date' === $fieldName) {
@@ -579,7 +579,7 @@ class JournalUpdateService
{
// update notes.
if ($this->hasFields(['notes'])) {
$notes = '' === (string)$this->data['notes'] ? null : $this->data['notes'];
$notes = '' === (string) $this->data['notes'] ? null : $this->data['notes'];
$this->storeNotes($this->transactionJournal, $notes);
}
}
@@ -636,7 +636,7 @@ class JournalUpdateService
foreach ($this->metaDate as $field) {
if ($this->hasFields([$field])) {
try {
$value = '' === (string)$this->data[$field] ? null : new Carbon($this->data[$field]);
$value = '' === (string) $this->data[$field] ? null : new Carbon($this->data[$field]);
} catch (Exception $e) { // @phpstan-ignore-line
Log::debug(sprintf('%s is not a valid date value: %s', $this->data[$field], $e->getMessage()));

View File

@@ -78,7 +78,7 @@ class RecurrenceUpdateService
$recurrence->repetitions = 0;
}
if (array_key_exists('nr_of_repetitions', $info)) {
if (0 !== (int)$info['nr_of_repetitions']) {
if (0 !== (int) $info['nr_of_repetitions']) {
$recurrence->repeat_until = null;
}
$recurrence->repetitions = $info['nr_of_repetitions'];
@@ -257,7 +257,7 @@ class RecurrenceUpdateService
unset($current['currency_id'], $current['currency_code']);
}
if (null !== $currency) {
$current['currency_id'] = (int)$currency->id;
$current['currency_id'] = (int) $currency->id;
}
if (array_key_exists('foreign_currency_id', $current) || array_key_exists('foreign_currency_code', $current)) {
$foreignCurrency = $currencyFactory->find($current['foreign_currency_id'] ?? null, $currency['foreign_currency_code'] ?? null);
@@ -266,7 +266,7 @@ class RecurrenceUpdateService
unset($current['foreign_currency_id'], $currency['foreign_currency_code']);
}
if (null !== $foreignCurrency) {
$current['foreign_currency_id'] = (int)$foreignCurrency->id;
$current['foreign_currency_id'] = (int) $foreignCurrency->id;
}
// update fields
@@ -287,27 +287,27 @@ class RecurrenceUpdateService
}
// update meta data
if (array_key_exists('budget_id', $current)) {
$this->setBudget($match, (int)$current['budget_id']);
$this->setBudget($match, (int) $current['budget_id']);
}
if (array_key_exists('bill_id', $current)) {
$this->setBill($match, (int)$current['bill_id']);
$this->setBill($match, (int) $current['bill_id']);
}
// reset category if name is set but empty:
// can be removed when v1 is retired.
if (array_key_exists('category_name', $current) && '' === (string)$current['category_name']) {
if (array_key_exists('category_name', $current) && '' === (string) $current['category_name']) {
$current['category_name'] = null;
$current['category_id'] = 0;
}
if (array_key_exists('category_id', $current)) {
$this->setCategory($match, (int)$current['category_id']);
$this->setCategory($match, (int) $current['category_id']);
}
if (array_key_exists('tags', $current) && is_array($current['tags'])) {
$this->updateTags($match, $current['tags']);
}
if (array_key_exists('piggy_bank_id', $current)) {
$this->updatePiggyBank($match, (int)$current['piggy_bank_id']);
$this->updatePiggyBank($match, (int) $current['piggy_bank_id']);
}
}
}

View File

@@ -62,7 +62,7 @@ class PwndVerifierV2 implements Verifier
try {
$client = new Client();
$res = $client->request('GET', $uri, $opt);
} catch (GuzzleException | RequestException $e) {
} catch (GuzzleException|RequestException $e) {
Log::error(sprintf('Could not verify password security: %s', $e->getMessage()));
return true;

View File

@@ -59,7 +59,7 @@ class StandardWebhookSender implements WebhookSenderInterface
try {
$signature = $signatureGenerator->generate($this->message);
} catch(FireflyException $e) {
} catch (FireflyException $e) {
Log::error('Did not send message because of a Firefly III Exception.');
Log::error($e->getMessage());
Log::error($e->getTraceAsString());