Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
PHPstan fixes.
James Colec1cc71f85c28
diff --git a/.ci/phpstan.sh b/.ci/phpstan.shindex a513bd9254..84ff119226 100755--- a/.ci/phpstan.sh+++ b/.ci/phpstan.sh@@ -33,7 +33,7 @@ if [[ $GITHUB_ACTIONS = "" ]]then./vendor/bin/phpstan analyse -c .ci/phpstan.neon --error-format=table > phpstan-report.txtEXIT_CODE=$?- echo 'The PHPstan report can be found in phpstan-report.txt'+ echo "The PHPstan report can be found in phpstan-report.txt. Exit code is $EXIT_CODE."fiif [[ $GITHUB_ACTIONS = "true" ]]@@ -42,7 +42,7 @@ thenEXIT_CODE=$?# temporary exit code 0- EXIT_CODE=0+ # EXIT_CODE=0fiexit $EXIT_CODEdiff --git a/.ci/phpunit.sh b/.ci/phpunit.shdeleted file mode 100755index 58b307c329..0000000000--- a/.ci/phpunit.sh+++ /dev/null@@ -1,63 +0,0 @@-#!/usr/bin/env bash--#-# phpunit.sh-# Copyright (c) 2021 [email protected]-#-# This file is part of Firefly III (https://github.com/firefly-iii).-#-# This program is free software: you can redistribute it and/or modify-# it under the terms of the GNU Affero General Public License as-# published by the Free Software Foundation, either version 3 of the-# License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU Affero General Public License for more details.-#-# You should have received a copy of the GNU Affero General Public License-# along with this program. If not, see <https://www.gnu.org/licenses/>.-#-SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"-# enable test .env file.-cp $SCRIPT_DIR/../.env $SCRIPT_DIR/../.env.backup-cp $SCRIPT_DIR/.env.ci $SCRIPT_DIR/../.env--COVERAGE=false-RESET=false-FILE=storage/database/database.sqlite--while getopts "cr" o; do- case "${o}" in- c) COVERAGE=true;;- r) RESET=true;;- esac-done--# reset if necessary.-if [ $RESET = "true" ] ; then- rm -f $FILE-fi--# download test database-if [ -f "$FILE" ]; then- echo 'DB exists, will use it'-else- echo 'Download new DB'- wget --quiet https://github.com/firefly-iii/test-fixtures/raw/main/test-database.sqlite -O $FILE-fi--# run phpunit-if [ $COVERAGE = "true" ] ; then- echo 'Run with coverage'- XDEBUG_MODE=coverage ./vendor/bin/phpunit --configuration phpunit.xml --coverage-html $SCRIPT_DIR/coverage-else- echo 'Run without coverage'- ./vendor/bin/phpunit --configuration phpunit.xml-fi--# restore .env file-mv $SCRIPT_DIR/../.env.backup $SCRIPT_DIR/../.env--cd $SCRIPT_DIR/..diff --git a/app/Console/Commands/Tools/Cron.php b/app/Console/Commands/Tools/Cron.phpindex 30aec19add..b30a67ef37 100644--- a/app/Console/Commands/Tools/Cron.php+++ b/app/Console/Commands/Tools/Cron.php@@ -74,7 +74,7 @@ class Cron extends Command} catch (InvalidArgumentException $e) {$this->friendlyError(sprintf('"%s" is not a valid date', $this->option('date')));}- $force = (bool) $this->option('force');+ $force = (bool) $this->option('force'); // @phpstan-ignore-line/** Fire exchange rates cron job.diff --git a/app/Console/Commands/Upgrade/DecryptDatabase.php b/app/Console/Commands/Upgrade/DecryptDatabase.phpindex e0285dd954..fce88405a1 100644--- a/app/Console/Commands/Upgrade/DecryptDatabase.php+++ b/app/Console/Commands/Upgrade/DecryptDatabase.php@@ -213,7 +213,7 @@ class DecryptDatabase extends Command}/** @var Preference $object */- $object = Preference::find((int)$id);+ $object = Preference::find($id);if (null !== $object) {$object->data = $newValue;$object->save();diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.phpindex 0154ecc54b..62acf1b180 100644--- a/app/Exceptions/Handler.php+++ b/app/Exceptions/Handler.php@@ -26,6 +26,7 @@ namespace FireflyIII\Exceptions;use ErrorException;use FireflyIII\Jobs\MailError;+use FireflyIII\Models\ObjectGroup;use Illuminate\Auth\AuthenticationException;use Illuminate\Contracts\Foundation\Application;use Illuminate\Database\QueryException;@@ -124,7 +125,7 @@ class Handler extends ExceptionHandler$errorCode = 500;$errorCode = $e instanceof MethodNotAllowedHttpException ? 405 : $errorCode;- $isDebug = config('app.debug', false);+ $isDebug = (bool) config('app.debug', false);if ($isDebug) {app('log')->debug(sprintf('Return JSON %s with debug.', get_class($e)));return response()->json(@@ -183,7 +184,7 @@ class Handler extends ExceptionHandler*/public function report(Throwable $e){- $doMailError = config('firefly.send_error_message');+ $doMailError = (bool) config('firefly.send_error_message');if ($this->shouldntReportLocal($e) || !$doMailError) {parent::report($e);diff --git a/app/Factory/TransactionCurrencyFactory.php b/app/Factory/TransactionCurrencyFactory.phpindex b97cb813b8..946f3f63b5 100644--- a/app/Factory/TransactionCurrencyFactory.php+++ b/app/Factory/TransactionCurrencyFactory.php@@ -82,7 +82,7 @@ class TransactionCurrencyFactory*/public function find(?int $currencyId, ?string $currencyCode): ?TransactionCurrency{- $currencyCode = (string)e($currencyCode);+ $currencyCode = e($currencyCode);$currencyId = (int)$currencyId;if ('' === $currencyCode && 0 === $currencyId) {diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.phpindex 61c46a0260..d7fae5f385 100644--- a/app/Factory/TransactionJournalFactory.php+++ b/app/Factory/TransactionJournalFactory.php@@ -368,10 +368,10 @@ class TransactionJournalFactory// validate source account.$array = [- 'id' => $data['source_id'] ? (int)$data['source_id'] : null,- 'name' => $data['source_name'] ? (string)$data['source_name'] : null,- 'iban' => $data['source_iban'] ? (string)$data['source_iban'] : null,- 'number' => $data['source_number'] ? (string)$data['source_number'] : null,+ 'id' => null !== $data['source_id'] ? (int)$data['source_id'] : null,+ 'name' => null !== $data['source_name'] ? (string)$data['source_name'] : null,+ 'iban' => null !== $data['source_iban'] ? (string)$data['source_iban'] : null,+ 'number' => null !== $data['source_number'] ? (string)$data['source_number'] : null,];$validSource = $this->accountValidator->validateSource($array);@@ -383,10 +383,10 @@ class TransactionJournalFactory// validate destination account$array = [- 'id' => $data['destination_id'] ? (int)$data['destination_id'] : null,- 'name' => $data['destination_name'] ? (string)$data['destination_name'] : null,- 'iban' => $data['destination_iban'] ? (string)$data['destination_iban'] : null,- 'number' => $data['destination_number'] ? (string)$data['destination_number'] : null,+ 'id' => null !== $data['destination_id'] ? (int)$data['destination_id'] : null,+ 'name' => null !== $data['destination_name'] ? (string)$data['destination_name'] : null,+ 'iban' => null !== $data['destination_iban'] ? (string)$data['destination_iban'] : null,+ 'number' => null !== $data['destination_number'] ? (string)$data['destination_number'] : null,];$validDestination = $this->accountValidator->validateDestination($array);diff --git a/app/Handlers/Events/UserEventHandler.php b/app/Handlers/Events/UserEventHandler.phpindex 26f39e2c22..a7980f6862 100644--- a/app/Handlers/Events/UserEventHandler.php+++ b/app/Handlers/Events/UserEventHandler.php@@ -228,7 +228,7 @@ class UserEventHandler*/public function sendAdminRegistrationNotification(RegisteredUser $event): void{- $sendMail = app('fireflyconfig')->get('notification_admin_new_reg', true)->data;+ $sendMail = (bool) app('fireflyconfig')->get('notification_admin_new_reg', true)->data;if ($sendMail) {/** @var UserRepositoryInterface $repository */$repository = app(UserRepositoryInterface::class);@@ -358,7 +358,7 @@ class UserEventHandler*/public function sendRegistrationMail(RegisteredUser $event): void{- $sendMail = app('fireflyconfig')->get('notification_user_new_reg', true)->data;+ $sendMail = (bool) app('fireflyconfig')->get('notification_user_new_reg', true)->data;if ($sendMail) {try {Notification::send($event->user, new UserRegistrationNotification());diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.phpindex e2e641a16d..cfe87cca85 100644--- a/app/Http/Controllers/Admin/UserController.php+++ b/app/Http/Controllers/Admin/UserController.php@@ -170,7 +170,7 @@ class UserController extends Controller$subTitle = (string)trans('firefly.user_administration');$subTitleIcon = 'fa-users';$users = $this->repository->all();- $singleUserMode = app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;+ $singleUserMode = (bool) app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;$allowInvites = false;if (!$this->externalIdentity && $singleUserMode) {// also registration enabled.diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.phpindex c98294122e..4c5e82533d 100644--- a/app/Http/Controllers/Auth/LoginController.php+++ b/app/Http/Controllers/Auth/LoginController.php@@ -191,9 +191,7 @@ class LoginController extends Controller$request->session()->regenerateToken();- if ($response = $this->loggedOut($request)) {- return $response;- }+ $this->loggedOut($request);return $request->wantsJson()? new Response('', 204)diff --git a/app/Http/Controllers/Bill/ShowController.php b/app/Http/Controllers/Bill/ShowController.phpindex 327c84c5f9..29861be314 100644--- a/app/Http/Controllers/Bill/ShowController.php+++ b/app/Http/Controllers/Bill/ShowController.php@@ -112,7 +112,7 @@ class ShowController extends Controller// file the rule(s)$ruleEngine->fire();- $request->session()->flash('success', (string)trans_choice('firefly.rescanned_bill', $total));+ $request->session()->flash('success', trans_choice('firefly.rescanned_bill', $total));app('preferences')->mark();return redirect(route('bills.show', [$bill->id]));diff --git a/app/Http/Controllers/Chart/ExpenseReportController.php b/app/Http/Controllers/Chart/ExpenseReportController.phpindex f6fb7e81ca..310b6174d9 100644--- a/app/Http/Controllers/Chart/ExpenseReportController.php+++ b/app/Http/Controllers/Chart/ExpenseReportController.php@@ -147,7 +147,7 @@ class ExpenseReportController extends Controllerwhile ($currentStart < $end) {$currentEnd = clone $currentStart;- $currentEnd = $currentEnd->$function();+ $currentEnd = $currentEnd->$function(); // @phpstan-ignore-line// get expenses grouped by opposing name:$expenses = $this->groupByName($this->getExpensesForOpposing($accounts, $all, $currentStart, $currentEnd));diff --git a/app/Http/Controllers/Report/CategoryController.php b/app/Http/Controllers/Report/CategoryController.phpindex c7842af5a2..e57b5ed18f 100644--- a/app/Http/Controllers/Report/CategoryController.php+++ b/app/Http/Controllers/Report/CategoryController.php@@ -674,7 +674,7 @@ class CategoryController extends Controllertry {- $result = (string)view('reports.partials.categories', compact('report'))->render();+ $result = view('reports.partials.categories', compact('report'))->render();$cache->store($result);} catch (Throwable $e) {app('log')->error(sprintf('Could not render category::expenses: %s', $e->getMessage()));diff --git a/app/Http/Controllers/Rule/IndexController.php b/app/Http/Controllers/Rule/IndexController.phpindex f4dec56a96..d83e726877 100644--- a/app/Http/Controllers/Rule/IndexController.php+++ b/app/Http/Controllers/Rule/IndexController.php@@ -89,7 +89,7 @@ class IndexController extends Controllerpublic function moveRule(Request $request, Rule $rule, RuleGroup $ruleGroup): JsonResponse{$order = (int)$request->get('order');- $this->ruleRepos->moveRule($rule, $ruleGroup, (int)$order);+ $this->ruleRepos->moveRule($rule, $ruleGroup, $order);return response()->json([]);}diff --git a/app/Http/Controllers/Rule/SelectController.php b/app/Http/Controllers/Rule/SelectController.phpindex 11d68f5b36..ff5983b7c8 100644--- a/app/Http/Controllers/Rule/SelectController.php+++ b/app/Http/Controllers/Rule/SelectController.php@@ -97,7 +97,7 @@ class SelectController extends Controller$newRuleEngine->fire();$resultCount = $newRuleEngine->getResults();- session()->flash('success', (string)trans_choice('firefly.applied_rule_selection', $resultCount, ['title' => $rule->title]));+ session()->flash('success', trans_choice('firefly.applied_rule_selection', $resultCount, ['title' => $rule->title]));return redirect()->route('rules.index');}diff --git a/app/Http/Controllers/System/InstallController.php b/app/Http/Controllers/System/InstallController.phpindex 61f3b8ef9f..14bc3d2445 100644--- a/app/Http/Controllers/System/InstallController.php+++ b/app/Http/Controllers/System/InstallController.php@@ -56,6 +56,7 @@ class InstallController extends Controller*/public function __construct(){+ parent::__construct();// empty on purpose.$this->upgradeCommands = [// there are 5 initial commandsdiff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.phpindex 322929bc3d..c5a320e5d4 100644--- a/app/Http/Controllers/TagController.php+++ b/app/Http/Controllers/TagController.php@@ -201,7 +201,7 @@ class TagController extends Controller$count++;}}- session()->flash('success', (string)trans_choice('firefly.deleted_x_tags', $count));+ session()->flash('success', trans_choice('firefly.deleted_x_tags', $count));return redirect(route('tags.index'));}diff --git a/app/Http/Controllers/Transaction/BulkController.php b/app/Http/Controllers/Transaction/BulkController.phpindex 9f732af36e..58f889bcb2 100644--- a/app/Http/Controllers/Transaction/BulkController.php+++ b/app/Http/Controllers/Transaction/BulkController.php@@ -127,7 +127,7 @@ class BulkController extends Controller}app('preferences')->mark();- $request->session()->flash('success', (string)trans_choice('firefly.mass_edited_transactions_success', $count));+ $request->session()->flash('success', trans_choice('firefly.mass_edited_transactions_success', $count));// redirect to previous URL:return redirect($this->getPreviousUrl('transactions.bulk-edit.url'));diff --git a/app/Http/Controllers/Transaction/DeleteController.php b/app/Http/Controllers/Transaction/DeleteController.phpindex 7d0c3e85e5..374272acd8 100644--- a/app/Http/Controllers/Transaction/DeleteController.php+++ b/app/Http/Controllers/Transaction/DeleteController.php@@ -117,10 +117,10 @@ class DeleteController extends Controller// grab asset account(s) from group:$accounts = [];- /** @var TransactionJournal $journal */- foreach ($group->transactionJournals as $journal) {+ /** @var TransactionJournal $currentJournal */+ foreach ($group->transactionJournals as $currentJournal) {/** @var Transaction $transaction */- foreach ($journal->transactions as $transaction) {+ foreach ($currentJournal->transactions as $transaction) {$type = $transaction->account->accountType->type;// if is valid liability, trigger event!if (in_array($type, config('firefly.valid_liabilities'), true)) {diff --git a/app/Http/Controllers/Transaction/MassController.php b/app/Http/Controllers/Transaction/MassController.phpindex a7e3b61b8c..f641ee33a7 100644--- a/app/Http/Controllers/Transaction/MassController.php+++ b/app/Http/Controllers/Transaction/MassController.php@@ -118,7 +118,7 @@ class MassController extends Controller}}app('preferences')->mark();- session()->flash('success', (string)trans_choice('firefly.mass_deleted_transactions_success', $count));+ session()->flash('success', trans_choice('firefly.mass_deleted_transactions_success', $count));// redirect to previous URL:return redirect($this->getPreviousUrl('transactions.mass-delete.url'));@@ -190,7 +190,7 @@ class MassController extends Controller}app('preferences')->mark();- session()->flash('success', (string)trans_choice('firefly.mass_edited_transactions_success', $count));+ session()->flash('success', trans_choice('firefly.mass_edited_transactions_success', $count));// redirect to previous URL:return redirect($this->getPreviousUrl('transactions.mass-edit.url'));diff --git a/app/Mail/ReportNewJournalsMail.php b/app/Mail/ReportNewJournalsMail.phpindex 62e6a12cd4..24820ab5b7 100644--- a/app/Mail/ReportNewJournalsMail.php+++ b/app/Mail/ReportNewJournalsMail.php@@ -67,7 +67,7 @@ class ReportNewJournalsMail extends Mailablereturn $this->markdown('emails.report-new-journals')- ->subject((string)trans_choice('email.new_journals_subject', $this->groups->count()));+ ->subject(trans_choice('email.new_journals_subject', $this->groups->count()));}/**diff --git a/app/Models/Account.php b/app/Models/Account.phpindex b9fdde9f25..85bf92b8c1 100644--- a/app/Models/Account.php+++ b/app/Models/Account.php@@ -49,7 +49,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @property int|string $user_id* @property int|string $account_type_id* @property string $name- * @property string|null $virtual_balance+ * @property string|float|null $virtual_balance* @property string|null $iban* @property bool $active* @property bool $encrypteddiff --git a/app/Models/RuleAction.php b/app/Models/RuleAction.phpindex b3b40a646a..dc563b66f5 100644--- a/app/Models/RuleAction.php+++ b/app/Models/RuleAction.php@@ -36,9 +36,9 @@ use Carbon\Carbon;* @property Carbon|null $created_at* @property Carbon|null $updated_at* @property int|string $rule_id- * @property string $action_type- * @property string $action_value- * @property int $order+ * @property string|null $action_type+ * @property string|null $action_value+ * @property int|string $order* @property bool $active* @property bool $stop_processing* @property-read Rule $rulediff --git a/app/Models/RuleGroup.php b/app/Models/RuleGroup.phpindex 35d7faeecb..5b49769cf4 100644--- a/app/Models/RuleGroup.php+++ b/app/Models/RuleGroup.php@@ -44,7 +44,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @property int|string $user_id* @property string|null $title* @property string|null $description- * @property int $order+ * @property int|string $order* @property bool $active* @property bool $stop_processing* @property Collection|Rule[] $rulesdiff --git a/app/Models/RuleTrigger.php b/app/Models/RuleTrigger.phpindex 31975de3fd..ef8fb5c329 100644--- a/app/Models/RuleTrigger.php+++ b/app/Models/RuleTrigger.php@@ -38,7 +38,7 @@ use Carbon\Carbon;* @property int|string $rule_id* @property string|null $trigger_type* @property string|null $trigger_value- * @property int $order+ * @property int|string $order* @property bool $active* @property bool $stop_processing* @property-read Rule $rulediff --git a/app/Models/Transaction.php b/app/Models/Transaction.phpindex c889ad19fe..f5a92e44f0 100644--- a/app/Models/Transaction.php+++ b/app/Models/Transaction.php@@ -46,8 +46,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;* @property int|string $transaction_journal_id* @property string|null $description* @property int|null $transaction_currency_id- * @property string $modified- * @property string $modified_foreign+ * @property string|null $modified+ * @property string|null $modified_foreign* @property string $date* @property string $max_date* @property string|float $amountdiff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.phpindex e199c39ea4..8c89d52ddb 100644--- a/app/Models/TransactionJournal.php+++ b/app/Models/TransactionJournal.php@@ -41,16 +41,16 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\TransactionJournal*- * @property int|string $id+ * @property int|string $id* @property Carbon|null $created_at* @property Carbon|null $updated_at* @property Carbon|null $deleted_at- * @property int|string $user_id- * @property int |string $transaction_type_id- * @property int|null $transaction_group_id- * @property int|null $bill_id- * @property int|null $transaction_currency_id- * @property string $description+ * @property int|string $user_id+ * @property int |string $transaction_type_id+ * @property int|string|null $transaction_group_id+ * @property int|string|null $bill_id+ * @property int|string|null $transaction_currency_id+ * @property string|null $description* @property Carbon $date* @property Carbon|null $interest_date* @property Carbon|null $book_date@@ -114,7 +114,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static \Illuminate\Database\Query\Builder|TransactionJournal withoutTrashed()* @property-read Collection|Location[] $locations* @property-read int|null $locations_count- * @property int $the_count+ * @property int|string $the_count* @property int|null $user_group_id* @method static EloquentBuilder|TransactionJournal whereUserGroupId($value)* @property-read Collection<int, AuditLogEntry> $auditLogEntriesdiff --git a/app/Notifications/User/TransactionCreation.php b/app/Notifications/User/TransactionCreation.phpindex ee41ce8e72..ecd51b6825 100644--- a/app/Notifications/User/TransactionCreation.php+++ b/app/Notifications/User/TransactionCreation.php@@ -72,7 +72,7 @@ class TransactionCreation extends Notification{return (new MailMessage())->markdown('emails.report-new-journals', ['transformed' => $this->collection])- ->subject((string)trans_choice('email.new_journals_subject', count($this->collection)));+ ->subject(trans_choice('email.new_journals_subject', count($this->collection)));}/**diff --git a/app/Repositories/Account/OperationsRepository.php b/app/Repositories/Account/OperationsRepository.phpindex a6e44b860e..680d482416 100644--- a/app/Repositories/Account/OperationsRepository.php+++ b/app/Repositories/Account/OperationsRepository.php@@ -111,7 +111,7 @@ class OperationsRepository implements OperationsRepositoryInterface];$array[$currencyId]['transaction_journals'][$journalId] = [- 'amount' => app('steam')->$direction((string)$journal['amount']),+ 'amount' => app('steam')->$direction((string)$journal['amount']), // @phpstan-ignore-line'date' => $journal['date'],'transaction_journal_id' => $journalId,'budget_name' => $journal['budget_name'],@@ -268,7 +268,7 @@ class OperationsRepository implements OperationsRepositoryInterface'currency_code' => $journal['currency_code'],'currency_decimal_places' => $journal['currency_decimal_places'],];- $array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->$direction($journal['amount']));+ $array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->$direction($journal['amount']));// @phpstan-ignore-line// also do foreign amount:$foreignId = (int)$journal['foreign_currency_id'];@@ -281,7 +281,7 @@ class OperationsRepository implements OperationsRepositoryInterface'currency_code' => $journal['foreign_currency_code'],'currency_decimal_places' => $journal['foreign_currency_decimal_places'],];- $array[$foreignId]['sum'] = bcadd($array[$foreignId]['sum'], app('steam')->$direction($journal['foreign_amount']));+ $array[$foreignId]['sum'] = bcadd($array[$foreignId]['sum'], app('steam')->$direction($journal['foreign_amount']));// @phpstan-ignore-line}}@@ -328,7 +328,7 @@ class OperationsRepository implements OperationsRepositoryInterface'currency_code' => $journal['currency_code'],'currency_decimal_places' => $journal['currency_decimal_places'],];- $array[$key]['sum'] = bcadd($array[$key]['sum'], app('steam')->$method((string)$journal['amount']));+ $array[$key]['sum'] = bcadd($array[$key]['sum'], app('steam')->$method((string)$journal['amount']));// @phpstan-ignore-line// also do foreign amount:if (0 !== (int)$journal['foreign_currency_id']) {@@ -343,7 +343,7 @@ class OperationsRepository implements OperationsRepositoryInterface'currency_code' => $journal['foreign_currency_code'],'currency_decimal_places' => $journal['foreign_currency_decimal_places'],];- $array[$key]['sum'] = bcadd($array[$key]['sum'], app('steam')->$method((string)$journal['foreign_amount']));+ $array[$key]['sum'] = bcadd($array[$key]['sum'], app('steam')->$method((string)$journal['foreign_amount']));// @phpstan-ignore-line}}diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.phpindex 786fa6cb58..df765dd005 100644--- a/app/Repositories/Bill/BillRepository.php+++ b/app/Repositories/Bill/BillRepository.php@@ -137,7 +137,7 @@ class BillRepository implements BillRepositoryInterfacepublic function findBill(?int $billId, ?string $billName): ?Bill{if (null !== $billId) {- $searchResult = $this->find((int)$billId);+ $searchResult = $this->find($billId);if (null !== $searchResult) {app('log')->debug(sprintf('Found bill based on #%d, will return it.', $billId));@@ -145,7 +145,7 @@ class BillRepository implements BillRepositoryInterface}}if (null !== $billName) {- $searchResult = $this->findByName((string)$billName);+ $searchResult = $this->findByName($billName);if (null !== $searchResult) {app('log')->debug(sprintf('Found bill based on "%s", will return it.', $billName));diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.phpindex 4cef859d8d..a99b8769f7 100644--- a/app/Repositories/Budget/BudgetRepository.php+++ b/app/Repositories/Budget/BudgetRepository.php@@ -530,7 +530,7 @@ class BudgetRepository implements BudgetRepositoryInterface$result = $this->find((int)$budgetId);if (null === $result && null !== $budgetName && '' !== $budgetName) {app('log')->debug(sprintf('Searching for budget with name %s...', $budgetName));- $result = $this->findByName((string)$budgetName);+ $result = $this->findByName($budgetName);}if (null !== $result) {app('log')->debug(sprintf('Found budget #%d: %s', $result->id, $result->name));diff --git a/app/Repositories/LinkType/LinkTypeRepository.php b/app/Repositories/LinkType/LinkTypeRepository.phpindex 98b0f05fcc..729dc4709b 100644--- a/app/Repositories/LinkType/LinkTypeRepository.php+++ b/app/Repositories/LinkType/LinkTypeRepository.php@@ -382,8 +382,8 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface*/public function updateLink(TransactionJournalLink $journalLink, array $data): TransactionJournalLink{- $journalLink->source_id = $data['inward_id'] ?: $journalLink->source_id;- $journalLink->destination_id = $data['outward_id'] ?: $journalLink->destination_id;+ $journalLink->source_id = null === $data['inward_id'] ? $journalLink->source_id : $data['inward_id'];+ $journalLink->destination_id = null === $data['outward_id'] ? $journalLink->destination_id : $data['outward_id'];$journalLink->save();if (array_key_exists('link_type_name', $data)) {$linkType = LinkType::whereName($data['link_type_name'])->first();@@ -394,7 +394,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface$journalLink->refresh();}- $journalLink->link_type_id = $data['link_type_id'] ?: $journalLink->link_type_id;+ $journalLink->link_type_id = null === $data['link_type_id'] ? $journalLink->link_type_id : $data['link_type_id'];$journalLink->save();if (array_key_exists('notes', $data) && null !== $data['notes']) {$this->setNoteText($journalLink, $data['notes']);diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.phpindex 32c2bcd55f..7f8e943f06 100644--- a/app/Repositories/PiggyBank/PiggyBankRepository.php+++ b/app/Repositories/PiggyBank/PiggyBankRepository.php@@ -68,7 +68,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterfaceapp('log')->debug('Searching for piggy information.');if (null !== $piggyBankId) {- $searchResult = $this->find((int)$piggyBankId);+ $searchResult = $this->find($piggyBankId);if (null !== $searchResult) {app('log')->debug(sprintf('Found piggy based on #%d, will return it.', $piggyBankId));@@ -76,7 +76,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface}}if (null !== $piggyBankName) {- $searchResult = $this->findByName((string)$piggyBankName);+ $searchResult = $this->findByName($piggyBankName);if (null !== $searchResult) {app('log')->debug(sprintf('Found piggy based on "%s", will return it.', $piggyBankName));@@ -227,11 +227,11 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface$amount = null;if ((int)$source->transaction_currency_id === (int)$currency->id) {app('log')->debug('Use normal amount');- $amount = app('steam')->$operator($source->amount);+ $amount = app('steam')->$operator($source->amount); // @phpstan-ignore-line}if ((int)$source->foreign_currency_id === (int)$currency->id) {app('log')->debug('Use foreign amount');- $amount = app('steam')->$operator($source->foreign_amount);+ $amount = app('steam')->$operator($source->foreign_amount); // @phpstan-ignore-line}if (null === $amount) {app('log')->debug('No match on currency, so amount remains null, return "0".');diff --git a/app/Repositories/UserGroup/UserGroupRepository.php b/app/Repositories/UserGroup/UserGroupRepository.phpindex 3a3faa6e5f..818a857b4a 100644--- a/app/Repositories/UserGroup/UserGroupRepository.php+++ b/app/Repositories/UserGroup/UserGroupRepository.php@@ -85,7 +85,7 @@ class UserGroupRepository implements UserGroupRepositoryInterface'recurrences', 'rules', 'ruleGroups', 'tags', 'transactionGroups', 'transactionJournals', 'piggyBanks', 'accounts', 'webhooks',];foreach ($objects as $object) {- foreach ($userGroup->$object()->get() as $item) {+ foreach ($userGroup->$object()->get() as $item) { // @phpstan-ignore-line$item->delete();}}@@ -135,7 +135,7 @@ class UserGroupRepository implements UserGroupRepositoryInterface}if (null !== $existingGroup) {// group already exists- $groupName = sprintf('%s-%s', $user->email, substr(sha1((string)(rand(1000, 9999) . microtime())), 0, 4));+ $groupName = sprintf('%s-%s', $user->email, substr(sha1((rand(1000, 9999) . microtime())), 0, 4));}$loop++;}diff --git a/app/Rules/BelongsUser.php b/app/Rules/BelongsUser.phpindex 5e2251f250..40eb1c625b 100644--- a/app/Rules/BelongsUser.php+++ b/app/Rules/BelongsUser.php@@ -49,7 +49,6 @@ class BelongsUser implements ValidationRule$fail('validation.belongs_user')->translate();return;}- $attribute = (string)$attribute;app('log')->debug(sprintf('Going to validate %s', $attribute));$result = match ($attribute) {@@ -135,7 +134,7 @@ class BelongsUser implements ValidationRule}$count = 0;foreach ($objects as $object) {- $objectValue = trim((string)$object->$field);+ $objectValue = trim((string)$object->$field); // @phpstan-ignore-lineapp('log')->debug(sprintf('Comparing object "%s" with value "%s"', $objectValue, $value));if ($objectValue === $value) {$count++;diff --git a/app/Rules/BelongsUserGroup.php b/app/Rules/BelongsUserGroup.phpindex 8ea2a19dd5..e74194bf6a 100644--- a/app/Rules/BelongsUserGroup.php+++ b/app/Rules/BelongsUserGroup.php@@ -64,7 +64,6 @@ class BelongsUserGroup implements ValidationRule$fail('validation.belongs_user_or_user_group')->translate();return;}- $attribute = (string)$attribute;app('log')->debug(sprintf('Group: Going to validate "%s"', $attribute));$result = match ($attribute) {@@ -150,7 +149,7 @@ class BelongsUserGroup implements ValidationRule}$count = 0;foreach ($objects as $object) {- $objectValue = trim((string)$object->$field);+ $objectValue = trim((string)$object->$field); // @phpstan-ignore-lineapp('log')->debug(sprintf('Comparing object "%s" with value "%s"', $objectValue, $value));if ($objectValue === $value) {$count++;diff --git a/app/Rules/IsValidAttachmentModel.php b/app/Rules/IsValidAttachmentModel.phpindex b5ca4bcdbd..9b6c548897 100644--- a/app/Rules/IsValidAttachmentModel.php+++ b/app/Rules/IsValidAttachmentModel.php@@ -107,7 +107,7 @@ class IsValidAttachmentModel implements ValidationRule}$method = $methods[$this->model];- $result = $this->$method((int)$value);+ $result = $this->$method((int)$value); // @phpstan-ignore-lineif(false === $result) {$fail('validation.model_id_invalid')->translate();}@@ -221,6 +221,6 @@ class IsValidAttachmentModel implements ValidationRule$repository = app(JournalAPIRepositoryInterface::class);$repository->setUser(auth()->user());- return null !== $repository->findTransaction((int)$value);+ return null !== $repository->findTransaction($value);}}diff --git a/app/Services/Internal/Support/RecurringTransactionTrait.php b/app/Services/Internal/Support/RecurringTransactionTrait.phpindex 02c04d9494..6c66716c01 100644--- a/app/Services/Internal/Support/RecurringTransactionTrait.php+++ b/app/Services/Internal/Support/RecurringTransactionTrait.php@@ -196,7 +196,7 @@ trait RecurringTransactionTrait$repository->setUser($this->user);// if user has submitted an account ID, search for it.- $result = $repository->find((int)$accountId);+ $result = $repository->find($accountId);if (null !== $result) {return $result;}diff --git a/app/Services/Internal/Update/CurrencyUpdateService.php b/app/Services/Internal/Update/CurrencyUpdateService.phpindex 9271b13981..02faa86a1f 100644--- a/app/Services/Internal/Update/CurrencyUpdateService.php+++ b/app/Services/Internal/Update/CurrencyUpdateService.php@@ -55,7 +55,7 @@ class CurrencyUpdateService$currency->enabled = false;if (array_key_exists('decimal_places', $data) && is_int($data['decimal_places'])) {- $currency->decimal_places = (int)$data['decimal_places'];+ $currency->decimal_places = $data['decimal_places'];}$currency->userEnabled = null;$currency->userDefault = null;diff --git a/app/Services/Internal/Update/JournalUpdateService.php b/app/Services/Internal/Update/JournalUpdateService.phpindex a314b79a13..ce2e0984cb 100644--- a/app/Services/Internal/Update/JournalUpdateService.php+++ b/app/Services/Internal/Update/JournalUpdateService.php@@ -536,12 +536,12 @@ class JournalUpdateService$this->transactionJournal->user,$this->transactionJournal,sprintf('update_%s', $fieldName),- $this->transactionJournal->$fieldName,+ $this->transactionJournal->$fieldName, // @phpstan-ignore-line$value));- $this->transactionJournal->$fieldName = $value;+ $this->transactionJournal->$fieldName = $value;// @phpstan-ignore-lineapp('log')->debug(sprintf('Updated %s', $fieldName));}}diff --git a/app/Support/Binder/CLIToken.php b/app/Support/Binder/CLIToken.phpindex 156f440c62..6863b1e362 100644--- a/app/Support/Binder/CLIToken.php+++ b/app/Support/Binder/CLIToken.php@@ -47,7 +47,7 @@ class CLIToken implements BinderInterface$users = $repository->all();// check for static token- if ($value === config('firefly.static_cron_token') && 32 === strlen((string)config('firefly.static_cron_token'))) {+ if ($value === config('firefly.static_cron_token') && 32 === strlen(config('firefly.static_cron_token'))) {return $value;}diff --git a/app/Support/Http/Controllers/ModelInformation.php b/app/Support/Http/Controllers/ModelInformation.phpindex 2b6e06c796..9b0e92ab6d 100644--- a/app/Support/Http/Controllers/ModelInformation.php+++ b/app/Support/Http/Controllers/ModelInformation.php@@ -249,7 +249,7 @@ trait ModelInformation$values[$index] = $notes->text;}- foreach ($journalTriggers as $index => $trigger) {+ foreach ($journalTriggers as $ii => $trigger) {try {$string = view('rules.partials.trigger',@@ -257,14 +257,13 @@ trait ModelInformation'oldTrigger' => $trigger,'oldValue' => $values[$index],'oldChecked' => false,- 'count' => $index + 1,+ 'count' => $ii + 1,'triggers' => $triggers,])->render();} catch (Throwable $e) {app('log')->debug(sprintf('Throwable was thrown in getTriggersForJournal(): %s', $e->getMessage()));app('log')->debug($e->getTraceAsString());- $string = '';throw new FireflyException('Could not render trigger', 0, $e);}if ('' !== $string) {diff --git a/app/Support/Navigation.php b/app/Support/Navigation.phpindex 4f39d5f5aa..70a32130b2 100644--- a/app/Support/Navigation.php+++ b/app/Support/Navigation.php@@ -46,7 +46,7 @@ class Navigation*/public function __construct(Calculator $calculator = null){- $this->calculator = ($calculator instanceof Calculator) ?: new Calculator();+ $this->calculator = $calculator instanceof Calculator ? $calculator : new Calculator();}/**@@ -213,7 +213,7 @@ class Navigation];if (array_key_exists($repeatFreq, $functionMap)) {$function = $functionMap[$repeatFreq];- $date->$function();+ $date->$function(); // @phpstan-ignore-linereturn $date;}@@ -325,7 +325,7 @@ class Navigation$function = $functionMap[$repeatFreq];if (array_key_exists($repeatFreq, $modifierMap)) {- $currentEnd->$function($modifierMap[$repeatFreq]);+ $currentEnd->$function($modifierMap[$repeatFreq]); // @phpstan-ignore-lineif (in_array($repeatFreq, $subDay, true)) {$currentEnd->subDay();}@@ -333,7 +333,7 @@ class Navigationreturn $currentEnd;}- $currentEnd->$function();+ $currentEnd->$function(); // @phpstan-ignore-line$currentEnd->endOfDay();if (in_array($repeatFreq, $subDay, true)) {$currentEnd->subDay();@@ -372,7 +372,7 @@ class Navigation}$func = $map[$period];// first do the diff- $floatDiff = $beginning->$func($end);+ $floatDiff = $beginning->$func($end); // @phpstan-ignore-line// then correct for quarterly or half-year@@ -434,7 +434,7 @@ class Navigationif (array_key_exists($repeatFreq, $functionMap)) {$function = $functionMap[$repeatFreq];- $currentEnd->$function();+ $currentEnd->$function(); // @phpstan-ignore-line}if (null !== $maxDate && $currentEnd > $maxDate) {@@ -508,7 +508,7 @@ class Navigation$formatted = $begin->format($format);$displayed = $begin->isoFormat($displayFormat);$entries[$formatted] = $displayed;- $begin->$increment();+ $begin->$increment(); // @phpstan-ignore-line}return $entries;@@ -563,7 +563,7 @@ class Navigation];if (array_key_exists($repeatFrequency, $formatMap)) {- return $date->isoFormat((string)$formatMap[$repeatFrequency]);+ return $date->isoFormat($formatMap[$repeatFrequency]);}if ('3M' === $repeatFrequency || 'quarter' === $repeatFrequency) {$quarter = ceil($theDate->month / 3);@@ -726,7 +726,7 @@ class Navigation];if (array_key_exists($repeatFreq, $functionMap)) {$function = $functionMap[$repeatFreq];- $date->$function($subtract);+ $date->$function($subtract); // @phpstan-ignore-linereturn $date;}@@ -801,7 +801,7 @@ class Navigationif (array_key_exists($range, $functionMap)) {$function = $functionMap[$range];- $end->$function();+ $end->$function(); // @phpstan-ignore-linereturn $end;}@@ -862,7 +862,7 @@ class Navigation];if (array_key_exists($range, $functionMap)) {$function = $functionMap[$range];- $start->$function();+ $start->$function(); // @phpstan-ignore-linereturn $start;}diff --git a/app/Support/ParseDateString.php b/app/Support/ParseDateString.phpindex 4c310a03eb..f70d35df9c 100644--- a/app/Support/ParseDateString.php+++ b/app/Support/ParseDateString.php@@ -201,7 +201,7 @@ class ParseDateString}$func = $functions[$direction][$period];app('log')->debug(sprintf('Will now do %s(%d) on %s', $func, $number, $today->format('Y-m-d')));- $today->$func($number);+ $today->$func($number); // @phpstan-ignore-lineapp('log')->debug(sprintf('Resulting date is %s', $today->format('Y-m-d')));}diff --git a/app/Support/Request/AppendsLocationData.php b/app/Support/Request/AppendsLocationData.phpindex f999f781d6..0157c03fb7 100644--- a/app/Support/Request/AppendsLocationData.php+++ b/app/Support/Request/AppendsLocationData.php@@ -117,9 +117,9 @@ trait AppendsLocationData** @return bool*/- private function isValidPOST(?string $prefix): bool+ private function isValidPost(?string $prefix): bool{- app('log')->debug('Now in isValidPOST()');+ app('log')->debug('Now in isValidPost()');$longitudeKey = $this->getLocationKey($prefix, 'longitude');$latitudeKey = $this->getLocationKey($prefix, 'latitude');$zoomLevelKey = $this->getLocationKey($prefix, 'zoom_level');diff --git a/app/Support/Request/ConvertsDataTypes.php b/app/Support/Request/ConvertsDataTypes.phpindex 5b6b36f11f..f94d25124f 100644--- a/app/Support/Request/ConvertsDataTypes.php+++ b/app/Support/Request/ConvertsDataTypes.php@@ -353,7 +353,7 @@ trait ConvertsDataTypes{$return = [];foreach ($fields as $field => $info) {- if ($this->has($info[0])) {+ if (true === $this->has($info[0])) {$method = $info[1];$return[$field] = $this->$method($info[0]); // @phpstan-ignore-line}@@ -422,7 +422,7 @@ trait ConvertsDataTypes*/protected function nullableInteger(string $field): ?int{- if (!$this->has($field)) {+ if (false === $this->has($field)) {return null;}diff --git a/app/Support/Search/OperatorQuerySearch.php b/app/Support/Search/OperatorQuerySearch.phpindex 0435d30b88..46a839247f 100644--- a/app/Support/Search/OperatorQuerySearch.php+++ b/app/Support/Search/OperatorQuerySearch.php@@ -60,7 +60,8 @@ use TypeError;/*** Class OperatorQuerySearch*/-class OperatorQuerySearch implements SearchInterface+class+OperatorQuerySearch implements SearchInterface{protected Carbon $date;private AccountRepositoryInterface $accountRepository;@@ -1422,7 +1423,7 @@ class OperatorQuerySearch implements SearchInterfacereturn;}app('log')->debug(sprintf('Left with %d, set as %s().', $filtered->count(), $collectorMethod));- $this->collector->$collectorMethod($filtered);+ $this->collector->$collectorMethod($filtered); // @phpstan-ignore-line}/**@@ -1512,7 +1513,7 @@ class OperatorQuerySearch implements SearchInterfacereturn;}app('log')->debug(sprintf('Left with %d, set as %s().', $filtered->count(), $collectorMethod));- $this->collector->$collectorMethod($filtered);+ $this->collector->$collectorMethod($filtered);// @phpstan-ignore-line}/**diff --git a/app/Support/Steam.php b/app/Support/Steam.phpindex d200dd681a..6461055fbb 100644--- a/app/Support/Steam.php+++ b/app/Support/Steam.php@@ -164,8 +164,8 @@ class Steam/** @var Transaction $entry */foreach ($set as $entry) {// normal amount and foreign amount- $modified = null === $entry->modified ? '0' : (string)$entry->modified;- $foreignModified = null === $entry->modified_foreign ? '0' : (string)$entry->modified_foreign;+ $modified = null === $entry->modified ? '0' : $entry->modified;+ $foreignModified = null === $entry->modified_foreign ? '0' :$entry->modified_foreign;$amount = '0';if ($currencyId === (int)$entry->transaction_currency_id || 0 === $currencyId) {// use normal amount: