Code cleanup.

This commit is contained in:
James Cole 2018-04-02 14:42:07 +02:00
parent f96f38b172
commit 7d02d0f762
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
55 changed files with 200 additions and 281 deletions

View File

@ -80,19 +80,19 @@ class TransactionRequest extends Request
$array = [ $array = [
'description' => $transaction['description'] ?? null, 'description' => $transaction['description'] ?? null,
'amount' => $transaction['amount'], 'amount' => $transaction['amount'],
'currency_id' => isset($transaction['currency_id']) ? intval($transaction['currency_id']) : null, 'currency_id' => isset($transaction['currency_id']) ? (int)$transaction['currency_id'] : null,
'currency_code' => isset($transaction['currency_code']) ? $transaction['currency_code'] : null, 'currency_code' => $transaction['currency_code'] ?? null,
'foreign_amount' => $transaction['foreign_amount'] ?? null, 'foreign_amount' => $transaction['foreign_amount'] ?? null,
'foreign_currency_id' => isset($transaction['foreign_currency_id']) ? intval($transaction['foreign_currency_id']) : null, 'foreign_currency_id' => isset($transaction['foreign_currency_id']) ? (int)$transaction['foreign_currency_id'] : null,
'foreign_currency_code' => $transaction['foreign_currency_code'] ?? null, 'foreign_currency_code' => $transaction['foreign_currency_code'] ?? null,
'budget_id' => isset($transaction['budget_id']) ? intval($transaction['budget_id']) : null, 'budget_id' => isset($transaction['budget_id']) ? (int)$transaction['budget_id'] : null,
'budget_name' => $transaction['budget_name'] ?? null, 'budget_name' => $transaction['budget_name'] ?? null,
'category_id' => isset($transaction['category_id']) ? intval($transaction['category_id']) : null, 'category_id' => isset($transaction['category_id']) ? (int)$transaction['category_id'] : null,
'category_name' => $transaction['category_name'] ?? null, 'category_name' => $transaction['category_name'] ?? null,
'source_id' => isset($transaction['source_id']) ? intval($transaction['source_id']) : null, 'source_id' => isset($transaction['source_id']) ? (int)$transaction['source_id'] : null,
'source_name' => isset($transaction['source_name']) ? strval($transaction['source_name']) : null, 'source_name' => isset($transaction['source_name']) ? (string)$transaction['source_name'] : null,
'destination_id' => isset($transaction['destination_id']) ? intval($transaction['destination_id']) : null, 'destination_id' => isset($transaction['destination_id']) ? (int)$transaction['destination_id'] : null,
'destination_name' => isset($transaction['destination_name']) ? strval($transaction['destination_name']) : null, 'destination_name' => isset($transaction['destination_name']) ? (string)$transaction['destination_name'] : null,
'reconciled' => $transaction['reconciled'] ?? false, 'reconciled' => $transaction['reconciled'] ?? false,
'identifier' => $index, 'identifier' => $index,
]; ];
@ -199,8 +199,8 @@ class TransactionRequest extends Request
protected function assetAccountExists(Validator $validator, ?int $accountId, ?string $accountName, string $idField, string $nameField): ?Account protected function assetAccountExists(Validator $validator, ?int $accountId, ?string $accountName, string $idField, string $nameField): ?Account
{ {
$accountId = intval($accountId); $accountId = (int)$accountId;
$accountName = strval($accountName); $accountName = (string)$accountName;
// both empty? hard exit. // both empty? hard exit.
if ($accountId < 1 && strlen($accountName) === 0) { if ($accountId < 1 && strlen($accountName) === 0) {
$validator->errors()->add($idField, trans('validation.filled', ['attribute' => $idField])); $validator->errors()->add($idField, trans('validation.filled', ['attribute' => $idField]));
@ -226,7 +226,7 @@ class TransactionRequest extends Request
} }
$account = $repository->findByNameNull($accountName, [AccountType::ASSET]); $account = $repository->findByNameNull($accountName, [AccountType::ASSET]);
if (is_null($account)) { if (null === $account) {
$validator->errors()->add($nameField, trans('validation.belongs_user')); $validator->errors()->add($nameField, trans('validation.belongs_user'));
return null; return null;
@ -260,10 +260,10 @@ class TransactionRequest extends Request
{ {
$data = $validator->getData(); $data = $validator->getData();
$transactions = $data['transactions'] ?? []; $transactions = $data['transactions'] ?? [];
$journalDescription = strval($data['description'] ?? ''); $journalDescription = (string)($data['description'] ?? '');
$validDescriptions = 0; $validDescriptions = 0;
foreach ($transactions as $index => $transaction) { foreach ($transactions as $index => $transaction) {
if (strlen(strval($transaction['description'] ?? '')) > 0) { if (strlen((string)($transaction['description'] ?? '')) > 0) {
$validDescriptions++; $validDescriptions++;
} }
} }
@ -286,7 +286,7 @@ class TransactionRequest extends Request
$data = $validator->getData(); $data = $validator->getData();
$transactions = $data['transactions'] ?? []; $transactions = $data['transactions'] ?? [];
foreach ($transactions as $index => $transaction) { foreach ($transactions as $index => $transaction) {
$description = strval($transaction['description'] ?? ''); $description = (string)($transaction['description'] ?? '');
// filled description is mandatory for split transactions. // filled description is mandatory for split transactions.
if (count($transactions) > 1 && strlen($description) === 0) { if (count($transactions) > 1 && strlen($description) === 0) {
$validator->errors()->add( $validator->errors()->add(
@ -306,9 +306,9 @@ class TransactionRequest extends Request
{ {
$data = $validator->getData(); $data = $validator->getData();
$transactions = $data['transactions'] ?? []; $transactions = $data['transactions'] ?? [];
$journalDescription = strval($data['description'] ?? ''); $journalDescription = (string)($data['description'] ?? '');
foreach ($transactions as $index => $transaction) { foreach ($transactions as $index => $transaction) {
$description = strval($transaction['description'] ?? ''); $description = (string)($transaction['description'] ?? '');
// description cannot be equal to journal description. // description cannot be equal to journal description.
if ($description === $journalDescription) { if ($description === $journalDescription) {
$validator->errors()->add('transactions.' . $index . '.description', trans('validation.equal_description')); $validator->errors()->add('transactions.' . $index . '.description', trans('validation.equal_description'));
@ -352,8 +352,8 @@ class TransactionRequest extends Request
*/ */
protected function opposingAccountExists(Validator $validator, string $type, ?int $accountId, ?string $accountName, string $idField): ?Account protected function opposingAccountExists(Validator $validator, string $type, ?int $accountId, ?string $accountName, string $idField): ?Account
{ {
$accountId = intval($accountId); $accountId = (int)$accountId;
$accountName = strval($accountName); $accountName = (string)$accountName;
// both empty? done! // both empty? done!
if ($accountId < 1 && strlen($accountName) === 0) { if ($accountId < 1 && strlen($accountName) === 0) {
return null; return null;
@ -397,15 +397,15 @@ class TransactionRequest extends Request
// the journal may exist in the request: // the journal may exist in the request:
/** @var Transaction $transaction */ /** @var Transaction $transaction */
$transaction = $this->route()->parameter('transaction'); $transaction = $this->route()->parameter('transaction');
if (is_null($transaction)) { if (null === $transaction) {
return; // @codeCoverageIgnore return; // @codeCoverageIgnore
} }
$data['type'] = strtolower($transaction->transactionJournal->transactionType->type); $data['type'] = strtolower($transaction->transactionJournal->transactionType->type);
} }
foreach ($transactions as $index => $transaction) { foreach ($transactions as $index => $transaction) {
$sourceId = isset($transaction['source_id']) ? intval($transaction['source_id']) : null; $sourceId = isset($transaction['source_id']) ? (int)$transaction['source_id'] : null;
$sourceName = $transaction['source_name'] ?? null; $sourceName = $transaction['source_name'] ?? null;
$destinationId = isset($transaction['destination_id']) ? intval($transaction['destination_id']) : null; $destinationId = isset($transaction['destination_id']) ? (int)$transaction['destination_id'] : null;
$destinationName = $transaction['destination_name'] ?? null; $destinationName = $transaction['destination_name'] ?? null;
$sourceAccount = null; $sourceAccount = null;
$destinationAccount = null; $destinationAccount = null;
@ -479,8 +479,8 @@ class TransactionRequest extends Request
$destinations = []; $destinations = [];
foreach ($data['transactions'] as $transaction) { foreach ($data['transactions'] as $transaction) {
$sources[] = isset($transaction['source_id']) ? intval($transaction['source_id']) : 0; $sources[] = isset($transaction['source_id']) ? (int)$transaction['source_id'] : 0;
$destinations[] = isset($transaction['destination_id']) ? intval($transaction['destination_id']) : 0; $destinations[] = isset($transaction['destination_id']) ? (int)$transaction['destination_id'] : 0;
} }
$destinations = array_unique($destinations); $destinations = array_unique($destinations);
$sources = array_unique($sources); $sources = array_unique($sources);

View File

@ -129,5 +129,7 @@ class CreateExport extends Command
$this->line('The export has finished! You can find the ZIP file in this location:'); $this->line('The export has finished! You can find the ZIP file in this location:');
$this->line(storage_path(sprintf('export/%s', $fileName))); $this->line(storage_path(sprintf('export/%s', $fileName)));
return 0;
} }
} }

View File

@ -47,14 +47,6 @@ class DecryptAttachment extends Command
= 'firefly:decrypt-attachment {id:The ID of the attachment.} {name:The file name of the attachment.} = 'firefly:decrypt-attachment {id:The ID of the attachment.} {name:The file name of the attachment.}
{directory:Where the file must be stored.}'; {directory:Where the file must be stored.}';
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
/** /**
* Execute the console command. * Execute the console command.
* *
@ -65,7 +57,7 @@ class DecryptAttachment extends Command
{ {
/** @var AttachmentRepositoryInterface $repository */ /** @var AttachmentRepositoryInterface $repository */
$repository = app(AttachmentRepositoryInterface::class); $repository = app(AttachmentRepositoryInterface::class);
$attachmentId = intval($this->argument('id')); $attachmentId = (int)$this->argument('id');
$attachment = $repository->findWithoutUser($attachmentId); $attachment = $repository->findWithoutUser($attachmentId);
$attachmentName = trim($this->argument('name')); $attachmentName = trim($this->argument('name'));
$storagePath = realpath(trim($this->argument('directory'))); $storagePath = realpath(trim($this->argument('directory')));

View File

@ -48,14 +48,6 @@ class Import extends Command
*/ */
protected $signature = 'firefly:start-import {key}'; protected $signature = 'firefly:start-import {key}';
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
/** /**
* Run the import routine. * Run the import routine.
* *

View File

@ -48,14 +48,6 @@ class ScanAttachments extends Command
*/ */
protected $signature = 'firefly:scan-attachments'; protected $signature = 'firefly:scan-attachments';
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
/** /**
* Execute the console command. * Execute the console command.
*/ */

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Console\Commands; namespace FireflyIII\Console\Commands;
use DB; use DB;
use Exception;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\AccountMeta; use FireflyIII\Models\AccountMeta;
use FireflyIII\Models\AccountType; use FireflyIII\Models\AccountType;
@ -64,18 +65,8 @@ class UpgradeDatabase extends Command
*/ */
protected $signature = 'firefly:upgrade-database'; protected $signature = 'firefly:upgrade-database';
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
/** /**
* Execute the console command. * Execute the console command.
*
* @throws \Exception
*/ */
public function handle() public function handle()
{ {
@ -120,7 +111,7 @@ class UpgradeDatabase extends Command
$journalIds = array_unique($result->pluck('id')->toArray()); $journalIds = array_unique($result->pluck('id')->toArray());
foreach ($journalIds as $journalId) { foreach ($journalIds as $journalId) {
$this->updateJournalidentifiers(intval($journalId)); $this->updateJournalidentifiers((int)$journalId);
} }
return; return;
@ -142,9 +133,9 @@ class UpgradeDatabase extends Command
// get users preference, fall back to system pref. // get users preference, fall back to system pref.
$defaultCurrencyCode = Preferences::getForUser($account->user, 'currencyPreference', config('firefly.default_currency', 'EUR'))->data; $defaultCurrencyCode = Preferences::getForUser($account->user, 'currencyPreference', config('firefly.default_currency', 'EUR'))->data;
$defaultCurrency = TransactionCurrency::where('code', $defaultCurrencyCode)->first(); $defaultCurrency = TransactionCurrency::where('code', $defaultCurrencyCode)->first();
$accountCurrency = intval($account->getMeta('currency_id')); $accountCurrency = (int)$account->getMeta('currency_id');
$openingBalance = $account->getOpeningBalance(); $openingBalance = $account->getOpeningBalance();
$obCurrency = intval($openingBalance->transaction_currency_id); $obCurrency = (int)$openingBalance->transaction_currency_id;
// both 0? set to default currency: // both 0? set to default currency:
if (0 === $accountCurrency && 0 === $obCurrency) { if (0 === $accountCurrency && 0 === $obCurrency) {
@ -211,7 +202,7 @@ class UpgradeDatabase extends Command
} }
/** @var Account $account */ /** @var Account $account */
$account = $transaction->account; $account = $transaction->account;
$currency = $repository->find(intval($account->getMeta('currency_id'))); $currency = $repository->find((int)$account->getMeta('currency_id'));
$transactions = $journal->transactions()->get(); $transactions = $journal->transactions()->get();
$transactions->each( $transactions->each(
function (Transaction $transaction) use ($currency) { function (Transaction $transaction) use ($currency) {
@ -221,8 +212,8 @@ class UpgradeDatabase extends Command
} }
// when mismatch in transaction: // when mismatch in transaction:
if (!(intval($transaction->transaction_currency_id) === intval($currency->id))) { if (!((int)$transaction->transaction_currency_id === (int)$currency->id)) {
$transaction->foreign_currency_id = intval($transaction->transaction_currency_id); $transaction->foreign_currency_id = (int)$transaction->transaction_currency_id;
$transaction->foreign_amount = $transaction->amount; $transaction->foreign_amount = $transaction->amount;
$transaction->transaction_currency_id = $currency->id; $transaction->transaction_currency_id = $currency->id;
$transaction->save(); $transaction->save();
@ -274,11 +265,11 @@ class UpgradeDatabase extends Command
{ {
// create transaction type "Reconciliation". // create transaction type "Reconciliation".
$type = TransactionType::where('type', TransactionType::RECONCILIATION)->first(); $type = TransactionType::where('type', TransactionType::RECONCILIATION)->first();
if (is_null($type)) { if (null === $type) {
TransactionType::create(['type' => TransactionType::RECONCILIATION]); TransactionType::create(['type' => TransactionType::RECONCILIATION]);
} }
$account = AccountType::where('type', AccountType::RECONCILIATION)->first(); $account = AccountType::where('type', AccountType::RECONCILIATION)->first();
if (is_null($account)) { if (null === $account) {
AccountType::create(['type' => AccountType::RECONCILIATION]); AccountType::create(['type' => AccountType::RECONCILIATION]);
} }
} }
@ -295,11 +286,11 @@ class UpgradeDatabase extends Command
foreach ($attachments as $att) { foreach ($attachments as $att) {
// move description: // move description:
$description = strval($att->description); $description = (string)$att->description;
if (strlen($description) > 0) { if (strlen($description) > 0) {
// find or create note: // find or create note:
$note = $att->notes()->first(); $note = $att->notes()->first();
if (is_null($note)) { if (null === $note) {
$note = new Note; $note = new Note;
$note->noteable()->associate($att); $note->noteable()->associate($att);
} }
@ -317,8 +308,6 @@ class UpgradeDatabase extends Command
/** /**
* Move all the journal_meta notes to their note object counter parts. * Move all the journal_meta notes to their note object counter parts.
*
* @throws \Exception
*/ */
private function migrateNotes(): void private function migrateNotes(): void
{ {
@ -335,7 +324,11 @@ class UpgradeDatabase extends Command
$note->text = $meta->data; $note->text = $meta->data;
$note->save(); $note->save();
Log::debug(sprintf('Migrated meta note #%d to Note #%d', $meta->id, $note->id)); Log::debug(sprintf('Migrated meta note #%d to Note #%d', $meta->id, $note->id));
$meta->delete(); try {
$meta->delete();
} catch (Exception $e) {
Log::error(sprintf('Could not delete old meta entry #%d: %s', $meta->id, $e->getMessage()));
}
} }
} }
@ -348,10 +341,10 @@ class UpgradeDatabase extends Command
{ {
/** @var CurrencyRepositoryInterface $repository */ /** @var CurrencyRepositoryInterface $repository */
$repository = app(CurrencyRepositoryInterface::class); $repository = app(CurrencyRepositoryInterface::class);
$currency = $repository->find(intval($transaction->account->getMeta('currency_id'))); $currency = $repository->find((int)$transaction->account->getMeta('currency_id'));
$journal = $transaction->transactionJournal; $journal = $transaction->transactionJournal;
if (!(intval($currency->id) === intval($journal->transaction_currency_id))) { if (!((int)$currency->id === (int)$journal->transaction_currency_id)) {
$this->line( $this->line(
sprintf( sprintf(
'Transfer #%d ("%s") has been updated to use %s instead of %s.', 'Transfer #%d ("%s") has been updated to use %s instead of %s.',
@ -382,7 +375,7 @@ class UpgradeDatabase extends Command
/** @var Transaction $transaction */ /** @var Transaction $transaction */
foreach ($transactions as $transaction) { foreach ($transactions as $transaction) {
// find opposing: // find opposing:
$amount = bcmul(strval($transaction->amount), '-1'); $amount = bcmul((string)$transaction->amount, '-1');
try { try {
/** @var Transaction $opposing */ /** @var Transaction $opposing */
@ -432,18 +425,18 @@ class UpgradeDatabase extends Command
{ {
/** @var CurrencyRepositoryInterface $repository */ /** @var CurrencyRepositoryInterface $repository */
$repository = app(CurrencyRepositoryInterface::class); $repository = app(CurrencyRepositoryInterface::class);
$currency = $repository->find(intval($transaction->account->getMeta('currency_id'))); $currency = $repository->find((int)$transaction->account->getMeta('currency_id'));
// has no currency ID? Must have, so fill in using account preference: // has no currency ID? Must have, so fill in using account preference:
if (null === $transaction->transaction_currency_id) { if (null === $transaction->transaction_currency_id) {
$transaction->transaction_currency_id = intval($currency->id); $transaction->transaction_currency_id = (int)$currency->id;
Log::debug(sprintf('Transaction #%d has no currency setting, now set to %s', $transaction->id, $currency->code)); Log::debug(sprintf('Transaction #%d has no currency setting, now set to %s', $transaction->id, $currency->code));
$transaction->save(); $transaction->save();
} }
// does not match the source account (see above)? Can be fixed // does not match the source account (see above)? Can be fixed
// when mismatch in transaction and NO foreign amount is set: // when mismatch in transaction and NO foreign amount is set:
if (!(intval($transaction->transaction_currency_id) === intval($currency->id)) && null === $transaction->foreign_amount) { if (!((int)$transaction->transaction_currency_id === (int)$currency->id) && null === $transaction->foreign_amount) {
Log::debug( Log::debug(
sprintf( sprintf(
'Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.', 'Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.',
@ -453,7 +446,7 @@ class UpgradeDatabase extends Command
$transaction->amount $transaction->amount
) )
); );
$transaction->transaction_currency_id = intval($currency->id); $transaction->transaction_currency_id = (int)$currency->id;
$transaction->save(); $transaction->save();
} }
@ -462,7 +455,7 @@ class UpgradeDatabase extends Command
$journal = $transaction->transactionJournal; $journal = $transaction->transactionJournal;
/** @var Transaction $opposing */ /** @var Transaction $opposing */
$opposing = $journal->transactions()->where('amount', '>', 0)->where('identifier', $transaction->identifier)->first(); $opposing = $journal->transactions()->where('amount', '>', 0)->where('identifier', $transaction->identifier)->first();
$opposingCurrency = $repository->find(intval($opposing->account->getMeta('currency_id'))); $opposingCurrency = $repository->find((int)$opposing->account->getMeta('currency_id'));
if (null === $opposingCurrency->id) { if (null === $opposingCurrency->id) {
Log::error(sprintf('Account #%d ("%s") must have currency preference but has none.', $opposing->account->id, $opposing->account->name)); Log::error(sprintf('Account #%d ("%s") must have currency preference but has none.', $opposing->account->id, $opposing->account->name));
@ -471,7 +464,7 @@ class UpgradeDatabase extends Command
} }
// if the destination account currency is the same, both foreign_amount and foreign_currency_id must be NULL for both transactions: // if the destination account currency is the same, both foreign_amount and foreign_currency_id must be NULL for both transactions:
if (intval($opposingCurrency->id) === intval($currency->id)) { if ((int)$opposingCurrency->id === (int)$currency->id) {
// update both transactions to match: // update both transactions to match:
$transaction->foreign_amount = null; $transaction->foreign_amount = null;
$transaction->foreign_currency_id = null; $transaction->foreign_currency_id = null;
@ -485,7 +478,7 @@ class UpgradeDatabase extends Command
return; return;
} }
// if destination account currency is different, both transactions must have this currency as foreign currency id. // if destination account currency is different, both transactions must have this currency as foreign currency id.
if (!(intval($opposingCurrency->id) === intval($currency->id))) { if (!((int)$opposingCurrency->id === (int)$currency->id)) {
$transaction->foreign_currency_id = $opposingCurrency->id; $transaction->foreign_currency_id = $opposingCurrency->id;
$opposing->foreign_currency_id = $opposingCurrency->id; $opposing->foreign_currency_id = $opposingCurrency->id;
$transaction->save(); $transaction->save();
@ -495,14 +488,14 @@ class UpgradeDatabase extends Command
// if foreign amount of one is null and the other is not, use this to restore: // if foreign amount of one is null and the other is not, use this to restore:
if (null === $transaction->foreign_amount && null !== $opposing->foreign_amount) { if (null === $transaction->foreign_amount && null !== $opposing->foreign_amount) {
$transaction->foreign_amount = bcmul(strval($opposing->foreign_amount), '-1'); $transaction->foreign_amount = bcmul((string)$opposing->foreign_amount, '-1');
$transaction->save(); $transaction->save();
Log::debug(sprintf('Restored foreign amount of transaction (1) #%d to %s', $transaction->id, $transaction->foreign_amount)); Log::debug(sprintf('Restored foreign amount of transaction (1) #%d to %s', $transaction->id, $transaction->foreign_amount));
} }
// if foreign amount of one is null and the other is not, use this to restore (other way around) // if foreign amount of one is null and the other is not, use this to restore (other way around)
if (null === $opposing->foreign_amount && null !== $transaction->foreign_amount) { if (null === $opposing->foreign_amount && null !== $transaction->foreign_amount) {
$opposing->foreign_amount = bcmul(strval($transaction->foreign_amount), '-1'); $opposing->foreign_amount = bcmul((string)$transaction->foreign_amount, '-1');
$opposing->save(); $opposing->save();
Log::debug(sprintf('Restored foreign amount of transaction (2) #%d to %s', $opposing->id, $opposing->foreign_amount)); Log::debug(sprintf('Restored foreign amount of transaction (2) #%d to %s', $opposing->id, $opposing->foreign_amount));
} }
@ -512,14 +505,14 @@ class UpgradeDatabase extends Command
$foreignAmount = $journal->getMeta('foreign_amount'); $foreignAmount = $journal->getMeta('foreign_amount');
if (null === $foreignAmount) { if (null === $foreignAmount) {
Log::debug(sprintf('Journal #%d has missing foreign currency data, forced to do 1:1 conversion :(.', $transaction->transaction_journal_id)); Log::debug(sprintf('Journal #%d has missing foreign currency data, forced to do 1:1 conversion :(.', $transaction->transaction_journal_id));
$transaction->foreign_amount = bcmul(strval($transaction->amount), '-1'); $transaction->foreign_amount = bcmul((string)$transaction->amount, '-1');
$opposing->foreign_amount = bcmul(strval($opposing->amount), '-1'); $opposing->foreign_amount = bcmul((string)$opposing->amount, '-1');
$transaction->save(); $transaction->save();
$opposing->save(); $opposing->save();
return; return;
} }
$foreignPositive = app('steam')->positive(strval($foreignAmount)); $foreignPositive = app('steam')->positive((string)$foreignAmount);
Log::debug( Log::debug(
sprintf( sprintf(
'Journal #%d has missing foreign currency info, try to restore from meta-data ("%s").', 'Journal #%d has missing foreign currency info, try to restore from meta-data ("%s").',

View File

@ -42,14 +42,6 @@ class UpgradeFireflyInstructions extends Command
*/ */
protected $signature = 'firefly:instructions {task}'; protected $signature = 'firefly:instructions {task}';
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
/** /**
* Execute the console command. * Execute the console command.
*/ */

View File

@ -44,14 +44,6 @@ class UseEncryption extends Command
*/ */
protected $signature = 'firefly:use-encryption'; protected $signature = 'firefly:use-encryption';
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
/** /**
* Execute the console command. * Execute the console command.
*/ */

View File

@ -61,14 +61,6 @@ class VerifyDatabase extends Command
*/ */
protected $signature = 'firefly:verify'; protected $signature = 'firefly:verify';
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
/** /**
* Execute the console command. * Execute the console command.
*/ */
@ -158,7 +150,7 @@ class VerifyDatabase extends Command
->get(['transaction_journal_id', DB::raw('SUM(amount) AS the_sum')]); ->get(['transaction_journal_id', DB::raw('SUM(amount) AS the_sum')]);
/** @var stdClass $entry */ /** @var stdClass $entry */
foreach ($journals as $entry) { foreach ($journals as $entry) {
if (0 !== bccomp(strval($entry->the_sum), '0')) { if (0 !== bccomp((string)$entry->the_sum, '0')) {
$errored[] = $entry->transaction_journal_id; $errored[] = $entry->transaction_journal_id;
} }
} }
@ -171,7 +163,7 @@ class VerifyDatabase extends Command
// report about it // report about it
/** @var TransactionJournal $journal */ /** @var TransactionJournal $journal */
$journal = TransactionJournal::find($journalId); $journal = TransactionJournal::find($journalId);
if (is_null($journal)) { if (null === $journal) {
continue; continue;
} }
if (TransactionType::OPENING_BALANCE === $journal->transactionType->type) { if (TransactionType::OPENING_BALANCE === $journal->transactionType->type) {
@ -297,7 +289,7 @@ class VerifyDatabase extends Command
); );
/** @var stdClass $entry */ /** @var stdClass $entry */
foreach ($set as $entry) { foreach ($set as $entry) {
$date = null === $entry->transaction_deleted_at ? $entry->journal_deleted_at : $entry->transaction_deleted_at; $date = $entry->transaction_deleted_at ?? $entry->journal_deleted_at;
$this->error( $this->error(
'Error: Account #' . $entry->account_id . ' should have been deleted, but has not.' . 'Error: Account #' . $entry->account_id . ' should have been deleted, but has not.' .
' Find it in the table called "accounts" and change the "deleted_at" field to: "' . $date . '"' ' Find it in the table called "accounts" and change the "deleted_at" field to: "' . $date . '"'
@ -448,7 +440,7 @@ class VerifyDatabase extends Command
/** @var User $user */ /** @var User $user */
foreach ($userRepository->all() as $user) { foreach ($userRepository->all() as $user) {
$sum = strval($user->transactions()->sum('amount')); $sum = (string)$user->transactions()->sum('amount');
if (0 !== bccomp($sum, '0')) { if (0 !== bccomp($sum, '0')) {
$this->error('Error: Transactions for user #' . $user->id . ' (' . $user->email . ') are off by ' . $sum . '!'); $this->error('Error: Transactions for user #' . $user->id . ' (' . $user->email . ') are off by ' . $sum . '!');
} else { } else {

View File

@ -118,7 +118,7 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface
*/ */
private function exportFileName($attachment): string private function exportFileName($attachment): string
{ {
return sprintf('%s-Attachment nr. %s - %s', $this->job->key, strval($attachment->id), $attachment->filename); return sprintf('%s-Attachment nr. %s - %s', $this->job->key, (string)$attachment->id, $attachment->filename);
} }
/** /**
@ -127,8 +127,7 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface
private function getAttachments(): Collection private function getAttachments(): Collection
{ {
$this->repository->setUser($this->user); $this->repository->setUser($this->user);
$attachments = $this->repository->getBetween($this->start, $this->end);
return $attachments; return $this->repository->getBetween($this->start, $this->end);
} }
} }

View File

@ -199,31 +199,29 @@ final class Entry
$entry->transaction_id = $transaction->id; $entry->transaction_id = $transaction->id;
$entry->date = $transaction->date->format('Ymd'); $entry->date = $transaction->date->format('Ymd');
$entry->description = $transaction->description; $entry->description = $transaction->description;
if (strlen(strval($transaction->transaction_description)) > 0) { if (strlen((string)$transaction->transaction_description) > 0) {
$entry->description = $transaction->transaction_description . '(' . $transaction->description . ')'; $entry->description = $transaction->transaction_description . '(' . $transaction->description . ')';
} }
$entry->currency_code = $transaction->transactionCurrency->code; $entry->currency_code = $transaction->transactionCurrency->code;
$entry->amount = strval(round($transaction->transaction_amount, $transaction->transactionCurrency->decimal_places)); $entry->amount = (string)round($transaction->transaction_amount, $transaction->transactionCurrency->decimal_places);
$entry->foreign_currency_code = null === $transaction->foreign_currency_id ? null : $transaction->foreignCurrency->code; $entry->foreign_currency_code = null === $transaction->foreign_currency_id ? null : $transaction->foreignCurrency->code;
$entry->foreign_amount = null === $transaction->foreign_currency_id $entry->foreign_amount = null === $transaction->foreign_currency_id
? null ? null
: strval( : (string)round(
round( $transaction->transaction_foreign_amount,
$transaction->transaction_foreign_amount, $transaction->foreignCurrency->decimal_places
$transaction->foreignCurrency->decimal_places
)
); );
$entry->transaction_type = $transaction->transaction_type_type; $entry->transaction_type = $transaction->transaction_type_type;
$entry->asset_account_id = strval($transaction->account_id); $entry->asset_account_id = (string)$transaction->account_id;
$entry->asset_account_name = app('steam')->tryDecrypt($transaction->account_name); $entry->asset_account_name = app('steam')->tryDecrypt($transaction->account_name);
$entry->asset_account_iban = $transaction->account_iban; $entry->asset_account_iban = $transaction->account_iban;
$entry->asset_account_number = $transaction->account_number; $entry->asset_account_number = $transaction->account_number;
$entry->asset_account_bic = $transaction->account_bic; $entry->asset_account_bic = $transaction->account_bic;
$entry->asset_currency_code = $transaction->account_currency_code; $entry->asset_currency_code = $transaction->account_currency_code;
$entry->opposing_account_id = strval($transaction->opposing_account_id); $entry->opposing_account_id = (string)$transaction->opposing_account_id;
$entry->opposing_account_name = app('steam')->tryDecrypt($transaction->opposing_account_name); $entry->opposing_account_name = app('steam')->tryDecrypt($transaction->opposing_account_name);
$entry->opposing_account_iban = $transaction->opposing_account_iban; $entry->opposing_account_iban = $transaction->opposing_account_iban;
$entry->opposing_account_number = $transaction->opposing_account_number; $entry->opposing_account_number = $transaction->opposing_account_number;
@ -231,7 +229,7 @@ final class Entry
$entry->opposing_currency_code = $transaction->opposing_currency_code; $entry->opposing_currency_code = $transaction->opposing_currency_code;
// budget // budget
$entry->budget_id = strval($transaction->transaction_budget_id); $entry->budget_id = (string)$transaction->transaction_budget_id;
$entry->budget_name = app('steam')->tryDecrypt($transaction->transaction_budget_name); $entry->budget_name = app('steam')->tryDecrypt($transaction->transaction_budget_name);
if (null === $transaction->transaction_budget_id) { if (null === $transaction->transaction_budget_id) {
$entry->budget_id = $transaction->transaction_journal_budget_id; $entry->budget_id = $transaction->transaction_journal_budget_id;
@ -239,7 +237,7 @@ final class Entry
} }
// category // category
$entry->category_id = strval($transaction->transaction_category_id); $entry->category_id = (string)$transaction->transaction_category_id;
$entry->category_name = app('steam')->tryDecrypt($transaction->transaction_category_name); $entry->category_name = app('steam')->tryDecrypt($transaction->transaction_category_name);
if (null === $transaction->transaction_category_id) { if (null === $transaction->transaction_category_id) {
$entry->category_id = $transaction->transaction_journal_category_id; $entry->category_id = $transaction->transaction_journal_category_id;
@ -247,7 +245,7 @@ final class Entry
} }
// budget // budget
$entry->bill_id = strval($transaction->bill_id); $entry->bill_id = (string)$transaction->bill_id;
$entry->bill_name = app('steam')->tryDecrypt($transaction->bill_name); $entry->bill_name = app('steam')->tryDecrypt($transaction->bill_name);
$entry->tags = $transaction->tags; $entry->tags = $transaction->tags;

View File

@ -118,11 +118,11 @@ class ExpandedProcessor implements ProcessorInterface
$currencies = $this->getAccountCurrencies($ibans); $currencies = $this->getAccountCurrencies($ibans);
$transactions->each( $transactions->each(
function (Transaction $transaction) use ($notes, $tags, $ibans, $currencies) { function (Transaction $transaction) use ($notes, $tags, $ibans, $currencies) {
$journalId = intval($transaction->journal_id); $journalId = (int)$transaction->journal_id;
$accountId = intval($transaction->account_id); $accountId = (int)$transaction->account_id;
$opposingId = intval($transaction->opposing_account_id); $opposingId = (int)$transaction->opposing_account_id;
$currencyId = $ibans[$accountId]['currency_id'] ?? 0; $currencyId = (int)($ibans[$accountId]['currency_id'] ?? 0.0);
$opposingCurrencyId = $ibans[$opposingId]['currency_id'] ?? 0; $opposingCurrencyId = (int)($ibans[$opposingId]['currency_id'] ?? 0.0);
$transaction->notes = $notes[$journalId] ?? ''; $transaction->notes = $notes[$journalId] ?? '';
$transaction->tags = implode(',', $tags[$journalId] ?? []); $transaction->tags = implode(',', $tags[$journalId] ?? []);
$transaction->account_number = $ibans[$accountId]['accountNumber'] ?? ''; $transaction->account_number = $ibans[$accountId]['accountNumber'] ?? '';
@ -263,7 +263,7 @@ class ExpandedProcessor implements ProcessorInterface
$ids = []; $ids = [];
$repository->setUser($this->job->user); $repository->setUser($this->job->user);
foreach ($array as $value) { foreach ($array as $value) {
$ids[] = $value['currency_id'] ?? 0; $ids[] = (int)($value['currency_id'] ?? 0.0);
} }
$ids = array_unique($ids); $ids = array_unique($ids);
$result = $repository->getByIds($ids); $result = $repository->getByIds($ids);
@ -293,7 +293,7 @@ class ExpandedProcessor implements ProcessorInterface
->get(['account_meta.id', 'account_meta.account_id', 'account_meta.name', 'account_meta.data']); ->get(['account_meta.id', 'account_meta.account_id', 'account_meta.name', 'account_meta.data']);
/** @var AccountMeta $meta */ /** @var AccountMeta $meta */
foreach ($set as $meta) { foreach ($set as $meta) {
$id = intval($meta->account_id); $id = (int)$meta->account_id;
$return[$id][$meta->name] = $meta->data; $return[$id][$meta->name] = $meta->data;
} }
@ -316,8 +316,8 @@ class ExpandedProcessor implements ProcessorInterface
$return = []; $return = [];
/** @var Note $note */ /** @var Note $note */
foreach ($notes as $note) { foreach ($notes as $note) {
if (strlen(trim(strval($note->text))) > 0) { if (strlen(trim((string)$note->text)) > 0) {
$id = intval($note->noteable_id); $id = (int)$note->noteable_id;
$return[$id] = $note->text; $return[$id] = $note->text;
} }
} }
@ -343,8 +343,8 @@ class ExpandedProcessor implements ProcessorInterface
->get(['tag_transaction_journal.transaction_journal_id', 'tags.tag']); ->get(['tag_transaction_journal.transaction_journal_id', 'tags.tag']);
$result = []; $result = [];
foreach ($set as $entry) { foreach ($set as $entry) {
$id = intval($entry->transaction_journal_id); $id = (int)$entry->transaction_journal_id;
$result[$id] = isset($result[$id]) ? $result[$id] : []; $result[$id] = $result[$id] ?? [];
$result[$id][] = Crypt::decrypt($entry->tag); $result[$id][] = Crypt::decrypt($entry->tag);
} }

View File

@ -34,14 +34,6 @@ class CsvExporter extends BasicExporter implements ExporterInterface
/** @var string */ /** @var string */
private $fileName; private $fileName;
/**
* CsvExporter constructor.
*/
public function __construct()
{
parent::__construct();
}
/** /**
* @return string * @return string
*/ */
@ -53,7 +45,6 @@ class CsvExporter extends BasicExporter implements ExporterInterface
/** /**
* @return bool * @return bool
* *
* @throws \TypeError
*/ */
public function run(): bool public function run(): bool
{ {

View File

@ -43,7 +43,6 @@ class AccountFactory
* @param array $data * @param array $data
* *
* @return Account * @return Account
* @throws \FireflyIII\Exceptions\FireflyException
*/ */
public function create(array $data): Account public function create(array $data): Account
{ {
@ -64,8 +63,8 @@ class AccountFactory
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'account_type_id' => $type->id, 'account_type_id' => $type->id,
'name' => $data['name'], 'name' => $data['name'],
'virtual_balance' => strlen(strval($data['virtualBalance'])) === 0 ? '0' : $data['virtualBalance'], 'virtual_balance' => $data['virtualBalance'] ?? '0',
'active' => true === $data['active'] ? true : false, 'active' => true === $data['active'],
'iban' => $data['iban'], 'iban' => $data['iban'],
]; ];
@ -117,8 +116,6 @@ class AccountFactory
* @param string $accountType * @param string $accountType
* *
* @return Account * @return Account
* @throws \FireflyIII\Exceptions\FireflyException
* @throws \FireflyIII\Exceptions\FireflyException
*/ */
public function findOrCreate(string $accountName, string $accountType): Account public function findOrCreate(string $accountName, string $accountType): Account
{ {
@ -161,13 +158,13 @@ class AccountFactory
*/ */
protected function getAccountType(?int $accountTypeId, ?string $accountType): ?AccountType protected function getAccountType(?int $accountTypeId, ?string $accountType): ?AccountType
{ {
$accountTypeId = intval($accountTypeId); $accountTypeId = (int)$accountTypeId;
if ($accountTypeId > 0) { if ($accountTypeId > 0) {
return AccountType::find($accountTypeId); return AccountType::find($accountTypeId);
} }
$type = config('firefly.accountTypeByIdentifier.' . strval($accountType)); $type = config('firefly.accountTypeByIdentifier.' . (string)$accountType);
$result = AccountType::whereType($type)->first(); $result = AccountType::whereType($type)->first();
if (is_null($result) && !is_null($accountType)) { if (null === $result && null !== $accountType) {
// try as full name: // try as full name:
$result = AccountType::whereType($accountType)->first(); $result = AccountType::whereType($accountType)->first();
} }

View File

@ -47,7 +47,7 @@ class BillFactory
{ {
$matchArray = explode(',', $data['match']); $matchArray = explode(',', $data['match']);
$matchArray = array_unique($matchArray); $matchArray = array_unique($matchArray);
$match = join(',', $matchArray); $match = implode(',', $matchArray);
/** @var Bill $bill */ /** @var Bill $bill */
$bill = Bill::create( $bill = Bill::create(
@ -81,14 +81,14 @@ class BillFactory
*/ */
public function find(?int $billId, ?string $billName): ?Bill public function find(?int $billId, ?string $billName): ?Bill
{ {
$billId = intval($billId); $billId = (int)$billId;
$billName = strval($billName); $billName = (string)$billName;
// first find by ID: // first find by ID:
if ($billId > 0) { if ($billId > 0) {
/** @var Bill $bill */ /** @var Bill $bill */
$bill = $this->user->bills()->find($billId); $bill = $this->user->bills()->find($billId);
if (!is_null($bill)) { if (null !== $bill) {
return $bill; return $bill;
} }
} }
@ -96,7 +96,7 @@ class BillFactory
// then find by name: // then find by name:
if (strlen($billName) > 0) { if (strlen($billName) > 0) {
$bill = $this->findByName($billName); $bill = $this->findByName($billName);
if (!is_null($bill)) { if (null !== $bill) {
return $bill; return $bill;
} }
} }

View File

@ -44,8 +44,8 @@ class BudgetFactory
*/ */
public function find(?int $budgetId, ?string $budgetName): ?Budget public function find(?int $budgetId, ?string $budgetName): ?Budget
{ {
$budgetId = intval($budgetId); $budgetId = (int)$budgetId;
$budgetName = strval($budgetName); $budgetName = (string)$budgetName;
if (strlen($budgetName) === 0 && $budgetId === 0) { if (strlen($budgetName) === 0 && $budgetId === 0) {
return null; return null;
@ -55,14 +55,14 @@ class BudgetFactory
if ($budgetId > 0) { if ($budgetId > 0) {
/** @var Budget $budget */ /** @var Budget $budget */
$budget = $this->user->budgets()->find($budgetId); $budget = $this->user->budgets()->find($budgetId);
if (!is_null($budget)) { if (null !== $budget) {
return $budget; return $budget;
} }
} }
if (strlen($budgetName) > 0) { if (strlen($budgetName) > 0) {
$budget = $this->findByName($budgetName); $budget = $this->findByName($budgetName);
if (!is_null($budget)) { if (null !== $budget) {
return $budget; return $budget;
} }
} }

View File

@ -44,16 +44,18 @@ class CategoryFactory
*/ */
public function findByName(string $name): ?Category public function findByName(string $name): ?Category
{ {
$result = null;
/** @var Collection $collection */ /** @var Collection $collection */
$collection = $this->user->categories()->get(); $collection = $this->user->categories()->get();
/** @var Category $category */ /** @var Category $category */
foreach ($collection as $category) { foreach ($collection as $category) {
if ($category->name === $name) { if ($category->name === $name) {
return $category; $result = $category;
break;
} }
} }
return null; return $result;
} }
/** /**
@ -64,8 +66,8 @@ class CategoryFactory
*/ */
public function findOrCreate(?int $categoryId, ?string $categoryName): ?Category public function findOrCreate(?int $categoryId, ?string $categoryName): ?Category
{ {
$categoryId = intval($categoryId); $categoryId = (int)$categoryId;
$categoryName = strval($categoryName); $categoryName = (string)$categoryName;
Log::debug(sprintf('Going to find category with ID %d and name "%s"', $categoryId, $categoryName)); Log::debug(sprintf('Going to find category with ID %d and name "%s"', $categoryId, $categoryName));
@ -76,14 +78,14 @@ class CategoryFactory
if ($categoryId > 0) { if ($categoryId > 0) {
/** @var Category $category */ /** @var Category $category */
$category = $this->user->categories()->find($categoryId); $category = $this->user->categories()->find($categoryId);
if (!is_null($category)) { if (null !== $category) {
return $category; return $category;
} }
} }
if (strlen($categoryName) > 0) { if (strlen($categoryName) > 0) {
$category = $this->findByName($categoryName); $category = $this->findByName($categoryName);
if (!is_null($category)) { if (null !== $category) {
return $category; return $category;
} }

View File

@ -46,7 +46,7 @@ class PiggyBankEventFactory
public function create(TransactionJournal $journal, ?PiggyBank $piggyBank): ?PiggyBankEvent public function create(TransactionJournal $journal, ?PiggyBank $piggyBank): ?PiggyBankEvent
{ {
Log::debug(sprintf('Now in PiggyBankEventCreate for a %s', $journal->transactionType->type)); Log::debug(sprintf('Now in PiggyBankEventCreate for a %s', $journal->transactionType->type));
if (is_null($piggyBank)) { if (null === $piggyBank) {
return null; return null;
} }

View File

@ -43,8 +43,8 @@ class PiggyBankFactory
*/ */
public function find(?int $piggyBankId, ?string $piggyBankName): ?PiggyBank public function find(?int $piggyBankId, ?string $piggyBankName): ?PiggyBank
{ {
$piggyBankId = intval($piggyBankId); $piggyBankId = (int)$piggyBankId;
$piggyBankName = strval($piggyBankName); $piggyBankName = (string)$piggyBankName;
if (strlen($piggyBankName) === 0 && $piggyBankId === 0) { if (strlen($piggyBankName) === 0 && $piggyBankId === 0) {
return null; return null;
} }
@ -52,7 +52,7 @@ class PiggyBankFactory
if ($piggyBankId > 0) { if ($piggyBankId > 0) {
/** @var PiggyBank $piggyBank */ /** @var PiggyBank $piggyBank */
$piggyBank = $this->user->piggyBanks()->find($piggyBankId); $piggyBank = $this->user->piggyBanks()->find($piggyBankId);
if (!is_null($piggyBank)) { if (null !== $piggyBank) {
return $piggyBank; return $piggyBank;
} }
} }
@ -61,7 +61,7 @@ class PiggyBankFactory
if (strlen($piggyBankName) > 0) { if (strlen($piggyBankName) > 0) {
/** @var PiggyBank $piggyBank */ /** @var PiggyBank $piggyBank */
$piggyBank = $this->findByName($piggyBankName); $piggyBank = $this->findByName($piggyBankName);
if (!is_null($piggyBank)) { if (null !== $piggyBank) {
return $piggyBank; return $piggyBank;
} }
} }

View File

@ -65,7 +65,7 @@ class TagFactory
*/ */
public function findOrCreate(string $tag): ?Tag public function findOrCreate(string $tag): ?Tag
{ {
if (is_null($this->tags)) { if (null === $this->tags) {
$this->tags = $this->user->tags()->get(); $this->tags = $this->user->tags()->get();
} }

View File

@ -65,24 +65,24 @@ class TransactionCurrencyFactory
*/ */
public function find(?int $currencyId, ?string $currencyCode): ?TransactionCurrency public function find(?int $currencyId, ?string $currencyCode): ?TransactionCurrency
{ {
$currencyCode = strval($currencyCode); $currencyCode = (string)$currencyCode;
$currencyId = intval($currencyId); $currencyId = (int)$currencyId;
if (strlen($currencyCode) === 0 && intval($currencyId) === 0) { if (strlen($currencyCode) === 0 && (int)$currencyId === 0) {
return null; return null;
} }
// first by ID: // first by ID:
if ($currencyId > 0) { if ($currencyId > 0) {
$currency = TransactionCurrency::find($currencyId); $currency = TransactionCurrency::find($currencyId);
if (!is_null($currency)) { if (null !== $currency) {
return $currency; return $currency;
} }
} }
// then by code: // then by code:
if (strlen($currencyCode) > 0) { if (strlen($currencyCode) > 0) {
$currency = TransactionCurrency::whereCode($currencyCode)->first(); $currency = TransactionCurrency::whereCode($currencyCode)->first();
if (!is_null($currency)) { if (null !== $currency) {
return $currency; return $currency;
} }
} }

View File

@ -90,7 +90,7 @@ class TransactionFactory
$source = $this->create( $source = $this->create(
[ [
'description' => $description, 'description' => $description,
'amount' => app('steam')->negative(strval($data['amount'])), 'amount' => app('steam')->negative((string)$data['amount']),
'foreign_amount' => null, 'foreign_amount' => null,
'currency' => $currency, 'currency' => $currency,
'account' => $sourceAccount, 'account' => $sourceAccount,
@ -103,7 +103,7 @@ class TransactionFactory
$dest = $this->create( $dest = $this->create(
[ [
'description' => $description, 'description' => $description,
'amount' => app('steam')->positive(strval($data['amount'])), 'amount' => app('steam')->positive((string)$data['amount']),
'foreign_amount' => null, 'foreign_amount' => null,
'currency' => $currency, 'currency' => $currency,
'account' => $destinationAccount, 'account' => $destinationAccount,
@ -119,9 +119,9 @@ class TransactionFactory
$this->setForeignCurrency($dest, $foreign); $this->setForeignCurrency($dest, $foreign);
// set foreign amount: // set foreign amount:
if (!is_null($data['foreign_amount'])) { if (null !== $data['foreign_amount']) {
$this->setForeignAmount($source, app('steam')->negative(strval($data['foreign_amount']))); $this->setForeignAmount($source, app('steam')->negative((string)$data['foreign_amount']));
$this->setForeignAmount($dest, app('steam')->positive(strval($data['foreign_amount']))); $this->setForeignAmount($dest, app('steam')->positive((string)$data['foreign_amount']));
} }
// set budget: // set budget:

View File

@ -40,8 +40,6 @@ class TransactionJournalFactory
private $user; private $user;
/** /**
* Create a new transaction journal and associated transactions.
*
* @param array $data * @param array $data
* *
* @return TransactionJournal * @return TransactionJournal
@ -89,11 +87,11 @@ class TransactionJournalFactory
$this->connectTags($journal, $data); $this->connectTags($journal, $data);
// store note: // store note:
$this->storeNote($journal, strval($data['notes'])); $this->storeNote($journal, (string)$data['notes']);
// store date meta fields (if present): // store date meta fields (if present):
$fields = ['sepa-cc', 'sepa-ct-op', 'sepa-ct-id', 'sepa-db', 'sepa-country', 'sepa-ep', 'sepa-ci', 'interest_date', 'book_date', 'process_date', $fields = ['sepa-cc', 'sepa-ct-op', 'sepa-ct-id', 'sepa-db', 'sepa-country', 'sepa-ep', 'sepa-ci', 'interest_date', 'book_date', 'process_date',
'due_date', 'payment_date', 'invoice_date', 'internal_reference','bunq_payment_id']; 'due_date', 'payment_date', 'invoice_date', 'internal_reference', 'bunq_payment_id'];
foreach ($fields as $field) { foreach ($fields as $field) {
$this->storeMeta($journal, $data, $field); $this->storeMeta($journal, $data, $field);
@ -124,7 +122,7 @@ class TransactionJournalFactory
$factory->setUser($this->user); $factory->setUser($this->user);
$piggyBank = $factory->find($data['piggy_bank_id'], $data['piggy_bank_name']); $piggyBank = $factory->find($data['piggy_bank_id'], $data['piggy_bank_name']);
if (!is_null($piggyBank)) { if (null !== $piggyBank) {
/** @var PiggyBankEventFactory $factory */ /** @var PiggyBankEventFactory $factory */
$factory = app(PiggyBankEventFactory::class); $factory = app(PiggyBankEventFactory::class);
$factory->create($journal, $piggyBank); $factory->create($journal, $piggyBank);
@ -144,7 +142,8 @@ class TransactionJournalFactory
{ {
$factory = app(TransactionTypeFactory::class); $factory = app(TransactionTypeFactory::class);
$transactionType = $factory->find($type); $transactionType = $factory->find($type);
if (is_null($transactionType)) { if (null === $transactionType) {
Log::error(sprintf('Could not find transaction type for "%s"', $type)); // @codeCoverageIgnore
throw new FireflyException(sprintf('Could not find transaction type for "%s"', $type)); // @codeCoverageIgnore throw new FireflyException(sprintf('Could not find transaction type for "%s"', $type)); // @codeCoverageIgnore
} }

View File

@ -128,7 +128,7 @@ class ChartJsGenerator implements GeneratorInterface
$index = 0; $index = 0;
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
// make larger than 0 // make larger than 0
$chartData['datasets'][0]['data'][] = floatval(Steam::positive($value)); $chartData['datasets'][0]['data'][] = (float)Steam::positive($value);
$chartData['datasets'][0]['backgroundColor'][] = ChartColour::getColour($index); $chartData['datasets'][0]['backgroundColor'][] = ChartColour::getColour($index);
$chartData['labels'][] = $key; $chartData['labels'][] = $key;
++$index; ++$index;

View File

@ -43,12 +43,11 @@ class MonthReportGenerator implements ReportGeneratorInterface
/** /**
* @return string * @return string
* *
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
$accountIds = join(',', $this->accounts->pluck('id')->toArray()); $accountIds = implode(',', $this->accounts->pluck('id')->toArray());
$expenseIds = join(',', $this->expense->pluck('id')->toArray()); $expenseIds = implode(',', $this->expense->pluck('id')->toArray());
$reportType = 'account'; $reportType = 'account';
$preferredPeriod = $this->preferredPeriod(); $preferredPeriod = $this->preferredPeriod();

View File

@ -45,7 +45,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/** /**
* @return string * @return string
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
@ -61,7 +60,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
$defaultShow = ['icon', 'description', 'balance_before', 'amount', 'balance_after', 'date', 'to']; $defaultShow = ['icon', 'description', 'balance_before', 'amount', 'balance_after', 'date', 'to'];
$reportType = 'audit'; $reportType = 'audit';
$accountIds = join(',', $this->accounts->pluck('id')->toArray()); $accountIds = implode(',', $this->accounts->pluck('id')->toArray());
$hideable = ['buttons', 'icon', 'description', 'balance_before', 'amount', 'balance_after', 'date', $hideable = ['buttons', 'icon', 'description', 'balance_before', 'amount', 'balance_after', 'date',
'interest_date', 'book_date', 'process_date', 'interest_date', 'book_date', 'process_date',
// three new optional fields. // three new optional fields.
@ -173,7 +172,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
$journals = $journals->reverse(); $journals = $journals->reverse();
$dayBeforeBalance = Steam::balance($account, $date); $dayBeforeBalance = Steam::balance($account, $date);
$startBalance = $dayBeforeBalance; $startBalance = $dayBeforeBalance;
$currency = $currencyRepos->find(intval($account->getMeta('currency_id'))); $currency = $currencyRepos->find((int)$account->getMeta('currency_id'));
/** @var Transaction $transaction */ /** @var Transaction $transaction */
foreach ($journals as $transaction) { foreach ($journals as $transaction) {
@ -193,9 +192,9 @@ class MonthReportGenerator implements ReportGeneratorInterface
$return = [ $return = [
'journals' => $journals->reverse(), 'journals' => $journals->reverse(),
'exists' => $journals->count() > 0, 'exists' => $journals->count() > 0,
'end' => $this->end->formatLocalized(strval(trans('config.month_and_day'))), 'end' => $this->end->formatLocalized((string)trans('config.month_and_day')),
'endBalance' => Steam::balance($account, $this->end), 'endBalance' => Steam::balance($account, $this->end),
'dayBefore' => $date->formatLocalized(strval(trans('config.month_and_day'))), 'dayBefore' => $date->formatLocalized((string)trans('config.month_and_day')),
'dayBeforeBalance' => $dayBeforeBalance, 'dayBeforeBalance' => $dayBeforeBalance,
]; ];

View File

@ -63,12 +63,11 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
/** /**
* @return string * @return string
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
$accountIds = join(',', $this->accounts->pluck('id')->toArray()); $accountIds = implode(',', $this->accounts->pluck('id')->toArray());
$budgetIds = join(',', $this->budgets->pluck('id')->toArray()); $budgetIds = implode(',', $this->budgets->pluck('id')->toArray());
$expenses = $this->getExpenses(); $expenses = $this->getExpenses();
$accountSummary = $this->summarizeByAccount($expenses); $accountSummary = $this->summarizeByAccount($expenses);
$budgetSummary = $this->summarizeByBudget($expenses); $budgetSummary = $this->summarizeByBudget($expenses);
@ -200,8 +199,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
]; ];
/** @var Transaction $transaction */ /** @var Transaction $transaction */
foreach ($collection as $transaction) { foreach ($collection as $transaction) {
$jrnlBudId = intval($transaction->transaction_journal_budget_id); $jrnlBudId = (int)$transaction->transaction_journal_budget_id;
$transBudId = intval($transaction->transaction_budget_id); $transBudId = (int)$transaction->transaction_budget_id;
$budgetId = max($jrnlBudId, $transBudId); $budgetId = max($jrnlBudId, $transBudId);
$result[$budgetId] = $result[$budgetId] ?? '0'; $result[$budgetId] = $result[$budgetId] ?? '0';
$result[$budgetId] = bcadd($transaction->transaction_amount, $result[$budgetId]); $result[$budgetId] = bcadd($transaction->transaction_amount, $result[$budgetId]);

View File

@ -64,12 +64,11 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
/** /**
* @return string * @return string
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
$accountIds = join(',', $this->accounts->pluck('id')->toArray()); $accountIds = implode(',', $this->accounts->pluck('id')->toArray());
$categoryIds = join(',', $this->categories->pluck('id')->toArray()); $categoryIds = implode(',', $this->categories->pluck('id')->toArray());
$reportType = 'category'; $reportType = 'category';
$expenses = $this->getExpenses(); $expenses = $this->getExpenses();
$income = $this->getIncome(); $income = $this->getIncome();
@ -240,8 +239,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
$result = []; $result = [];
/** @var Transaction $transaction */ /** @var Transaction $transaction */
foreach ($collection as $transaction) { foreach ($collection as $transaction) {
$jrnlCatId = intval($transaction->transaction_journal_category_id); $jrnlCatId = (int)$transaction->transaction_journal_category_id;
$transCatId = intval($transaction->transaction_category_id); $transCatId = (int)$transaction->transaction_category_id;
$categoryId = max($jrnlCatId, $transCatId); $categoryId = max($jrnlCatId, $transCatId);
$result[$categoryId] = $result[$categoryId] ?? '0'; $result[$categoryId] = $result[$categoryId] ?? '0';
$result[$categoryId] = bcadd($transaction->transaction_amount, $result[$categoryId]); $result[$categoryId] = bcadd($transaction->transaction_amount, $result[$categoryId]);

View File

@ -42,14 +42,14 @@ class MonthReportGenerator implements ReportGeneratorInterface
/** /**
* @return string * @return string
* *
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
/** @var ReportHelperInterface $helper */ /** @var ReportHelperInterface $helper */
$helper = app(ReportHelperInterface::class); $helper = app(ReportHelperInterface::class);
$bills = $helper->getBillReport($this->start, $this->end, $this->accounts); $bills = $helper->getBillReport($this->start, $this->end, $this->accounts);
$accountIds = join(',', $this->accounts->pluck('id')->toArray()); $accountIds = implode(',', $this->accounts->pluck('id')->toArray());
$reportType = 'default'; $reportType = 'default';
// continue! // continue!

View File

@ -41,12 +41,12 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
/** /**
* @return string * @return string
* *
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
// and some id's, joined: // and some id's, joined:
$accountIds = join(',', $this->accounts->pluck('id')->toArray()); $accountIds = implode(',', $this->accounts->pluck('id')->toArray());
$reportType = 'default'; $reportType = 'default';
// continue! // continue!

View File

@ -41,12 +41,12 @@ class YearReportGenerator implements ReportGeneratorInterface
/** /**
* @return string * @return string
* *
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
// and some id's, joined: // and some id's, joined:
$accountIds = join(',', $this->accounts->pluck('id')->toArray()); $accountIds = implode(',', $this->accounts->pluck('id')->toArray());
$reportType = 'default'; $reportType = 'default';
// continue! // continue!

View File

@ -35,9 +35,7 @@ class Support
*/ */
public function getTopExpenses(): Collection public function getTopExpenses(): Collection
{ {
$transactions = $this->getExpenses()->sortBy('transaction_amount'); return $this->getExpenses()->sortBy('transaction_amount');
return $transactions;
} }
/** /**
@ -45,9 +43,7 @@ class Support
*/ */
public function getTopIncome(): Collection public function getTopIncome(): Collection
{ {
$transactions = $this->getIncome()->sortByDesc('transaction_amount'); return $this->getIncome()->sortByDesc('transaction_amount');
return $transactions;
} }
/** /**
@ -78,13 +74,13 @@ class Support
} }
++$result[$opposingId]['count']; ++$result[$opposingId]['count'];
$result[$opposingId]['sum'] = bcadd($result[$opposingId]['sum'], $transaction->transaction_amount); $result[$opposingId]['sum'] = bcadd($result[$opposingId]['sum'], $transaction->transaction_amount);
$result[$opposingId]['average'] = bcdiv($result[$opposingId]['sum'], strval($result[$opposingId]['count'])); $result[$opposingId]['average'] = bcdiv($result[$opposingId]['sum'], (string)$result[$opposingId]['count']);
} }
// sort result by average: // sort result by average:
$average = []; $average = [];
foreach ($result as $key => $row) { foreach ($result as $key => $row) {
$average[$key] = floatval($row['average']); $average[$key] = (float)$row['average'];
} }
array_multisort($average, $sortFlag, $result); array_multisort($average, $sortFlag, $result);

View File

@ -65,12 +65,11 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
/** /**
* @return string * @return string
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
$accountIds = join(',', $this->accounts->pluck('id')->toArray()); $accountIds = implode(',', $this->accounts->pluck('id')->toArray());
$tagTags = join(',', $this->tags->pluck('tag')->toArray()); $tagTags = implode(',', $this->tags->pluck('tag')->toArray());
$reportType = 'tag'; $reportType = 'tag';
$expenses = $this->getExpenses(); $expenses = $this->getExpenses();
$income = $this->getIncome(); $income = $this->getIncome();

View File

@ -22,13 +22,13 @@ declare(strict_types=1);
namespace FireflyIII\Handlers\Events; namespace FireflyIII\Handlers\Events;
use Exception;
use FireflyIII\Events\AdminRequestedTestMessage; use FireflyIII\Events\AdminRequestedTestMessage;
use FireflyIII\Mail\AdminTestMail; use FireflyIII\Mail\AdminTestMail;
use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\Repositories\User\UserRepositoryInterface;
use Log; use Log;
use Mail; use Mail;
use Session; use Session;
use Swift_TransportException;
/** /**
* Class AdminEventHandler. * Class AdminEventHandler.
@ -61,7 +61,7 @@ class AdminEventHandler
Log::debug('Trying to send message...'); Log::debug('Trying to send message...');
Mail::to($email)->send(new AdminTestMail($email, $ipAddress)); Mail::to($email)->send(new AdminTestMail($email, $ipAddress));
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
} catch (Swift_TransportException $e) { } catch (Exception $e) {
Log::debug('Send message failed! :('); Log::debug('Send message failed! :(');
Log::error($e->getMessage()); Log::error($e->getMessage());
Log::error($e->getTraceAsString()); Log::error($e->getTraceAsString());

View File

@ -22,6 +22,7 @@ declare(strict_types=1);
namespace FireflyIII\Handlers\Events; namespace FireflyIII\Handlers\Events;
use Exception;
use FireflyIII\Events\RegisteredUser; use FireflyIII\Events\RegisteredUser;
use FireflyIII\Events\RequestedNewPassword; use FireflyIII\Events\RequestedNewPassword;
use FireflyIII\Events\UserChangedEmail; use FireflyIII\Events\UserChangedEmail;
@ -36,7 +37,6 @@ use Illuminate\Auth\Events\Login;
use Log; use Log;
use Mail; use Mail;
use Preferences; use Preferences;
use Swift_TransportException;
/** /**
* Class UserEventHandler. * Class UserEventHandler.
@ -95,7 +95,7 @@ class UserEventHandler
} }
// user is the only user but does not have role "owner". // user is the only user but does not have role "owner".
$role = $repository->getRole('owner'); $role = $repository->getRole('owner');
if (is_null($role)) { if (null === $role) {
// create role, does not exist. Very strange situation so let's raise a big fuss about it. // create role, does not exist. Very strange situation so let's raise a big fuss about it.
$role = $repository->createRole('owner', 'Site Owner', 'User runs this instance of FF3'); $role = $repository->createRole('owner', 'Site Owner', 'User runs this instance of FF3');
Log::error('Could not find role "owner". This is weird.'); Log::error('Could not find role "owner". This is weird.');
@ -124,7 +124,7 @@ class UserEventHandler
try { try {
Mail::to($newEmail)->send(new ConfirmEmailChangeMail($newEmail, $oldEmail, $uri, $ipAddress)); Mail::to($newEmail)->send(new ConfirmEmailChangeMail($newEmail, $oldEmail, $uri, $ipAddress));
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
} catch (Swift_TransportException $e) { } catch (Exception $e) {
Log::error($e->getMessage()); Log::error($e->getMessage());
} }
@ -148,7 +148,7 @@ class UserEventHandler
try { try {
Mail::to($oldEmail)->send(new UndoEmailChangeMail($newEmail, $oldEmail, $uri, $ipAddress)); Mail::to($oldEmail)->send(new UndoEmailChangeMail($newEmail, $oldEmail, $uri, $ipAddress));
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
} catch (Swift_TransportException $e) { } catch (Exception $e) {
Log::error($e->getMessage()); Log::error($e->getMessage());
} }
@ -173,7 +173,7 @@ class UserEventHandler
try { try {
Mail::to($email)->send(new RequestedNewPasswordMail($url, $ipAddress)); Mail::to($email)->send(new RequestedNewPasswordMail($url, $ipAddress));
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
} catch (Swift_TransportException $e) { } catch (Exception $e) {
Log::error($e->getMessage()); Log::error($e->getMessage());
} }
@ -205,7 +205,7 @@ class UserEventHandler
try { try {
Mail::to($email)->send(new RegisteredUserMail($uri, $ipAddress)); Mail::to($email)->send(new RegisteredUserMail($uri, $ipAddress));
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
} catch (Swift_TransportException $e) { } catch (Exception $e) {
Log::error($e->getMessage()); Log::error($e->getMessage());
} }

View File

@ -99,7 +99,7 @@ class VersionCheckEventHandler
} }
$string = 'no result: ' . $check; $string = 'no result: ' . $check;
if ($check === -2) { if ($check === -2) {
$string = strval(trans('firefly.update_check_error')); $string = (string)trans('firefly.update_check_error');
} }
if ($check === -1) { if ($check === -1) {
// there is a new FF version! // there is a new FF version!

View File

@ -56,7 +56,7 @@ class AttachmentHelper implements AttachmentHelperInterface
*/ */
public function __construct() public function __construct()
{ {
$this->maxUploadSize = intval(config('firefly.maxUploadSize')); $this->maxUploadSize = (int)config('firefly.maxUploadSize');
$this->allowedMimes = (array)config('firefly.allowedMimes'); $this->allowedMimes = (array)config('firefly.allowedMimes');
$this->errors = new MessageBag; $this->errors = new MessageBag;
$this->messages = new MessageBag; $this->messages = new MessageBag;
@ -71,7 +71,7 @@ class AttachmentHelper implements AttachmentHelperInterface
*/ */
public function getAttachmentLocation(Attachment $attachment): string public function getAttachmentLocation(Attachment $attachment): string
{ {
$path = sprintf('%s%sat-%d.data', storage_path('upload'), DIRECTORY_SEPARATOR, intval($attachment->id)); $path = sprintf('%s%sat-%d.data', storage_path('upload'), DIRECTORY_SEPARATOR, (int)$attachment->id);
return $path; return $path;
} }

View File

@ -103,7 +103,7 @@ class MetaPieChart implements MetaPieChartInterface
$transactions = $this->getTransactions($direction); $transactions = $this->getTransactions($direction);
$grouped = $this->groupByFields($transactions, $this->grouping[$group]); $grouped = $this->groupByFields($transactions, $this->grouping[$group]);
$chartData = $this->organizeByType($group, $grouped); $chartData = $this->organizeByType($group, $grouped);
$key = strval(trans('firefly.everything_else')); $key = (string)trans('firefly.everything_else');
// also collect all other transactions // also collect all other transactions
if ($this->collectOtherObjects && 'expense' === $direction) { if ($this->collectOtherObjects && 'expense' === $direction) {
@ -113,7 +113,7 @@ class MetaPieChart implements MetaPieChartInterface
$collector->setAccounts($this->accounts)->setRange($this->start, $this->end)->setTypes([TransactionType::WITHDRAWAL]); $collector->setAccounts($this->accounts)->setRange($this->start, $this->end)->setTypes([TransactionType::WITHDRAWAL]);
$journals = $collector->getJournals(); $journals = $collector->getJournals();
$sum = strval($journals->sum('transaction_amount')); $sum = (string)$journals->sum('transaction_amount');
$sum = bcmul($sum, '-1'); $sum = bcmul($sum, '-1');
$sum = bcsub($sum, $this->total); $sum = bcsub($sum, $this->total);
$chartData[$key] = $sum; $chartData[$key] = $sum;
@ -125,7 +125,7 @@ class MetaPieChart implements MetaPieChartInterface
$collector->setUser($this->user); $collector->setUser($this->user);
$collector->setAccounts($this->accounts)->setRange($this->start, $this->end)->setTypes([TransactionType::DEPOSIT]); $collector->setAccounts($this->accounts)->setRange($this->start, $this->end)->setTypes([TransactionType::DEPOSIT]);
$journals = $collector->getJournals(); $journals = $collector->getJournals();
$sum = strval($journals->sum('transaction_amount')); $sum = (string)$journals->sum('transaction_amount');
$sum = bcsub($sum, $this->total); $sum = bcsub($sum, $this->total);
$chartData[$key] = $sum; $chartData[$key] = $sum;
} }
@ -308,7 +308,7 @@ class MetaPieChart implements MetaPieChartInterface
foreach ($set as $transaction) { foreach ($set as $transaction) {
$values = []; $values = [];
foreach ($fields as $field) { foreach ($fields as $field) {
$values[] = intval($transaction->$field); $values[] = (int)$transaction->$field;
} }
$value = max($values); $value = max($values);
$grouped[$value] = $grouped[$value] ?? '0'; $grouped[$value] = $grouped[$value] ?? '0';
@ -332,7 +332,7 @@ class MetaPieChart implements MetaPieChartInterface
$repository->setUser($this->user); $repository->setUser($this->user);
foreach ($array as $objectId => $amount) { foreach ($array as $objectId => $amount) {
if (!isset($names[$objectId])) { if (!isset($names[$objectId])) {
$object = $repository->find(intval($objectId)); $object = $repository->find((int)$objectId);
$names[$objectId] = $object->name ?? $object->tag; $names[$objectId] = $object->name ?? $object->tag;
} }
$amount = Steam::positive($amount); $amount = Steam::positive($amount);

View File

@ -162,13 +162,13 @@ class BalanceLine
return $this->getBudget()->name; return $this->getBudget()->name;
} }
if (self::ROLE_DEFAULTROLE === $this->getRole()) { if (self::ROLE_DEFAULTROLE === $this->getRole()) {
return strval(trans('firefly.no_budget')); return (string)trans('firefly.no_budget');
} }
if (self::ROLE_TAGROLE === $this->getRole()) { if (self::ROLE_TAGROLE === $this->getRole()) {
return strval(trans('firefly.coveredWithTags')); return (string)trans('firefly.coveredWithTags');
} }
if (self::ROLE_DIFFROLE === $this->getRole()) { if (self::ROLE_DIFFROLE === $this->getRole()) {
return strval(trans('firefly.leftUnbalanced')); return (string)trans('firefly.leftUnbalanced');
} }
return ''; return '';

View File

@ -101,7 +101,7 @@ class Bill
{ {
$set = $this->bills->sortBy( $set = $this->bills->sortBy(
function (BillLine $bill) { function (BillLine $bill) {
$active = 0 === intval($bill->getBill()->active) ? 1 : 0; $active = 0 === (int)$bill->getBill()->active ? 1 : 0;
$name = $bill->getBill()->name; $name = $bill->getBill()->name;
return $active . $name; return $active . $name;

View File

@ -190,7 +190,7 @@ class BillLine
*/ */
public function isActive(): bool public function isActive(): bool
{ {
return 1 === intval($this->bill->active); return 1 === (int)$this->bill->active;
} }
/** /**

View File

@ -237,7 +237,7 @@ class JournalCollector implements JournalCollectorInterface
$countQuery->getQuery()->groups = null; $countQuery->getQuery()->groups = null;
$countQuery->getQuery()->orders = null; $countQuery->getQuery()->orders = null;
$countQuery->groupBy('accounts.user_id'); $countQuery->groupBy('accounts.user_id');
$this->count = intval($countQuery->count()); $this->count = (int)$countQuery->count();
return $this->count; return $this->count;
} }
@ -270,10 +270,10 @@ class JournalCollector implements JournalCollectorInterface
$set->each( $set->each(
function (Transaction $transaction) { function (Transaction $transaction) {
$transaction->date = new Carbon($transaction->date); $transaction->date = new Carbon($transaction->date);
$transaction->description = Steam::decrypt(intval($transaction->encrypted), $transaction->description); $transaction->description = Steam::decrypt((int)$transaction->encrypted, $transaction->description);
if (null !== $transaction->bill_name) { if (null !== $transaction->bill_name) {
$transaction->bill_name = Steam::decrypt(intval($transaction->bill_name_encrypted), $transaction->bill_name); $transaction->bill_name = Steam::decrypt((int)$transaction->bill_name_encrypted, $transaction->bill_name);
} }
$transaction->account_name = app('steam')->tryDecrypt($transaction->account_name); $transaction->account_name = app('steam')->tryDecrypt($transaction->account_name);
$transaction->opposing_account_name = app('steam')->tryDecrypt($transaction->opposing_account_name); $transaction->opposing_account_name = app('steam')->tryDecrypt($transaction->opposing_account_name);
@ -338,7 +338,7 @@ class JournalCollector implements JournalCollectorInterface
if ($accounts->count() > 0) { if ($accounts->count() > 0) {
$accountIds = $accounts->pluck('id')->toArray(); $accountIds = $accounts->pluck('id')->toArray();
$this->query->whereIn('transactions.account_id', $accountIds); $this->query->whereIn('transactions.account_id', $accountIds);
Log::debug(sprintf('setAccounts: %s', join(', ', $accountIds))); Log::debug(sprintf('setAccounts: %s', implode(', ', $accountIds)));
$this->accountIds = $accountIds; $this->accountIds = $accountIds;
} }
@ -834,7 +834,6 @@ class JournalCollector implements JournalCollectorInterface
/** /**
* *
* @throws \InvalidArgumentException
*/ */
private function joinOpposingTables() private function joinOpposingTables()
{ {

View File

@ -35,7 +35,7 @@ use Log;
class AmountFilter implements FilterInterface class AmountFilter implements FilterInterface
{ {
/** @var int */ /** @var int */
private $modifier = 0; private $modifier;
/** /**
* AmountFilter constructor. * AmountFilter constructor.

View File

@ -57,7 +57,7 @@ class CountAttachmentsFilter implements FilterInterface
$set->each( $set->each(
function (Transaction $transaction) use ($counter) { function (Transaction $transaction) use ($counter) {
$id = (int)$transaction->journal_id; $id = (int)$transaction->journal_id;
$count = $counter[$id] ?? 0; $count = (int)($counter[$id] ?? 0.0);
$transaction->attachmentCount = $count; $transaction->attachmentCount = $count;
} }
); );

View File

@ -36,7 +36,7 @@ use Log;
class InternalTransferFilter implements FilterInterface class InternalTransferFilter implements FilterInterface
{ {
/** @var array */ /** @var array */
private $accounts = []; private $accounts;
/** /**
* InternalTransferFilter constructor. * InternalTransferFilter constructor.

View File

@ -35,7 +35,7 @@ use Log;
class OpposingAccountFilter implements FilterInterface class OpposingAccountFilter implements FilterInterface
{ {
/** @var array */ /** @var array */
private $accounts = []; private $accounts;
/** /**
* InternalTransferFilter constructor. * InternalTransferFilter constructor.

View File

@ -54,7 +54,7 @@ class SplitIndicatorFilter implements FilterInterface
$set->each( $set->each(
function (Transaction $transaction) use ($counter) { function (Transaction $transaction) use ($counter) {
$id = (int)$transaction->journal_id; $id = (int)$transaction->journal_id;
$count = $counter[$id] ?? 0; $count = (int)($counter[$id] ?? 0.0);
$transaction->is_split = false; $transaction->is_split = false;
if ($count > 2) { if ($count > 2) {
$transaction->is_split = true; $transaction->is_split = true;

View File

@ -52,11 +52,11 @@ class TransferFilter implements FilterInterface
// make property string: // make property string:
$journalId = $transaction->transaction_journal_id; $journalId = $transaction->transaction_journal_id;
$amount = Steam::positive($transaction->transaction_amount); $amount = Steam::positive($transaction->transaction_amount);
$accountIds = [intval($transaction->account_id), intval($transaction->opposing_account_id)]; $accountIds = [(int)$transaction->account_id, (int)$transaction->opposing_account_id];
$transactionIds = [$transaction->id, intval($transaction->opposing_id)]; $transactionIds = [$transaction->id, (int)$transaction->opposing_id];
sort($accountIds); sort($accountIds);
sort($transactionIds); sort($transactionIds);
$key = $journalId . '-' . join(',', $transactionIds) . '-' . join(',', $accountIds) . '-' . $amount; $key = $journalId . '-' . implode(',', $transactionIds) . '-' . implode(',', $accountIds) . '-' . $amount;
if (!isset($count[$key])) { if (!isset($count[$key])) {
// not yet counted? add to new set and count it: // not yet counted? add to new set and count it:
$new->push($transaction); $new->push($transaction);

View File

@ -73,8 +73,8 @@ class FiscalHelper implements FiscalHelperInterface
$startDate = clone $date; $startDate = clone $date;
if (true === $this->useCustomFiscalYear) { if (true === $this->useCustomFiscalYear) {
$prefStartStr = Preferences::get('fiscalYearStart', '01-01')->data; $prefStartStr = Preferences::get('fiscalYearStart', '01-01')->data;
list($mth, $day) = explode('-', $prefStartStr); [$mth, $day] = explode('-', $prefStartStr);
$startDate->month(intval($mth))->day(intval($day)); $startDate->month((int)$mth)->day((int)$day);
// if start date is after passed date, sub 1 year. // if start date is after passed date, sub 1 year.
if ($startDate > $date) { if ($startDate > $date) {

View File

@ -23,10 +23,10 @@ declare(strict_types=1);
namespace FireflyIII\Helpers\Help; namespace FireflyIII\Helpers\Help;
use Cache; use Cache;
use Exception;
use League\CommonMark\CommonMarkConverter; use League\CommonMark\CommonMarkConverter;
use Log; use Log;
use Requests; use Requests;
use Requests_Exception;
use Route; use Route;
/** /**
@ -68,7 +68,7 @@ class Help implements HelpInterface
$content = ''; $content = '';
try { try {
$result = Requests::get($uri, [], $opt); $result = Requests::get($uri, [], $opt);
} catch (Requests_Exception $e) { } catch (Exception $e) {
Log::error($e); Log::error($e);
return ''; return '';

View File

@ -91,7 +91,7 @@ class BudgetReportHelper implements BudgetReportHelperInterface
'id' => $budget->id, 'id' => $budget->id,
'name' => $budget->name, 'name' => $budget->name,
'budgeted' => strval($budgetLimit->amount), 'budgeted' => (string)$budgetLimit->amount,
'spent' => $data['expenses'], 'spent' => $data['expenses'],
'left' => $data['left'], 'left' => $data['left'],
'overspent' => $data['overspent'], 'overspent' => $data['overspent'],

View File

@ -75,9 +75,8 @@ class PopupReport implements PopupReportInterface
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class); $collector = app(JournalCollectorInterface::class);
$collector->setAccounts(new Collection([$account]))->setRange($attributes['startDate'], $attributes['endDate'])->setBudget($budget); $collector->setAccounts(new Collection([$account]))->setRange($attributes['startDate'], $attributes['endDate'])->setBudget($budget);
$journals = $collector->getJournals();
return $journals; return $collector->getJournals();
} }
/** /**
@ -118,9 +117,8 @@ class PopupReport implements PopupReportInterface
if (null !== $budget->id) { if (null !== $budget->id) {
$collector->setBudget($budget); $collector->setBudget($budget);
} }
$journals = $collector->getJournals();
return $journals; return $collector->getJournals();
} }
/** /**
@ -136,9 +134,8 @@ class PopupReport implements PopupReportInterface
$collector->setAccounts($attributes['accounts'])->setTypes([TransactionType::WITHDRAWAL, TransactionType::TRANSFER]) $collector->setAccounts($attributes['accounts'])->setTypes([TransactionType::WITHDRAWAL, TransactionType::TRANSFER])
->setRange($attributes['startDate'], $attributes['endDate'])->withOpposingAccount() ->setRange($attributes['startDate'], $attributes['endDate'])->withOpposingAccount()
->setCategory($category); ->setCategory($category);
$journals = $collector->getJournals();
return $journals; return $collector->getJournals();
} }
/** /**

View File

@ -90,8 +90,8 @@ class ReportHelper implements ReportHelperInterface
$billLine->setBill($bill); $billLine->setBill($bill);
$billLine->setPayDate($payDate); $billLine->setPayDate($payDate);
$billLine->setEndOfPayDate($endOfPayPeriod); $billLine->setEndOfPayDate($endOfPayPeriod);
$billLine->setMin(strval($bill->amount_min)); $billLine->setMin((string)$bill->amount_min);
$billLine->setMax(strval($bill->amount_max)); $billLine->setMax((string)$bill->amount_max);
$billLine->setHit(false); $billLine->setHit(false);
$entry = $journals->filter( $entry = $journals->filter(
function (Transaction $transaction) use ($bill) { function (Transaction $transaction) use ($bill) {
@ -119,7 +119,6 @@ class ReportHelper implements ReportHelperInterface
* @param Carbon $date * @param Carbon $date
* *
* @return array * @return array
* @throws \InvalidArgumentException
*/ */
public function listOfMonths(Carbon $date): array public function listOfMonths(Carbon $date): array
{ {

2
public/css/app.css vendored

File diff suppressed because one or more lines are too long

2
public/js/app.js vendored

File diff suppressed because one or more lines are too long