Use PSR-12 code style

This commit is contained in:
James Cole
2022-10-30 14:24:37 +01:00
parent f53923f16c
commit f52675068b
151 changed files with 251 additions and 403 deletions

View File

@@ -65,7 +65,6 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
$journal = $this->user->transactionJournals()->find($journalId); $journal = $this->user->transactionJournals()->find($journalId);
return $journal->attachments()->count(); return $journal->attachments()->count();
} }
/** /**
@@ -73,7 +72,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
*/ */
public function destroy(TransactionGroup $group): void public function destroy(TransactionGroup $group): void
{ {
$service = new TransactionGroupDestroyService; $service = new TransactionGroupDestroyService();
$service->destroy($group); $service->destroy($group);
} }
@@ -181,7 +180,6 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
$current['notes'] = $repository->getNoteText($attachment); $current['notes'] = $repository->getNoteText($attachment);
$current['journal_title'] = $attachment->attachable->description; // @phpstan-ignore-line $current['journal_title'] = $attachment->attachable->description; // @phpstan-ignore-line
$result[$journalId][] = $current; $result[$journalId][] = $current;
} }
return $result; return $result;
@@ -198,8 +196,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
{ {
$return = []; $return = [];
$journals = $group->transactionJournals->pluck('id')->toArray(); $journals = $group->transactionJournals->pluck('id')->toArray();
$set = TransactionJournalLink $set = TransactionJournalLink::where(
::where(
static function (Builder $q) use ($journals) { static function (Builder $q) use ($journals) {
$q->whereIn('source_id', $journals); $q->whereIn('source_id', $journals);
$q->orWhereIn('destination_id', $journals); $q->orWhereIn('destination_id', $journals);
@@ -262,7 +259,6 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
} }
if (TransactionType::WITHDRAWAL !== $type) { if (TransactionType::WITHDRAWAL !== $type) {
$return = app('amount')->formatAnything($currency, $amount); $return = app('amount')->formatAnything($currency, $amount);
} }
return $return; return $return;
@@ -319,8 +315,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
*/ */
public function getMetaDateFields(int $journalId, array $fields): NullArrayObject public function getMetaDateFields(int $journalId, array $fields): NullArrayObject
{ {
$query = DB $query = DB::table('journal_meta')
::table('journal_meta')
->where('transaction_journal_id', $journalId) ->where('transaction_journal_id', $journalId)
->whereIn('name', $fields) ->whereIn('name', $fields)
->whereNull('deleted_at') ->whereNull('deleted_at')
@@ -344,8 +339,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
*/ */
public function getMetaFields(int $journalId, array $fields): NullArrayObject public function getMetaFields(int $journalId, array $fields): NullArrayObject
{ {
$query = DB $query = DB::table('journal_meta')
::table('journal_meta')
->where('transaction_journal_id', $journalId) ->where('transaction_journal_id', $journalId)
->whereIn('name', $fields) ->whereIn('name', $fields)
->whereNull('deleted_at') ->whereNull('deleted_at')
@@ -369,8 +363,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
public function getNoteText(int $journalId): ?string public function getNoteText(int $journalId): ?string
{ {
/** @var Note|null $note */ /** @var Note|null $note */
$note = Note $note = Note::where('noteable_id', $journalId)
::where('noteable_id', $journalId)
->where('noteable_type', TransactionJournal::class) ->where('noteable_type', TransactionJournal::class)
->first(); ->first();
if (null === $note) { if (null === $note) {
@@ -394,8 +387,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
$return = []; $return = [];
$journals = $group->transactionJournals->pluck('id')->toArray(); $journals = $group->transactionJournals->pluck('id')->toArray();
$currency = app('amount')->getDefaultCurrencyByUser($this->user); $currency = app('amount')->getDefaultCurrencyByUser($this->user);
$data = PiggyBankEvent $data = PiggyBankEvent::whereIn('transaction_journal_id', $journals)
::whereIn('transaction_journal_id', $journals)
->with('piggyBank', 'piggyBank.account') ->with('piggyBank', 'piggyBank.account')
->get(['piggy_bank_events.*']); ->get(['piggy_bank_events.*']);
/** @var PiggyBankEvent $row */ /** @var PiggyBankEvent $row */
@@ -404,8 +396,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
continue; continue;
} }
// get currency preference. // get currency preference.
$currencyPreference = AccountMeta $currencyPreference = AccountMeta::where('account_id', $row->piggyBank->account_id)
::where('account_id', $row->piggyBank->account_id)
->where('name', 'currency_id') ->where('name', 'currency_id')
->first(); ->first();
if (null !== $currencyPreference) { if (null !== $currencyPreference) {
@@ -448,8 +439,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
*/ */
public function getTags(int $journalId): array public function getTags(int $journalId): array
{ {
$result = DB $result = DB::table('tag_transaction_journal')
::table('tag_transaction_journal')
->leftJoin('tags', 'tag_transaction_journal.tag_id', '=', 'tags.id') ->leftJoin('tags', 'tag_transaction_journal.tag_id', '=', 'tags.id')
->where('tag_transaction_journal.transaction_journal_id', $journalId) ->where('tag_transaction_journal.transaction_journal_id', $journalId)
->orderBy('tags.tag', 'ASC') ->orderBy('tags.tag', 'ASC')

View File

@@ -176,5 +176,4 @@ interface TransactionGroupRepositoryInterface
* @return TransactionGroup * @return TransactionGroup
*/ */
public function update(TransactionGroup $transactionGroup, array $data): TransactionGroup; public function update(TransactionGroup $transactionGroup, array $data): TransactionGroup;
} }

View File

@@ -32,7 +32,6 @@ use Log;
*/ */
class TransactionTypeRepository implements TransactionTypeRepositoryInterface class TransactionTypeRepository implements TransactionTypeRepositoryInterface
{ {
/** /**
* @param TransactionType|null $type * @param TransactionType|null $type
* @param string|null $typeString * @param string|null $typeString

View File

@@ -274,7 +274,7 @@ class UserRepository implements UserRepositoryInterface
{ {
$now = Carbon::now(); $now = Carbon::now();
$now->addDays(2); $now->addDays(2);
$invitee = new InvitedUser; $invitee = new InvitedUser();
$invitee->user()->associate($user); $invitee->user()->associate($user);
$invitee->invite_code = Str::random(64); $invitee->invite_code = Str::random(64);
$invitee->email = $email; $invitee->email = $email;
@@ -353,7 +353,6 @@ class UserRepository implements UserRepositoryInterface
$user->blocked = false; $user->blocked = false;
$user->blocked_code = ''; $user->blocked_code = '';
$user->save(); $user->save();
} }
/** /**

View File

@@ -32,7 +32,6 @@ use Illuminate\Support\Collection;
*/ */
interface UserRepositoryInterface interface UserRepositoryInterface
{ {
/** /**
* Returns a collection of all users. * Returns a collection of all users.
* *

View File

@@ -98,5 +98,4 @@ interface WebhookRepositoryInterface
* @return Webhook * @return Webhook
*/ */
public function update(Webhook $webhook, array $data): Webhook; public function update(Webhook $webhook, array $data): Webhook;
} }

View File

@@ -154,7 +154,6 @@ class BelongsUser implements Rule
if (PiggyBank::class === $class) { if (PiggyBank::class === $class) {
$objects = PiggyBank::leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id') $objects = PiggyBank::leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')
->where('accounts.user_id', '=', auth()->user()->id)->get(['piggy_banks.*']); ->where('accounts.user_id', '=', auth()->user()->id)->get(['piggy_banks.*']);
} }
if (PiggyBank::class !== $class) { if (PiggyBank::class !== $class) {
$objects = $class::where('user_id', '=', auth()->user()->id)->get(); $objects = $class::where('user_id', '=', auth()->user()->id)->get();

View File

@@ -61,7 +61,7 @@ class IsBoolean implements Rule
if (is_int($value) && 1 === $value) { if (is_int($value) && 1 === $value) {
return true; return true;
} }
if (is_string($value) && in_array($value, ['0', '1', 'true', 'false', 'on', 'off', 'yes', 'no', 'y', 'n'])) { if (is_string($value) && in_array($value, ['0', '1', 'true', 'false', 'on', 'off', 'yes', 'no', 'y', 'n'], true)) {
return true; return true;
} }

View File

@@ -35,7 +35,6 @@ use Log;
*/ */
class IsDateOrTime implements Rule class IsDateOrTime implements Rule
{ {
/** /**
* Get the validation error message. * Get the validation error message.
* *

View File

@@ -101,7 +101,10 @@ class UniqueAccountNumber implements Rule
Log::debug( Log::debug(
sprintf( sprintf(
'account number "%s" is in use with %d account(s) of type "%s", which is too much for expected type "%s"', 'account number "%s" is in use with %d account(s) of type "%s", which is too much for expected type "%s"',
$value, $count, $type, $this->expectedType $value,
$count,
$type,
$this->expectedType
) )
); );
@@ -147,8 +150,7 @@ class UniqueAccountNumber implements Rule
*/ */
private function countHits(string $type, string $accountNumber): int private function countHits(string $type, string $accountNumber): int
{ {
$query = AccountMeta $query = AccountMeta::leftJoin('accounts', 'accounts.id', '=', 'account_meta.account_id')
::leftJoin('accounts', 'accounts.id', '=', 'account_meta.account_id')
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id') ->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
->where('accounts.user_id', auth()->user()->id) ->where('accounts.user_id', auth()->user()->id)
->where('account_types.type', $type) ->where('account_types.type', $type)

View File

@@ -98,7 +98,10 @@ class UniqueIban implements Rule
Log::debug( Log::debug(
sprintf( sprintf(
'IBAN "%s" is in use with %d account(s) of type "%s", which is too much for expected type "%s"', 'IBAN "%s" is in use with %d account(s) of type "%s", which is too much for expected type "%s"',
$value, $count, $type, $this->expectedType $value,
$count,
$type,
$this->expectedType
) )
); );

View File

@@ -32,7 +32,6 @@ use Illuminate\Contracts\Validation\Rule;
*/ */
class ValidRecurrenceRepetitionType implements Rule class ValidRecurrenceRepetitionType implements Rule
{ {
/** /**
* Get the validation error message. * Get the validation error message.
* *
@@ -60,7 +59,7 @@ class ValidRecurrenceRepetitionType implements Rule
} }
//monthly,17 //monthly,17
//ndom,3,7 //ndom,3,7
if (in_array(substr($value, 0, 6), ['yearly', 'weekly'])) { if (in_array(substr($value, 0, 6), ['yearly', 'weekly'], true)) {
return true; return true;
} }
if (str_starts_with($value, 'monthly')) { if (str_starts_with($value, 'monthly')) {

View File

@@ -35,7 +35,6 @@ use Log;
*/ */
class ValidRecurrenceRepetitionValue implements Rule class ValidRecurrenceRepetitionValue implements Rule
{ {
/** /**
* Get the validation error message. * Get the validation error message.
* *

View File

@@ -36,7 +36,6 @@ use Log;
*/ */
class UpdateRequest implements UpdateRequestInterface class UpdateRequest implements UpdateRequestInterface
{ {
/** /**
* @param string $channel * @param string $channel
* *
@@ -83,7 +82,7 @@ class UpdateRequest implements UpdateRequestInterface
$url = config('firefly.update_endpoint'); $url = config('firefly.update_endpoint');
Log::debug(sprintf('Going to call %s', $url)); Log::debug(sprintf('Going to call %s', $url));
try { try {
$client = new Client; $client = new Client();
$options = [ $options = [
'headers' => [ 'headers' => [
'User-Agent' => sprintf('FireflyIII/%s/%s', config('firefly.version'), $channel), 'User-Agent' => sprintf('FireflyIII/%s/%s', config('firefly.version'), $channel),
@@ -110,7 +109,6 @@ class UpdateRequest implements UpdateRequestInterface
$body = (string) $res->getBody(); $body = (string) $res->getBody();
try { try {
$json = json_decode($body, true, 512, JSON_THROW_ON_ERROR); $json = json_decode($body, true, 512, JSON_THROW_ON_ERROR);
} catch (JsonException $e) { } catch (JsonException $e) {
Log::error('Body is not valid JSON'); Log::error('Body is not valid JSON');
Log::error($body); Log::error($body);

View File

@@ -35,5 +35,4 @@ interface UpdateRequestInterface
* @return array * @return array
*/ */
public function getUpdateInformation(string $channel): array; public function getUpdateInformation(string $channel): array;
} }

View File

@@ -91,8 +91,7 @@ class AccountDestroyService
Log::debug(sprintf('Found opening balance journal with ID #%d', $journalId)); Log::debug(sprintf('Found opening balance journal with ID #%d', $journalId));
// get transactions with this journal (should be just one): // get transactions with this journal (should be just one):
$transactions = Transaction $transactions = Transaction::where('transaction_journal_id', $journalId)
::where('transaction_journal_id', $journalId)
->where('account_id', '!=', $account->id) ->where('account_id', '!=', $account->id)
->get(); ->get();
/** @var Transaction $transaction */ /** @var Transaction $transaction */
@@ -159,7 +158,6 @@ class AccountDestroyService
*/ */
private function destroyJournals(Account $account): void private function destroyJournals(Account $account): void
{ {
/** @var JournalDestroyService $service */ /** @var JournalDestroyService $service */
$service = app(JournalDestroyService::class); $service = app(JournalDestroyService::class);
@@ -181,8 +179,7 @@ class AccountDestroyService
*/ */
private function destroyRecurrences(Account $account): void private function destroyRecurrences(Account $account): void
{ {
$recurrences = RecurrenceTransaction:: $recurrences = RecurrenceTransaction::where(
where(
static function (Builder $q) use ($account) { static function (Builder $q) use ($account) {
$q->where('source_id', $account->id); $q->where('source_id', $account->id);
$q->orWhere('destination_id', $account->id); $q->orWhere('destination_id', $account->id);
@@ -195,5 +192,4 @@ class AccountDestroyService
$destroyService->destroyById((int) $recurrenceId); $destroyService->destroyById((int) $recurrenceId);
} }
} }
} }

View File

@@ -43,5 +43,4 @@ class BillDestroyService
// @ignoreException // @ignoreException
} }
} }
} }

View File

@@ -39,7 +39,6 @@ class BudgetDestroyService
*/ */
public function destroy(Budget $budget): void public function destroy(Budget $budget): void
{ {
try { try {
$budget->delete(); $budget->delete();
} catch (Exception $e) { // @phpstan-ignore-line } catch (Exception $e) { // @phpstan-ignore-line

View File

@@ -38,12 +38,10 @@ class CurrencyDestroyService
*/ */
public function destroy(TransactionCurrency $currency): void public function destroy(TransactionCurrency $currency): void
{ {
try { try {
$currency->delete(); $currency->delete();
} catch (Exception $e) { // @phpstan-ignore-line } catch (Exception $e) { // @phpstan-ignore-line
// @ignoreException // @ignoreException
} }
} }
} }

View File

@@ -95,11 +95,8 @@ class JournalDestroyService
$group->delete(); $group->delete();
} }
} }
} catch (Exception $e) { // @phpstan-ignore-line } catch (Exception $e) { // @phpstan-ignore-line
// @ignoreException // @ignoreException
} }
} }
} }

View File

@@ -45,7 +45,6 @@ class RecurrenceDestroyService
return; return;
} }
$this->destroy($recurrence); $this->destroy($recurrence);
} }
/** /**
@@ -82,5 +81,4 @@ class RecurrenceDestroyService
// @ignoreException // @ignoreException
} }
} }
} }

View File

@@ -33,7 +33,6 @@ use FireflyIII\Models\TransactionGroup;
*/ */
class TransactionGroupDestroyService class TransactionGroupDestroyService
{ {
/** /**
* @param TransactionGroup $transactionGroup * @param TransactionGroup $transactionGroup
*/ */
@@ -50,5 +49,4 @@ class TransactionGroupDestroyService
// @ignoreException // @ignoreException
} }
} }
} }

View File

@@ -118,8 +118,8 @@ trait AccountServiceTrait
// remove currency_id if necessary. // remove currency_id if necessary.
$type = $account->accountType->type; $type = $account->accountType->type;
$list = config('firefly.valid_currency_account_types'); $list = config('firefly.valid_currency_account_types');
if(!in_array($type, $list, true)) { if (!in_array($type, $list, true)) {
$pos = array_search('currency_id', $fields); $pos = array_search('currency_id', $fields, true);
if ($pos !== false) { if ($pos !== false) {
unset($fields[$pos]); unset($fields[$pos]);
} }
@@ -147,7 +147,6 @@ trait AccountServiceTrait
// if the field is set but NULL, skip it. // if the field is set but NULL, skip it.
// if the field is set but "", update it. // if the field is set but "", update it.
if (array_key_exists($field, $data) && null !== $data[$field]) { if (array_key_exists($field, $data) && null !== $data[$field]) {
// convert boolean value: // convert boolean value:
if (is_bool($data[$field]) && false === $data[$field]) { if (is_bool($data[$field]) && false === $data[$field]) {
$data[$field] = 0; $data[$field] = 0;
@@ -184,7 +183,7 @@ trait AccountServiceTrait
} }
$dbNote = $account->notes()->first(); $dbNote = $account->notes()->first();
if (null === $dbNote) { if (null === $dbNote) {
$dbNote = new Note; $dbNote = new Note();
$dbNote->noteable()->associate($account); $dbNote->noteable()->associate($account);
} }
$dbNote->text = trim($note); $dbNote->text = trim($note);

View File

@@ -36,7 +36,6 @@ use Log;
*/ */
trait BillServiceTrait trait BillServiceTrait
{ {
/** /**
* @param Bill $bill * @param Bill $bill
* @param string $oldName * @param string $oldName
@@ -90,5 +89,4 @@ trait BillServiceTrait
return true; return true;
} }
} }

View File

@@ -22,10 +22,8 @@
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Services\Internal\Support; namespace FireflyIII\Services\Internal\Support;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Factory\AccountMetaFactory; use FireflyIII\Factory\AccountMetaFactory;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
@@ -110,11 +108,11 @@ class CreditRecalculateService
// destination or source must be liability. // destination or source must be liability.
$valid = config('firefly.valid_liabilities'); $valid = config('firefly.valid_liabilities');
if (in_array($destination->accountType->type, $valid)) { if (in_array($destination->accountType->type, $valid, true)) {
Log::debug(sprintf('Dest account type is "%s", include it.', $destination->accountType->type)); Log::debug(sprintf('Dest account type is "%s", include it.', $destination->accountType->type));
$this->work[] = $destination; $this->work[] = $destination;
} }
if (in_array($source->accountType->type, $valid)) { if (in_array($source->accountType->type, $valid, true)) {
Log::debug(sprintf('Src account type is "%s", include it.', $source->accountType->type)); Log::debug(sprintf('Src account type is "%s", include it.', $source->accountType->type));
$this->work[] = $source; $this->work[] = $source;
} }
@@ -170,7 +168,7 @@ class CreditRecalculateService
private function processAccount(): void private function processAccount(): void
{ {
$valid = config('firefly.valid_liabilities'); $valid = config('firefly.valid_liabilities');
if (in_array($this->account->accountType->type, $valid)) { if (in_array($this->account->accountType->type, $valid, true)) {
Log::debug(sprintf('Account type is "%s", include it.', $this->account->accountType->type)); Log::debug(sprintf('Account type is "%s", include it.', $this->account->accountType->type));
$this->work[] = $this->account; $this->work[] = $this->account;
} }
@@ -290,6 +288,4 @@ class CreditRecalculateService
{ {
$this->group = $group; $this->group = $group;
} }
} }

View File

@@ -206,13 +206,13 @@ trait JournalServiceTrait
Log::debug( Log::debug(
sprintf( sprintf(
'Was given %s account #%d ("%s") so will simply return that.', 'Was given %s account #%d ("%s") so will simply return that.',
$account->accountType->type, $account->id, $account->name $account->accountType->type,
$account->id,
$account->name
) )
); );
} }
if (null === $account) { if (null === $account) {
// final attempt, create it. // final attempt, create it.
if (AccountType::ASSET === $preferredType) { if (AccountType::ASSET === $preferredType) {
throw new FireflyException(sprintf('TransactionFactory: Cannot create asset account with these values: %s', json_encode($data))); throw new FireflyException(sprintf('TransactionFactory: Cannot create asset account with these values: %s', json_encode($data)));
@@ -258,7 +258,6 @@ trait JournalServiceTrait
$metaFactory = app(AccountMetaFactory::class); $metaFactory = app(AccountMetaFactory::class);
$metaFactory->create(['account_id' => $account->id, 'name' => 'account_number', 'data' => $data['number']]); $metaFactory->create(['account_id' => $account->id, 'name' => 'account_number', 'data' => $data['number']]);
} }
} }
return $account; return $account;
@@ -385,7 +384,7 @@ trait JournalServiceTrait
$note = $journal->notes()->first(); $note = $journal->notes()->first();
if ('' !== $notes) { if ('' !== $notes) {
if (null === $note) { if (null === $note) {
$note = new Note; $note = new Note();
$note->noteable()->associate($journal); $note->noteable()->associate($journal);
} }
$note->text = $notes; $note->text = $notes;

View File

@@ -42,7 +42,7 @@ trait LocationServiceTrait
{ {
$data['store_location'] = $data['store_location'] ?? false; $data['store_location'] = $data['store_location'] ?? false;
if ($data['store_location']) { if ($data['store_location']) {
$location = new Location; $location = new Location();
$location->latitude = $data['latitude'] ?? config('firefly.default_location.latitude'); $location->latitude = $data['latitude'] ?? config('firefly.default_location.latitude');
$location->longitude = $data['longitude'] ?? config('firefly.default_location.longitude'); $location->longitude = $data['longitude'] ?? config('firefly.default_location.longitude');
$location->zoom_level = $data['zoom_level'] ?? config('firefly.default_location.zoom_level'); $location->zoom_level = $data['zoom_level'] ?? config('firefly.default_location.zoom_level');
@@ -54,5 +54,4 @@ trait LocationServiceTrait
return null; return null;
} }
} }

View File

@@ -97,7 +97,6 @@ trait RecurringTransactionTrait
'weekend' => $array['weekend'] ?? 1, 'weekend' => $array['weekend'] ?? 1,
] ]
); );
} }
} }
@@ -181,7 +180,6 @@ trait RecurringTransactionTrait
if (array_key_exists('tags', $array) && is_array($array['tags'])) { if (array_key_exists('tags', $array) && is_array($array['tags'])) {
$this->updateTags($transaction, $array['tags']); $this->updateTags($transaction, $array['tags']);
} }
} }
} }
@@ -226,11 +224,9 @@ trait RecurringTransactionTrait
if (!in_array($expectedType, $cannotCreate, true)) { if (!in_array($expectedType, $cannotCreate, true)) {
try { try {
$result = $factory->findOrCreate($accountName, $expectedType); $result = $factory->findOrCreate($accountName, $expectedType);
} catch (FireflyException $e) { } catch (FireflyException $e) {
Log::error($e->getMessage()); Log::error($e->getMessage());
} }
} }
} }
@@ -252,7 +248,7 @@ trait RecurringTransactionTrait
$meta = $transaction->recurrenceTransactionMeta()->where('name', 'budget_id')->first(); $meta = $transaction->recurrenceTransactionMeta()->where('name', 'budget_id')->first();
if (null === $meta) { if (null === $meta) {
$meta = new RecurrenceTransactionMeta; $meta = new RecurrenceTransactionMeta();
$meta->rt_id = $transaction->id; $meta->rt_id = $transaction->id;
$meta->name = 'budget_id'; $meta->name = 'budget_id';
} }
@@ -275,7 +271,7 @@ trait RecurringTransactionTrait
$meta = $transaction->recurrenceTransactionMeta()->where('name', 'bill_id')->first(); $meta = $transaction->recurrenceTransactionMeta()->where('name', 'bill_id')->first();
if (null === $meta) { if (null === $meta) {
$meta = new RecurrenceTransactionMeta; $meta = new RecurrenceTransactionMeta();
$meta->rt_id = $transaction->id; $meta->rt_id = $transaction->id;
$meta->name = 'bill_id'; $meta->name = 'bill_id';
} }
@@ -304,7 +300,7 @@ trait RecurringTransactionTrait
$meta = $transaction->recurrenceTransactionMeta()->where('name', 'category_id')->first(); $meta = $transaction->recurrenceTransactionMeta()->where('name', 'category_id')->first();
if (null === $meta) { if (null === $meta) {
$meta = new RecurrenceTransactionMeta; $meta = new RecurrenceTransactionMeta();
$meta->rt_id = $transaction->id; $meta->rt_id = $transaction->id;
$meta->name = 'category_id'; $meta->name = 'category_id';
} }

View File

@@ -270,7 +270,7 @@ class AccountUpdateService
if (!(null === $data['latitude'] && null === $data['longitude'] && null === $data['zoom_level'])) { if (!(null === $data['latitude'] && null === $data['longitude'] && null === $data['zoom_level'])) {
$location = $this->accountRepository->getLocation($account); $location = $this->accountRepository->getLocation($account);
if (null === $location) { if (null === $location) {
$location = new Location; $location = new Location();
$location->locatable()->associate($account); $location->locatable()->associate($account);
} }

View File

@@ -40,7 +40,8 @@ use Log;
*/ */
class BillUpdateService class BillUpdateService
{ {
use BillServiceTrait, CreatesObjectGroups; use BillServiceTrait;
use CreatesObjectGroups;
protected User $user; protected User $user;
@@ -203,7 +204,6 @@ class BillUpdateService
$bill->order = $newOrder; $bill->order = $newOrder;
$bill->save(); $bill->save();
} }
} }
/** /**
@@ -239,7 +239,6 @@ class BillUpdateService
} }
$this->updateRules($rules, $ruleTriggerKey, $oldData[$field], $newData[$field]); $this->updateRules($rules, $ruleTriggerKey, $oldData[$field], $newData[$field]);
} }
} }
/** /**

View File

@@ -130,8 +130,7 @@ class CategoryUpdateService
*/ */
private function updateRecurrences(string $oldName, string $newName): void private function updateRecurrences(string $oldName, string $newName): void
{ {
RecurrenceTransactionMeta RecurrenceTransactionMeta::leftJoin('recurrences_transactions', 'rt_meta.rt_id', '=', 'recurrences_transactions.id')
::leftJoin('recurrences_transactions', 'rt_meta.rt_id', '=', 'recurrences_transactions.id')
->leftJoin('recurrences', 'recurrences.id', '=', 'recurrences_transactions.recurrence_id') ->leftJoin('recurrences', 'recurrences.id', '=', 'recurrences_transactions.recurrence_id')
->where('recurrences.user_id', $this->user->id) ->where('recurrences.user_id', $this->user->id)
->where('rt_meta.name', 'category_name') ->where('rt_meta.name', 'category_name')
@@ -165,11 +164,10 @@ class CategoryUpdateService
} }
$dbNote = $category->notes()->first(); $dbNote = $category->notes()->first();
if (null === $dbNote) { if (null === $dbNote) {
$dbNote = new Note; $dbNote = new Note();
$dbNote->noteable()->associate($category); $dbNote->noteable()->associate($category);
} }
$dbNote->text = trim($note); $dbNote->text = trim($note);
$dbNote->save(); $dbNote->save();
} }
} }

View File

@@ -64,5 +64,4 @@ class CurrencyUpdateService
return $currency; return $currency;
} }
} }

View File

@@ -108,7 +108,7 @@ class GroupCloneService
// clone linked piggy banks // clone linked piggy banks
/** @var PiggyBankEvent $event */ /** @var PiggyBankEvent $event */
$event = $journal->piggyBankEvents()->first(); $event = $journal->piggyBankEvents()->first();
if(null !== $event) { if (null !== $event) {
$piggyBank = $event->piggyBank; $piggyBank = $event->piggyBank;
$factory = app(PiggyBankEventFactory::class); $factory = app(PiggyBankEventFactory::class);
$factory->create($newJournal, $piggyBank); $factory->create($newJournal, $piggyBank);
@@ -136,11 +136,11 @@ class GroupCloneService
{ {
$newNote = $note->replicate(); $newNote = $note->replicate();
$newNote->text .= sprintf( $newNote->text .= sprintf(
"\n\n%s", trans('firefly.clones_journal_x', ['description' => $newJournal->description, 'id' => $oldGroupId]) "\n\n%s",
trans('firefly.clones_journal_x', ['description' => $newJournal->description, 'id' => $oldGroupId])
); );
$newNote->noteable_id = $newJournal->id; $newNote->noteable_id = $newJournal->id;
$newNote->save(); $newNote->save();
} }
/** /**

View File

@@ -227,5 +227,4 @@ class GroupUpdateService
return $collection->first(); return $collection->first();
} }
} }

View File

@@ -456,7 +456,9 @@ class JournalUpdateService
Log::debug( Log::debug(
sprintf( sprintf(
'Trying to change journal #%d from a %s to a %s.', 'Trying to change journal #%d from a %s to a %s.',
$this->transactionJournal->id, $this->transactionJournal->transactionType->type, $type $this->transactionJournal->id,
$this->transactionJournal->transactionType->type,
$type
) )
); );
@@ -483,10 +485,10 @@ class JournalUpdateService
{ {
$type = $this->transactionJournal->transactionType->type; $type = $this->transactionJournal->transactionType->type;
if (( if ((
array_key_exists('bill_id', $this->data) array_key_exists('bill_id', $this->data)
|| array_key_exists('bill_name', $this->data) || array_key_exists('bill_name', $this->data)
) )
&& TransactionType::WITHDRAWAL === $type && TransactionType::WITHDRAWAL === $type
) { ) {
$billId = (int) ($this->data['bill_id'] ?? 0); $billId = (int) ($this->data['bill_id'] ?? 0);
$billName = (string) ($this->data['bill_name'] ?? ''); $billName = (string) ($this->data['bill_name'] ?? '');

View File

@@ -42,7 +42,8 @@ use Log;
*/ */
class RecurrenceUpdateService class RecurrenceUpdateService
{ {
use TransactionTypeTrait, RecurringTransactionTrait; use TransactionTypeTrait;
use RecurringTransactionTrait;
private User $user; private User $user;

View File

@@ -63,7 +63,7 @@ class StandardWebhookSender implements WebhookSenderInterface
Log::error('Did not send message because of a Firefly III Exception.'); Log::error('Did not send message because of a Firefly III Exception.');
Log::error($e->getMessage()); Log::error($e->getMessage());
Log::error($e->getTraceAsString()); Log::error($e->getTraceAsString());
$attempt = new WebhookAttempt; $attempt = new WebhookAttempt();
$attempt->webhookMessage()->associate($this->message); $attempt->webhookMessage()->associate($this->message);
$attempt->status_code = 0; $attempt->status_code = 0;
$attempt->logs = sprintf('Exception: %s', $e->getMessage()); $attempt->logs = sprintf('Exception: %s', $e->getMessage());
@@ -83,7 +83,7 @@ class StandardWebhookSender implements WebhookSenderInterface
Log::error('Did not send message because of a JSON error.'); Log::error('Did not send message because of a JSON error.');
Log::error($e->getMessage()); Log::error($e->getMessage());
Log::error($e->getTraceAsString()); Log::error($e->getTraceAsString());
$attempt = new WebhookAttempt; $attempt = new WebhookAttempt();
$attempt->webhookMessage()->associate($this->message); $attempt->webhookMessage()->associate($this->message);
$attempt->status_code = 0; $attempt->status_code = 0;
$attempt->logs = sprintf('Json error: %s', $e->getMessage()); $attempt->logs = sprintf('Json error: %s', $e->getMessage());
@@ -105,7 +105,7 @@ class StandardWebhookSender implements WebhookSenderInterface
'timeout' => 10, 'timeout' => 10,
], ],
]; ];
$client = new Client; $client = new Client();
try { try {
$res = $client->request('POST', $this->message->webhook->url, $options); $res = $client->request('POST', $this->message->webhook->url, $options);
$this->message->sent = true; $this->message->sent = true;
@@ -119,7 +119,7 @@ class StandardWebhookSender implements WebhookSenderInterface
$this->message->sent = false; $this->message->sent = false;
$this->message->save(); $this->message->save();
$attempt = new WebhookAttempt; $attempt = new WebhookAttempt();
$attempt->webhookMessage()->associate($this->message); $attempt->webhookMessage()->associate($this->message);
$attempt->status_code = $e->hasResponse() ? $e->getResponse()->getStatusCode() : 0; $attempt->status_code = $e->hasResponse() ? $e->getResponse()->getStatusCode() : 0;
$attempt->logs = $logs; $attempt->logs = $logs;

View File

@@ -117,7 +117,7 @@ class Amount
*/ */
public function getCurrencyCode(): string public function getCurrencyCode(): string
{ {
$cache = new CacheProperties; $cache = new CacheProperties();
$cache->addProperty('getCurrencyCode'); $cache->addProperty('getCurrencyCode');
if ($cache->has()) { if ($cache->has()) {
return $cache->get(); return $cache->get();
@@ -155,7 +155,7 @@ class Amount
*/ */
public function getDefaultCurrencyByUser(User $user): TransactionCurrency public function getDefaultCurrencyByUser(User $user): TransactionCurrency
{ {
$cache = new CacheProperties; $cache = new CacheProperties();
$cache->addProperty('getDefaultCurrency'); $cache->addProperty('getDefaultCurrency');
$cache->addProperty($user->id); $cache->addProperty($user->id);
if ($cache->has()) { if ($cache->has()) {

View File

@@ -38,8 +38,8 @@ use Log;
class RemoteUserGuard implements Guard class RemoteUserGuard implements Guard
{ {
protected Application $application; protected Application $application;
protected $provider; protected $provider;
protected $user; protected $user;
/** /**
* Create a new authentication guard. * Create a new authentication guard.

View File

@@ -37,7 +37,6 @@ use Str;
*/ */
class RemoteUserProvider implements UserProvider class RemoteUserProvider implements UserProvider
{ {
/** /**
* @inheritDoc * @inheritDoc
*/ */
@@ -65,7 +64,7 @@ class RemoteUserProvider implements UserProvider
] ]
); );
// if this is the first user, give them admin as well. // if this is the first user, give them admin as well.
if(1 === User::count()) { if (1 === User::count()) {
$roleObject = Role::where('name', 'owner')->first(); $roleObject = Role::where('name', 'owner')->first();
$user->roles()->attach($roleObject); $user->roles()->attach($roleObject);
} }

View File

@@ -33,7 +33,6 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/ */
class AccountList implements BinderInterface class AccountList implements BinderInterface
{ {
/** /**
* @param string $value * @param string $value
* @param Route $route * @param Route $route
@@ -45,7 +44,7 @@ class AccountList implements BinderInterface
public static function routeBinder(string $value, Route $route): Collection public static function routeBinder(string $value, Route $route): Collection
{ {
if (auth()->check()) { if (auth()->check()) {
$collection = new Collection; $collection = new Collection();
if ('allAssetAccounts' === $value) { if ('allAssetAccounts' === $value) {
/** @var Collection $collection */ /** @var Collection $collection */
$collection = auth()->user()->accounts() $collection = auth()->user()->accounts()
@@ -70,6 +69,6 @@ class AccountList implements BinderInterface
} }
} }
Log::error(sprintf('Trying to show account list (%s), but user is not logged in or list is empty.', $route->uri)); Log::error(sprintf('Trying to show account list (%s), but user is not logged in or list is empty.', $route->uri));
throw new NotFoundHttpException; throw new NotFoundHttpException();
} }
} }

View File

@@ -44,7 +44,6 @@ class BudgetList implements BinderInterface
public static function routeBinder(string $value, Route $route): Collection public static function routeBinder(string $value, Route $route): Collection
{ {
if (auth()->check()) { if (auth()->check()) {
if ('allBudgets' === $value) { if ('allBudgets' === $value) {
return auth()->user()->budgets()->where('active', true) return auth()->user()->budgets()->where('active', true)
->orderBy('order', 'ASC') ->orderBy('order', 'ASC')
@@ -57,7 +56,7 @@ class BudgetList implements BinderInterface
if (empty($list)) { if (empty($list)) {
Log::warning('Budget list count is zero, return 404.'); Log::warning('Budget list count is zero, return 404.');
throw new NotFoundHttpException; throw new NotFoundHttpException();
} }
@@ -69,15 +68,14 @@ class BudgetList implements BinderInterface
// add empty budget if applicable. // add empty budget if applicable.
if (in_array(0, $list, true)) { if (in_array(0, $list, true)) {
$collection->push(new Budget); $collection->push(new Budget());
} }
if ($collection->count() > 0) { if ($collection->count() > 0) {
return $collection; return $collection;
} }
} }
Log::warning('BudgetList fallback to 404.'); Log::warning('BudgetList fallback to 404.');
throw new NotFoundHttpException; throw new NotFoundHttpException();
} }
} }

View File

@@ -34,7 +34,6 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/ */
class CLIToken implements BinderInterface class CLIToken implements BinderInterface
{ {
/** /**
* @param string $value * @param string $value
* @param Route $route * @param Route $route
@@ -62,6 +61,6 @@ class CLIToken implements BinderInterface
} }
} }
Log::error(sprintf('Recognized no users by access token "%s"', $value)); Log::error(sprintf('Recognized no users by access token "%s"', $value));
throw new NotFoundHttpException; throw new NotFoundHttpException();
} }
} }

View File

@@ -51,7 +51,7 @@ class CategoryList implements BinderInterface
$list = array_unique(array_map('\intval', explode(',', $value))); $list = array_unique(array_map('\intval', explode(',', $value)));
if (empty($list)) { if (empty($list)) {
throw new NotFoundHttpException; throw new NotFoundHttpException();
} }
/** @var Collection $collection */ /** @var Collection $collection */
@@ -61,13 +61,13 @@ class CategoryList implements BinderInterface
// add empty category if applicable. // add empty category if applicable.
if (in_array(0, $list, true)) { if (in_array(0, $list, true)) {
$collection->push(new Category); $collection->push(new Category());
} }
if ($collection->count() > 0) { if ($collection->count() > 0) {
return $collection; return $collection;
} }
} }
throw new NotFoundHttpException; throw new NotFoundHttpException();
} }
} }

View File

@@ -46,6 +46,6 @@ class CurrencyCode implements BinderInterface
return $currency; return $currency;
} }
} }
throw new NotFoundHttpException; throw new NotFoundHttpException();
} }
} }

View File

@@ -73,7 +73,7 @@ class Date implements BinderInterface
$result = new Carbon($value); $result = new Carbon($value);
} catch (Exception $e) { // @phpstan-ignore-line } catch (Exception $e) { // @phpstan-ignore-line
Log::error(sprintf('Could not parse date "%s" for user #%d: %s', $value, auth()->user()->id, $e->getMessage())); Log::error(sprintf('Could not parse date "%s" for user #%d: %s', $value, auth()->user()->id, $e->getMessage()));
throw new NotFoundHttpException; throw new NotFoundHttpException();
} }
return $result; return $result;

View File

@@ -31,7 +31,6 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/ */
class DynamicConfigKey class DynamicConfigKey
{ {
public static array $accepted public static array $accepted
= [ = [
'configuration.is_demo_site', 'configuration.is_demo_site',
@@ -52,7 +51,6 @@ class DynamicConfigKey
if (in_array($value, self::$accepted, true)) { if (in_array($value, self::$accepted, true)) {
return $value; return $value;
} }
throw new NotFoundHttpException; throw new NotFoundHttpException();
} }
} }

View File

@@ -68,6 +68,6 @@ class EitherConfigKey
if (in_array($value, self::$static, true) || in_array($value, DynamicConfigKey::$accepted, true)) { if (in_array($value, self::$static, true) || in_array($value, DynamicConfigKey::$accepted, true)) {
return $value; return $value;
} }
throw new NotFoundHttpException; throw new NotFoundHttpException();
} }
} }

View File

@@ -53,12 +53,12 @@ class JournalList implements BinderInterface
$collector->setJournalIds($list); $collector->setJournalIds($list);
$result = $collector->getExtractedJournals(); $result = $collector->getExtractedJournals();
if (empty($result)) { if (empty($result)) {
throw new NotFoundHttpException; throw new NotFoundHttpException();
} }
return $result; return $result;
} }
throw new NotFoundHttpException; throw new NotFoundHttpException();
} }
/** /**
@@ -70,7 +70,7 @@ class JournalList implements BinderInterface
{ {
$list = array_unique(array_map('\intval', explode(',', $value))); $list = array_unique(array_map('\intval', explode(',', $value)));
if (empty($list)) { if (empty($list)) {
throw new NotFoundHttpException; throw new NotFoundHttpException();
} }
return $list; return $list;

View File

@@ -44,7 +44,6 @@ class TagList implements BinderInterface
public static function routeBinder(string $value, Route $route): Collection public static function routeBinder(string $value, Route $route): Collection
{ {
if (auth()->check()) { if (auth()->check()) {
if ('allTags' === $value) { if ('allTags' === $value) {
return auth()->user()->tags() return auth()->user()->tags()
->orderBy('tag', 'ASC') ->orderBy('tag', 'ASC')
@@ -55,7 +54,7 @@ class TagList implements BinderInterface
if (empty($list)) { if (empty($list)) {
Log::error('Tag list is empty.'); Log::error('Tag list is empty.');
throw new NotFoundHttpException; throw new NotFoundHttpException();
} }
@@ -82,6 +81,6 @@ class TagList implements BinderInterface
} }
} }
Log::error('TagList: user is not logged in.'); Log::error('TagList: user is not logged in.');
throw new NotFoundHttpException; throw new NotFoundHttpException();
} }
} }

View File

@@ -54,9 +54,9 @@ class TagOrId implements BinderInterface
return $result; return $result;
} }
Log::error('TagOrId: tag not found.'); Log::error('TagOrId: tag not found.');
throw new NotFoundHttpException; throw new NotFoundHttpException();
} }
Log::error('TagOrId: user is not logged in.'); Log::error('TagOrId: user is not logged in.');
throw new NotFoundHttpException; throw new NotFoundHttpException();
} }
} }

View File

@@ -41,7 +41,7 @@ class CacheProperties
*/ */
public function __construct() public function __construct()
{ {
$this->properties = new Collection; $this->properties = new Collection();
if (auth()->check()) { if (auth()->check()) {
$this->addProperty(auth()->user()->id); $this->addProperty(auth()->user()->id);
$this->addProperty(app('preferences')->lastActivity()); $this->addProperty(app('preferences')->lastActivity());

View File

@@ -64,7 +64,6 @@ class FrontpageChartGenerator
$this->accountRepos = app(AccountRepositoryInterface::class); $this->accountRepos = app(AccountRepositoryInterface::class);
$this->opsRepos = app(OperationsRepositoryInterface::class); $this->opsRepos = app(OperationsRepositoryInterface::class);
$this->noCatRepos = app(NoCategoryRepositoryInterface::class); $this->noCatRepos = app(NoCategoryRepositoryInterface::class);
} }
/** /**
@@ -200,10 +199,8 @@ class FrontpageChartGenerator
$category = $array['name']; $category = $array['name'];
$amount = $array['sum_float'] < 0 ? $array['sum_float'] * -1 : $array['sum_float']; $amount = $array['sum_float'] < 0 ? $array['sum_float'] * -1 : $array['sum_float'];
$currencyData[$key]['entries'][$category] = $amount; $currencyData[$key]['entries'][$category] = $amount;
} }
return $currencyData; return $currencyData;
} }
} }

View File

@@ -124,7 +124,6 @@ class WholePeriodChartGenerator
*/ */
protected function calculateStep(Carbon $start, Carbon $end): string protected function calculateStep(Carbon $start, Carbon $end): string
{ {
$step = '1D'; $step = '1D';
$months = $start->diffInMonths($end); $months = $start->diffInMonths($end);
if ($months > 3) { if ($months > 3) {
@@ -165,5 +164,4 @@ class WholePeriodChartGenerator
return $return; return $return;
} }
} }

View File

@@ -74,5 +74,4 @@ abstract class AbstractCronjob
{ {
$this->force = $force; $this->force = $force;
} }
} }

View File

@@ -34,7 +34,6 @@ use Log;
*/ */
class AutoBudgetCronjob extends AbstractCronjob class AutoBudgetCronjob extends AbstractCronjob
{ {
/** /**
* @inheritDoc * @inheritDoc
*/ */

View File

@@ -34,7 +34,6 @@ use Log;
*/ */
class ExchangeRatesCronjob extends AbstractCronjob class ExchangeRatesCronjob extends AbstractCronjob
{ {
/** /**
* @inheritDoc * @inheritDoc
*/ */

View File

@@ -340,7 +340,6 @@ class ExpandedForm
*/ */
public function password(string $name, array $options = null): string public function password(string $name, array $options = null): string
{ {
$label = $this->label($name, $options); $label = $this->label($name, $options);
$options = $this->expandOptionArray($name, $label, $options); $options = $this->expandOptionArray($name, $label, $options);
$classes = $this->getHolderClasses($name); $classes = $this->getHolderClasses($name);

View File

@@ -82,7 +82,7 @@ class ExportDataGenerator
public function __construct() public function __construct()
{ {
$this->accounts = new Collection; $this->accounts = new Collection();
$this->start = today(config('app.timezone')); $this->start = today(config('app.timezone'));
$this->start->subYear(); $this->start->subYear();
$this->end = today(config('app.timezone')); $this->end = today(config('app.timezone'));
@@ -310,7 +310,6 @@ class ExportDataGenerator
} }
return $string; return $string;
} }
/** /**
@@ -737,7 +736,6 @@ class ExportDataGenerator
$metaData['recurrence_total'], $metaData['recurrence_total'],
$metaData['recurrence_count'], $metaData['recurrence_count'],
]; ];
} }
//load the CSV document from a string //load the CSV document from a string
@@ -883,5 +881,4 @@ class ExportDataGenerator
{ {
$this->user = $user; $this->user = $user;
} }
} }

View File

@@ -35,7 +35,6 @@ use Illuminate\Database\QueryException;
*/ */
class FireflyConfig class FireflyConfig
{ {
/** /**
* @param string $name * @param string $name
*/ */
@@ -97,7 +96,7 @@ class FireflyConfig
try { try {
$config = Configuration::whereName($name)->whereNull('deleted_at')->first(); $config = Configuration::whereName($name)->whereNull('deleted_at')->first();
} catch (QueryException|Exception $e) { // @phpstan-ignore-line } catch (QueryException|Exception $e) { // @phpstan-ignore-line
$item = new Configuration; $item = new Configuration();
$item->name = $name; $item->name = $name;
$item->data = $value; $item->data = $value;
@@ -105,7 +104,7 @@ class FireflyConfig
} }
if (null === $config) { if (null === $config) {
$item = new Configuration; $item = new Configuration();
$item->name = $name; $item->name = $name;
$item->data = $value; $item->data = $value;
$item->save(); $item->save();
@@ -128,10 +127,8 @@ class FireflyConfig
*/ */
public function getFresh(string $name, $default = null): ?Configuration public function getFresh(string $name, $default = null): ?Configuration
{ {
$config = Configuration::where('name', $name)->first(['id', 'name', 'data']); $config = Configuration::where('name', $name)->first(['id', 'name', 'data']);
if ($config) { if ($config) {
return $config; return $config;
} }
// no preference found and default is null: // no preference found and default is null:

View File

@@ -224,5 +224,4 @@ class CurrencyForm
return $this->select($name, $array, $value, $options); return $this->select($name, $array, $value, $options);
} }
} }

View File

@@ -87,7 +87,6 @@ trait ConvertsExchangeRates
$entry['native_decimal_places'] = $native->decimal_places; $entry['native_decimal_places'] = $native->decimal_places;
} }
$return[] = $entry; $return[] = $entry;
} }
return $return; return $return;
} }
@@ -267,5 +266,4 @@ trait ConvertsExchangeRates
{ {
$this->enabled = true; $this->enabled = true;
} }
} }

View File

@@ -59,7 +59,7 @@ trait AugumentData
$combined = []; $combined = [];
/** @var Account $expenseAccount */ /** @var Account $expenseAccount */
foreach ($accounts as $expenseAccount) { foreach ($accounts as $expenseAccount) {
$collection = new Collection; $collection = new Collection();
$collection->push($expenseAccount); $collection->push($expenseAccount);
$revenue = $repository->findByName($expenseAccount->name, [AccountType::REVENUE]); $revenue = $repository->findByName($expenseAccount->name, [AccountType::REVENUE]);
@@ -200,7 +200,7 @@ trait AugumentData
/** @var BudgetLimitRepositoryInterface $blRepository */ /** @var BudgetLimitRepositoryInterface $blRepository */
$blRepository = app(BudgetLimitRepositoryInterface::class); $blRepository = app(BudgetLimitRepositoryInterface::class);
// properties for cache // properties for cache
$cache = new CacheProperties; $cache = new CacheProperties();
$cache->addProperty($start); $cache->addProperty($start);
$cache->addProperty($end); $cache->addProperty($end);
$cache->addProperty($budget->id); $cache->addProperty($budget->id);
@@ -240,7 +240,6 @@ trait AugumentData
*/ */
protected function groupByName(array $array): array // filter + group data protected function groupByName(array $array): array // filter + group data
{ {
// group by opposing account name. // group by opposing account name.
$grouped = []; $grouped = [];
/** @var array $journal */ /** @var array $journal */

View File

@@ -52,7 +52,6 @@ trait ChartGeneration
*/ */
protected function accountBalanceChart(Collection $accounts, Carbon $start, Carbon $end): array // chart helper method. protected function accountBalanceChart(Collection $accounts, Carbon $start, Carbon $end): array // chart helper method.
{ {
// chart properties for cache: // chart properties for cache:
$cache = new CacheProperties(); $cache = new CacheProperties();
$cache->addProperty($start); $cache->addProperty($start);

View File

@@ -39,7 +39,6 @@ use phpseclib3\Crypt\RSA;
*/ */
trait CreateStuff trait CreateStuff
{ {
/** /**
* Creates an asset account. * Creates an asset account.
* *
@@ -61,7 +60,7 @@ trait CreateStuff
'active' => true, 'active' => true,
'account_role' => 'defaultAsset', 'account_role' => 'defaultAsset',
'opening_balance' => $request->input('bank_balance'), 'opening_balance' => $request->input('bank_balance'),
'opening_balance_date' => new Carbon, 'opening_balance_date' => new Carbon(),
'currency_id' => $currency->id, 'currency_id' => $currency->id,
]; ];
@@ -120,7 +119,7 @@ trait CreateStuff
if (class_exists(LegacyRSA::class)) { if (class_exists(LegacyRSA::class)) {
// PHP 7 // PHP 7
Log::info('Will run PHP7 code.'); Log::info('Will run PHP7 code.');
$keys = (new LegacyRSA)->createKey(4096); $keys = (new LegacyRSA())->createKey(4096);
} }
if (!class_exists(LegacyRSA::class)) { if (!class_exists(LegacyRSA::class)) {
@@ -158,7 +157,7 @@ trait CreateStuff
'active' => true, 'active' => true,
'account_role' => 'savingAsset', 'account_role' => 'savingAsset',
'opening_balance' => $request->input('savings_balance'), 'opening_balance' => $request->input('savings_balance'),
'opening_balance_date' => new Carbon, 'opening_balance_date' => new Carbon(),
'currency_id' => $currency->id, 'currency_id' => $currency->id,
]; ];
$repository->store($savingsAccount); $repository->store($savingsAccount);
@@ -182,5 +181,4 @@ trait CreateStuff
] ]
); );
} }
} }

View File

@@ -93,8 +93,5 @@ trait CronRunner
'job_errored' => $recurring->jobErrored, 'job_errored' => $recurring->jobErrored,
'message' => $recurring->message, 'message' => $recurring->message,
]; ];
} }
} }

View File

@@ -84,7 +84,6 @@ trait DateCalculation
*/ */
protected function calculateStep(Carbon $start, Carbon $end): string protected function calculateStep(Carbon $start, Carbon $end): string
{ {
$step = '1D'; $step = '1D';
$months = $start->diffInMonths($end); $months = $start->diffInMonths($end);
if ($months > 3) { if ($months > 3) {
@@ -167,5 +166,4 @@ trait DateCalculation
return $loop; return $loop;
} }
} }

View File

@@ -140,26 +140,26 @@ trait GetConfigurationData
// last seven days: // last seven days:
$seven = Carbon::now()->subDays(7); $seven = Carbon::now()->subDays(7);
$index = (string) trans('firefly.last_seven_days'); $index = (string) trans('firefly.last_seven_days');
$ranges[$index] = [$seven, new Carbon]; $ranges[$index] = [$seven, new Carbon()];
// last 30 days: // last 30 days:
$thirty = Carbon::now()->subDays(30); $thirty = Carbon::now()->subDays(30);
$index = (string) trans('firefly.last_thirty_days'); $index = (string) trans('firefly.last_thirty_days');
$ranges[$index] = [$thirty, new Carbon]; $ranges[$index] = [$thirty, new Carbon()];
// month to date: // month to date:
$monthBegin = Carbon::now()->startOfMonth(); $monthBegin = Carbon::now()->startOfMonth();
$index = (string) trans('firefly.month_to_date'); $index = (string) trans('firefly.month_to_date');
$ranges[$index] = [$monthBegin, new Carbon]; $ranges[$index] = [$monthBegin, new Carbon()];
// year to date: // year to date:
$yearBegin = Carbon::now()->startOfYear(); $yearBegin = Carbon::now()->startOfYear();
$index = (string) trans('firefly.year_to_date'); $index = (string) trans('firefly.year_to_date');
$ranges[$index] = [$yearBegin, new Carbon]; $ranges[$index] = [$yearBegin, new Carbon()];
// everything // everything
$index = (string) trans('firefly.everything'); $index = (string) trans('firefly.everything');
$ranges[$index] = [$first, new Carbon]; $ranges[$index] = [$first, new Carbon()];
return [ return [
'title' => $title, 'title' => $title,

View File

@@ -119,7 +119,6 @@ trait ModelInformation
$triggers = []; $triggers = [];
foreach ($operators as $key => $operator) { foreach ($operators as $key => $operator) {
if ('user_action' !== $key && false === $operator['alias']) { if ('user_action' !== $key && false === $operator['alias']) {
$triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key)); $triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
} }
} }
@@ -146,7 +145,6 @@ trait ModelInformation
] ]
)->render(); )->render();
} catch (Throwable $e) { // @phpstan-ignore-line } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Throwable was thrown in getTriggersForBill(): %s', $e->getMessage())); Log::debug(sprintf('Throwable was thrown in getTriggersForBill(): %s', $e->getMessage()));
Log::debug($e->getTraceAsString()); Log::debug($e->getTraceAsString());
$string = ''; $string = '';
@@ -171,7 +169,6 @@ trait ModelInformation
$triggers = []; $triggers = [];
foreach ($operators as $key => $operator) { foreach ($operators as $key => $operator) {
if ('user_action' !== $key && false === $operator['alias']) { if ('user_action' !== $key && false === $operator['alias']) {
$triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key)); $triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
} }
} }
@@ -262,7 +259,6 @@ trait ModelInformation
] ]
)->render(); )->render();
} catch (Throwable $e) { // @phpstan-ignore-line } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Throwable was thrown in getTriggersForJournal(): %s', $e->getMessage())); Log::debug(sprintf('Throwable was thrown in getTriggersForJournal(): %s', $e->getMessage()));
Log::debug($e->getTraceAsString()); Log::debug($e->getTraceAsString());
$string = ''; $string = '';

View File

@@ -88,7 +88,7 @@ trait PeriodOverview
[$start, $end] = $end < $start ? [$end, $start] : [$start, $end]; [$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
// properties for cache // properties for cache
$cache = new CacheProperties; $cache = new CacheProperties();
$cache->addProperty($start); $cache->addProperty($start);
$cache->addProperty($end); $cache->addProperty($end);
$cache->addProperty('account-show-period-entries'); $cache->addProperty('account-show-period-entries');
@@ -252,12 +252,10 @@ trait PeriodOverview
'currency_symbol' => $journal['foreign_currency_symbol'], 'currency_symbol' => $journal['foreign_currency_symbol'],
'currency_decimal_places' => $journal['foreign_currency_decimal_places'], 'currency_decimal_places' => $journal['foreign_currency_decimal_places'],
]; ];
} }
$return[$foreignCurrencyId]['count']++; $return[$foreignCurrencyId]['count']++;
$return[$foreignCurrencyId]['amount'] = bcadd($return[$foreignCurrencyId]['amount'], $journal['foreign_amount']); $return[$foreignCurrencyId]['amount'] = bcadd($return[$foreignCurrencyId]['amount'], $journal['foreign_amount']);
} }
} }
return $return; return $return;
@@ -361,7 +359,7 @@ trait PeriodOverview
[$start, $end] = $end < $start ? [$end, $start] : [$start, $end]; [$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
$cache = new CacheProperties; $cache = new CacheProperties();
$cache->addProperty($start); $cache->addProperty($start);
$cache->addProperty($end); $cache->addProperty($end);
$cache->addProperty('no-budget-period-entries'); $cache->addProperty('no-budget-period-entries');
@@ -415,7 +413,7 @@ trait PeriodOverview
Log::debug(sprintf('Now in getNoCategoryPeriodOverview(%s)', $theDate->format('Y-m-d'))); Log::debug(sprintf('Now in getNoCategoryPeriodOverview(%s)', $theDate->format('Y-m-d')));
$range = app('preferences')->get('viewRange', '1M')->data; $range = app('preferences')->get('viewRange', '1M')->data;
$first = $this->journalRepos->firstNull(); $first = $this->journalRepos->firstNull();
$start = null === $first ? new Carbon : $first->date; $start = null === $first ? new Carbon() : $first->date;
$end = $theDate ?? today(config('app.timezone')); $end = $theDate ?? today(config('app.timezone'));
Log::debug(sprintf('Start for getNoCategoryPeriodOverview() is %s', $start->format('Y-m-d'))); Log::debug(sprintf('Start for getNoCategoryPeriodOverview() is %s', $start->format('Y-m-d')));
@@ -484,12 +482,11 @@ trait PeriodOverview
*/ */
protected function getTagPeriodOverview(Tag $tag, Carbon $start, Carbon $end): array // period overview for tags. protected function getTagPeriodOverview(Tag $tag, Carbon $start, Carbon $end): array // period overview for tags.
{ {
$range = app('preferences')->get('viewRange', '1M')->data; $range = app('preferences')->get('viewRange', '1M')->data;
[$start, $end] = $end < $start ? [$end, $start] : [$start, $end]; [$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
// properties for cache // properties for cache
$cache = new CacheProperties; $cache = new CacheProperties();
$cache->addProperty($start); $cache->addProperty($start);
$cache->addProperty($end); $cache->addProperty($end);
$cache->addProperty('tag-period-entries'); $cache->addProperty('tag-period-entries');
@@ -565,7 +562,7 @@ trait PeriodOverview
[$start, $end] = $end < $start ? [$end, $start] : [$start, $end]; [$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
// properties for cache // properties for cache
$cache = new CacheProperties; $cache = new CacheProperties();
$cache->addProperty($start); $cache->addProperty($start);
$cache->addProperty($end); $cache->addProperty($end);
$cache->addProperty('transactions-period-entries'); $cache->addProperty('transactions-period-entries');

View File

@@ -44,7 +44,6 @@ use Throwable;
*/ */
trait RenderPartialViews trait RenderPartialViews
{ {
/** /**
* View for transactions in a budget for an account. * View for transactions in a budget for an account.
* *
@@ -114,7 +113,7 @@ trait RenderPartialViews
$budget = $budgetRepository->find((int) $attributes['budgetId']); $budget = $budgetRepository->find((int) $attributes['budgetId']);
if (null === $budget) { if (null === $budget) {
$budget = new Budget; $budget = new Budget();
} }
$journals = $popupHelper->byBudget($budget, $attributes); $journals = $popupHelper->byBudget($budget, $attributes);
@@ -276,7 +275,6 @@ trait RenderPartialViews
'count' => $count, 'count' => $count,
] ]
)->render(); )->render();
} catch (Throwable $e) { // @phpstan-ignore-line } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Throwable was thrown in getCurrentActions(): %s', $e->getMessage())); Log::debug(sprintf('Throwable was thrown in getCurrentActions(): %s', $e->getMessage()));
Log::error($e->getTraceAsString()); Log::error($e->getTraceAsString());
@@ -303,7 +301,6 @@ trait RenderPartialViews
$triggers = []; $triggers = [];
foreach ($operators as $key => $operator) { foreach ($operators as $key => $operator) {
if ('user_action' !== $key && false === $operator['alias']) { if ('user_action' !== $key && false === $operator['alias']) {
$triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key)); $triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
} }
} }
@@ -318,7 +315,7 @@ trait RenderPartialViews
$count = ($index + 1); $count = ($index + 1);
try { try {
$rootOperator = OperatorQuerySearch::getRootOperator($entry->trigger_type); $rootOperator = OperatorQuerySearch::getRootOperator($entry->trigger_type);
if(str_starts_with($rootOperator, '-')) { if (str_starts_with($rootOperator, '-')) {
$rootOperator = substr($rootOperator, 1); $rootOperator = substr($rootOperator, 1);
} }
$renderedEntries[] = view( $renderedEntries[] = view(
@@ -332,7 +329,6 @@ trait RenderPartialViews
'triggers' => $triggers, 'triggers' => $triggers,
] ]
)->render(); )->render();
} catch (Throwable $e) { // @phpstan-ignore-line } catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Throwable was thrown in getCurrentTriggers(): %s', $e->getMessage())); Log::debug(sprintf('Throwable was thrown in getCurrentTriggers(): %s', $e->getMessage()));
Log::error($e->getTraceAsString()); Log::error($e->getTraceAsString());
@@ -384,7 +380,6 @@ trait RenderPartialViews
*/ */
protected function noReportOptions(): string // render a view protected function noReportOptions(): string // render a view
{ {
try { try {
$result = view('reports.options.no-options')->render(); $result = view('reports.options.no-options')->render();
} catch (Throwable $e) { // @phpstan-ignore-line } catch (Throwable $e) { // @phpstan-ignore-line

View File

@@ -228,5 +228,4 @@ trait RequestInformation
] ]
); );
} }
} }

View File

@@ -35,7 +35,6 @@ use Throwable;
*/ */
trait RuleManagement trait RuleManagement
{ {
/** /**
* @param Request $request * @param Request $request
* *
@@ -83,7 +82,6 @@ trait RuleManagement
$triggers = []; $triggers = [];
foreach ($operators as $key => $operator) { foreach ($operators as $key => $operator) {
if ('user_action' !== $key && false === $operator['alias']) { if ('user_action' !== $key && false === $operator['alias']) {
$triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key)); $triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
} }
} }
@@ -130,7 +128,6 @@ trait RuleManagement
$triggers = []; $triggers = [];
foreach ($operators as $key => $operator) { foreach ($operators as $key => $operator) {
if ('user_action' !== $key && false === $operator['alias']) { if ('user_action' !== $key && false === $operator['alias']) {
$triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key)); $triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
} }
} }

View File

@@ -183,5 +183,4 @@ trait TransactionCalculation
return $collector->getExtractedJournals(); return $collector->getExtractedJournals();
} }
} }

View File

@@ -39,7 +39,6 @@ use Log;
*/ */
trait UserNavigation trait UserNavigation
{ {
/** /**
* Functionality:. * Functionality:.
* *

View File

@@ -44,13 +44,12 @@ class AuditLogger
*/ */
public function __invoke(Logger $logger) public function __invoke(Logger $logger)
{ {
$processor = new AuditProcessor; $processor = new AuditProcessor();
/** @var AbstractProcessingHandler $handler */ /** @var AbstractProcessingHandler $handler */
foreach ($logger->getHandlers() as $handler) { foreach ($logger->getHandlers() as $handler) {
$formatter = new LineFormatter("[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n"); $formatter = new LineFormatter("[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n");
$handler->setFormatter($formatter); $handler->setFormatter($formatter);
$handler->pushProcessor($processor); $handler->pushProcessor($processor);
} }
} }
} }

View File

@@ -39,13 +39,13 @@ class AuditProcessor
public function __invoke(array $record): array public function __invoke(array $record): array
{ {
if (auth()->check()) { if (auth()->check()) {
$record['message'] = sprintf( $record['message'] = sprintf(
'AUDIT: %s (%s (%s) -> %s:%s)', 'AUDIT: %s (%s (%s) -> %s:%s)',
$record['message'], $record['message'],
app('request')->ip(), app('request')->ip(),
auth()->user()->email, auth()->user()->email,
request()->method(), request()->url() request()->method(),
request()->url()
); );
return $record; return $record;
@@ -55,7 +55,8 @@ class AuditProcessor
'AUDIT: %s (%s -> %s:%s)', 'AUDIT: %s (%s -> %s:%s)',
$record['message'], $record['message'],
app('request')->ip(), app('request')->ip(),
request()->method(), request()->url() request()->method(),
request()->url()
); );
return $record; return $record;

View File

@@ -207,7 +207,6 @@ class Navigation
Log::error(sprintf('Cannot do startOfPeriod for $repeat_freq "%s"', $repeatFreq)); Log::error(sprintf('Cannot do startOfPeriod for $repeat_freq "%s"', $repeatFreq));
return $theDate; return $theDate;
} }
/** /**
@@ -426,7 +425,6 @@ class Navigation
Log::error(sprintf('No date formats for frequency "%s"!', $repeatFrequency)); Log::error(sprintf('No date formats for frequency "%s"!', $repeatFrequency));
return $date->format('Y-m-d'); return $date->format('Y-m-d');
} }
/** /**
@@ -585,12 +583,12 @@ class Navigation
switch ($repeatFreq) { switch ($repeatFreq) {
default: default:
break; break;
case 'last7'; case 'last7':
$date->subDays(7); $date->subDays(7);
return $date; return $date;
case 'last30'; case 'last30':
$date->subDays(30); $date->subDays(30);
return $date; return $date;
case 'last90': case 'last90':
$date->subDays(90); $date->subDays(90);
return $date; return $date;
@@ -658,8 +656,8 @@ class Navigation
switch ($range) { switch ($range) {
default: default:
break; break;
case 'last7'; case 'last7':
case 'last30'; case 'last30':
case 'last90': case 'last90':
case 'last365': case 'last365':
case 'YTD': case 'YTD':
@@ -715,12 +713,12 @@ class Navigation
switch ($range) { switch ($range) {
default: default:
break; break;
case 'last7'; case 'last7':
$start->subDays(7); $start->subDays(7);
return $start; return $start;
case 'last30'; case 'last30':
$start->subDays(30); $start->subDays(30);
return $start; return $start;
case 'last90': case 'last90':
$start->subDays(90); $start->subDays(90);
return $start; return $start;

View File

@@ -95,7 +95,6 @@ class ParseDateString
// if + or -: // if + or -:
if (str_starts_with($date, '+') || str_starts_with($date, '-')) { if (str_starts_with($date, '+') || str_starts_with($date, '-')) {
return $this->parseRelativeDate($date); return $this->parseRelativeDate($date);
} }
if ('xxxx-xx-xx' === strtolower($date)) { if ('xxxx-xx-xx' === strtolower($date)) {
@@ -204,7 +203,6 @@ class ParseDateString
Log::debug(sprintf('Will now do %s(%d) on %s', $func, $number, $today->format('Y-m-d'))); Log::debug(sprintf('Will now do %s(%d) on %s', $func, $number, $today->format('Y-m-d')));
$today->$func($number); $today->$func($number);
Log::debug(sprintf('Resulting date is %s', $today->format('Y-m-d'))); Log::debug(sprintf('Resulting date is %s', $today->format('Y-m-d')));
} }
return $today; return $today;
@@ -464,5 +462,4 @@ class ParseDateString
'month' => $parts[1], 'month' => $parts[1],
]; ];
} }
} }

View File

@@ -45,7 +45,7 @@ class Preferences
{ {
$user = auth()->user(); $user = auth()->user();
if (null === $user) { if (null === $user) {
return new Collection; return new Collection();
} }
return Preference::where('user_id', $user->id)->get(); return Preference::where('user_id', $user->id)->get();
@@ -139,7 +139,7 @@ class Preferences
/** @var User|null $user */ /** @var User|null $user */
$user = auth()->user(); $user = auth()->user();
if (null === $user) { if (null === $user) {
$preference = new Preference; $preference = new Preference();
$preference->data = $default; $preference->data = $default;
return $preference; return $preference;
@@ -183,7 +183,6 @@ class Preferences
} }
if (null !== $preference) { if (null !== $preference) {
return $preference; return $preference;
} }
// no preference found and default is null: // no preference found and default is null:
@@ -217,13 +216,13 @@ class Preferences
throw new FireflyException(sprintf('Could not delete preference: %s', $e->getMessage()), 0, $e); throw new FireflyException(sprintf('Could not delete preference: %s', $e->getMessage()), 0, $e);
} }
return new Preference; return new Preference();
} }
if (null === $value) { if (null === $value) {
return new Preference; return new Preference();
} }
if (null === $pref) { if (null === $pref) {
$pref = new Preference; $pref = new Preference();
$pref->user_id = $user->id; $pref->user_id = $user->id;
$pref->name = $name; $pref->name = $name;
} }
@@ -269,7 +268,7 @@ class Preferences
/** @var User|null $user */ /** @var User|null $user */
$user = auth()->user(); $user = auth()->user();
if (null === $user) { if (null === $user) {
$preference = new Preference; $preference = new Preference();
$preference->data = $default; $preference->data = $default;
return $preference; return $preference;
@@ -299,7 +298,7 @@ class Preferences
$user = auth()->user(); $user = auth()->user();
if (null === $user) { if (null === $user) {
// make new preference, return it: // make new preference, return it:
$pref = new Preference; $pref = new Preference();
$pref->name = $name; $pref->name = $name;
$pref->data = $value; $pref->data = $value;

View File

@@ -69,7 +69,6 @@ class BudgetReportGenerator
*/ */
public function accountPerBudget(): void public function accountPerBudget(): void
{ {
$spent = $this->opsRepository->listExpenses($this->start, $this->end, $this->accounts, $this->budgets); $spent = $this->opsRepository->listExpenses($this->start, $this->end, $this->accounts, $this->budgets);
$this->report = []; $this->report = [];
/** @var Account $account */ /** @var Account $account */
@@ -87,7 +86,6 @@ class BudgetReportGenerator
foreach ($spent as $currency) { foreach ($spent as $currency) {
$this->processExpenses($currency); $this->processExpenses($currency);
} }
} }
/** /**
@@ -251,7 +249,6 @@ class BudgetReportGenerator
$noBudget = $this->nbRepository->sumExpenses($this->start, $this->end, $this->accounts); $noBudget = $this->nbRepository->sumExpenses($this->start, $this->end, $this->accounts);
foreach ($noBudget as $noBudgetEntry) { foreach ($noBudget as $noBudgetEntry) {
// currency information: // currency information:
$nbCurrencyId = (int) ($noBudgetEntry['currency_id'] ?? $this->currency->id); $nbCurrencyId = (int) ($noBudgetEntry['currency_id'] ?? $this->currency->id);
$nbCurrencyCode = $noBudgetEntry['currency_code'] ?? $this->currency->code; $nbCurrencyCode = $noBudgetEntry['currency_code'] ?? $this->currency->code;

View File

@@ -210,5 +210,4 @@ class CategoryReportGenerator
$this->noCatRepository->setUser($user); $this->noCatRepository->setUser($user);
$this->opsRepository->setUser($user); $this->opsRepository->setUser($user);
} }
} }

View File

@@ -32,7 +32,6 @@ use Illuminate\Support\Facades\Log;
*/ */
trait CalculateRangeOccurrences trait CalculateRangeOccurrences
{ {
/** /**
* Get the number of daily occurrences for a recurring transaction until date $end is reached. Will skip every $skipMod-1 occurrences. * Get the number of daily occurrences for a recurring transaction until date $end is reached. Will skip every $skipMod-1 occurrences.
* *
@@ -185,7 +184,6 @@ trait CalculateRangeOccurrences
$return = []; $return = [];
if ($start > $date) { if ($start > $date) {
$date->addYear(); $date->addYear();
} }
// is $date between $start and $end? // is $date between $start and $end?
@@ -201,6 +199,5 @@ trait CalculateRangeOccurrences
} }
return $return; return $return;
} }
} }

View File

@@ -31,7 +31,6 @@ use Carbon\Carbon;
*/ */
trait CalculateXOccurrences trait CalculateXOccurrences
{ {
/** /**
* Calculates the number of daily occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip * Calculates the number of daily occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip
* over $skipMod -1 recurrences. * over $skipMod -1 recurrences.
@@ -210,6 +209,5 @@ trait CalculateXOccurrences
} }
return $return; return $return;
} }
} }

View File

@@ -32,7 +32,6 @@ use Log;
*/ */
trait CalculateXOccurrencesSince trait CalculateXOccurrencesSince
{ {
/** /**
* Calculates the number of daily occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip * Calculates the number of daily occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip
* over $skipMod -1 recurrences. * over $skipMod -1 recurrences.
@@ -234,6 +233,5 @@ trait CalculateXOccurrencesSince
} }
return $return; return $return;
} }
} }

View File

@@ -34,7 +34,6 @@ use Illuminate\Support\Facades\Log;
*/ */
trait FiltersWeekends trait FiltersWeekends
{ {
/** /**
* Filters out all weekend entries, if necessary. * Filters out all weekend entries, if necessary.
* *

View File

@@ -240,13 +240,12 @@ trait AppendsLocationData
$zoomLevelKey = $this->getLocationKey($prefix, 'zoom_level'); $zoomLevelKey = $this->getLocationKey($prefix, 'zoom_level');
return ( return (
null === $this->get($longitudeKey) null === $this->get($longitudeKey)
&& null === $this->get($latitudeKey) && null === $this->get($latitudeKey)
&& null === $this->get($zoomLevelKey)) && null === $this->get($zoomLevelKey))
&& ('PUT' === $this->method() && (
|| ('POST' === $this->method() && $this->routeIs('*.update')) 'PUT' === $this->method()
|| ('POST' === $this->method() && $this->routeIs('*.update'))
); );
} }
} }

View File

@@ -28,5 +28,4 @@ namespace FireflyIII\Support\Request;
*/ */
trait ConvertAPIDataTypes trait ConvertAPIDataTypes
{ {
} }

View File

@@ -314,5 +314,4 @@ trait ConvertsDataTypes
return (int) $value; return (int) $value;
} }
} }

View File

@@ -86,5 +86,4 @@ trait GetRecurrenceData
return $return; return $return;
} }
} }

View File

@@ -28,7 +28,6 @@ namespace FireflyIII\Support\Request;
*/ */
trait GetRuleConfiguration trait GetRuleConfiguration
{ {
/** /**
* @return array * @return array
*/ */

View File

@@ -59,7 +59,6 @@ class AccountSearch implements GenericSearchInterface
*/ */
public function search(): Collection public function search(): Collection
{ {
$searchQuery = $this->user->accounts() $searchQuery = $this->user->accounts()
->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id') ->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id')
->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id') ->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
@@ -140,5 +139,4 @@ class AccountSearch implements GenericSearchInterface
{ {
$this->user = $user; $this->user = $user;
} }
} }

View File

@@ -35,5 +35,4 @@ interface GenericSearchInterface
* @return Collection * @return Collection
*/ */
public function search(): Collection; public function search(): Collection;
} }

View File

@@ -88,7 +88,7 @@ class OperatorQuerySearch implements SearchInterface
public function __construct() public function __construct()
{ {
Log::debug('Constructed OperatorQuerySearch'); Log::debug('Constructed OperatorQuerySearch');
$this->operators = new Collection; $this->operators = new Collection();
$this->page = 1; $this->page = 1;
$this->words = []; $this->words = [];
$this->prohibitedWords = []; $this->prohibitedWords = [];
@@ -241,7 +241,6 @@ class OperatorQuerySearch implements SearchInterface
]; ];
} }
} }
} }
/** /**
@@ -267,13 +266,13 @@ class OperatorQuerySearch implements SearchInterface
default: default:
Log::error(sprintf('No such operator: %s', $operator)); Log::error(sprintf('No such operator: %s', $operator));
throw new FireflyException(sprintf('Unsupported search operator: "%s"', $operator)); throw new FireflyException(sprintf('Unsupported search operator: "%s"', $operator));
// some search operators are ignored, basically: // some search operators are ignored, basically:
case 'user_action': case 'user_action':
Log::info(sprintf('Ignore search operator "%s"', $operator)); Log::info(sprintf('Ignore search operator "%s"', $operator));
return false; return false;
// //
// all account related searches: // all account related searches:
// //
case 'account_is': case 'account_is':
$this->searchAccount($value, 3, 4); $this->searchAccount($value, 3, 4);
@@ -475,7 +474,7 @@ class OperatorQuerySearch implements SearchInterface
break; break;
case 'account_id': case 'account_id':
$parts = explode(',', $value); $parts = explode(',', $value);
$collection = new Collection; $collection = new Collection();
foreach ($parts as $accountId) { foreach ($parts as $accountId) {
$account = $this->accountRepository->find((int) $accountId); $account = $this->accountRepository->find((int) $accountId);
if (null !== $account) { if (null !== $account) {
@@ -491,7 +490,7 @@ class OperatorQuerySearch implements SearchInterface
break; break;
case '-account_id': case '-account_id':
$parts = explode(',', $value); $parts = explode(',', $value);
$collection = new Collection; $collection = new Collection();
foreach ($parts as $accountId) { foreach ($parts as $accountId) {
$account = $this->accountRepository->find((int) $accountId); $account = $this->accountRepository->find((int) $accountId);
if (null !== $account) { if (null !== $account) {
@@ -506,7 +505,7 @@ class OperatorQuerySearch implements SearchInterface
} }
break; break;
// //
// cash account // cash account
// //
case 'source_is_cash': case 'source_is_cash':
$account = $this->getCashAccount(); $account = $this->getCashAccount();
@@ -533,7 +532,7 @@ class OperatorQuerySearch implements SearchInterface
$this->collector->excludeAccounts(new Collection([$account])); $this->collector->excludeAccounts(new Collection([$account]));
break; break;
// //
// description // description
// //
case 'description_starts': case 'description_starts':
$this->collector->descriptionStarts([$value]); $this->collector->descriptionStarts([$value]);
@@ -562,7 +561,7 @@ class OperatorQuerySearch implements SearchInterface
$this->collector->descriptionIsNot($value); $this->collector->descriptionIsNot($value);
break; break;
// //
// currency // currency
// //
case 'currency_is': case 'currency_is':
$currency = $this->findCurrency($value); $currency = $this->findCurrency($value);
@@ -601,7 +600,7 @@ class OperatorQuerySearch implements SearchInterface
} }
break; break;
// //
// attachments // attachments
// //
case 'has_attachments': case 'has_attachments':
case '-has_no_attachments': case '-has_no_attachments':
@@ -614,7 +613,7 @@ class OperatorQuerySearch implements SearchInterface
$this->collector->hasNoAttachments(); $this->collector->hasNoAttachments();
break; break;
// //
// categories // categories
case '-has_any_category': case '-has_any_category':
case 'has_no_category': case 'has_no_category':
$this->collector->withoutCategory(); $this->collector->withoutCategory();
@@ -693,7 +692,7 @@ class OperatorQuerySearch implements SearchInterface
} }
break; break;
// //
// budgets // budgets
// //
case '-has_any_budget': case '-has_any_budget':
case 'has_no_budget': case 'has_no_budget':
@@ -774,7 +773,7 @@ class OperatorQuerySearch implements SearchInterface
} }
break; break;
// //
// bill // bill
// //
case '-has_any_bill': case '-has_any_bill':
case 'has_no_bill': case 'has_no_bill':
@@ -853,7 +852,7 @@ class OperatorQuerySearch implements SearchInterface
} }
break; break;
// //
// tags // tags
// //
case '-has_any_tag': case '-has_any_tag':
case 'has_no_tag': case 'has_no_tag':
@@ -883,7 +882,7 @@ class OperatorQuerySearch implements SearchInterface
} }
break; break;
// //
// notes // notes
// //
case 'notes_contains': case 'notes_contains':
$this->collector->notesContain($value); $this->collector->notesContain($value);
@@ -924,7 +923,7 @@ class OperatorQuerySearch implements SearchInterface
$this->collector->isNotReconciled(); $this->collector->isNotReconciled();
break; break;
// //
// amount // amount
// //
case 'amount_is': case 'amount_is':
// strip comma's, make dots. // strip comma's, make dots.
@@ -997,7 +996,7 @@ class OperatorQuerySearch implements SearchInterface
$this->collector->foreignAmountMore($amount); $this->collector->foreignAmountMore($amount);
break; break;
// //
// transaction type // transaction type
// //
case 'transaction_type': case 'transaction_type':
$this->collector->setTypes([ucfirst($value)]); $this->collector->setTypes([ucfirst($value)]);
@@ -1008,7 +1007,7 @@ class OperatorQuerySearch implements SearchInterface
Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $value)); Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $value));
break; break;
// //
// dates // dates
// //
case '-date_on': case '-date_on':
case 'date_on': case 'date_on':
@@ -1160,7 +1159,7 @@ class OperatorQuerySearch implements SearchInterface
$this->setObjectDateAfterParams('updated_at', $range); $this->setObjectDateAfterParams('updated_at', $range);
return false; return false;
// //
// external URL // external URL
// //
case '-any_external_url': case '-any_external_url':
case 'no_external_url': case 'no_external_url':
@@ -1197,7 +1196,7 @@ class OperatorQuerySearch implements SearchInterface
break; break;
// //
// other fields // other fields
// //
case 'external_id_is': case 'external_id_is':
$this->collector->setExternalId($value); $this->collector->setExternalId($value);
@@ -1310,7 +1309,6 @@ class OperatorQuerySearch implements SearchInterface
case '-exists': case '-exists':
$this->collector->findNothing(); $this->collector->findNothing();
break; break;
} }
return true; return true;
} }
@@ -1550,7 +1548,7 @@ class OperatorQuerySearch implements SearchInterface
*/ */
private function parseDateRange(string $value): array private function parseDateRange(string $value): array
{ {
$parser = new ParseDateString; $parser = new ParseDateString();
if ($parser->isDateRange($value)) { if ($parser->isDateRange($value)) {
return $parser->parseRange($value); return $parser->parseRange($value);
} }
@@ -2044,7 +2042,6 @@ class OperatorQuerySearch implements SearchInterface
$this->collector->withAccountInformation()->withCategoryInformation()->withBudgetInformation(); $this->collector->withAccountInformation()->withCategoryInformation()->withBudgetInformation();
$this->setLimit((int) app('preferences')->getForUser($user, 'listPageSize', 50)->data); $this->setLimit((int) app('preferences')->getForUser($user, 'listPageSize', 50)->data);
} }
/** /**

View File

@@ -43,7 +43,6 @@ use ValueError;
*/ */
class Steam class Steam
{ {
/** /**
* @param Account $account * @param Account $account
* @param Carbon $date * @param Carbon $date
@@ -53,7 +52,7 @@ class Steam
public function balanceIgnoreVirtual(Account $account, Carbon $date): string public function balanceIgnoreVirtual(Account $account, Carbon $date): string
{ {
// abuse chart properties: // abuse chart properties:
$cache = new CacheProperties; $cache = new CacheProperties();
$cache->addProperty($account->id); $cache->addProperty($account->id);
$cache->addProperty('balance-no-virtual'); $cache->addProperty('balance-no-virtual');
$cache->addProperty($date); $cache->addProperty($date);
@@ -124,7 +123,7 @@ class Steam
public function balanceInRange(Account $account, Carbon $start, Carbon $end, ?TransactionCurrency $currency = null): array public function balanceInRange(Account $account, Carbon $start, Carbon $end, ?TransactionCurrency $currency = null): array
{ {
// abuse chart properties: // abuse chart properties:
$cache = new CacheProperties; $cache = new CacheProperties();
$cache->addProperty($account->id); $cache->addProperty($account->id);
$cache->addProperty('balance-in-range'); $cache->addProperty('balance-in-range');
$cache->addProperty($currency ? $currency->id : 0); $cache->addProperty($currency ? $currency->id : 0);
@@ -210,7 +209,7 @@ class Steam
public function balance(Account $account, Carbon $date, ?TransactionCurrency $currency = null): string public function balance(Account $account, Carbon $date, ?TransactionCurrency $currency = null): string
{ {
// abuse chart properties: // abuse chart properties:
$cache = new CacheProperties; $cache = new CacheProperties();
$cache->addProperty($account->id); $cache->addProperty($account->id);
$cache->addProperty('balance'); $cache->addProperty('balance');
$cache->addProperty($date); $cache->addProperty($date);
@@ -259,7 +258,7 @@ class Steam
{ {
$ids = $accounts->pluck('id')->toArray(); $ids = $accounts->pluck('id')->toArray();
// cache this property. // cache this property.
$cache = new CacheProperties; $cache = new CacheProperties();
$cache->addProperty($ids); $cache->addProperty($ids);
$cache->addProperty('balances'); $cache->addProperty('balances');
$cache->addProperty($date); $cache->addProperty($date);
@@ -292,7 +291,7 @@ class Steam
{ {
$ids = $accounts->pluck('id')->toArray(); $ids = $accounts->pluck('id')->toArray();
// cache this property. // cache this property.
$cache = new CacheProperties; $cache = new CacheProperties();
$cache->addProperty($ids); $cache->addProperty($ids);
$cache->addProperty('balances-per-currency'); $cache->addProperty('balances-per-currency');
$cache->addProperty($date); $cache->addProperty($date);
@@ -321,7 +320,7 @@ class Steam
public function balancePerCurrency(Account $account, Carbon $date): array public function balancePerCurrency(Account $account, Carbon $date): array
{ {
// abuse chart properties: // abuse chart properties:
$cache = new CacheProperties; $cache = new CacheProperties();
$cache->addProperty($account->id); $cache->addProperty($account->id);
$cache->addProperty('balance-per-currency'); $cache->addProperty('balance-per-currency');
$cache->addProperty($date); $cache->addProperty($date);

View File

@@ -58,5 +58,4 @@ trait GeneratesInstallationId
app('fireflyconfig')->set('installation_id', $uniqueId); app('fireflyconfig')->set('installation_id', $uniqueId);
} }
} }
} }

View File

@@ -146,5 +146,4 @@ class OAuthKeys
file_put_contents($public, $publicContent); file_put_contents($public, $publicContent);
return true; return true;
} }
} }

View File

@@ -120,11 +120,10 @@ class AmountFormat extends AbstractExtension
{ {
return new TwigFunction( return new TwigFunction(
'formatAmountBySymbol', 'formatAmountBySymbol',
static function (string $amount, string $symbol, int $decimalPlaces = null, bool $coloured = null): string { static function (string $amount, string $symbol, int $decimalPlaces = null, bool $coloured = null): string {
$decimalPlaces = $decimalPlaces ?? 2; $decimalPlaces = $decimalPlaces ?? 2;
$coloured = $coloured ?? true; $coloured = $coloured ?? true;
$currency = new TransactionCurrency; $currency = new TransactionCurrency();
$currency->symbol = $symbol; $currency->symbol = $symbol;
$currency->decimal_places = $decimalPlaces; $currency->decimal_places = $decimalPlaces;

View File

@@ -114,7 +114,7 @@ class General extends AbstractExtension
return 'fa-file-o'; return 'fa-file-o';
case 'application/pdf': case 'application/pdf':
return 'fa-file-pdf-o'; return 'fa-file-pdf-o';
/* image */ /* image */
case 'image/png': case 'image/png':
case 'image/jpeg': case 'image/jpeg':
case 'image/svg+xml': case 'image/svg+xml':
@@ -122,7 +122,7 @@ class General extends AbstractExtension
case 'image/heic-sequence': case 'image/heic-sequence':
case 'application/vnd.oasis.opendocument.image': case 'application/vnd.oasis.opendocument.image':
return 'fa-file-image-o'; return 'fa-file-image-o';
/* MS word */ /* MS word */
case 'application/msword': case 'application/msword':
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.template': case 'application/vnd.openxmlformats-officedocument.wordprocessingml.template':
@@ -137,7 +137,7 @@ class General extends AbstractExtension
case 'application/vnd.oasis.opendocument.text-web': case 'application/vnd.oasis.opendocument.text-web':
case 'application/vnd.oasis.opendocument.text-master': case 'application/vnd.oasis.opendocument.text-master':
return 'fa-file-word-o'; return 'fa-file-word-o';
/* MS excel */ /* MS excel */
case 'application/vnd.ms-excel': case 'application/vnd.ms-excel':
case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
case 'application/vnd.openxmlformats-officedocument.spreadsheetml.template': case 'application/vnd.openxmlformats-officedocument.spreadsheetml.template':
@@ -147,7 +147,7 @@ class General extends AbstractExtension
case 'application/vnd.oasis.opendocument.spreadsheet': case 'application/vnd.oasis.opendocument.spreadsheet':
case 'application/vnd.oasis.opendocument.spreadsheet-template': case 'application/vnd.oasis.opendocument.spreadsheet-template':
return 'fa-file-excel-o'; return 'fa-file-excel-o';
/* MS powerpoint */ /* MS powerpoint */
case 'application/vnd.ms-powerpoint': case 'application/vnd.ms-powerpoint':
case 'application/vnd.openxmlformats-officedocument.presentationml.presentation': case 'application/vnd.openxmlformats-officedocument.presentationml.presentation':
case 'application/vnd.openxmlformats-officedocument.presentationml.template': case 'application/vnd.openxmlformats-officedocument.presentationml.template':
@@ -158,7 +158,7 @@ class General extends AbstractExtension
case 'application/vnd.oasis.opendocument.presentation': case 'application/vnd.oasis.opendocument.presentation':
case 'application/vnd.oasis.opendocument.presentation-template': case 'application/vnd.oasis.opendocument.presentation-template':
return 'fa-file-powerpoint-o'; return 'fa-file-powerpoint-o';
/* calc */ /* calc */
case 'application/vnd.sun.xml.draw': case 'application/vnd.sun.xml.draw':
case 'application/vnd.sun.xml.draw.template': case 'application/vnd.sun.xml.draw.template':
case 'application/vnd.stardivision.draw': case 'application/vnd.stardivision.draw':
@@ -171,7 +171,6 @@ class General extends AbstractExtension
case 'application/vnd.oasis.opendocument.formula': case 'application/vnd.oasis.opendocument.formula':
case 'application/vnd.oasis.opendocument.database': case 'application/vnd.oasis.opendocument.database':
return 'fa-calculator'; return 'fa-calculator';
} }
}, },
['is_safe' => ['html']] ['is_safe' => ['html']]
@@ -184,9 +183,8 @@ class General extends AbstractExtension
protected function markdown(): TwigFilter protected function markdown(): TwigFilter
{ {
return new TwigFilter( return new TwigFilter(
'markdown', 'markdown',
static function (string $text): string { static function (string $text): string {
$converter = new GithubFlavoredMarkdownConverter( $converter = new GithubFlavoredMarkdownConverter(
[ [
'allow_unsafe_links' => false, 'allow_unsafe_links' => false,
@@ -196,7 +194,8 @@ class General extends AbstractExtension
); );
return (string) $converter->convert($text); return (string) $converter->convert($text);
}, ['is_safe' => ['html']] },
['is_safe' => ['html']]
); );
} }

View File

@@ -112,7 +112,6 @@ class TransactionGroupTwig extends AbstractExtension
*/ */
private function signAmount(string $amount, string $transactionType, string $sourceType): string private function signAmount(string $amount, string $transactionType, string $sourceType): string
{ {
// withdrawals stay negative // withdrawals stay negative
if ($transactionType !== TransactionType::WITHDRAWAL) { if ($transactionType !== TransactionType::WITHDRAWAL) {
$amount = bcmul($amount, '-1'); $amount = bcmul($amount, '-1');

Some files were not shown because too many files have changed in this diff Show More