Merge branch 'release/4.7.2.1'

This commit is contained in:
James Cole
2018-04-02 16:52:23 +02:00
366 changed files with 1895 additions and 2152 deletions

View File

@@ -14,12 +14,17 @@ apt-get install -y python-software-properties software-properties-common
# install all languages # install all languages
sed -i 's/# de_DE.UTF-8 UTF-8/de_DE.UTF-8 UTF-8/g' /etc/locale.gen sed -i 's/# de_DE.UTF-8 UTF-8/de_DE.UTF-8 UTF-8/g' /etc/locale.gen
sed -i 's/# es_ES.UTF-8 UTF-8/es_ES.UTF-8 UTF-8/g' /etc/locale.gen
sed -i 's/# fr_FR.UTF-8 UTF-8/fr_FR.UTF-8 UTF-8/g' /etc/locale.gen sed -i 's/# fr_FR.UTF-8 UTF-8/fr_FR.UTF-8 UTF-8/g' /etc/locale.gen
sed -i 's/# id_ID.UTF-8 UTF-8/id_ID.UTF-8 UTF-8/g' /etc/locale.gen sed -i 's/# id_ID.UTF-8 UTF-8/id_ID.UTF-8 UTF-8/g' /etc/locale.gen
sed -i 's/# it_IT.UTF-8 UTF-8/it_IT.UTF-8 UTF-8/g' /etc/locale.gen
sed -i 's/# nl_NL.UTF-8 UTF-8/nl_NL.UTF-8 UTF-8/g' /etc/locale.gen sed -i 's/# nl_NL.UTF-8 UTF-8/nl_NL.UTF-8 UTF-8/g' /etc/locale.gen
sed -i 's/# pl_PL.UTF-8 UTF-8/pl_PL.UTF-8 UTF-8/g' /etc/locale.gen sed -i 's/# pl_PL.UTF-8 UTF-8/pl_PL.UTF-8 UTF-8/g' /etc/locale.gen
sed -i 's/# pt_BR.UTF-8 UTF-8/pt_BR.UTF-8 UTF-8/g' /etc/locale.gen
sed -i 's/# ru_RU.UTF-8 UTF-8/ru_RU.UTF-8 UTF-8/g' /etc/locale.gen sed -i 's/# ru_RU.UTF-8 UTF-8/ru_RU.UTF-8 UTF-8/g' /etc/locale.gen
sed -i 's/# tr_TR.UTF-8 UTF-8/tr_TR.UTF-8 UTF-8/g' /etc/locale.gen sed -i 's/# tr_TR.UTF-8 UTF-8/tr_TR.UTF-8 UTF-8/g' /etc/locale.gen
dpkg-reconfigure --frontend=noninteractive locales dpkg-reconfigure --frontend=noninteractive locales

View File

@@ -35,16 +35,6 @@ use League\Fractal\Serializer\JsonApiSerializer;
*/ */
class AboutController extends Controller class AboutController extends Controller
{ {
/**
* AccountController constructor.
*
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function __construct()
{
parent::__construct();
}
/** /**
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */

View File

@@ -103,7 +103,7 @@ class AccountController extends Controller
// types to get, page size: // types to get, page size:
$types = $this->mapTypes($this->parameters->get('type')); $types = $this->mapTypes($this->parameters->get('type'));
$pageSize = intval(Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data); $pageSize = (int)Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of accounts. Count it and split it. // get list of accounts. Count it and split it.
$collection = $this->repository->getAccountsByType($types); $collection = $this->repository->getAccountsByType($types);
@@ -154,7 +154,7 @@ class AccountController extends Controller
// if currency ID is 0, find the currency by the code: // if currency ID is 0, find the currency by the code:
if (0 === $data['currency_id']) { if (0 === $data['currency_id']) {
$currency = $this->currencyRepository->findByCodeNull($data['currency_code']); $currency = $this->currencyRepository->findByCodeNull($data['currency_code']);
$data['currency_id'] = is_null($currency) ? 0 : $currency->id; $data['currency_id'] = null === $currency ? 0 : $currency->id;
} }
$account = $this->repository->store($data); $account = $this->repository->store($data);
$manager = new Manager(); $manager = new Manager();
@@ -180,7 +180,7 @@ class AccountController extends Controller
// if currency ID is 0, find the currency by the code: // if currency ID is 0, find the currency by the code:
if (0 === $data['currency_id']) { if (0 === $data['currency_id']) {
$currency = $this->currencyRepository->findByCodeNull($data['currency_code']); $currency = $this->currencyRepository->findByCodeNull($data['currency_code']);
$data['currency_id'] = is_null($currency) ? 0 : $currency->id; $data['currency_id'] = null === $currency ? 0 : $currency->id;
} }
// set correct type: // set correct type:
$data['type'] = config('firefly.shortNamesByFullName.' . $account->accountType->type); $data['type'] = config('firefly.shortNamesByFullName.' . $account->accountType->type);

View File

@@ -85,7 +85,7 @@ class BillController extends Controller
*/ */
public function index(Request $request) public function index(Request $request)
{ {
$pageSize = intval(Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data); $pageSize = (int)Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data;
$paginator = $this->repository->getPaginator($pageSize); $paginator = $this->repository->getPaginator($pageSize);
/** @var Collection $bills */ /** @var Collection $bills */
$bills = $paginator->getCollection(); $bills = $paginator->getCollection();

View File

@@ -107,7 +107,7 @@ class Controller extends BaseController
foreach ($dates as $field) { foreach ($dates as $field) {
$date = request()->get($field); $date = request()->get($field);
$obj = null; $obj = null;
if (!is_null($date)) { if (null !== $date) {
try { try {
$obj = new Carbon($date); $obj = new Carbon($date);
} catch (InvalidDateException $e) { } catch (InvalidDateException $e) {

View File

@@ -91,7 +91,7 @@ class TransactionController extends Controller
*/ */
public function index(Request $request) public function index(Request $request)
{ {
$pageSize = intval(Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data); $pageSize = (int)Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data;
// read type from URI // read type from URI
$type = $request->get('type') ?? 'default'; $type = $request->get('type') ?? 'default';
@@ -115,7 +115,7 @@ class TransactionController extends Controller
$collector->removeFilter(InternalTransferFilter::class); $collector->removeFilter(InternalTransferFilter::class);
} }
if (!is_null($this->parameters->get('start')) && !is_null($this->parameters->get('end'))) { if (null !== $this->parameters->get('start') && null !== $this->parameters->get('end')) {
$collector->setRange($this->parameters->get('start'), $this->parameters->get('end')); $collector->setRange($this->parameters->get('start'), $this->parameters->get('end'));
} }
$collector->setLimit($pageSize)->setPage($this->parameters->get('page')); $collector->setLimit($pageSize)->setPage($this->parameters->get('page'));

View File

@@ -92,7 +92,7 @@ class UserController extends Controller
public function index(Request $request) public function index(Request $request)
{ {
// user preferences // user preferences
$pageSize = intval(Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data); $pageSize = (int)Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data;
// make manager // make manager
$manager = new Manager(); $manager = new Manager();

View File

@@ -108,8 +108,8 @@ class BillRequest extends Request
$validator->after( $validator->after(
function (Validator $validator) { function (Validator $validator) {
$data = $validator->getData(); $data = $validator->getData();
$min = floatval($data['amount_min'] ?? 0); $min = (float)($data['amount_min'] ?? 0);
$max = floatval($data['amount_max'] ?? 0); $max = (float)($data['amount_max'] ?? 0);
if ($min > $max) { if ($min > $max) {
$validator->errors()->add('amount_min', trans('validation.amount_min_over_max')); $validator->errors()->add('amount_min', trans('validation.amount_min_over_max'));
} }

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
{ {

View File

@@ -123,7 +123,6 @@ class ReconcileController extends Controller
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
* *
* @throws FireflyException * @throws FireflyException
* @throws \Throwable
*/ */
public function overview(Request $request, Account $account, Carbon $start, Carbon $end) public function overview(Request $request, Account $account, Carbon $start, Carbon $end)
{ {
@@ -189,7 +188,7 @@ class ReconcileController extends Controller
return redirect(route('accounts.index', [config('firefly.shortNamesByFullName.' . $account->accountType->type)])); return redirect(route('accounts.index', [config('firefly.shortNamesByFullName.' . $account->accountType->type)]));
} }
$currencyId = intval($this->accountRepos->getMetaValue($account, 'currency_id')); $currencyId = (int)$this->accountRepos->getMetaValue($account, 'currency_id');
$currency = $this->currencyRepos->findNull($currencyId); $currency = $this->currencyRepos->findNull($currencyId);
if (0 === $currencyId) { if (0 === $currencyId) {
$currency = app('amount')->getDefaultCurrency(); // @codeCoverageIgnore $currency = app('amount')->getDefaultCurrency(); // @codeCoverageIgnore
@@ -263,7 +262,7 @@ class ReconcileController extends Controller
/** @var Transaction $transaction */ /** @var Transaction $transaction */
foreach ($data['transactions'] as $transactionId) { foreach ($data['transactions'] as $transactionId) {
$repository->reconcileById(intval($transactionId)); $repository->reconcileById((int)$transactionId);
} }
Log::debug('Reconciled all transactions.'); Log::debug('Reconciled all transactions.');
@@ -300,7 +299,7 @@ class ReconcileController extends Controller
'tags' => null, 'tags' => null,
'interest_date' => null, 'interest_date' => null,
'transactions' => [[ 'transactions' => [[
'currency_id' => intval($this->accountRepos->getMetaValue($account, 'currency_id')), 'currency_id' => (int)$this->accountRepos->getMetaValue($account, 'currency_id'),
'currency_code' => null, 'currency_code' => null,
'description' => null, 'description' => null,
'amount' => app('steam')->positive($difference), 'amount' => app('steam')->positive($difference),
@@ -338,7 +337,6 @@ class ReconcileController extends Controller
* *
* @return mixed * @return mixed
* *
* @throws \Throwable
* @throws FireflyException * @throws FireflyException
*/ */
public function transactions(Account $account, Carbon $start, Carbon $end) public function transactions(Account $account, Carbon $start, Carbon $end)
@@ -350,7 +348,7 @@ class ReconcileController extends Controller
$startDate = clone $start; $startDate = clone $start;
$startDate->subDays(1); $startDate->subDays(1);
$currencyId = intval($this->accountRepos->getMetaValue($account, 'currency_id')); $currencyId = (int)$this->accountRepos->getMetaValue($account, 'currency_id');
$currency = $this->currencyRepos->findNull($currencyId); $currency = $this->currencyRepos->findNull($currencyId);
if (0 === $currencyId) { if (0 === $currencyId) {
$currency = app('amount')->getDefaultCurrency(); // @codeCoverageIgnore $currency = app('amount')->getDefaultCurrency(); // @codeCoverageIgnore
@@ -400,7 +398,7 @@ class ReconcileController extends Controller
$destination = $this->repository->getJournalDestinationAccounts($journal)->first(); $destination = $this->repository->getJournalDestinationAccounts($journal)->first();
if (bccomp($submitted['amount'], '0') === 1) { if (bccomp($submitted['amount'], '0') === 1) {
// amount is positive, switch accounts: // amount is positive, switch accounts:
list($source, $destination) = [$destination, $source]; [$source, $destination] = [$destination, $source];
} }
// expand data with journal data: // expand data with journal data:
@@ -417,7 +415,7 @@ class ReconcileController extends Controller
'interest_date' => null, 'interest_date' => null,
'book_date' => null, 'book_date' => null,
'transactions' => [[ 'transactions' => [[
'currency_id' => intval($journal->transaction_currency_id), 'currency_id' => (int)$journal->transaction_currency_id,
'currency_code' => null, 'currency_code' => null,
'description' => null, 'description' => null,
'amount' => app('steam')->positive($submitted['amount']), 'amount' => app('steam')->positive($submitted['amount']),
@@ -442,7 +440,7 @@ class ReconcileController extends Controller
$this->repository->update($journal, $data); $this->repository->update($journal, $data);
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
if (1 === intval($request->get('return_to_edit'))) { if (1 === (int)$request->get('return_to_edit')) {
Session::put('reconcile.edit.fromUpdate', true); Session::put('reconcile.edit.fromUpdate', true);
return redirect(route('accounts.reconcile.edit', [$journal->id]))->withInput(['return_to_edit' => 1]); return redirect(route('accounts.reconcile.edit', [$journal->id]))->withInput(['return_to_edit' => 1]);

View File

@@ -84,7 +84,6 @@ class AccountController extends Controller
* @param string $what * @param string $what
* *
* @return View * @return View
* @throws \RuntimeException
*/ */
public function create(Request $request, string $what = 'asset') public function create(Request $request, string $what = 'asset')
{ {
@@ -133,18 +132,17 @@ class AccountController extends Controller
* @param Account $account * @param Account $account
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function destroy(Request $request, Account $account) public function destroy(Request $request, Account $account)
{ {
$type = $account->accountType->type; $type = $account->accountType->type;
$typeName = config('firefly.shortNamesByFullName.' . $type); $typeName = config('firefly.shortNamesByFullName.' . $type);
$name = $account->name; $name = $account->name;
$moveTo = $this->repository->findNull(intval($request->get('move_account_before_delete'))); $moveTo = $this->repository->findNull((int)$request->get('move_account_before_delete'));
$this->repository->destroy($account, $moveTo); $this->repository->destroy($account, $moveTo);
$request->session()->flash('success', strval(trans('firefly.' . $typeName . '_deleted', ['name' => $name]))); $request->session()->flash('success', (string)trans('firefly.' . $typeName . '_deleted', ['name' => $name]));
Preferences::mark(); Preferences::mark();
return redirect($this->getPreviousUri('accounts.delete.uri')); return redirect($this->getPreviousUri('accounts.delete.uri'));
@@ -163,7 +161,7 @@ class AccountController extends Controller
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // long and complex but not that excessively so. * @SuppressWarnings(PHPMD.CyclomaticComplexity) // long and complex but not that excessively so.
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* *
* @throws \RuntimeException
*/ */
public function edit(Request $request, Account $account, AccountRepositoryInterface $repository) public function edit(Request $request, Account $account, AccountRepositoryInterface $repository)
{ {
@@ -174,7 +172,7 @@ class AccountController extends Controller
$currencySelectList = ExpandedForm::makeSelectList($allCurrencies); $currencySelectList = ExpandedForm::makeSelectList($allCurrencies);
$roles = []; $roles = [];
foreach (config('firefly.accountRoles') as $role) { foreach (config('firefly.accountRoles') as $role) {
$roles[$role] = strval(trans('firefly.account_role_' . $role)); $roles[$role] = (string)trans('firefly.account_role_' . $role);
} }
// put previous url in session if not redirect from store (not "return_to_edit"). // put previous url in session if not redirect from store (not "return_to_edit").
@@ -186,11 +184,11 @@ class AccountController extends Controller
// pre fill some useful values. // pre fill some useful values.
// the opening balance is tricky: // the opening balance is tricky:
$openingBalanceAmount = strval($repository->getOpeningBalanceAmount($account)); $openingBalanceAmount = (string)$repository->getOpeningBalanceAmount($account);
$openingBalanceDate = $repository->getOpeningBalanceDate($account); $openingBalanceDate = $repository->getOpeningBalanceDate($account);
$default = app('amount')->getDefaultCurrency(); $default = app('amount')->getDefaultCurrency();
$currency = $this->currencyRepos->findNull(intval($repository->getMetaValue($account, 'currency_id'))); $currency = $this->currencyRepos->findNull((int)$repository->getMetaValue($account, 'currency_id'));
if (is_null($currency)) { if (null === $currency) {
$currency = $default; $currency = $default;
} }
@@ -246,8 +244,8 @@ class AccountController extends Controller
$types = config('firefly.accountTypesByIdentifier.' . $what); $types = config('firefly.accountTypesByIdentifier.' . $what);
$collection = $this->repository->getAccountsByType($types); $collection = $this->repository->getAccountsByType($types);
$total = $collection->count(); $total = $collection->count();
$page = 0 === intval($request->get('page')) ? 1 : intval($request->get('page')); $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
$pageSize = intval(Preferences::get('listPageSize', 50)->data); $pageSize = (int)Preferences::get('listPageSize', 50)->data;
$accounts = $collection->slice(($page - 1) * $pageSize, $pageSize); $accounts = $collection->slice(($page - 1) * $pageSize, $pageSize);
unset($collection); unset($collection);
/** @var Carbon $start */ /** @var Carbon $start */
@@ -378,7 +376,6 @@ class AccountController extends Controller
* @param AccountFormRequest $request * @param AccountFormRequest $request
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function store(AccountFormRequest $request) public function store(AccountFormRequest $request)
{ {
@@ -396,7 +393,7 @@ class AccountController extends Controller
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
} }
if (1 === intval($request->get('create_another'))) { if (1 === (int)$request->get('create_another')) {
// set value so create routine will not overwrite URL: // set value so create routine will not overwrite URL:
$request->session()->put('accounts.create.fromStore', true); $request->session()->put('accounts.create.fromStore', true);
@@ -412,17 +409,16 @@ class AccountController extends Controller
* @param Account $account * @param Account $account
* *
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function update(AccountFormRequest $request, Account $account) public function update(AccountFormRequest $request, Account $account)
{ {
$data = $request->getAccountData(); $data = $request->getAccountData();
$this->repository->update($account, $data); $this->repository->update($account, $data);
$request->session()->flash('success', strval(trans('firefly.updated_account', ['name' => $account->name]))); $request->session()->flash('success', (string)trans('firefly.updated_account', ['name' => $account->name]));
Preferences::mark(); Preferences::mark();
if (1 === intval($request->get('return_to_edit'))) { if (1 === (int)$request->get('return_to_edit')) {
// set value so edit routine will not overwrite URL: // set value so edit routine will not overwrite URL:
$request->session()->put('accounts.edit.fromUpdate', true); $request->session()->put('accounts.edit.fromUpdate', true);
@@ -467,7 +463,7 @@ class AccountController extends Controller
$start = $this->repository->oldestJournalDate($account); $start = $this->repository->oldestJournalDate($account);
$end = $date ?? new Carbon; $end = $date ?? new Carbon;
if ($end < $start) { if ($end < $start) {
list($start, $end) = [$end, $start]; // @codeCoverageIgnore [$start, $end] = [$end, $start]; // @codeCoverageIgnore
} }
// properties for cache // properties for cache

View File

@@ -46,7 +46,7 @@ class ConfigurationController extends Controller
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
app('view')->share('title', strval(trans('firefly.administration'))); app('view')->share('title', (string)trans('firefly.administration'));
app('view')->share('mainTitleIcon', 'fa-hand-spock-o'); app('view')->share('mainTitleIcon', 'fa-hand-spock-o');
return $next($request); return $next($request);
@@ -61,7 +61,7 @@ class ConfigurationController extends Controller
*/ */
public function index() public function index()
{ {
$subTitle = strval(trans('firefly.instance_configuration')); $subTitle = (string)trans('firefly.instance_configuration');
$subTitleIcon = 'fa-wrench'; $subTitleIcon = 'fa-wrench';
// all available configuration and their default value in case // all available configuration and their default value in case
@@ -91,7 +91,7 @@ class ConfigurationController extends Controller
FireflyConfig::set('is_demo_site', $data['is_demo_site']); FireflyConfig::set('is_demo_site', $data['is_demo_site']);
// flash message // flash message
Session::flash('success', strval(trans('firefly.configuration_updated'))); Session::flash('success', (string)trans('firefly.configuration_updated'));
Preferences::mark(); Preferences::mark();
return Redirect::route('admin.configuration.index'); return Redirect::route('admin.configuration.index');

View File

@@ -50,7 +50,7 @@ class HomeController extends Controller
*/ */
public function index() public function index()
{ {
$title = strval(trans('firefly.administration')); $title = (string)trans('firefly.administration');
$mainTitleIcon = 'fa-hand-spock-o'; $mainTitleIcon = 'fa-hand-spock-o';
return view('admin.index', compact('title', 'mainTitleIcon')); return view('admin.index', compact('title', 'mainTitleIcon'));
@@ -66,7 +66,7 @@ class HomeController extends Controller
$ipAddress = $request->ip(); $ipAddress = $request->ip();
Log::debug(sprintf('Now in testMessage() controller. IP is %s', $ipAddress)); Log::debug(sprintf('Now in testMessage() controller. IP is %s', $ipAddress));
event(new AdminRequestedTestMessage(auth()->user(), $ipAddress)); event(new AdminRequestedTestMessage(auth()->user(), $ipAddress));
Session::flash('info', strval(trans('firefly.send_test_triggered'))); Session::flash('info', (string)trans('firefly.send_test_triggered'));
return redirect(route('admin.index')); return redirect(route('admin.index'));
} }

View File

@@ -45,7 +45,7 @@ class LinkController extends Controller
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
app('view')->share('title', strval(trans('firefly.administration'))); app('view')->share('title', (string)trans('firefly.administration'));
app('view')->share('mainTitleIcon', 'fa-hand-spock-o'); app('view')->share('mainTitleIcon', 'fa-hand-spock-o');
return $next($request); return $next($request);
@@ -76,12 +76,11 @@ class LinkController extends Controller
* @param LinkType $linkType * @param LinkType $linkType
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
* @throws \RuntimeException
*/ */
public function delete(Request $request, LinkTypeRepositoryInterface $repository, LinkType $linkType) public function delete(Request $request, LinkTypeRepositoryInterface $repository, LinkType $linkType)
{ {
if (!$linkType->editable) { if (!$linkType->editable) {
$request->session()->flash('error', strval(trans('firefly.cannot_edit_link_type', ['name' => $linkType->name]))); $request->session()->flash('error', (string)trans('firefly.cannot_edit_link_type', ['name' => $linkType->name]));
return redirect(route('admin.links.index')); return redirect(route('admin.links.index'));
} }
@@ -109,15 +108,14 @@ class LinkController extends Controller
* @param LinkType $linkType * @param LinkType $linkType
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function destroy(Request $request, LinkTypeRepositoryInterface $repository, LinkType $linkType) public function destroy(Request $request, LinkTypeRepositoryInterface $repository, LinkType $linkType)
{ {
$name = $linkType->name; $name = $linkType->name;
$moveTo = $repository->find(intval($request->get('move_link_type_before_delete'))); $moveTo = $repository->find((int)$request->get('move_link_type_before_delete'));
$repository->destroy($linkType, $moveTo); $repository->destroy($linkType, $moveTo);
$request->session()->flash('success', strval(trans('firefly.deleted_link_type', ['name' => $name]))); $request->session()->flash('success', (string)trans('firefly.deleted_link_type', ['name' => $name]));
Preferences::mark(); Preferences::mark();
return redirect($this->getPreviousUri('link_types.delete.uri')); return redirect($this->getPreviousUri('link_types.delete.uri'));
@@ -128,12 +126,11 @@ class LinkController extends Controller
* @param LinkType $linkType * @param LinkType $linkType
* *
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
* @throws \RuntimeException
*/ */
public function edit(Request $request, LinkType $linkType) public function edit(Request $request, LinkType $linkType)
{ {
if (!$linkType->editable) { if (!$linkType->editable) {
$request->session()->flash('error', strval(trans('firefly.cannot_edit_link_type', ['name' => $linkType->name]))); $request->session()->flash('error', (string)trans('firefly.cannot_edit_link_type', ['name' => $linkType->name]));
return redirect(route('admin.links.index')); return redirect(route('admin.links.index'));
} }
@@ -187,7 +184,6 @@ class LinkController extends Controller
* @param LinkTypeRepositoryInterface $repository * @param LinkTypeRepositoryInterface $repository
* *
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function store(LinkTypeFormRequest $request, LinkTypeRepositoryInterface $repository) public function store(LinkTypeFormRequest $request, LinkTypeRepositoryInterface $repository)
{ {
@@ -197,9 +193,9 @@ class LinkController extends Controller
'outward' => $request->string('outward'), 'outward' => $request->string('outward'),
]; ];
$linkType = $repository->store($data); $linkType = $repository->store($data);
$request->session()->flash('success', strval(trans('firefly.stored_new_link_type', ['name' => $linkType->name]))); $request->session()->flash('success', (string)trans('firefly.stored_new_link_type', ['name' => $linkType->name]));
if (1 === intval($request->get('create_another'))) { if (1 === (int)$request->get('create_another')) {
// set value so create routine will not overwrite URL: // set value so create routine will not overwrite URL:
$request->session()->put('link_types.create.fromStore', true); $request->session()->put('link_types.create.fromStore', true);
@@ -216,12 +212,11 @@ class LinkController extends Controller
* @param LinkType $linkType * @param LinkType $linkType
* *
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function update(LinkTypeFormRequest $request, LinkTypeRepositoryInterface $repository, LinkType $linkType) public function update(LinkTypeFormRequest $request, LinkTypeRepositoryInterface $repository, LinkType $linkType)
{ {
if (!$linkType->editable) { if (!$linkType->editable) {
$request->session()->flash('error', strval(trans('firefly.cannot_edit_link_type', ['name' => $linkType->name]))); $request->session()->flash('error', (string)trans('firefly.cannot_edit_link_type', ['name' => $linkType->name]));
return redirect(route('admin.links.index')); return redirect(route('admin.links.index'));
} }
@@ -233,10 +228,10 @@ class LinkController extends Controller
]; ];
$repository->update($linkType, $data); $repository->update($linkType, $data);
$request->session()->flash('success', strval(trans('firefly.updated_link_type', ['name' => $linkType->name]))); $request->session()->flash('success', (string)trans('firefly.updated_link_type', ['name' => $linkType->name]));
Preferences::mark(); Preferences::mark();
if (1 === intval($request->get('return_to_edit'))) { if (1 === (int)$request->get('return_to_edit')) {
// set value so edit routine will not overwrite URL: // set value so edit routine will not overwrite URL:
$request->session()->put('link_types.edit.fromUpdate', true); $request->session()->put('link_types.edit.fromUpdate', true);

View File

@@ -49,7 +49,7 @@ class UpdateController extends Controller
parent::__construct(); parent::__construct();
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
app('view')->share('title', strval(trans('firefly.administration'))); app('view')->share('title', (string)trans('firefly.administration'));
app('view')->share('mainTitleIcon', 'fa-hand-spock-o'); app('view')->share('mainTitleIcon', 'fa-hand-spock-o');
return $next($request); return $next($request);
@@ -87,10 +87,10 @@ class UpdateController extends Controller
*/ */
public function post(Request $request) public function post(Request $request)
{ {
$checkForUpdates = intval($request->get('check_for_updates')); $checkForUpdates = (int)$request->get('check_for_updates');
FireflyConfig::set('permission_update_check', $checkForUpdates); FireflyConfig::set('permission_update_check', $checkForUpdates);
FireflyConfig::set('last_update_check', time()); FireflyConfig::set('last_update_check', time());
Session::flash('success', strval(trans('firefly.configuration_updated'))); Session::flash('success', (string)trans('firefly.configuration_updated'));
return redirect(route('admin.update-check')); return redirect(route('admin.update-check'));
} }
@@ -118,7 +118,7 @@ class UpdateController extends Controller
Log::error(sprintf('Could not check for updates: %s', $e->getMessage())); Log::error(sprintf('Could not check for updates: %s', $e->getMessage()));
} }
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) {
@@ -126,25 +126,23 @@ class UpdateController extends Controller
// has it been released for more than three days? // has it been released for more than three days?
$today = new Carbon; $today = new Carbon;
if ($today->diffInDays($first->getUpdated(), true) > 3) { if ($today->diffInDays($first->getUpdated(), true) > 3) {
$string = strval( $string = (string)trans(
trans( 'firefly.update_new_version_alert',
'firefly.update_new_version_alert', [
[ 'your_version' => $current,
'your_version' => $current, 'new_version' => $first->getTitle(),
'new_version' => $first->getTitle(), 'date' => $first->getUpdated()->formatLocalized($this->monthAndDayFormat),
'date' => $first->getUpdated()->formatLocalized($this->monthAndDayFormat), ]
]
)
); );
} }
} }
if ($check === 0) { if ($check === 0) {
// you are running the current version! // you are running the current version!
$string = strval(trans('firefly.update_current_version_alert', ['version' => $current])); $string = (string)trans('firefly.update_current_version_alert', ['version' => $current]);
} }
if ($check === 1) { if ($check === 1) {
// you are running a newer version! // you are running a newer version!
$string = strval(trans('firefly.update_newer_version_alert', ['your_version' => $current, 'new_version' => $first->getTitle()])); $string = (string)trans('firefly.update_newer_version_alert', ['your_version' => $current, 'new_version' => $first->getTitle()]);
} }
return response()->json(['result' => $string]); return response()->json(['result' => $string]);

View File

@@ -47,7 +47,7 @@ class UserController extends Controller
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
app('view')->share('title', strval(trans('firefly.administration'))); app('view')->share('title', (string)trans('firefly.administration'));
app('view')->share('mainTitleIcon', 'fa-hand-spock-o'); app('view')->share('mainTitleIcon', 'fa-hand-spock-o');
return $next($request); return $next($request);
@@ -78,7 +78,7 @@ class UserController extends Controller
public function destroy(User $user, UserRepositoryInterface $repository) public function destroy(User $user, UserRepositoryInterface $repository)
{ {
$repository->destroy($user); $repository->destroy($user);
Session::flash('success', strval(trans('firefly.user_deleted'))); Session::flash('success', (string)trans('firefly.user_deleted'));
return redirect(route('admin.users')); return redirect(route('admin.users'));
} }
@@ -96,13 +96,13 @@ class UserController extends Controller
} }
Session::forget('users.edit.fromUpdate'); Session::forget('users.edit.fromUpdate');
$subTitle = strval(trans('firefly.edit_user', ['email' => $user->email])); $subTitle = (string)trans('firefly.edit_user', ['email' => $user->email]);
$subTitleIcon = 'fa-user-o'; $subTitleIcon = 'fa-user-o';
$codes = [ $codes = [
'' => strval(trans('firefly.no_block_code')), '' => (string)trans('firefly.no_block_code'),
'bounced' => strval(trans('firefly.block_code_bounced')), 'bounced' => (string)trans('firefly.block_code_bounced'),
'expired' => strval(trans('firefly.block_code_expired')), 'expired' => (string)trans('firefly.block_code_expired'),
'email_changed' => strval(trans('firefly.block_code_email_changed')), 'email_changed' => (string)trans('firefly.block_code_email_changed'),
]; ];
return view('admin.users.edit', compact('user', 'subTitle', 'subTitleIcon', 'codes')); return view('admin.users.edit', compact('user', 'subTitle', 'subTitleIcon', 'codes'));
@@ -115,7 +115,7 @@ class UserController extends Controller
*/ */
public function index(UserRepositoryInterface $repository) public function index(UserRepositoryInterface $repository)
{ {
$subTitle = strval(trans('firefly.user_administration')); $subTitle = (string)trans('firefly.user_administration');
$subTitleIcon = 'fa-users'; $subTitleIcon = 'fa-users';
$users = $repository->all(); $users = $repository->all();
@@ -143,9 +143,9 @@ class UserController extends Controller
*/ */
public function show(UserRepositoryInterface $repository, User $user) public function show(UserRepositoryInterface $repository, User $user)
{ {
$title = strval(trans('firefly.administration')); $title = (string)trans('firefly.administration');
$mainTitleIcon = 'fa-hand-spock-o'; $mainTitleIcon = 'fa-hand-spock-o';
$subTitle = strval(trans('firefly.single_user_administration', ['email' => $user->email])); $subTitle = (string)trans('firefly.single_user_administration', ['email' => $user->email]);
$subTitleIcon = 'fa-user'; $subTitleIcon = 'fa-user';
$information = $repository->getUserData($user); $information = $repository->getUserData($user);
@@ -182,10 +182,10 @@ class UserController extends Controller
$repository->changeStatus($user, $data['blocked'], $data['blocked_code']); $repository->changeStatus($user, $data['blocked'], $data['blocked_code']);
$repository->updateEmail($user, $data['email']); $repository->updateEmail($user, $data['email']);
Session::flash('success', strval(trans('firefly.updated_user', ['email' => $user->email]))); Session::flash('success', (string)trans('firefly.updated_user', ['email' => $user->email]));
Preferences::mark(); Preferences::mark();
if (1 === intval($request->get('return_to_edit'))) { if (1 === (int)$request->get('return_to_edit')) {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
Session::put('users.edit.fromUpdate', true); Session::put('users.edit.fromUpdate', true);

View File

@@ -80,7 +80,6 @@ class AttachmentController extends Controller
* @param Attachment $attachment * @param Attachment $attachment
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function destroy(Request $request, Attachment $attachment) public function destroy(Request $request, Attachment $attachment)
{ {
@@ -88,7 +87,7 @@ class AttachmentController extends Controller
$this->repository->destroy($attachment); $this->repository->destroy($attachment);
$request->session()->flash('success', strval(trans('firefly.attachment_deleted', ['name' => $name]))); $request->session()->flash('success', (string)trans('firefly.attachment_deleted', ['name' => $name]));
Preferences::mark(); Preferences::mark();
return redirect($this->getPreviousUri('attachments.delete.uri')); return redirect($this->getPreviousUri('attachments.delete.uri'));
@@ -130,7 +129,6 @@ class AttachmentController extends Controller
* @param Attachment $attachment * @param Attachment $attachment
* *
* @return View * @return View
* @throws \RuntimeException
*/ */
public function edit(Request $request, Attachment $attachment) public function edit(Request $request, Attachment $attachment)
{ {
@@ -154,17 +152,16 @@ class AttachmentController extends Controller
* @param Attachment $attachment * @param Attachment $attachment
* *
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* @throws \RuntimeException
*/ */
public function update(AttachmentFormRequest $request, Attachment $attachment) public function update(AttachmentFormRequest $request, Attachment $attachment)
{ {
$data = $request->getAttachmentData(); $data = $request->getAttachmentData();
$this->repository->update($attachment, $data); $this->repository->update($attachment, $data);
$request->session()->flash('success', strval(trans('firefly.attachment_updated', ['name' => $attachment->filename]))); $request->session()->flash('success', (string)trans('firefly.attachment_updated', ['name' => $attachment->filename]));
Preferences::mark(); Preferences::mark();
if (1 === intval($request->get('return_to_edit'))) { if (1 === (int)$request->get('return_to_edit')) {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
$request->session()->put('attachments.edit.fromUpdate', true); $request->session()->put('attachments.edit.fromUpdate', true);

View File

@@ -73,7 +73,7 @@ class ForgotPasswordController extends Controller
// verify if the user is not a demo user. If so, we give him back an error. // verify if the user is not a demo user. If so, we give him back an error.
$user = User::where('email', $request->get('email'))->first(); $user = User::where('email', $request->get('email'))->first();
if (!is_null($user) && $repository->hasRole($user, 'demo')) { if (null !== $user && $repository->hasRole($user, 'demo')) {
return back()->withErrors(['email' => trans('firefly.cannot_reset_demo_user')]); return back()->withErrors(['email' => trans('firefly.cannot_reset_demo_user')]);
} }

View File

@@ -65,7 +65,6 @@ class LoginController extends Controller
* *
* @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response * @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
* *
* @throws \RuntimeException
* @throws \Illuminate\Validation\ValidationException * @throws \Illuminate\Validation\ValidationException
*/ */
public function login(Request $request) public function login(Request $request)
@@ -103,7 +102,6 @@ class LoginController extends Controller
* @param CookieJar $cookieJar * @param CookieJar $cookieJar
* *
* @return $this|\Illuminate\Http\RedirectResponse * @return $this|\Illuminate\Http\RedirectResponse
* @throws \RuntimeException
*/ */
public function logout(Request $request, CookieJar $cookieJar) public function logout(Request $request, CookieJar $cookieJar)
{ {
@@ -121,7 +119,6 @@ class LoginController extends Controller
* @param Request $request * @param Request $request
* *
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @throws \RuntimeException
*/ */
public function showLoginForm(Request $request) public function showLoginForm(Request $request)
{ {

View File

@@ -83,7 +83,7 @@ class RegisterController extends Controller
$this->guard()->login($user); $this->guard()->login($user);
Session::flash('success', strval(trans('firefly.registered'))); Session::flash('success', (string)trans('firefly.registered'));
return $this->registered($request, $user) return $this->registered($request, $user)
?: redirect($this->redirectPath()); ?: redirect($this->redirectPath());

View File

@@ -40,7 +40,6 @@ class TwoFactorController extends Controller
* *
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
* *
* @throws \RuntimeException
* @throws FireflyException * @throws FireflyException
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.CyclomaticComplexity)
@@ -52,7 +51,7 @@ class TwoFactorController extends Controller
// to make sure the validator in the next step gets the secret, we push it in session // to make sure the validator in the next step gets the secret, we push it in session
$secretPreference = Preferences::get('twoFactorAuthSecret', null); $secretPreference = Preferences::get('twoFactorAuthSecret', null);
$secret = null === $secretPreference ? null : $secretPreference->data; $secret = null === $secretPreference ? null : $secretPreference->data;
$title = strval(trans('firefly.two_factor_title')); $title = (string)trans('firefly.two_factor_title');
// make sure the user has two factor configured: // make sure the user has two factor configured:
$has2FA = Preferences::get('twoFactorAuthEnabled', false)->data; $has2FA = Preferences::get('twoFactorAuthEnabled', false)->data;
@@ -60,7 +59,7 @@ class TwoFactorController extends Controller
return redirect(route('index')); return redirect(route('index'));
} }
if (0 === strlen(strval($secret))) { if (0 === strlen((string)$secret)) {
throw new FireflyException('Your two factor authentication secret is empty, which it cannot be at this point. Please check the log files.'); throw new FireflyException('Your two factor authentication secret is empty, which it cannot be at this point. Please check the log files.');
} }
$request->session()->flash('two-factor-secret', $secret); $request->session()->flash('two-factor-secret', $secret);
@@ -75,7 +74,7 @@ class TwoFactorController extends Controller
{ {
$user = auth()->user(); $user = auth()->user();
$siteOwner = env('SITE_OWNER', ''); $siteOwner = env('SITE_OWNER', '');
$title = strval(trans('firefly.two_factor_forgot_title')); $title = (string)trans('firefly.two_factor_forgot_title');
Log::info( Log::info(
'To reset the two factor authentication for user #' . $user->id . 'To reset the two factor authentication for user #' . $user->id .
@@ -92,7 +91,6 @@ class TwoFactorController extends Controller
* *
* @return mixed * @return mixed
* @SuppressWarnings(PHPMD.UnusedFormalParameter) // it's unused but the class does some validation. * @SuppressWarnings(PHPMD.UnusedFormalParameter) // it's unused but the class does some validation.
* @throws \RuntimeException
*/ */
public function postIndex(TokenFormRequest $request, CookieJar $cookieJar) public function postIndex(TokenFormRequest $request, CookieJar $cookieJar)
{ {

View File

@@ -75,7 +75,6 @@ class BillController extends Controller
* @param Request $request * @param Request $request
* *
* @return View * @return View
* @throws \RuntimeException
*/ */
public function create(Request $request) public function create(Request $request)
{ {
@@ -114,14 +113,13 @@ class BillController extends Controller
* @param Bill $bill * @param Bill $bill
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function destroy(Request $request, BillRepositoryInterface $repository, Bill $bill) public function destroy(Request $request, BillRepositoryInterface $repository, Bill $bill)
{ {
$name = $bill->name; $name = $bill->name;
$repository->destroy($bill); $repository->destroy($bill);
$request->session()->flash('success', strval(trans('firefly.deleted_bill', ['name' => $name]))); $request->session()->flash('success', (string)trans('firefly.deleted_bill', ['name' => $name]));
Preferences::mark(); Preferences::mark();
return redirect($this->getPreviousUri('bills.delete.uri')); return redirect($this->getPreviousUri('bills.delete.uri'));
@@ -132,7 +130,6 @@ class BillController extends Controller
* @param Bill $bill * @param Bill $bill
* *
* @return View * @return View
* @throws \RuntimeException
*/ */
public function edit(Request $request, Bill $bill) public function edit(Request $request, Bill $bill)
{ {
@@ -177,7 +174,7 @@ class BillController extends Controller
{ {
$start = session('start'); $start = session('start');
$end = session('end'); $end = session('end');
$pageSize = intval(Preferences::get('listPageSize', 50)->data); $pageSize = (int)Preferences::get('listPageSize', 50)->data;
$paginator = $repository->getPaginator($pageSize); $paginator = $repository->getPaginator($pageSize);
$parameters = new ParameterBag(); $parameters = new ParameterBag();
$parameters->set('start', $start); $parameters->set('start', $start);
@@ -201,12 +198,11 @@ class BillController extends Controller
* @param Bill $bill * @param Bill $bill
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function rescan(Request $request, BillRepositoryInterface $repository, Bill $bill) public function rescan(Request $request, BillRepositoryInterface $repository, Bill $bill)
{ {
if (0 === intval($bill->active)) { if (0 === (int)$bill->active) {
$request->session()->flash('warning', strval(trans('firefly.cannot_scan_inactive_bill'))); $request->session()->flash('warning', (string)trans('firefly.cannot_scan_inactive_bill'));
return redirect(URL::previous()); return redirect(URL::previous());
} }
@@ -217,7 +213,7 @@ class BillController extends Controller
$repository->scan($bill, $journal); $repository->scan($bill, $journal);
} }
$request->session()->flash('success', strval(trans('firefly.rescanned_bill'))); $request->session()->flash('success', (string)trans('firefly.rescanned_bill'));
Preferences::mark(); Preferences::mark();
return redirect(URL::previous()); return redirect(URL::previous());
@@ -236,8 +232,8 @@ class BillController extends Controller
$start = session('start'); $start = session('start');
$end = session('end'); $end = session('end');
$year = $start->year; $year = $start->year;
$page = intval($request->get('page')); $page = (int)$request->get('page');
$pageSize = intval(Preferences::get('listPageSize', 50)->data); $pageSize = (int)Preferences::get('listPageSize', 50)->data;
$yearAverage = $repository->getYearAverage($bill, $start); $yearAverage = $repository->getYearAverage($bill, $start);
$overallAverage = $repository->getOverallAverage($bill); $overallAverage = $repository->getOverallAverage($bill);
$manager = new Manager(); $manager = new Manager();
@@ -268,13 +264,12 @@ class BillController extends Controller
* @param BillRepositoryInterface $repository * @param BillRepositoryInterface $repository
* *
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* @throws \RuntimeException
*/ */
public function store(BillFormRequest $request, BillRepositoryInterface $repository) public function store(BillFormRequest $request, BillRepositoryInterface $repository)
{ {
$billData = $request->getBillData(); $billData = $request->getBillData();
$bill = $repository->store($billData); $bill = $repository->store($billData);
$request->session()->flash('success', strval(trans('firefly.stored_new_bill', ['name' => $bill->name]))); $request->session()->flash('success', (string)trans('firefly.stored_new_bill', ['name' => $bill->name]));
Preferences::mark(); Preferences::mark();
/** @var array $files */ /** @var array $files */
@@ -286,7 +281,7 @@ class BillController extends Controller
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
} }
if (1 === intval($request->get('create_another'))) { if (1 === (int)$request->get('create_another')) {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
$request->session()->put('bills.create.fromStore', true); $request->session()->put('bills.create.fromStore', true);
@@ -304,14 +299,13 @@ class BillController extends Controller
* @param Bill $bill * @param Bill $bill
* *
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* @throws \RuntimeException
*/ */
public function update(BillFormRequest $request, BillRepositoryInterface $repository, Bill $bill) public function update(BillFormRequest $request, BillRepositoryInterface $repository, Bill $bill)
{ {
$billData = $request->getBillData(); $billData = $request->getBillData();
$bill = $repository->update($bill, $billData); $bill = $repository->update($bill, $billData);
$request->session()->flash('success', strval(trans('firefly.updated_bill', ['name' => $bill->name]))); $request->session()->flash('success', (string)trans('firefly.updated_bill', ['name' => $bill->name]));
Preferences::mark(); Preferences::mark();
/** @var array $files */ /** @var array $files */
@@ -323,7 +317,7 @@ class BillController extends Controller
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
} }
if (1 === intval($request->get('return_to_edit'))) { if (1 === (int)$request->get('return_to_edit')) {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
$request->session()->put('bills.edit.fromUpdate', true); $request->session()->put('bills.edit.fromUpdate', true);

View File

@@ -78,11 +78,10 @@ class BudgetController extends Controller
* @param Budget $budget * @param Budget $budget
* *
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
* @throws \InvalidArgumentException
*/ */
public function amount(Request $request, BudgetRepositoryInterface $repository, Budget $budget) public function amount(Request $request, BudgetRepositoryInterface $repository, Budget $budget)
{ {
$amount = strval($request->get('amount')); $amount = (string)$request->get('amount');
$start = Carbon::createFromFormat('Y-m-d', $request->get('start')); $start = Carbon::createFromFormat('Y-m-d', $request->get('start'));
$end = Carbon::createFromFormat('Y-m-d', $request->get('end')); $end = Carbon::createFromFormat('Y-m-d', $request->get('end'));
$budgetLimit = $this->repository->updateLimitAmount($budget, $start, $end, $amount); $budgetLimit = $this->repository->updateLimitAmount($budget, $start, $end, $amount);
@@ -106,18 +105,16 @@ class BudgetController extends Controller
$diff = $start->diffInDays($end); $diff = $start->diffInDays($end);
$current = $amount; $current = $amount;
if ($diff > 0) { if ($diff > 0) {
$current = bcdiv($amount, strval($diff)); $current = bcdiv($amount, (string)$diff);
} }
if (bccomp(bcmul('1.1', $average), $current) === -1) { if (bccomp(bcmul('1.1', $average), $current) === -1) {
$largeDiff = true; $largeDiff = true;
$warnText = strval( $warnText = (string)trans(
trans( 'firefly.over_budget_warn',
'firefly.over_budget_warn', [
[ 'amount' => app('amount')->formatAnything($currency, $average, false),
'amount' => app('amount')->formatAnything($currency, $average, false), 'over_amount' => app('amount')->formatAnything($currency, $current, false),
'over_amount' => app('amount')->formatAnything($currency, $current, false), ]
]
)
); );
} }
@@ -142,7 +139,6 @@ class BudgetController extends Controller
* @param Request $request * @param Request $request
* *
* @return View * @return View
* @throws \RuntimeException
*/ */
public function create(Request $request) public function create(Request $request)
{ {
@@ -176,13 +172,12 @@ class BudgetController extends Controller
* @param Budget $budget * @param Budget $budget
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function destroy(Request $request, Budget $budget) public function destroy(Request $request, Budget $budget)
{ {
$name = $budget->name; $name = $budget->name;
$this->repository->destroy($budget); $this->repository->destroy($budget);
$request->session()->flash('success', strval(trans('firefly.deleted_budget', ['name' => $name]))); $request->session()->flash('success', (string)trans('firefly.deleted_budget', ['name' => $name]));
Preferences::mark(); Preferences::mark();
return redirect($this->getPreviousUri('budgets.delete.uri')); return redirect($this->getPreviousUri('budgets.delete.uri'));
@@ -193,7 +188,6 @@ class BudgetController extends Controller
* @param Budget $budget * @param Budget $budget
* *
* @return View * @return View
* @throws \RuntimeException
*/ */
public function edit(Request $request, Budget $budget) public function edit(Request $request, Budget $budget)
{ {
@@ -222,8 +216,8 @@ class BudgetController extends Controller
$range = Preferences::get('viewRange', '1M')->data; $range = Preferences::get('viewRange', '1M')->data;
$start = session('start', new Carbon); $start = session('start', new Carbon);
$end = session('end', new Carbon); $end = session('end', new Carbon);
$page = 0 === intval($request->get('page')) ? 1 : intval($request->get('page')); $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
$pageSize = intval(Preferences::get('listPageSize', 50)->data); $pageSize = (int)Preferences::get('listPageSize', 50)->data;
// make date if present: // make date if present:
if (null !== $moment || '' !== (string)$moment) { if (null !== $moment || '' !== (string)$moment) {
@@ -366,7 +360,7 @@ class BudgetController extends Controller
if (0 === $count) { if (0 === $count) {
$count = 1; $count = 1;
} }
$result['available'] = bcdiv($total, strval($count)); $result['available'] = bcdiv($total, (string)$count);
// amount earned in this period: // amount earned in this period:
$subDay = clone $end; $subDay = clone $end;
@@ -374,13 +368,13 @@ class BudgetController extends Controller
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class); $collector = app(JournalCollectorInterface::class);
$collector->setAllAssetAccounts()->setRange($begin, $subDay)->setTypes([TransactionType::DEPOSIT])->withOpposingAccount(); $collector->setAllAssetAccounts()->setRange($begin, $subDay)->setTypes([TransactionType::DEPOSIT])->withOpposingAccount();
$result['earned'] = bcdiv(strval($collector->getJournals()->sum('transaction_amount')), strval($count)); $result['earned'] = bcdiv((string)$collector->getJournals()->sum('transaction_amount'), (string)$count);
// amount spent in period // amount spent in period
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class); $collector = app(JournalCollectorInterface::class);
$collector->setAllAssetAccounts()->setRange($begin, $subDay)->setTypes([TransactionType::WITHDRAWAL])->withOpposingAccount(); $collector->setAllAssetAccounts()->setRange($begin, $subDay)->setTypes([TransactionType::WITHDRAWAL])->withOpposingAccount();
$result['spent'] = bcdiv(strval($collector->getJournals()->sum('transaction_amount')), strval($count)); $result['spent'] = bcdiv((string)$collector->getJournals()->sum('transaction_amount'), (string)$count);
// suggestion starts with the amount spent // suggestion starts with the amount spent
$result['suggested'] = bcmul($result['spent'], '-1'); $result['suggested'] = bcmul($result['spent'], '-1');
$result['suggested'] = 1 === bccomp($result['suggested'], $result['earned']) ? $result['earned'] : $result['suggested']; $result['suggested'] = 1 === bccomp($result['suggested'], $result['earned']) ? $result['earned'] : $result['suggested'];
@@ -439,8 +433,8 @@ class BudgetController extends Controller
); );
} }
$page = intval($request->get('page')); $page = (int)$request->get('page');
$pageSize = intval(Preferences::get('listPageSize', 50)->data); $pageSize = (int)Preferences::get('listPageSize', 50)->data;
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class); $collector = app(JournalCollectorInterface::class);
@@ -456,7 +450,6 @@ class BudgetController extends Controller
* @param BudgetIncomeRequest $request * @param BudgetIncomeRequest $request
* *
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* @throws \InvalidArgumentException
*/ */
public function postUpdateIncome(BudgetIncomeRequest $request) public function postUpdateIncome(BudgetIncomeRequest $request)
{ {
@@ -477,7 +470,6 @@ class BudgetController extends Controller
* @param Budget $budget * @param Budget $budget
* *
* @return View * @return View
* @throws \InvalidArgumentException
*/ */
public function show(Request $request, Budget $budget) public function show(Request $request, Budget $budget)
{ {
@@ -508,7 +500,6 @@ class BudgetController extends Controller
* *
* @return View * @return View
* *
* @throws \InvalidArgumentException
* @throws FireflyException * @throws FireflyException
*/ */
public function showByBudgetLimit(Request $request, Budget $budget, BudgetLimit $budgetLimit) public function showByBudgetLimit(Request $request, Budget $budget, BudgetLimit $budgetLimit)
@@ -517,8 +508,8 @@ class BudgetController extends Controller
throw new FireflyException('This budget limit is not part of this budget.'); throw new FireflyException('This budget limit is not part of this budget.');
} }
$page = intval($request->get('page')); $page = (int)$request->get('page');
$pageSize = intval(Preferences::get('listPageSize', 50)->data); $pageSize = (int)Preferences::get('listPageSize', 50)->data;
$subTitle = trans( $subTitle = trans(
'firefly.budget_in_period', 'firefly.budget_in_period',
[ [
@@ -546,17 +537,16 @@ class BudgetController extends Controller
* @param BudgetFormRequest $request * @param BudgetFormRequest $request
* *
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* @throws \RuntimeException
*/ */
public function store(BudgetFormRequest $request) public function store(BudgetFormRequest $request)
{ {
$data = $request->getBudgetData(); $data = $request->getBudgetData();
$budget = $this->repository->store($data); $budget = $this->repository->store($data);
$this->repository->cleanupBudgets(); $this->repository->cleanupBudgets();
$request->session()->flash('success', strval(trans('firefly.stored_new_budget', ['name' => $budget->name]))); $request->session()->flash('success', (string)trans('firefly.stored_new_budget', ['name' => $budget->name]));
Preferences::mark(); Preferences::mark();
if (1 === intval($request->get('create_another'))) { if (1 === (int)$request->get('create_another')) {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
$request->session()->put('budgets.create.fromStore', true); $request->session()->put('budgets.create.fromStore', true);
@@ -572,18 +562,17 @@ class BudgetController extends Controller
* @param Budget $budget * @param Budget $budget
* *
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* @throws \RuntimeException
*/ */
public function update(BudgetFormRequest $request, Budget $budget) public function update(BudgetFormRequest $request, Budget $budget)
{ {
$data = $request->getBudgetData(); $data = $request->getBudgetData();
$this->repository->update($budget, $data); $this->repository->update($budget, $data);
$request->session()->flash('success', strval(trans('firefly.updated_budget', ['name' => $budget->name]))); $request->session()->flash('success', (string)trans('firefly.updated_budget', ['name' => $budget->name]));
$this->repository->cleanupBudgets(); $this->repository->cleanupBudgets();
Preferences::mark(); Preferences::mark();
if (1 === intval($request->get('return_to_edit'))) { if (1 === (int)$request->get('return_to_edit')) {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
$request->session()->put('budgets.edit.fromUpdate', true); $request->session()->put('budgets.edit.fromUpdate', true);
@@ -606,7 +595,7 @@ class BudgetController extends Controller
$defaultCurrency = app('amount')->getDefaultCurrency(); $defaultCurrency = app('amount')->getDefaultCurrency();
$available = $this->repository->getAvailableBudget($defaultCurrency, $start, $end); $available = $this->repository->getAvailableBudget($defaultCurrency, $start, $end);
$available = round($available, $defaultCurrency->decimal_places); $available = round($available, $defaultCurrency->decimal_places);
$page = intval($request->get('page')); $page = (int)$request->get('page');
return view('budgets.income', compact('available', 'start', 'end', 'page')); return view('budgets.income', compact('available', 'start', 'end', 'page'));
} }
@@ -672,7 +661,7 @@ class BudgetController extends Controller
[TransactionType::WITHDRAWAL] [TransactionType::WITHDRAWAL]
); );
$set = $collector->getJournals(); $set = $collector->getJournals();
$sum = strval($set->sum('transaction_amount') ?? '0'); $sum = (string)($set->sum('transaction_amount') ?? '0');
$journals = $set->count(); $journals = $set->count();
$dateStr = $date['end']->format('Y-m-d'); $dateStr = $date['end']->format('Y-m-d');
$dateName = app('navigation')->periodShow($date['end'], $date['period']); $dateName = app('navigation')->periodShow($date['end'], $date['period']);

View File

@@ -77,7 +77,6 @@ class CategoryController extends Controller
* @param Request $request * @param Request $request
* *
* @return View * @return View
* @throws \RuntimeException
*/ */
public function create(Request $request) public function create(Request $request)
{ {
@@ -110,14 +109,13 @@ class CategoryController extends Controller
* @param Category $category * @param Category $category
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function destroy(Request $request, Category $category) public function destroy(Request $request, Category $category)
{ {
$name = $category->name; $name = $category->name;
$this->repository->destroy($category); $this->repository->destroy($category);
$request->session()->flash('success', strval(trans('firefly.deleted_category', ['name' => $name]))); $request->session()->flash('success', (string)trans('firefly.deleted_category', ['name' => $name]));
Preferences::mark(); Preferences::mark();
return redirect($this->getPreviousUri('categories.delete.uri')); return redirect($this->getPreviousUri('categories.delete.uri'));
@@ -128,7 +126,6 @@ class CategoryController extends Controller
* @param Category $category * @param Category $category
* *
* @return View * @return View
* @throws \RuntimeException
*/ */
public function edit(Request $request, Category $category) public function edit(Request $request, Category $category)
{ {
@@ -150,8 +147,8 @@ class CategoryController extends Controller
*/ */
public function index(Request $request) public function index(Request $request)
{ {
$page = 0 === intval($request->get('page')) ? 1 : intval($request->get('page')); $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
$pageSize = intval(Preferences::get('listPageSize', 50)->data); $pageSize = (int)Preferences::get('listPageSize', 50)->data;
$collection = $this->repository->getCategories(); $collection = $this->repository->getCategories();
$total = $collection->count(); $total = $collection->count();
$collection = $collection->slice(($page - 1) * $pageSize, $pageSize); $collection = $collection->slice(($page - 1) * $pageSize, $pageSize);
@@ -182,8 +179,8 @@ class CategoryController extends Controller
$start = null; $start = null;
$end = null; $end = null;
$periods = new Collection; $periods = new Collection;
$page = intval($request->get('page')); $page = (int)$request->get('page');
$pageSize = intval(Preferences::get('listPageSize', 50)->data); $pageSize = (int)Preferences::get('listPageSize', 50)->data;
// prep for "all" view. // prep for "all" view.
if ('all' === $moment) { if ('all' === $moment) {
@@ -239,8 +236,8 @@ class CategoryController extends Controller
// default values: // default values:
$subTitle = $category->name; $subTitle = $category->name;
$subTitleIcon = 'fa-bar-chart'; $subTitleIcon = 'fa-bar-chart';
$page = intval($request->get('page')); $page = (int)$request->get('page');
$pageSize = intval(Preferences::get('listPageSize', 50)->data); $pageSize = (int)Preferences::get('listPageSize', 50)->data;
$range = Preferences::get('viewRange', '1M')->data; $range = Preferences::get('viewRange', '1M')->data;
$start = null; $start = null;
$end = null; $end = null;
@@ -252,7 +249,7 @@ class CategoryController extends Controller
$subTitle = trans('firefly.all_journals_for_category', ['name' => $category->name]); $subTitle = trans('firefly.all_journals_for_category', ['name' => $category->name]);
$first = $repository->firstUseDate($category); $first = $repository->firstUseDate($category);
/** @var Carbon $start */ /** @var Carbon $start */
$start = null === $first ? new Carbon : $first; $start = $first ?? new Carbon;
$end = new Carbon; $end = new Carbon;
$path = route('categories.show', [$category->id, 'all']); $path = route('categories.show', [$category->id, 'all']);
} }
@@ -300,17 +297,16 @@ class CategoryController extends Controller
* @param CategoryRepositoryInterface $repository * @param CategoryRepositoryInterface $repository
* *
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function store(CategoryFormRequest $request, CategoryRepositoryInterface $repository) public function store(CategoryFormRequest $request, CategoryRepositoryInterface $repository)
{ {
$data = $request->getCategoryData(); $data = $request->getCategoryData();
$category = $repository->store($data); $category = $repository->store($data);
$request->session()->flash('success', strval(trans('firefly.stored_category', ['name' => $category->name]))); $request->session()->flash('success', (string)trans('firefly.stored_category', ['name' => $category->name]));
Preferences::mark(); Preferences::mark();
if (1 === intval($request->get('create_another'))) { if (1 === (int)$request->get('create_another')) {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
$request->session()->put('categories.create.fromStore', true); $request->session()->put('categories.create.fromStore', true);
@@ -327,17 +323,16 @@ class CategoryController extends Controller
* @param Category $category * @param Category $category
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function update(CategoryFormRequest $request, CategoryRepositoryInterface $repository, Category $category) public function update(CategoryFormRequest $request, CategoryRepositoryInterface $repository, Category $category)
{ {
$data = $request->getCategoryData(); $data = $request->getCategoryData();
$repository->update($category, $data); $repository->update($category, $data);
$request->session()->flash('success', strval(trans('firefly.updated_category', ['name' => $category->name]))); $request->session()->flash('success', (string)trans('firefly.updated_category', ['name' => $category->name]));
Preferences::mark(); Preferences::mark();
if (1 === intval($request->get('return_to_edit'))) { if (1 === (int)$request->get('return_to_edit')) {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
$request->session()->put('categories.edit.fromUpdate', true); $request->session()->put('categories.edit.fromUpdate', true);

View File

@@ -93,7 +93,7 @@ class AccountController extends Controller
} }
arsort($chartData); arsort($chartData);
$data = $this->generator->singleSet(strval(trans('firefly.spent')), $chartData); $data = $this->generator->singleSet((string)trans('firefly.spent'), $chartData);
$cache->store($data); $cache->store($data);
return response()->json($data); return response()->json($data);
@@ -124,8 +124,8 @@ class AccountController extends Controller
/** @var Transaction $transaction */ /** @var Transaction $transaction */
foreach ($transactions as $transaction) { foreach ($transactions as $transaction) {
$jrnlBudgetId = intval($transaction->transaction_journal_budget_id); $jrnlBudgetId = (int)$transaction->transaction_journal_budget_id;
$transBudgetId = intval($transaction->transaction_budget_id); $transBudgetId = (int)$transaction->transaction_budget_id;
$budgetId = max($jrnlBudgetId, $transBudgetId); $budgetId = max($jrnlBudgetId, $transBudgetId);
$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]);
@@ -181,8 +181,8 @@ class AccountController extends Controller
$chartData = []; $chartData = [];
/** @var Transaction $transaction */ /** @var Transaction $transaction */
foreach ($transactions as $transaction) { foreach ($transactions 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]);
@@ -264,8 +264,8 @@ class AccountController extends Controller
$chartData = []; $chartData = [];
/** @var Transaction $transaction */ /** @var Transaction $transaction */
foreach ($transactions as $transaction) { foreach ($transactions 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]);
@@ -336,7 +336,7 @@ class AccountController extends Controller
$theDate = $current->format('Y-m-d'); $theDate = $current->format('Y-m-d');
$balance = $range[$theDate] ?? $previous; $balance = $range[$theDate] ?? $previous;
$label = $current->formatLocalized($format); $label = $current->formatLocalized($format);
$chartData[$label] = floatval($balance); $chartData[$label] = (float)$balance;
$previous = $balance; $previous = $balance;
$current->addDay(); $current->addDay();
} }
@@ -346,7 +346,7 @@ class AccountController extends Controller
case '1M': case '1M':
case '1Y': case '1Y':
while ($end >= $current) { while ($end >= $current) {
$balance = floatval(app('steam')->balance($account, $current)); $balance = (float)app('steam')->balance($account, $current);
$label = app('navigation')->periodShow($current, $step); $label = app('navigation')->periodShow($current, $step);
$chartData[$label] = $balance; $chartData[$label] = $balance;
$current = app('navigation')->addPeriod($current, $step, 1); $current = app('navigation')->addPeriod($current, $step, 1);
@@ -411,7 +411,7 @@ class AccountController extends Controller
} }
arsort($chartData); arsort($chartData);
$data = $this->generator->singleSet(strval(trans('firefly.earned')), $chartData); $data = $this->generator->singleSet((string)trans('firefly.earned'), $chartData);
$cache->store($data); $cache->store($data);
return response()->json($data); return response()->json($data);
@@ -442,7 +442,7 @@ class AccountController extends Controller
$chartData = []; $chartData = [];
foreach ($accounts as $account) { foreach ($accounts as $account) {
$currency = $repository->findNull(intval($account->getMeta('currency_id'))); $currency = $repository->findNull((int)$account->getMeta('currency_id'));
$currentSet = [ $currentSet = [
'label' => $account->name, 'label' => $account->name,
'currency_symbol' => $currency->symbol, 'currency_symbol' => $currency->symbol,
@@ -453,7 +453,7 @@ class AccountController extends Controller
$previous = array_values($range)[0]; $previous = array_values($range)[0];
while ($currentStart <= $end) { while ($currentStart <= $end) {
$format = $currentStart->format('Y-m-d'); $format = $currentStart->format('Y-m-d');
$label = $currentStart->formatLocalized(strval(trans('config.month_and_day'))); $label = $currentStart->formatLocalized((string)trans('config.month_and_day'));
$balance = isset($range[$format]) ? round($range[$format], 12) : $previous; $balance = isset($range[$format]) ? round($range[$format], 12) : $previous;
$previous = $balance; $previous = $balance;
$currentStart->addDay(); $currentStart->addDay();

View File

@@ -71,8 +71,8 @@ class BillController extends Controller
$paid = $repository->getBillsPaidInRange($start, $end); // will be a negative amount. $paid = $repository->getBillsPaidInRange($start, $end); // will be a negative amount.
$unpaid = $repository->getBillsUnpaidInRange($start, $end); // will be a positive amount. $unpaid = $repository->getBillsUnpaidInRange($start, $end); // will be a positive amount.
$chartData = [ $chartData = [
strval(trans('firefly.unpaid')) => $unpaid, (string)trans('firefly.unpaid') => $unpaid,
strval(trans('firefly.paid')) => $paid, (string)trans('firefly.paid') => $paid,
]; ];
$data = $this->generator->pieChart($chartData); $data = $this->generator->pieChart($chartData);
@@ -110,7 +110,7 @@ class BillController extends Controller
/** @var Transaction $entry */ /** @var Transaction $entry */
foreach ($results as $entry) { foreach ($results as $entry) {
$date = $entry->date->formatLocalized(strval(trans('config.month_and_day'))); $date = $entry->date->formatLocalized((string)trans('config.month_and_day'));
$chartData[0]['entries'][$date] = $bill->amount_min; // minimum amount of bill $chartData[0]['entries'][$date] = $bill->amount_min; // minimum amount of bill
$chartData[1]['entries'][$date] = $bill->amount_max; // maximum amount of bill $chartData[1]['entries'][$date] = $bill->amount_max; // maximum amount of bill
$chartData[2]['entries'][$date] = bcmul($entry->transaction_amount, '-1'); // amount of journal $chartData[2]['entries'][$date] = bcmul($entry->transaction_amount, '-1'); // amount of journal

View File

@@ -112,12 +112,12 @@ class BudgetController extends Controller
} }
$spent = $this->repository->spentInPeriod($budgetCollection, new Collection, $current, $currentEnd); $spent = $this->repository->spentInPeriod($budgetCollection, new Collection, $current, $currentEnd);
$label = app('navigation')->periodShow($current, $step); $label = app('navigation')->periodShow($current, $step);
$chartData[$label] = floatval(bcmul($spent, '-1')); $chartData[$label] = (float)bcmul($spent, '-1');
$current = clone $currentEnd; $current = clone $currentEnd;
$current->addDay(); $current->addDay();
} }
$data = $this->generator->singleSet(strval(trans('firefly.spent')), $chartData); $data = $this->generator->singleSet((string)trans('firefly.spent'), $chartData);
$cache->store($data); $cache->store($data);
@@ -161,12 +161,12 @@ class BudgetController extends Controller
while ($start <= $end) { while ($start <= $end) {
$spent = $this->repository->spentInPeriod($budgetCollection, new Collection, $start, $start); $spent = $this->repository->spentInPeriod($budgetCollection, new Collection, $start, $start);
$amount = bcadd($amount, $spent); $amount = bcadd($amount, $spent);
$format = $start->formatLocalized(strval(trans('config.month_and_day'))); $format = $start->formatLocalized((string)trans('config.month_and_day'));
$entries[$format] = $amount; $entries[$format] = $amount;
$start->addDay(); $start->addDay();
} }
$data = $this->generator->singleSet(strval(trans('firefly.left')), $entries); $data = $this->generator->singleSet((string)trans('firefly.left'), $entries);
$cache->store($data); $cache->store($data);
return response()->json($data); return response()->json($data);
@@ -200,7 +200,7 @@ class BudgetController extends Controller
$chartData = []; $chartData = [];
/** @var Transaction $transaction */ /** @var Transaction $transaction */
foreach ($transactions as $transaction) { foreach ($transactions as $transaction) {
$assetId = intval($transaction->account_id); $assetId = (int)$transaction->account_id;
$result[$assetId] = $result[$assetId] ?? '0'; $result[$assetId] = $result[$assetId] ?? '0';
$result[$assetId] = bcadd($transaction->transaction_amount, $result[$assetId]); $result[$assetId] = bcadd($transaction->transaction_amount, $result[$assetId]);
} }
@@ -244,8 +244,8 @@ class BudgetController extends Controller
$chartData = []; $chartData = [];
/** @var Transaction $transaction */ /** @var Transaction $transaction */
foreach ($transactions as $transaction) { foreach ($transactions 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]);
@@ -290,7 +290,7 @@ class BudgetController extends Controller
$chartData = []; $chartData = [];
/** @var Transaction $transaction */ /** @var Transaction $transaction */
foreach ($transactions as $transaction) { foreach ($transactions as $transaction) {
$opposingId = intval($transaction->opposing_account_id); $opposingId = (int)$transaction->opposing_account_id;
$result[$opposingId] = $result[$opposingId] ?? '0'; $result[$opposingId] = $result[$opposingId] ?? '0';
$result[$opposingId] = bcadd($transaction->transaction_amount, $result[$opposingId]); $result[$opposingId] = bcadd($transaction->transaction_amount, $result[$opposingId]);
} }
@@ -329,9 +329,9 @@ class BudgetController extends Controller
} }
$budgets = $this->repository->getActiveBudgets(); $budgets = $this->repository->getActiveBudgets();
$chartData = [ $chartData = [
['label' => strval(trans('firefly.spent_in_budget')), 'entries' => [], 'type' => 'bar'], ['label' => (string)trans('firefly.spent_in_budget'), 'entries' => [], 'type' => 'bar'],
['label' => strval(trans('firefly.left_to_spend')), 'entries' => [], 'type' => 'bar'], ['label' => (string)trans('firefly.left_to_spend'), 'entries' => [], 'type' => 'bar'],
['label' => strval(trans('firefly.overspent')), 'entries' => [], 'type' => 'bar'], ['label' => (string)trans('firefly.overspent'), 'entries' => [], 'type' => 'bar'],
]; ];
/** @var Budget $budget */ /** @var Budget $budget */
@@ -348,7 +348,7 @@ class BudgetController extends Controller
} }
// for no budget: // for no budget:
$spent = $this->spentInPeriodWithout($start, $end); $spent = $this->spentInPeriodWithout($start, $end);
$name = strval(trans('firefly.no_budget')); $name = (string)trans('firefly.no_budget');
if (0 !== bccomp($spent, '0')) { if (0 !== bccomp($spent, '0')) {
$chartData[0]['entries'][$name] = bcmul($spent, '-1'); $chartData[0]['entries'][$name] = bcmul($spent, '-1');
$chartData[1]['entries'][$name] = '0'; $chartData[1]['entries'][$name] = '0';
@@ -389,14 +389,14 @@ class BudgetController extends Controller
// join them into one set of data: // join them into one set of data:
$chartData = [ $chartData = [
['label' => strval(trans('firefly.spent')), 'type' => 'bar', 'entries' => []], ['label' => (string)trans('firefly.spent'), 'type' => 'bar', 'entries' => []],
['label' => strval(trans('firefly.budgeted')), 'type' => 'bar', 'entries' => []], ['label' => (string)trans('firefly.budgeted'), 'type' => 'bar', 'entries' => []],
]; ];
foreach (array_keys($periods) as $period) { foreach (array_keys($periods) as $period) {
$label = $periods[$period]; $label = $periods[$period];
$spent = isset($entries[$budget->id]['entries'][$period]) ? $entries[$budget->id]['entries'][$period] : '0'; $spent = $entries[$budget->id]['entries'][$period] ?? '0';
$limit = isset($budgeted[$period]) ? $budgeted[$period] : 0; $limit = (int)($budgeted[$period] ?? 0);
$chartData[0]['entries'][$label] = round(bcmul($spent, '-1'), 12); $chartData[0]['entries'][$label] = round(bcmul($spent, '-1'), 12);
$chartData[1]['entries'][$label] = $limit; $chartData[1]['entries'][$label] = $limit;
} }
@@ -433,10 +433,10 @@ class BudgetController extends Controller
// join them: // join them:
foreach (array_keys($periods) as $period) { foreach (array_keys($periods) as $period) {
$label = $periods[$period]; $label = $periods[$period];
$spent = isset($entries['entries'][$period]) ? $entries['entries'][$period] : '0'; $spent = $entries['entries'][$period] ?? '0';
$chartData[$label] = bcmul($spent, '-1'); $chartData[$label] = bcmul($spent, '-1');
} }
$data = $this->generator->singleSet(strval(trans('firefly.spent')), $chartData); $data = $this->generator->singleSet((string)trans('firefly.spent'), $chartData);
$cache->store($data); $cache->store($data);
return response()->json($data); return response()->json($data);
@@ -568,7 +568,7 @@ class BudgetController extends Controller
private function spentInPeriodMulti(Budget $budget, Collection $limits): array private function spentInPeriodMulti(Budget $budget, Collection $limits): array
{ {
$return = []; $return = [];
$format = strval(trans('config.month_and_day')); $format = (string)trans('config.month_and_day');
$name = $budget->name; $name = $budget->name;
/** @var BudgetLimit $budgetLimit */ /** @var BudgetLimit $budgetLimit */
foreach ($limits as $budgetLimit) { foreach ($limits as $budgetLimit) {

View File

@@ -83,7 +83,7 @@ class BudgetReportController extends Controller
$helper->setBudgets($budgets); $helper->setBudgets($budgets);
$helper->setStart($start); $helper->setStart($start);
$helper->setEnd($end); $helper->setEnd($end);
$helper->setCollectOtherObjects(1 === intval($others)); $helper->setCollectOtherObjects(1 === (int)$others);
$chartData = $helper->generate('expense', 'account'); $chartData = $helper->generate('expense', 'account');
$data = $this->generator->pieChart($chartData); $data = $this->generator->pieChart($chartData);
@@ -107,7 +107,7 @@ class BudgetReportController extends Controller
$helper->setBudgets($budgets); $helper->setBudgets($budgets);
$helper->setStart($start); $helper->setStart($start);
$helper->setEnd($end); $helper->setEnd($end);
$helper->setCollectOtherObjects(1 === intval($others)); $helper->setCollectOtherObjects(1 === (int)$others);
$chartData = $helper->generate('expense', 'budget'); $chartData = $helper->generate('expense', 'budget');
$data = $this->generator->pieChart($chartData); $data = $this->generator->pieChart($chartData);
@@ -141,20 +141,20 @@ class BudgetReportController extends Controller
// prep chart data: // prep chart data:
foreach ($budgets as $budget) { foreach ($budgets as $budget) {
$chartData[$budget->id] = [ $chartData[$budget->id] = [
'label' => strval(trans('firefly.spent_in_specific_budget', ['budget' => $budget->name])), 'label' => (string)trans('firefly.spent_in_specific_budget', ['budget' => $budget->name]),
'type' => 'bar', 'type' => 'bar',
'yAxisID' => 'y-axis-0', 'yAxisID' => 'y-axis-0',
'entries' => [], 'entries' => [],
]; ];
$chartData[$budget->id . '-sum'] = [ $chartData[$budget->id . '-sum'] = [
'label' => strval(trans('firefly.sum_of_expenses_in_budget', ['budget' => $budget->name])), 'label' => (string)trans('firefly.sum_of_expenses_in_budget', ['budget' => $budget->name]),
'type' => 'line', 'type' => 'line',
'fill' => false, 'fill' => false,
'yAxisID' => 'y-axis-1', 'yAxisID' => 'y-axis-1',
'entries' => [], 'entries' => [],
]; ];
$chartData[$budget->id . '-left'] = [ $chartData[$budget->id . '-left'] = [
'label' => strval(trans('firefly.left_in_budget_limit', ['budget' => $budget->name])), 'label' => (string)trans('firefly.left_in_budget_limit', ['budget' => $budget->name]),
'type' => 'bar', 'type' => 'bar',
'fill' => false, 'fill' => false,
'yAxisID' => 'y-axis-0', 'yAxisID' => 'y-axis-0',
@@ -182,7 +182,7 @@ class BudgetReportController extends Controller
if (count($budgetLimits) > 0) { if (count($budgetLimits) > 0) {
$budgetLimitId = $budgetLimits->first()->id; $budgetLimitId = $budgetLimits->first()->id;
$leftOfLimits[$budgetLimitId] = $leftOfLimits[$budgetLimitId] ?? strval($budgetLimits->sum('amount')); $leftOfLimits[$budgetLimitId] = $leftOfLimits[$budgetLimitId] ?? (string)$budgetLimits->sum('amount');
$leftOfLimits[$budgetLimitId] = bcadd($leftOfLimits[$budgetLimitId], $currentExpenses); $leftOfLimits[$budgetLimitId] = bcadd($leftOfLimits[$budgetLimitId], $currentExpenses);
$chartData[$budget->id . '-left']['entries'][$label] = $leftOfLimits[$budgetLimitId]; $chartData[$budget->id . '-left']['entries'][$label] = $leftOfLimits[$budgetLimitId];
} }
@@ -244,9 +244,7 @@ class BudgetReportController extends Controller
$collector->addFilter(OpposingAccountFilter::class); $collector->addFilter(OpposingAccountFilter::class);
$collector->addFilter(PositiveAmountFilter::class); $collector->addFilter(PositiveAmountFilter::class);
$transactions = $collector->getJournals(); return $collector->getJournals();
return $transactions;
} }
/** /**
@@ -260,8 +258,8 @@ class BudgetReportController extends Controller
$grouped = []; $grouped = [];
/** @var Transaction $transaction */ /** @var Transaction $transaction */
foreach ($set as $transaction) { foreach ($set 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);
$grouped[$budgetId] = $grouped[$budgetId] ?? '0'; $grouped[$budgetId] = $grouped[$budgetId] ?? '0';
$grouped[$budgetId] = bcadd($transaction->transaction_amount, $grouped[$budgetId]); $grouped[$budgetId] = bcadd($transaction->transaction_amount, $grouped[$budgetId]);

View File

@@ -81,17 +81,17 @@ class CategoryController extends Controller
$accounts = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]); $accounts = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
$chartData = [ $chartData = [
[ [
'label' => strval(trans('firefly.spent')), 'label' => (string)trans('firefly.spent'),
'entries' => [], 'entries' => [],
'type' => 'bar', 'type' => 'bar',
], ],
[ [
'label' => strval(trans('firefly.earned')), 'label' => (string)trans('firefly.earned'),
'entries' => [], 'entries' => [],
'type' => 'bar', 'type' => 'bar',
], ],
[ [
'label' => strval(trans('firefly.sum')), 'label' => (string)trans('firefly.sum'),
'entries' => [], 'entries' => [],
'type' => 'line', 'type' => 'line',
'fill' => false, 'fill' => false,
@@ -145,12 +145,12 @@ class CategoryController extends Controller
} }
} }
$chartData[strval(trans('firefly.no_category'))] = bcmul($repository->spentInPeriodWithoutCategory(new Collection, $start, $end), '-1'); $chartData[(string)trans('firefly.no_category')] = bcmul($repository->spentInPeriodWithoutCategory(new Collection, $start, $end), '-1');
// sort // sort
arsort($chartData); arsort($chartData);
$data = $this->generator->singleSet(strval(trans('firefly.spent')), $chartData); $data = $this->generator->singleSet((string)trans('firefly.spent'), $chartData);
$cache->store($data); $cache->store($data);
return response()->json($data); return response()->json($data);
@@ -181,17 +181,17 @@ class CategoryController extends Controller
$periods = app('navigation')->listOfPeriods($start, $end); $periods = app('navigation')->listOfPeriods($start, $end);
$chartData = [ $chartData = [
[ [
'label' => strval(trans('firefly.spent')), 'label' => (string)trans('firefly.spent'),
'entries' => [], 'entries' => [],
'type' => 'bar', 'type' => 'bar',
], ],
[ [
'label' => strval(trans('firefly.earned')), 'label' => (string)trans('firefly.earned'),
'entries' => [], 'entries' => [],
'type' => 'bar', 'type' => 'bar',
], ],
[ [
'label' => strval(trans('firefly.sum')), 'label' => (string)trans('firefly.sum'),
'entries' => [], 'entries' => [],
'type' => 'line', 'type' => 'line',
'fill' => false, 'fill' => false,
@@ -237,17 +237,17 @@ class CategoryController extends Controller
$periods = app('navigation')->listOfPeriods($start, $end); $periods = app('navigation')->listOfPeriods($start, $end);
$chartData = [ $chartData = [
[ [
'label' => strval(trans('firefly.spent')), 'label' => (string)trans('firefly.spent'),
'entries' => [], 'entries' => [],
'type' => 'bar', 'type' => 'bar',
], ],
[ [
'label' => strval(trans('firefly.earned')), 'label' => (string)trans('firefly.earned'),
'entries' => [], 'entries' => [],
'type' => 'bar', 'type' => 'bar',
], ],
[ [
'label' => strval(trans('firefly.sum')), 'label' => (string)trans('firefly.sum'),
'entries' => [], 'entries' => [],
'type' => 'line', 'type' => 'line',
'fill' => false, 'fill' => false,
@@ -313,17 +313,17 @@ class CategoryController extends Controller
// chart data // chart data
$chartData = [ $chartData = [
[ [
'label' => strval(trans('firefly.spent')), 'label' => (string)trans('firefly.spent'),
'entries' => [], 'entries' => [],
'type' => 'bar', 'type' => 'bar',
], ],
[ [
'label' => strval(trans('firefly.earned')), 'label' => (string)trans('firefly.earned'),
'entries' => [], 'entries' => [],
'type' => 'bar', 'type' => 'bar',
], ],
[ [
'label' => strval(trans('firefly.sum')), 'label' => (string)trans('firefly.sum'),
'entries' => [], 'entries' => [],
'type' => 'line', 'type' => 'line',
'fill' => false, 'fill' => false,

View File

@@ -75,7 +75,7 @@ class CategoryReportController extends Controller
{ {
/** @var MetaPieChartInterface $helper */ /** @var MetaPieChartInterface $helper */
$helper = app(MetaPieChartInterface::class); $helper = app(MetaPieChartInterface::class);
$helper->setAccounts($accounts)->setCategories($categories)->setStart($start)->setEnd($end)->setCollectOtherObjects(1 === intval($others)); $helper->setAccounts($accounts)->setCategories($categories)->setStart($start)->setEnd($end)->setCollectOtherObjects(1 === (int)$others);
$chartData = $helper->generate('expense', 'account'); $chartData = $helper->generate('expense', 'account');
$data = $this->generator->pieChart($chartData); $data = $this->generator->pieChart($chartData);
@@ -100,7 +100,7 @@ class CategoryReportController extends Controller
$helper->setCategories($categories); $helper->setCategories($categories);
$helper->setStart($start); $helper->setStart($start);
$helper->setEnd($end); $helper->setEnd($end);
$helper->setCollectOtherObjects(1 === intval($others)); $helper->setCollectOtherObjects(1 === (int)$others);
$chartData = $helper->generate('income', 'account'); $chartData = $helper->generate('income', 'account');
$data = $this->generator->pieChart($chartData); $data = $this->generator->pieChart($chartData);
@@ -124,7 +124,7 @@ class CategoryReportController extends Controller
$helper->setCategories($categories); $helper->setCategories($categories);
$helper->setStart($start); $helper->setStart($start);
$helper->setEnd($end); $helper->setEnd($end);
$helper->setCollectOtherObjects(1 === intval($others)); $helper->setCollectOtherObjects(1 === (int)$others);
$chartData = $helper->generate('expense', 'category'); $chartData = $helper->generate('expense', 'category');
$data = $this->generator->pieChart($chartData); $data = $this->generator->pieChart($chartData);
@@ -148,7 +148,7 @@ class CategoryReportController extends Controller
$helper->setCategories($categories); $helper->setCategories($categories);
$helper->setStart($start); $helper->setStart($start);
$helper->setEnd($end); $helper->setEnd($end);
$helper->setCollectOtherObjects(1 === intval($others)); $helper->setCollectOtherObjects(1 === (int)$others);
$chartData = $helper->generate('income', 'category'); $chartData = $helper->generate('income', 'category');
$data = $this->generator->pieChart($chartData); $data = $this->generator->pieChart($chartData);
@@ -183,27 +183,27 @@ class CategoryReportController extends Controller
// prep chart data: // prep chart data:
foreach ($categories as $category) { foreach ($categories as $category) {
$chartData[$category->id . '-in'] = [ $chartData[$category->id . '-in'] = [
'label' => $category->name . ' (' . strtolower(strval(trans('firefly.income'))) . ')', 'label' => $category->name . ' (' . strtolower((string)trans('firefly.income')) . ')',
'type' => 'bar', 'type' => 'bar',
'yAxisID' => 'y-axis-0', 'yAxisID' => 'y-axis-0',
'entries' => [], 'entries' => [],
]; ];
$chartData[$category->id . '-out'] = [ $chartData[$category->id . '-out'] = [
'label' => $category->name . ' (' . strtolower(strval(trans('firefly.expenses'))) . ')', 'label' => $category->name . ' (' . strtolower((string)trans('firefly.expenses')) . ')',
'type' => 'bar', 'type' => 'bar',
'yAxisID' => 'y-axis-0', 'yAxisID' => 'y-axis-0',
'entries' => [], 'entries' => [],
]; ];
// total in, total out: // total in, total out:
$chartData[$category->id . '-total-in'] = [ $chartData[$category->id . '-total-in'] = [
'label' => $category->name . ' (' . strtolower(strval(trans('firefly.sum_of_income'))) . ')', 'label' => $category->name . ' (' . strtolower((string)trans('firefly.sum_of_income')) . ')',
'type' => 'line', 'type' => 'line',
'fill' => false, 'fill' => false,
'yAxisID' => 'y-axis-1', 'yAxisID' => 'y-axis-1',
'entries' => [], 'entries' => [],
]; ];
$chartData[$category->id . '-total-out'] = [ $chartData[$category->id . '-total-out'] = [
'label' => $category->name . ' (' . strtolower(strval(trans('firefly.sum_of_expenses'))) . ')', 'label' => $category->name . ' (' . strtolower((string)trans('firefly.sum_of_expenses')) . ')',
'type' => 'line', 'type' => 'line',
'fill' => false, 'fill' => false,
'yAxisID' => 'y-axis-1', 'yAxisID' => 'y-axis-1',
@@ -279,9 +279,7 @@ class CategoryReportController extends Controller
$collector->addFilter(OpposingAccountFilter::class); $collector->addFilter(OpposingAccountFilter::class);
$collector->addFilter(PositiveAmountFilter::class); $collector->addFilter(PositiveAmountFilter::class);
$transactions = $collector->getJournals(); return $collector->getJournals();
return $transactions;
} }
/** /**
@@ -302,9 +300,7 @@ class CategoryReportController extends Controller
$collector->addFilter(OpposingAccountFilter::class); $collector->addFilter(OpposingAccountFilter::class);
$collector->addFilter(NegativeAmountFilter::class); $collector->addFilter(NegativeAmountFilter::class);
$transactions = $collector->getJournals(); return $collector->getJournals();
return $transactions;
} }
/** /**
@@ -318,8 +314,8 @@ class CategoryReportController extends Controller
$grouped = []; $grouped = [];
/** @var Transaction $transaction */ /** @var Transaction $transaction */
foreach ($set as $transaction) { foreach ($set 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);
$grouped[$categoryId] = $grouped[$categoryId] ?? '0'; $grouped[$categoryId] = $grouped[$categoryId] ?? '0';
$grouped[$categoryId] = bcadd($transaction->transaction_amount, $grouped[$categoryId]); $grouped[$categoryId] = bcadd($transaction->transaction_amount, $grouped[$categoryId]);

View File

@@ -100,27 +100,27 @@ class ExpenseReportController extends Controller
/** @var Account $exp */ /** @var Account $exp */
$exp = $combi->first(); $exp = $combi->first();
$chartData[$exp->id . '-in'] = [ $chartData[$exp->id . '-in'] = [
'label' => $name . ' (' . strtolower(strval(trans('firefly.income'))) . ')', 'label' => $name . ' (' . strtolower((string)trans('firefly.income')) . ')',
'type' => 'bar', 'type' => 'bar',
'yAxisID' => 'y-axis-0', 'yAxisID' => 'y-axis-0',
'entries' => [], 'entries' => [],
]; ];
$chartData[$exp->id . '-out'] = [ $chartData[$exp->id . '-out'] = [
'label' => $name . ' (' . strtolower(strval(trans('firefly.expenses'))) . ')', 'label' => $name . ' (' . strtolower((string)trans('firefly.expenses')) . ')',
'type' => 'bar', 'type' => 'bar',
'yAxisID' => 'y-axis-0', 'yAxisID' => 'y-axis-0',
'entries' => [], 'entries' => [],
]; ];
// total in, total out: // total in, total out:
$chartData[$exp->id . '-total-in'] = [ $chartData[$exp->id . '-total-in'] = [
'label' => $name . ' (' . strtolower(strval(trans('firefly.sum_of_income'))) . ')', 'label' => $name . ' (' . strtolower((string)trans('firefly.sum_of_income')) . ')',
'type' => 'line', 'type' => 'line',
'fill' => false, 'fill' => false,
'yAxisID' => 'y-axis-1', 'yAxisID' => 'y-axis-1',
'entries' => [], 'entries' => [],
]; ];
$chartData[$exp->id . '-total-out'] = [ $chartData[$exp->id . '-total-out'] = [
'label' => $name . ' (' . strtolower(strval(trans('firefly.sum_of_expenses'))) . ')', 'label' => $name . ' (' . strtolower((string)trans('firefly.sum_of_expenses')) . ')',
'type' => 'line', 'type' => 'line',
'fill' => false, 'fill' => false,
'yAxisID' => 'y-axis-1', 'yAxisID' => 'y-axis-1',
@@ -196,7 +196,7 @@ class ExpenseReportController extends Controller
$collection->push($expenseAccount); $collection->push($expenseAccount);
$revenue = $this->accountRepository->findByName($expenseAccount->name, [AccountType::REVENUE]); $revenue = $this->accountRepository->findByName($expenseAccount->name, [AccountType::REVENUE]);
if (!is_null($revenue)) { if (null !== $revenue) {
$collection->push($revenue); $collection->push($revenue);
} }
$combined[$expenseAccount->name] = $collection; $combined[$expenseAccount->name] = $collection;
@@ -219,9 +219,7 @@ class ExpenseReportController extends Controller
$collector = app(JournalCollectorInterface::class); $collector = app(JournalCollectorInterface::class);
$collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setOpposingAccounts($opposing); $collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setOpposingAccounts($opposing);
$transactions = $collector->getJournals(); return $collector->getJournals();
return $transactions;
} }
/** /**
@@ -239,9 +237,7 @@ class ExpenseReportController extends Controller
$collector = app(JournalCollectorInterface::class); $collector = app(JournalCollectorInterface::class);
$collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->setOpposingAccounts($opposing); $collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->setOpposingAccounts($opposing);
$transactions = $collector->getJournals(); return $collector->getJournals();
return $transactions;
} }
/** /**

View File

@@ -71,7 +71,7 @@ class PiggyBankController extends Controller
$sum = '0'; $sum = '0';
/** @var PiggyBankEvent $entry */ /** @var PiggyBankEvent $entry */
foreach ($set as $entry) { foreach ($set as $entry) {
$label = $entry->date->formatLocalized(strval(trans('config.month_and_day'))); $label = $entry->date->formatLocalized((string)trans('config.month_and_day'));
$sum = bcadd($sum, $entry->amount); $sum = bcadd($sum, $entry->amount);
$chartData[$label] = $sum; $chartData[$label] = $sum;
} }

View File

@@ -75,12 +75,12 @@ class ReportController extends Controller
while ($current < $end) { while ($current < $end) {
$balances = Steam::balancesByAccounts($accounts, $current); $balances = Steam::balancesByAccounts($accounts, $current);
$sum = $this->arraySum($balances); $sum = $this->arraySum($balances);
$label = $current->formatLocalized(strval(trans('config.month_and_day'))); $label = $current->formatLocalized((string)trans('config.month_and_day'));
$chartData[$label] = $sum; $chartData[$label] = $sum;
$current->addDays(7); $current->addDays(7);
} }
$data = $this->generator->singleSet(strval(trans('firefly.net_worth')), $chartData); $data = $this->generator->singleSet((string)trans('firefly.net_worth'), $chartData);
$cache->store($data); $cache->store($data);
return response()->json($data); return response()->json($data);
@@ -188,19 +188,19 @@ class ReportController extends Controller
$chartData = [ $chartData = [
[ [
'label' => strval(trans('firefly.income')), 'label' => (string)trans('firefly.income'),
'type' => 'bar', 'type' => 'bar',
'entries' => [ 'entries' => [
strval(trans('firefly.sum_of_period')) => $numbers['sum_earned'], (string)trans('firefly.sum_of_period') => $numbers['sum_earned'],
strval(trans('firefly.average_in_period')) => $numbers['avg_earned'], (string)trans('firefly.average_in_period') => $numbers['avg_earned'],
], ],
], ],
[ [
'label' => trans('firefly.expenses'), 'label' => trans('firefly.expenses'),
'type' => 'bar', 'type' => 'bar',
'entries' => [ 'entries' => [
strval(trans('firefly.sum_of_period')) => $numbers['sum_spent'], (string)trans('firefly.sum_of_period') => $numbers['sum_spent'],
strval(trans('firefly.average_in_period')) => $numbers['avg_spent'], (string)trans('firefly.average_in_period') => $numbers['avg_spent'],
], ],
], ],
]; ];
@@ -255,25 +255,21 @@ class ReportController extends Controller
while ($currentStart <= $end) { while ($currentStart <= $end) {
$currentEnd = app('navigation')->endOfPeriod($currentStart, '1M'); $currentEnd = app('navigation')->endOfPeriod($currentStart, '1M');
$earned = strval( $earned = (string)array_sum(
array_sum( array_map(
array_map( function ($item) {
function ($item) { return $item['sum'];
return $item['sum']; },
}, $tasker->getIncomeReport($currentStart, $currentEnd, $accounts)
$tasker->getIncomeReport($currentStart, $currentEnd, $accounts)
)
) )
); );
$spent = strval( $spent = (string)array_sum(
array_sum( array_map(
array_map( function ($item) {
function ($item) { return $item['sum'];
return $item['sum']; },
}, $tasker->getExpenseReport($currentStart, $currentEnd, $accounts)
$tasker->getExpenseReport($currentStart, $currentEnd, $accounts)
)
) )
); );

View File

@@ -72,7 +72,7 @@ class TagReportController extends Controller
$helper->setTags($tags); $helper->setTags($tags);
$helper->setStart($start); $helper->setStart($start);
$helper->setEnd($end); $helper->setEnd($end);
$helper->setCollectOtherObjects(1 === intval($others)); $helper->setCollectOtherObjects(1 === (int)$others);
$chartData = $helper->generate('expense', 'account'); $chartData = $helper->generate('expense', 'account');
$data = $this->generator->pieChart($chartData); $data = $this->generator->pieChart($chartData);
@@ -96,7 +96,7 @@ class TagReportController extends Controller
$helper->setTags($tags); $helper->setTags($tags);
$helper->setStart($start); $helper->setStart($start);
$helper->setEnd($end); $helper->setEnd($end);
$helper->setCollectOtherObjects(1 === intval($others)); $helper->setCollectOtherObjects(1 === (int)$others);
$chartData = $helper->generate('income', 'account'); $chartData = $helper->generate('income', 'account');
$data = $this->generator->pieChart($chartData); $data = $this->generator->pieChart($chartData);
@@ -177,27 +177,27 @@ class TagReportController extends Controller
// prep chart data: // prep chart data:
foreach ($tags as $tag) { foreach ($tags as $tag) {
$chartData[$tag->id . '-in'] = [ $chartData[$tag->id . '-in'] = [
'label' => $tag->tag . ' (' . strtolower(strval(trans('firefly.income'))) . ')', 'label' => $tag->tag . ' (' . strtolower((string)trans('firefly.income')) . ')',
'type' => 'bar', 'type' => 'bar',
'yAxisID' => 'y-axis-0', 'yAxisID' => 'y-axis-0',
'entries' => [], 'entries' => [],
]; ];
$chartData[$tag->id . '-out'] = [ $chartData[$tag->id . '-out'] = [
'label' => $tag->tag . ' (' . strtolower(strval(trans('firefly.expenses'))) . ')', 'label' => $tag->tag . ' (' . strtolower((string)trans('firefly.expenses')) . ')',
'type' => 'bar', 'type' => 'bar',
'yAxisID' => 'y-axis-0', 'yAxisID' => 'y-axis-0',
'entries' => [], 'entries' => [],
]; ];
// total in, total out: // total in, total out:
$chartData[$tag->id . '-total-in'] = [ $chartData[$tag->id . '-total-in'] = [
'label' => $tag->tag . ' (' . strtolower(strval(trans('firefly.sum_of_income'))) . ')', 'label' => $tag->tag . ' (' . strtolower((string)trans('firefly.sum_of_income')) . ')',
'type' => 'line', 'type' => 'line',
'fill' => false, 'fill' => false,
'yAxisID' => 'y-axis-1', 'yAxisID' => 'y-axis-1',
'entries' => [], 'entries' => [],
]; ];
$chartData[$tag->id . '-total-out'] = [ $chartData[$tag->id . '-total-out'] = [
'label' => $tag->tag . ' (' . strtolower(strval(trans('firefly.sum_of_expenses'))) . ')', 'label' => $tag->tag . ' (' . strtolower((string)trans('firefly.sum_of_expenses')) . ')',
'type' => 'line', 'type' => 'line',
'fill' => false, 'fill' => false,
'yAxisID' => 'y-axis-1', 'yAxisID' => 'y-axis-1',
@@ -271,7 +271,7 @@ class TagReportController extends Controller
$helper->setTags($tags); $helper->setTags($tags);
$helper->setStart($start); $helper->setStart($start);
$helper->setEnd($end); $helper->setEnd($end);
$helper->setCollectOtherObjects(1 === intval($others)); $helper->setCollectOtherObjects(1 === (int)$others);
$chartData = $helper->generate('expense', 'tag'); $chartData = $helper->generate('expense', 'tag');
$data = $this->generator->pieChart($chartData); $data = $this->generator->pieChart($chartData);
@@ -295,7 +295,7 @@ class TagReportController extends Controller
$helper->setTags($tags); $helper->setTags($tags);
$helper->setStart($start); $helper->setStart($start);
$helper->setEnd($end); $helper->setEnd($end);
$helper->setCollectOtherObjects(1 === intval($others)); $helper->setCollectOtherObjects(1 === (int)$others);
$chartData = $helper->generate('income', 'tag'); $chartData = $helper->generate('income', 'tag');
$data = $this->generator->pieChart($chartData); $data = $this->generator->pieChart($chartData);
@@ -321,9 +321,7 @@ class TagReportController extends Controller
$collector->addFilter(OpposingAccountFilter::class); $collector->addFilter(OpposingAccountFilter::class);
$collector->addFilter(PositiveAmountFilter::class); $collector->addFilter(PositiveAmountFilter::class);
$transactions = $collector->getJournals(); return $collector->getJournals();
return $transactions;
} }
/** /**
@@ -344,9 +342,7 @@ class TagReportController extends Controller
$collector->addFilter(OpposingAccountFilter::class); $collector->addFilter(OpposingAccountFilter::class);
$collector->addFilter(NegativeAmountFilter::class); $collector->addFilter(NegativeAmountFilter::class);
$transactions = $collector->getJournals(); return $collector->getJournals();
return $transactions;
} }
/** /**

View File

@@ -121,7 +121,7 @@ class Controller extends BaseController
*/ */
protected function getPreviousUri(string $identifier): string protected function getPreviousUri(string $identifier): string
{ {
$uri = strval(session($identifier)); $uri = (string)session($identifier);
if (!(false === strpos($identifier, 'delete')) && !(false === strpos($uri, '/show/'))) { if (!(false === strpos($identifier, 'delete')) && !(false === strpos($uri, '/show/'))) {
$uri = $this->redirectUri; $uri = $this->redirectUri;
} }
@@ -159,7 +159,7 @@ class Controller extends BaseController
} }
} }
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
Session::flash('error', strval(trans('firefly.cannot_redirect_to_account'))); Session::flash('error', (string)trans('firefly.cannot_redirect_to_account'));
return redirect(route('index')); return redirect(route('index'));
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd

View File

@@ -67,7 +67,6 @@ class CurrencyController extends Controller
* @param Request $request * @param Request $request
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
* @throws \RuntimeException
*/ */
public function create(Request $request) public function create(Request $request)
{ {
@@ -94,7 +93,6 @@ class CurrencyController extends Controller
* @param TransactionCurrency $currency * @param TransactionCurrency $currency
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function defaultCurrency(Request $request, TransactionCurrency $currency) public function defaultCurrency(Request $request, TransactionCurrency $currency)
{ {
@@ -113,7 +111,6 @@ class CurrencyController extends Controller
* @param TransactionCurrency $currency * @param TransactionCurrency $currency
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
* @throws \RuntimeException
*/ */
public function delete(Request $request, TransactionCurrency $currency) public function delete(Request $request, TransactionCurrency $currency)
{ {
@@ -143,7 +140,6 @@ class CurrencyController extends Controller
* @param TransactionCurrency $currency * @param TransactionCurrency $currency
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function destroy(Request $request, TransactionCurrency $currency) public function destroy(Request $request, TransactionCurrency $currency)
{ {
@@ -172,7 +168,6 @@ class CurrencyController extends Controller
* @param TransactionCurrency $currency * @param TransactionCurrency $currency
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
* @throws \RuntimeException
*/ */
public function edit(Request $request, TransactionCurrency $currency) public function edit(Request $request, TransactionCurrency $currency)
{ {
@@ -201,12 +196,11 @@ class CurrencyController extends Controller
* @param Request $request * @param Request $request
* *
* @return View * @return View
* @throws \RuntimeException
*/ */
public function index(Request $request) public function index(Request $request)
{ {
$page = 0 === intval($request->get('page')) ? 1 : intval($request->get('page')); $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
$pageSize = intval(Preferences::get('listPageSize', 50)->data); $pageSize = (int)Preferences::get('listPageSize', 50)->data;
$collection = $this->repository->get(); $collection = $this->repository->get();
$total = $collection->count(); $total = $collection->count();
$collection = $collection->sortBy( $collection = $collection->sortBy(
@@ -232,7 +226,6 @@ class CurrencyController extends Controller
* @param CurrencyFormRequest $request * @param CurrencyFormRequest $request
* *
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function store(CurrencyFormRequest $request) public function store(CurrencyFormRequest $request)
{ {
@@ -248,7 +241,7 @@ class CurrencyController extends Controller
$currency = $this->repository->store($data); $currency = $this->repository->store($data);
$request->session()->flash('success', trans('firefly.created_currency', ['name' => $currency->name])); $request->session()->flash('success', trans('firefly.created_currency', ['name' => $currency->name]));
if (1 === intval($request->get('create_another'))) { if (1 === (int)$request->get('create_another')) {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
$request->session()->put('currencies.create.fromStore', true); $request->session()->put('currencies.create.fromStore', true);
@@ -264,7 +257,6 @@ class CurrencyController extends Controller
* @param TransactionCurrency $currency * @param TransactionCurrency $currency
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function update(CurrencyFormRequest $request, TransactionCurrency $currency) public function update(CurrencyFormRequest $request, TransactionCurrency $currency)
{ {
@@ -281,7 +273,7 @@ class CurrencyController extends Controller
$request->session()->flash('success', trans('firefly.updated_currency', ['name' => $currency->name])); $request->session()->flash('success', trans('firefly.updated_currency', ['name' => $currency->name]));
Preferences::mark(); Preferences::mark();
if (1 === intval($request->get('return_to_edit'))) { if (1 === (int)$request->get('return_to_edit')) {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
$request->session()->put('currencies.edit.fromUpdate', true); $request->session()->put('currencies.edit.fromUpdate', true);

View File

@@ -50,7 +50,6 @@ class DebugController extends Controller
* @param Request $request * @param Request $request
* *
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @throws \InvalidArgumentException
*/ */
public function index(Request $request) public function index(Request $request)
{ {
@@ -69,7 +68,7 @@ class DebugController extends Controller
$isDocker = var_export(env('IS_DOCKER', 'unknown'), true); $isDocker = var_export(env('IS_DOCKER', 'unknown'), true);
$trustedProxies = env('TRUSTED_PROXIES', '(none)'); $trustedProxies = env('TRUSTED_PROXIES', '(none)');
$displayErrors = ini_get('display_errors'); $displayErrors = ini_get('display_errors');
$errorReporting = $this->errorReporting(intval(ini_get('error_reporting'))); $errorReporting = $this->errorReporting((int)ini_get('error_reporting'));
$appEnv = env('APP_ENV', ''); $appEnv = env('APP_ENV', '');
$appDebug = var_export(env('APP_DEBUG', false), true); $appDebug = var_export(env('APP_DEBUG', false), true);
$appLog = env('APP_LOG', ''); $appLog = env('APP_LOG', '');
@@ -156,7 +155,7 @@ class DebugController extends Controller
return $array[$value]; return $array[$value];
} }
return strval($value); // @codeCoverageIgnore return (string)$value; // @codeCoverageIgnore
} }
/** /**

View File

@@ -111,7 +111,6 @@ class ExportController extends Controller
* @param ExportJobRepositoryInterface $jobs * @param ExportJobRepositoryInterface $jobs
* *
* @return View * @return View
* @throws \InvalidArgumentException
*/ */
public function index(AccountRepositoryInterface $repository, ExportJobRepositoryInterface $jobs) public function index(AccountRepositoryInterface $repository, ExportJobRepositoryInterface $jobs)
{ {
@@ -121,7 +120,7 @@ class ExportController extends Controller
$jobs->cleanup(); $jobs->cleanup();
// does the user have shared accounts? // does the user have shared accounts?
$accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]); $accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
$accountList = ExpandedForm::makeSelectList($accounts); $accountList = ExpandedForm::makeSelectList($accounts);
$checked = array_keys($accountList); $checked = array_keys($accountList);
$formats = array_keys(config('firefly.export_formats')); $formats = array_keys(config('firefly.export_formats'));

View File

@@ -72,7 +72,7 @@ class HelpController extends Controller
private function getHelpText(string $route, string $language): string private function getHelpText(string $route, string $language): string
{ {
// get language and default variables. // get language and default variables.
$content = '<p>' . strval(trans('firefly.route_has_no_help')) . '</p>'; $content = '<p>' . (string)trans('firefly.route_has_no_help') . '</p>';
// if no such route, log error and return default text. // if no such route, log error and return default text.
if (!$this->help->hasRoute($route)) { if (!$this->help->hasRoute($route)) {
@@ -114,6 +114,6 @@ class HelpController extends Controller
return $content; return $content;
} }
return '<p>' . strval(trans('firefly.route_has_no_help')) . '</p>'; return '<p>' . (string)trans('firefly.route_has_no_help') . '</p>';
} }
} }

View File

@@ -62,7 +62,6 @@ class HomeController extends Controller
* @param Request $request * @param Request $request
* *
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
* @throws \RuntimeException
*/ */
public function dateRange(Request $request) public function dateRange(Request $request)
{ {
@@ -75,7 +74,7 @@ class HomeController extends Controller
// check if the label is "everything" or "Custom range" which will betray // check if the label is "everything" or "Custom range" which will betray
// a possible problem with the budgets. // a possible problem with the budgets.
if ($label === strval(trans('firefly.everything')) || $label === strval(trans('firefly.customRange'))) { if ($label === (string)trans('firefly.everything') || $label === (string)trans('firefly.customRange')) {
$isCustomRange = true; $isCustomRange = true;
Log::debug('Range is now marked as "custom".'); Log::debug('Range is now marked as "custom".');
} }
@@ -83,7 +82,7 @@ class HomeController extends Controller
$diff = $start->diffInDays($end); $diff = $start->diffInDays($end);
if ($diff > 50) { if ($diff > 50) {
$request->session()->flash('warning', strval(trans('firefly.warning_much_data', ['days' => $diff]))); $request->session()->flash('warning', (string)trans('firefly.warning_much_data', ['days' => $diff]));
} }
$request->session()->put('is_custom_range', $isCustomRange); $request->session()->put('is_custom_range', $isCustomRange);
@@ -117,7 +116,6 @@ class HomeController extends Controller
* @param Request $request * @param Request $request
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function flush(Request $request) public function flush(Request $request)
{ {
@@ -232,7 +230,6 @@ class HomeController extends Controller
* @param Request $request * @param Request $request
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function testFlash(Request $request) public function testFlash(Request $request)
{ {

View File

@@ -97,7 +97,6 @@ class ConfigurationController extends Controller
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* *
* @throws \RuntimeException
* @throws FireflyException * @throws FireflyException
*/ */
public function post(Request $request, ImportJob $job) public function post(Request $request, ImportJob $job)

View File

@@ -69,7 +69,7 @@ class PrerequisitesController extends Controller
if (true === !config(sprintf('import.enabled.%s', $bank))) { if (true === !config(sprintf('import.enabled.%s', $bank))) {
throw new FireflyException(sprintf('Cannot import from "%s" at this time.', $bank)); // @codeCoverageIgnore throw new FireflyException(sprintf('Cannot import from "%s" at this time.', $bank)); // @codeCoverageIgnore
} }
$class = strval(config(sprintf('import.prerequisites.%s', $bank))); $class = (string)config(sprintf('import.prerequisites.%s', $bank));
if (!class_exists($class)) { if (!class_exists($class)) {
throw new FireflyException(sprintf('No class to handle "%s".', $bank)); // @codeCoverageIgnore throw new FireflyException(sprintf('No class to handle "%s".', $bank)); // @codeCoverageIgnore
} }
@@ -80,7 +80,7 @@ class PrerequisitesController extends Controller
if ($object->hasPrerequisites()) { if ($object->hasPrerequisites()) {
$view = $object->getView(); $view = $object->getView();
$parameters = ['title' => strval(trans('firefly.import_index_title')), 'mainTitleIcon' => 'fa-archive']; $parameters = ['title' => (string)trans('firefly.import_index_title'), 'mainTitleIcon' => 'fa-archive'];
$parameters = array_merge($object->getViewParameters(), $parameters); $parameters = array_merge($object->getViewParameters(), $parameters);
return view($view, $parameters); return view($view, $parameters);
@@ -103,7 +103,6 @@ class PrerequisitesController extends Controller
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* *
* @throws \RuntimeException
* @throws FireflyException * @throws FireflyException
*/ */
public function post(Request $request, string $bank) public function post(Request $request, string $bank)
@@ -114,7 +113,7 @@ class PrerequisitesController extends Controller
throw new FireflyException(sprintf('Cannot import from "%s" at this time.', $bank)); // @codeCoverageIgnore throw new FireflyException(sprintf('Cannot import from "%s" at this time.', $bank)); // @codeCoverageIgnore
} }
$class = strval(config(sprintf('import.prerequisites.%s', $bank))); $class = (string)config(sprintf('import.prerequisites.%s', $bank));
if (!class_exists($class)) { if (!class_exists($class)) {
throw new FireflyException(sprintf('Cannot find class %s', $class)); // @codeCoverageIgnore throw new FireflyException(sprintf('Cannot find class %s', $class)); // @codeCoverageIgnore
} }

View File

@@ -97,7 +97,7 @@ class StatusController extends Controller
} }
if ('finished' === $job->status) { if ('finished' === $job->status) {
$result['finished'] = true; $result['finished'] = true;
$tagId = intval($job->extended_status['tag']); $tagId = (int)$job->extended_status['tag'];
if ($tagId !== 0) { if ($tagId !== 0) {
/** @var TagRepositoryInterface $repository */ /** @var TagRepositoryInterface $repository */
$repository = app(TagRepositoryInterface::class); $repository = app(TagRepositoryInterface::class);

View File

@@ -54,7 +54,7 @@ class JavascriptController extends Controller
/** @var Account $account */ /** @var Account $account */
foreach ($accounts as $account) { foreach ($accounts as $account) {
$accountId = $account->id; $accountId = $account->id;
$currency = intval($repository->getMetaValue($account, 'currency_id')); $currency = (int)$repository->getMetaValue($account, 'currency_id');
$currency = 0 === $currency ? $default->id : $currency; $currency = 0 === $currency ? $default->id : $currency;
$entry = ['preferredCurrency' => $currency, 'name' => $account->name]; $entry = ['preferredCurrency' => $currency, 'name' => $account->name];
$data['accounts'][$accountId] = $entry; $data['accounts'][$accountId] = $entry;
@@ -92,14 +92,13 @@ class JavascriptController extends Controller
* @param CurrencyRepositoryInterface $currencyRepository * @param CurrencyRepositoryInterface $currencyRepository
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
* @throws \RuntimeException
*/ */
public function variables(Request $request, AccountRepositoryInterface $repository, CurrencyRepositoryInterface $currencyRepository) public function variables(Request $request, AccountRepositoryInterface $repository, CurrencyRepositoryInterface $currencyRepository)
{ {
$account = $repository->findNull(intval($request->get('account'))); $account = $repository->findNull((int)$request->get('account'));
$currencyId = 0; $currencyId = 0;
if (null !== $account) { if (null !== $account) {
$currencyId = intval($repository->getMetaValue($account, 'currency_id')); $currencyId = (int)$repository->getMetaValue($account, 'currency_id');
} }
/** @var TransactionCurrency $currency */ /** @var TransactionCurrency $currency */
$currency = $currencyRepository->findNull($currencyId); $currency = $currencyRepository->findNull($currencyId);
@@ -175,21 +174,21 @@ class JavascriptController extends Controller
$todayStart = app('navigation')->startOfPeriod($today, $viewRange); $todayStart = app('navigation')->startOfPeriod($today, $viewRange);
$todayEnd = app('navigation')->endOfPeriod($todayStart, $viewRange); $todayEnd = app('navigation')->endOfPeriod($todayStart, $viewRange);
if ($todayStart->ne($start) || $todayEnd->ne($end)) { if ($todayStart->ne($start) || $todayEnd->ne($end)) {
$ranges[ucfirst(strval(trans('firefly.today')))] = [$todayStart, $todayEnd]; $ranges[ucfirst((string)trans('firefly.today'))] = [$todayStart, $todayEnd];
} }
// everything // everything
$index = strval(trans('firefly.everything')); $index = (string)trans('firefly.everything');
$ranges[$index] = [$first, new Carbon]; $ranges[$index] = [$first, new Carbon];
$return = [ $return = [
'title' => $title, 'title' => $title,
'configuration' => [ 'configuration' => [
'apply' => strval(trans('firefly.apply')), 'apply' => (string)trans('firefly.apply'),
'cancel' => strval(trans('firefly.cancel')), 'cancel' => (string)trans('firefly.cancel'),
'from' => strval(trans('firefly.from')), 'from' => (string)trans('firefly.from'),
'to' => strval(trans('firefly.to')), 'to' => (string)trans('firefly.to'),
'customRange' => strval(trans('firefly.customRange')), 'customRange' => (string)trans('firefly.customRange'),
'start' => $start->format('Y-m-d'), 'start' => $start->format('Y-m-d'),
'end' => $end->format('Y-m-d'), 'end' => $end->format('Y-m-d'),
'ranges' => $ranges, 'ranges' => $ranges,

View File

@@ -113,7 +113,7 @@ class AutoCompleteController extends Controller
$set = $collector->getJournals()->pluck('description', 'journal_id')->toArray(); $set = $collector->getJournals()->pluck('description', 'journal_id')->toArray();
$return = []; $return = [];
foreach ($set as $id => $description) { foreach ($set as $id => $description) {
$id = intval($id); $id = (int)$id;
if ($id !== $except->id) { if ($id !== $except->id) {
$return[] = [ $return[] = [
'id' => $id, 'id' => $id,

View File

@@ -123,7 +123,7 @@ class BoxController extends Controller
$set = $collector->getJournals(); $set = $collector->getJournals();
/** @var Transaction $transaction */ /** @var Transaction $transaction */
foreach ($set as $transaction) { foreach ($set as $transaction) {
$currencyId = intval($transaction->transaction_currency_id); $currencyId = (int)$transaction->transaction_currency_id;
$incomes[$currencyId] = $incomes[$currencyId] ?? '0'; $incomes[$currencyId] = $incomes[$currencyId] ?? '0';
$incomes[$currencyId] = bcadd($incomes[$currencyId], $transaction->transaction_amount); $incomes[$currencyId] = bcadd($incomes[$currencyId], $transaction->transaction_amount);
$sums[$currencyId] = $sums[$currencyId] ?? '0'; $sums[$currencyId] = $sums[$currencyId] ?? '0';

View File

@@ -50,9 +50,6 @@ class ExchangeController extends Controller
$rate = $repository->getExchangeRate($fromCurrency, $toCurrency, $date); $rate = $repository->getExchangeRate($fromCurrency, $toCurrency, $date);
if (null === $rate->id) { if (null === $rate->id) {
Log::debug(sprintf('No cached exchange rate in database for %s to %s on %s', $fromCurrency->code, $toCurrency->code, $date->format('Y-m-d'))); Log::debug(sprintf('No cached exchange rate in database for %s to %s on %s', $fromCurrency->code, $toCurrency->code, $date->format('Y-m-d')));
@@ -69,7 +66,7 @@ class ExchangeController extends Controller
$return['amount'] = null; $return['amount'] = null;
if (null !== $request->get('amount')) { if (null !== $request->get('amount')) {
// assume amount is in "from" currency: // assume amount is in "from" currency:
$return['amount'] = bcmul($request->get('amount'), strval($rate->rate), 12); $return['amount'] = bcmul($request->get('amount'), (string)$rate->rate, 12);
// round to toCurrency decimal places: // round to toCurrency decimal places:
$return['amount'] = round($return['amount'], $toCurrency->decimal_places); $return['amount'] = round($return['amount'], $toCurrency->decimal_places);
} }

View File

@@ -36,7 +36,7 @@ class FrontpageController extends Controller
* *
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
* *
* @throws \Throwable
*/ */
public function piggyBanks(PiggyBankRepositoryInterface $repository) public function piggyBanks(PiggyBankRepositoryInterface $repository)
{ {

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