Skip to content

Firefly III: a personal finances manager

Final set of php8.4 changes.

James Cole194d22ad90f2
diff --git a/app/Api/V1/Controllers/Chart/BudgetController.php b/app/Api/V1/Controllers/Chart/BudgetController.php
index 573f90be51..61315e2b59 100644
--- a/app/Api/V1/Controllers/Chart/BudgetController.php
+++ b/app/Api/V1/Controllers/Chart/BudgetController.php
@@ -193,7 +193,7 @@ class BudgetController extends Controller
// var_dump($return);
/** @var array $journal */
foreach ($currentBudgetArray['transaction_journals'] as $journal) {
- $return[$currencyId]['spent'] = bcadd($return[$currencyId]['spent'], $journal['amount']);
+ $return[$currencyId]['spent'] = bcadd($return[$currencyId]['spent'], (string) $journal['amount']);
}
}
@@ -245,13 +245,13 @@ class BudgetController extends Controller
}
$result = $this->processExpenses($budget->id, $filtered, $limit->start_date, $end);
if (1 === count($result)) {
- $compare = bccomp($limit->amount, app('steam')->positive($result[$limitCurrencyId]['spent']));
+ $compare = bccomp($limit->amount, (string) app('steam')->positive($result[$limitCurrencyId]['spent']));
if (1 === $compare) {
// convert this amount into the native currency:
- $result[$limitCurrencyId]['left'] = bcadd($limit->amount, $result[$limitCurrencyId]['spent']);
+ $result[$limitCurrencyId]['left'] = bcadd($limit->amount, (string) $result[$limitCurrencyId]['spent']);
}
if ($compare <= 0) {
- $result[$limitCurrencyId]['overspent'] = app('steam')->positive(bcadd($limit->amount, $result[$limitCurrencyId]['spent']));
+ $result[$limitCurrencyId]['overspent'] = app('steam')->positive(bcadd($limit->amount, (string) $result[$limitCurrencyId]['spent']));
}
}
diff --git a/app/Api/V1/Controllers/Chart/CategoryController.php b/app/Api/V1/Controllers/Chart/CategoryController.php
index 8053d5c122..e833e0cfce 100644
--- a/app/Api/V1/Controllers/Chart/CategoryController.php
+++ b/app/Api/V1/Controllers/Chart/CategoryController.php
@@ -96,7 +96,7 @@ class CategoryController extends Controller
$currencyId = (int) $journal['currency_id'];
$currency = $currencies[$currencyId] ?? $this->currencyRepos->find($currencyId);
$currencies[$currencyId] = $currency;
- $categoryName = null === $journal['category_name'] ? (string) trans('firefly.no_category') : $journal['category_name'];
+ $categoryName = $journal['category_name'] ?? (string) trans('firefly.no_category');
$amount = app('steam')->positive($journal['amount']);
$key = sprintf('%s-%s', $categoryName, $currency->code);
// create arrays
@@ -114,7 +114,7 @@ class CategoryController extends Controller
];
// add monies
- $return[$key]['amount'] = bcadd($return[$key]['amount'], $amount);
+ $return[$key]['amount'] = bcadd($return[$key]['amount'], (string) $amount);
}
$return = array_values($return);
diff --git a/app/Api/V1/Controllers/Data/Export/ExportController.php b/app/Api/V1/Controllers/Data/Export/ExportController.php
index ad578e6f42..e88fda1226 100644
--- a/app/Api/V1/Controllers/Data/Export/ExportController.php
+++ b/app/Api/V1/Controllers/Data/Export/ExportController.php
@@ -89,7 +89,7 @@ class ExportController extends Controller
->header('Expires', '0')
->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
->header('Pragma', 'public')
- ->header('Content-Length', (string) strlen($data[$key]))
+ ->header('Content-Length', (string) strlen((string) $data[$key]))
;
return $response;
diff --git a/app/Api/V1/Controllers/Insight/Expense/TagController.php b/app/Api/V1/Controllers/Insight/Expense/TagController.php
index ce58076857..2e140656fe 100644
--- a/app/Api/V1/Controllers/Insight/Expense/TagController.php
+++ b/app/Api/V1/Controllers/Insight/Expense/TagController.php
@@ -160,7 +160,7 @@ class TagController extends Controller
'currency_id' => (string) $currencyId,
'currency_code' => $journal['currency_code'],
];
- $response[$key]['difference'] = bcadd($response[$key]['difference'], $journal['amount']);
+ $response[$key]['difference'] = bcadd((string) $response[$key]['difference'], (string) $journal['amount']);
$response[$key]['difference_float'] = (float) $response[$key]['difference']; // float but on purpose.
}
@@ -172,7 +172,7 @@ class TagController extends Controller
'currency_id' => (string) $foreignCurrencyId,
'currency_code' => $journal['foreign_currency_code'],
];
- $response[$foreignKey]['difference'] = bcadd($response[$foreignKey]['difference'], $journal['foreign_amount']);
+ $response[$foreignKey]['difference'] = bcadd((string) $response[$foreignKey]['difference'], (string) $journal['foreign_amount']);
$response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference']; // float but on purpose.
}
}
diff --git a/app/Api/V1/Controllers/Insight/Income/PeriodController.php b/app/Api/V1/Controllers/Insight/Income/PeriodController.php
index 6c720700a3..d11e93829b 100644
--- a/app/Api/V1/Controllers/Insight/Income/PeriodController.php
+++ b/app/Api/V1/Controllers/Insight/Income/PeriodController.php
@@ -75,7 +75,7 @@ class PeriodController extends Controller
'currency_id' => (string) $currencyId,
'currency_code' => $currencyCode,
];
- $response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal[$field]));
+ $response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], (string) app('steam')->positive($journal[$field]));
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // float but on purpose.
}
diff --git a/app/Api/V1/Controllers/Insight/Income/TagController.php b/app/Api/V1/Controllers/Insight/Income/TagController.php
index f7cffd7f3a..1f127f298d 100644
--- a/app/Api/V1/Controllers/Insight/Income/TagController.php
+++ b/app/Api/V1/Controllers/Insight/Income/TagController.php
@@ -100,7 +100,7 @@ class TagController extends Controller
'currency_id' => (string) $currencyId,
'currency_code' => $currencyCode,
];
- $response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal[$field]));
+ $response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], (string) app('steam')->positive($journal[$field]));
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
}
@@ -154,7 +154,7 @@ class TagController extends Controller
'currency_id' => (string) $currencyId,
'currency_code' => $journal['currency_code'],
];
- $response[$key]['difference'] = bcadd($response[$key]['difference'], app('steam')->positive($journal['amount']));
+ $response[$key]['difference'] = bcadd((string) $response[$key]['difference'], (string) app('steam')->positive($journal['amount']));
$response[$key]['difference_float'] = (float) $response[$key]['difference'];
}
@@ -167,8 +167,8 @@ class TagController extends Controller
'currency_code' => $journal['foreign_currency_code'],
];
$response[$foreignKey]['difference'] = bcadd(
- $response[$foreignKey]['difference'],
- app('steam')->positive($journal['foreign_amount'])
+ (string) $response[$foreignKey]['difference'],
+ (string) app('steam')->positive($journal['foreign_amount'])
);
$response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference'];
}
diff --git a/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php b/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php
index 31a8b0886a..d35c2b74df 100644
--- a/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php
+++ b/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php
@@ -75,7 +75,7 @@ class PeriodController extends Controller
'currency_id' => (string) $currencyId,
'currency_code' => $currencyCode,
];
- $response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal[$field]));
+ $response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], (string) app('steam')->positive($journal[$field]));
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
}
diff --git a/app/Api/V1/Controllers/Insight/Transfer/TagController.php b/app/Api/V1/Controllers/Insight/Transfer/TagController.php
index 6950f513e2..f0c02a2df5 100644
--- a/app/Api/V1/Controllers/Insight/Transfer/TagController.php
+++ b/app/Api/V1/Controllers/Insight/Transfer/TagController.php
@@ -99,7 +99,7 @@ class TagController extends Controller
'currency_id' => (string) $currencyId,
'currency_code' => $currencyCode,
];
- $response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal[$field]));
+ $response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], (string) app('steam')->positive($journal[$field]));
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
}
@@ -153,7 +153,7 @@ class TagController extends Controller
'currency_id' => (string) $currencyId,
'currency_code' => $journal['currency_code'],
];
- $response[$key]['difference'] = bcadd($response[$key]['difference'], app('steam')->positive($journal['amount']));
+ $response[$key]['difference'] = bcadd((string) $response[$key]['difference'], (string) app('steam')->positive($journal['amount']));
$response[$key]['difference_float'] = (float) $response[$key]['difference'];
}
@@ -166,8 +166,8 @@ class TagController extends Controller
'currency_code' => $journal['foreign_currency_code'],
];
$response[$foreignKey]['difference'] = bcadd(
- $response[$foreignKey]['difference'],
- app('steam')->positive($journal['foreign_amount'])
+ (string) $response[$foreignKey]['difference'],
+ (string) app('steam')->positive($journal['foreign_amount'])
);
$response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference']; // intentional float
}
diff --git a/app/Api/V1/Controllers/Summary/BasicController.php b/app/Api/V1/Controllers/Summary/BasicController.php
index 76c6029f8d..f974df4c1b 100644
--- a/app/Api/V1/Controllers/Summary/BasicController.php
+++ b/app/Api/V1/Controllers/Summary/BasicController.php
@@ -191,14 +191,14 @@ class BasicController extends Controller
// if it is the native currency already.
if ($entry['currency_id'] === $default->id) {
- $sums[$default->id]['sum'] = bcadd($entry['sum'], $sums[$default->id]['sum']);
+ $sums[$default->id]['sum'] = bcadd((string) $entry['sum'], $sums[$default->id]['sum']);
// don't forget to add it to newExpenses and newIncome
if (0 === $index) {
- $newExpenses[$default->id]['sum'] = bcadd($newExpenses[$default->id]['sum'], $entry['sum']);
+ $newExpenses[$default->id]['sum'] = bcadd($newExpenses[$default->id]['sum'], (string) $entry['sum']);
}
if (1 === $index) {
- $newIncomes[$default->id]['sum'] = bcadd($newIncomes[$default->id]['sum'], $entry['sum']);
+ $newIncomes[$default->id]['sum'] = bcadd($newIncomes[$default->id]['sum'], (string) $entry['sum']);
}
continue;
@@ -229,7 +229,7 @@ class BasicController extends Controller
'currency_decimal_places' => $entry['currency_decimal_places'],
'sum' => '0',
];
- $sums[$currencyId]['sum'] = bcadd($sums[$currencyId]['sum'], $entry['sum']);
+ $sums[$currencyId]['sum'] = bcadd($sums[$currencyId]['sum'], (string) $entry['sum']);
}
}
}
@@ -362,7 +362,7 @@ class BasicController extends Controller
if (0 === $index) {
// paid amount
if ($currencyId === $this->nativeCurrency->id) {
- $newPaidAmount[0]['sum'] = bcadd($newPaidAmount[0]['sum'], $item['sum']);
+ $newPaidAmount[0]['sum'] = bcadd($newPaidAmount[0]['sum'], (string) $item['sum']);
continue;
}
@@ -374,7 +374,7 @@ class BasicController extends Controller
}
// unpaid amount
if ($currencyId === $this->nativeCurrency->id) {
- $newUnpaidAmount[0]['sum'] = bcadd($newUnpaidAmount[0]['sum'], $item['sum']);
+ $newUnpaidAmount[0]['sum'] = bcadd($newUnpaidAmount[0]['sum'], (string) $item['sum']);
continue;
}
@@ -397,7 +397,7 @@ class BasicController extends Controller
* @var array $info
*/
foreach ($paidAmount as $info) {
- $amount = bcmul($info['sum'], '-1');
+ $amount = bcmul((string) $info['sum'], '-1');
$return[] = [
'key' => sprintf('bills-paid-in-%s', $info['code']),
'title' => trans('firefly.box_bill_paid_in_currency', ['currency' => $info['symbol']]),
@@ -416,7 +416,7 @@ class BasicController extends Controller
* @var array $info
*/
foreach ($unpaidAmount as $info) {
- $amount = bcmul($info['sum'], '-1');
+ $amount = bcmul((string) $info['sum'], '-1');
$return[] = [
'key' => sprintf('bills-unpaid-in-%s', $info['code']),
'title' => trans('firefly.box_bill_unpaid_in_currency', ['currency' => $info['symbol']]),
@@ -513,7 +513,7 @@ class BasicController extends Controller
continue;
}
$spentInCurrency = $row['sum'];
- $leftToSpend = bcadd($amount, $spentInCurrency);
+ $leftToSpend = bcadd($amount, (string) $spentInCurrency);
$perDay = '0';
if (0 !== $days && bccomp($leftToSpend, '0') > -1) {
$perDay = bcdiv($leftToSpend, (string) $days);
@@ -549,8 +549,8 @@ class BasicController extends Controller
$currencyId = (int) $row['currency_id'];
$spentInCurrency = $row['sum'];
$perDay = '0';
- if (0 !== $days && -1 === bccomp($spentInCurrency, '0')) {
- $perDay = bcdiv($spentInCurrency, (string) $days);
+ if (0 !== $days && -1 === bccomp((string) $spentInCurrency, '0')) {
+ $perDay = bcdiv((string) $spentInCurrency, (string) $days);
}
Log::debug(sprintf('Spent %s %s', $row['currency_code'], $row['sum']));
@@ -631,7 +631,7 @@ class BasicController extends Controller
continue;
}
$amount = $data['balance'];
- if (0 === bccomp($amount, '0')) {
+ if (0 === bccomp((string) $amount, '0')) {
continue;
}
// return stuff
diff --git a/app/Api/V2/Controllers/Chart/BudgetController.php b/app/Api/V2/Controllers/Chart/BudgetController.php
index 424ef0a02e..9ef001cc77 100644
--- a/app/Api/V2/Controllers/Chart/BudgetController.php
+++ b/app/Api/V2/Controllers/Chart/BudgetController.php
@@ -212,13 +212,13 @@ class BudgetController extends Controller
foreach ($currentBudgetArray['transaction_journals'] as $journal) {
// convert the amount to the native currency.
$rate = $converter->getCurrencyRate($this->currencies[$currencyId], $this->currency, $journal['date']);
- $convertedAmount = bcmul($journal['amount'], $rate);
+ $convertedAmount = bcmul((string) $journal['amount'], $rate);
if ($journal['foreign_currency_id'] === $this->currency->id) {
$convertedAmount = $journal['foreign_amount'];
}
- $return[$currencyId]['spent'] = bcadd($return[$currencyId]['spent'], $journal['amount']);
- $return[$currencyId]['native_spent'] = bcadd($return[$currencyId]['native_spent'], $convertedAmount);
+ $return[$currencyId]['spent'] = bcadd($return[$currencyId]['spent'], (string) $journal['amount']);
+ $return[$currencyId]['native_spent'] = bcadd($return[$currencyId]['native_spent'], (string) $convertedAmount);
}
}
$converter->summarize();
@@ -275,15 +275,15 @@ class BudgetController extends Controller
}
$result = $this->processExpenses($budget->id, $filtered, $limit->start_date, $end);
if (1 === count($result)) {
- $compare = bccomp($limit->amount, app('steam')->positive($result[$limitCurrencyId]['spent']));
+ $compare = bccomp($limit->amount, (string) app('steam')->positive($result[$limitCurrencyId]['spent']));
if (1 === $compare) {
// convert this amount into the native currency:
- $result[$limitCurrencyId]['left'] = bcadd($limit->amount, $result[$limitCurrencyId]['spent']);
- $result[$limitCurrencyId]['native_left'] = bcadd($convertedLimitAmount, $result[$limitCurrencyId]['native_spent']);
+ $result[$limitCurrencyId]['left'] = bcadd($limit->amount, (string) $result[$limitCurrencyId]['spent']);
+ $result[$limitCurrencyId]['native_left'] = bcadd($convertedLimitAmount, (string) $result[$limitCurrencyId]['native_spent']);
}
if ($compare <= 0) {
- $result[$limitCurrencyId]['overspent'] = app('steam')->positive(bcadd($limit->amount, $result[$limitCurrencyId]['spent']));
- $result[$limitCurrencyId]['native_overspent'] = app('steam')->positive(bcadd($convertedLimitAmount, $result[$limitCurrencyId]['native_spent']));
+ $result[$limitCurrencyId]['overspent'] = app('steam')->positive(bcadd($limit->amount, (string) $result[$limitCurrencyId]['spent']));
+ $result[$limitCurrencyId]['native_overspent'] = app('steam')->positive(bcadd($convertedLimitAmount, (string) $result[$limitCurrencyId]['native_spent']));
}
}
$converter->summarize();
diff --git a/app/Api/V2/Controllers/Chart/CategoryController.php b/app/Api/V2/Controllers/Chart/CategoryController.php
index 7d66f5080b..ed0dcebd59 100644
--- a/app/Api/V2/Controllers/Chart/CategoryController.php
+++ b/app/Api/V2/Controllers/Chart/CategoryController.php
@@ -100,7 +100,7 @@ class CategoryController extends Controller
$currencyId = (int) $journal['currency_id'];
$currency = $currencies[$currencyId] ?? $this->currencyRepos->find($currencyId);
$currencies[$currencyId] = $currency;
- $categoryName = null === $journal['category_name'] ? (string) trans('firefly.no_category') : $journal['category_name'];
+ $categoryName = $journal['category_name'] ?? (string) trans('firefly.no_category');
$amount = app('steam')->positive($journal['amount']);
$nativeAmount = $converter->convert($default, $currency, $journal['date'], $amount);
$key = sprintf('%s-%s', $categoryName, $currency->code);
@@ -128,8 +128,8 @@ class CategoryController extends Controller
];
// add monies
- $return[$key]['amount'] = bcadd($return[$key]['amount'], $amount);
- $return[$key]['native_amount'] = bcadd($return[$key]['native_amount'], $nativeAmount);
+ $return[$key]['amount'] = bcadd($return[$key]['amount'], (string) $amount);
+ $return[$key]['native_amount'] = bcadd($return[$key]['native_amount'], (string) $nativeAmount);
}
$return = array_values($return);
diff --git a/app/Api/V2/Controllers/Summary/BasicController.php b/app/Api/V2/Controllers/Summary/BasicController.php
index 80e83f48d7..079f7f7305 100644
--- a/app/Api/V2/Controllers/Summary/BasicController.php
+++ b/app/Api/V2/Controllers/Summary/BasicController.php
@@ -174,8 +174,8 @@ class BasicController extends Controller
* @var array $info
*/
foreach ($paidAmount as $info) {
- $amount = bcmul($info['sum'], '-1');
- $nativeAmount = bcmul($info['native_sum'], '-1');
+ $amount = bcmul((string) $info['sum'], '-1');
+ $nativeAmount = bcmul((string) $info['native_sum'], '-1');
$return[] = [
'key' => sprintf('bills-paid-in-%s', $info['currency_code']),
'value' => $amount,
@@ -198,8 +198,8 @@ class BasicController extends Controller
* @var array $info
*/
foreach ($unpaidAmount as $info) {
- $amount = bcmul($info['sum'], '-1');
- $nativeAmount = bcmul($info['native_sum'], '-1');
+ $amount = bcmul((string) $info['sum'], '-1');
+ $nativeAmount = bcmul((string) $info['native_sum'], '-1');
$return[] = [
'key' => sprintf('bills-unpaid-in-%s', $info['currency_code']),
'value' => $amount,
@@ -279,8 +279,8 @@ class BasicController extends Controller
if ((int) $journal['foreign_currency_id'] === $default->id) {
$amountNative = $journal['foreign_amount'];
}
- $spent = bcadd($spent, $amount);
- $spentNative = bcadd($spentNative, $amountNative);
+ $spent = bcadd($spent, (string) $amount);
+ $spentNative = bcadd($spentNative, (string) $amountNative);
}
app('log')->debug(sprintf('Total spent in budget "%s" is %s', $budget['name'], $spent));
}
diff --git a/app/Console/Commands/Correction/CorrectsLongDescriptions.php b/app/Console/Commands/Correction/CorrectsLongDescriptions.php
index 36dae29fc3..a5b98a3cf4 100644
--- a/app/Console/Commands/Correction/CorrectsLongDescriptions.php
+++ b/app/Console/Commands/Correction/CorrectsLongDescriptions.php
@@ -48,8 +48,8 @@ class CorrectsLongDescriptions extends Command
/** @var TransactionJournal $journal */
foreach ($journals as $journal) {
- if (strlen($journal->description) > self::MAX_LENGTH) {
- $journal->description = substr($journal->description, 0, self::MAX_LENGTH);
+ if (strlen((string) $journal->description) > self::MAX_LENGTH) {
+ $journal->description = substr((string) $journal->description, 0, self::MAX_LENGTH);
$journal->save();
$this->friendlyWarning(sprintf('Truncated description of transaction journal #%d', $journal->id));
++$count;
@@ -61,7 +61,7 @@ class CorrectsLongDescriptions extends Command
/** @var TransactionGroup $group */
foreach ($groups as $group) {
if (strlen((string) $group->title) > self::MAX_LENGTH) {
- $group->title = substr($group->title, 0, self::MAX_LENGTH);
+ $group->title = substr((string) $group->title, 0, self::MAX_LENGTH);
$group->save();
$this->friendlyWarning(sprintf('Truncated description of transaction group #%d', $group->id));
++$count;
diff --git a/app/Console/Commands/Correction/CorrectsRecurringTransactions.php b/app/Console/Commands/Correction/CorrectsRecurringTransactions.php
index e7d302dff2..e47dad7236 100644
--- a/app/Console/Commands/Correction/CorrectsRecurringTransactions.php
+++ b/app/Console/Commands/Correction/CorrectsRecurringTransactions.php
@@ -100,7 +100,7 @@ class CorrectsRecurringTransactions extends Command
$destination = $transaction->destinationAccount;
$type = $recurrence->transactionType;
$link = config(sprintf('firefly.account_to_transaction.%s.%s', $source->accountType->type, $destination->accountType->type));
- if (null !== $link && strtolower($type->type) !== strtolower($link)) {
+ if (null !== $link && strtolower((string) $type->type) !== strtolower($link)) {
$this->friendlyWarning(
sprintf('Recurring transaction #%d should be a "%s" but is a "%s" and will be corrected.', $recurrence->id, $link, $type->type)
);
diff --git a/app/Console/Commands/Correction/CorrectsUnevenAmount.php b/app/Console/Commands/Correction/CorrectsUnevenAmount.php
index d2b2e9e364..895eb45b4d 100644
--- a/app/Console/Commands/Correction/CorrectsUnevenAmount.php
+++ b/app/Console/Commands/Correction/CorrectsUnevenAmount.php
@@ -184,7 +184,7 @@ class CorrectsUnevenAmount extends Command
return;
}
- $amount = bcmul('-1', $source->amount);
+ $amount = bcmul('-1', (string) $source->amount);
// fix amount of destination:
/** @var null|Transaction $destination */
@@ -249,9 +249,9 @@ class CorrectsUnevenAmount extends Command
// Log::debug(sprintf('[c] %s', var_export($source->transaction_currency_id === $destination->foreign_currency_id,true)));
// Log::debug(sprintf('[d] %s', var_export((int) $destination->transaction_currency_id ===(int) $source->foreign_currency_id, true)));
- if (0 === bccomp(app('steam')->positive($source->amount), app('steam')->positive($destination->foreign_amount))
+ if (0 === bccomp((string) app('steam')->positive($source->amount), (string) app('steam')->positive($destination->foreign_amount))
&& $source->transaction_currency_id === $destination->foreign_currency_id
- && 0 === bccomp(app('steam')->positive($destination->amount), app('steam')->positive($source->foreign_amount))
+ && 0 === bccomp((string) app('steam')->positive($destination->amount), (string) app('steam')->positive($source->foreign_amount))
&& (int) $destination->transaction_currency_id === (int) $source->foreign_currency_id
) {
return true;
diff --git a/app/Console/Commands/Upgrade/UpgradesRuleActions.php b/app/Console/Commands/Upgrade/UpgradesRuleActions.php
index 18d1141fe5..c3619be8f9 100644
--- a/app/Console/Commands/Upgrade/UpgradesRuleActions.php
+++ b/app/Console/Commands/Upgrade/UpgradesRuleActions.php
@@ -78,8 +78,8 @@ class UpgradesRuleActions extends Command
/** @var RuleAction $action */
foreach ($actions as $action) {
- if (str_starts_with($action->action_value, '=')) {
- $action->action_value = sprintf('%s%s', '\=', substr($action->action_value, 1));
+ if (str_starts_with((string) $action->action_value, '=')) {
+ $action->action_value = sprintf('%s%s', '\=', substr((string) $action->action_value, 1));
$action->save();
++$count;
}
diff --git a/app/Console/Commands/Upgrade/UpgradesToGroups.php b/app/Console/Commands/Upgrade/UpgradesToGroups.php
index 07b92e00a4..cb6b95a637 100644
--- a/app/Console/Commands/Upgrade/UpgradesToGroups.php
+++ b/app/Console/Commands/Upgrade/UpgradesToGroups.php
@@ -234,7 +234,7 @@ class UpgradesToGroups extends Command
$categoryId = $this->getTransactionCategory($transaction, $opposingTr) ?? $categoryId;
return [
- 'type' => strtolower($journal->transactionType->type),
+ 'type' => strtolower((string) $journal->transactionType->type),
'date' => $journal->date,
'user' => $journal->user,
'user_group' => $journal->user->userGroup,
diff --git a/app/Exceptions/GracefulNotFoundHandler.php b/app/Exceptions/GracefulNotFoundHandler.php
index 46bef0b640..7faa9e03e2 100644
--- a/app/Exceptions/GracefulNotFoundHandler.php
+++ b/app/Exceptions/GracefulNotFoundHandler.php
@@ -218,7 +218,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
return redirect(route('accounts.index', ['asset']));
}
- return redirect(route('transactions.index', [strtolower($type)]));
+ return redirect(route('transactions.index', [strtolower((string) $type)]));
}
/**
diff --git a/app/Factory/AttachmentFactory.php b/app/Factory/AttachmentFactory.php
index bd64ea57a8..421af6dca2 100644
--- a/app/Factory/AttachmentFactory.php
+++ b/app/Factory/AttachmentFactory.php
@@ -44,7 +44,7 @@ class AttachmentFactory
public function create(array $data): ?Attachment
{
// append if necessary.
- $model = !str_contains($data['attachable_type'], 'FireflyIII') ? sprintf('FireflyIII\Models\%s', $data['attachable_type'])
+ $model = !str_contains((string) $data['attachable_type'], 'FireflyIII') ? sprintf('FireflyIII\Models\%s', $data['attachable_type'])
: $data['attachable_type'];
// get journal instead of transaction.
diff --git a/app/Factory/RecurrenceFactory.php b/app/Factory/RecurrenceFactory.php
index 8df3357b9b..8254a8a4ec 100644
--- a/app/Factory/RecurrenceFactory.php
+++ b/app/Factory/RecurrenceFactory.php
@@ -59,7 +59,7 @@ class RecurrenceFactory
public function create(array $data): Recurrence
{
try {
- $type = $this->findTransactionType(ucfirst($data['recurrence']['type']));
+ $type = $this->findTransactionType(ucfirst((string) $data['recurrence']['type']));
} catch (FireflyException $e) {
$message = sprintf('Cannot make a recurring transaction of type "%s"', $data['recurrence']['type']);
app('log')->error($message);
diff --git a/app/Factory/TagFactory.php b/app/Factory/TagFactory.php
index 302624004c..2a8b29a037 100644
--- a/app/Factory/TagFactory.php
+++ b/app/Factory/TagFactory.php
@@ -77,7 +77,7 @@ class TagFactory
$array = [
'user_id' => $this->user->id,
'user_group_id' => $this->userGroup->id,
- 'tag' => trim($data['tag']),
+ 'tag' => trim((string) $data['tag']),
'tagMode' => 'nothing',
'date' => $data['date'],
'description' => $data['description'],
diff --git a/app/Factory/TransactionGroupFactory.php b/app/Factory/TransactionGroupFactory.php
index f28153f4e6..3d347e4b20 100644
--- a/app/Factory/TransactionGroupFactory.php
+++ b/app/Factory/TransactionGroupFactory.php
@@ -71,7 +71,7 @@ class TransactionGroupFactory
$title = '' === $title ? null : $title;
if (null !== $title) {
- $title = substr($title, 0, 1000);
+ $title = substr((string) $title, 0, 1000);
}
if (0 === $collection->count()) {
throw new FireflyException('Created zero transaction journals.');
diff --git a/app/Generator/Report/Audit/MonthReportGenerator.php b/app/Generator/Report/Audit/MonthReportGenerator.php
index b5af328497..5d6767a6db 100644
--- a/app/Generator/Report/Audit/MonthReportGenerator.php
+++ b/app/Generator/Report/Audit/MonthReportGenerator.php
@@ -159,7 +159,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
}
}
- $newBalance = bcadd($startBalance, $transactionAmount);
+ $newBalance = bcadd((string) $startBalance, (string) $transactionAmount);
$journals[$index]['balance_after'] = $newBalance;
$startBalance = $newBalance;
diff --git a/app/Handlers/Events/Model/BudgetLimitHandler.php b/app/Handlers/Events/Model/BudgetLimitHandler.php
index 1942c5459b..b36bbad397 100644
--- a/app/Handlers/Events/Model/BudgetLimitHandler.php
+++ b/app/Handlers/Events/Model/BudgetLimitHandler.php
@@ -194,12 +194,12 @@ class BudgetLimitHandler
// if both equal each other, amount from this BL must be added to the AB
if ($limitPeriod->equals($abPeriod)) {
Log::debug('This budget limit is equal to the available budget period.');
- $newAmount = bcadd($newAmount, $budgetLimit->amount);
+ $newAmount = bcadd($newAmount, (string) $budgetLimit->amount);
}
// if budget limit period is inside AB period, it can be added in full.
if (!$limitPeriod->equals($abPeriod) && $abPeriod->contains($limitPeriod)) {
Log::debug('This budget limit is smaller than the available budget period.');
- $newAmount = bcadd($newAmount, $budgetLimit->amount);
+ $newAmount = bcadd($newAmount, (string) $budgetLimit->amount);
}
if (!$limitPeriod->equals($abPeriod) && !$abPeriod->contains($limitPeriod) && $abPeriod->overlapsWith($limitPeriod)) {
Log::debug('This budget limit is something else entirely!');
diff --git a/app/Helpers/Collector/Extensions/AccountCollection.php b/app/Helpers/Collector/Extensions/AccountCollection.php
index 2a755dba2e..38d6a96622 100644
--- a/app/Helpers/Collector/Extensions/AccountCollection.php
+++ b/app/Helpers/Collector/Extensions/AccountCollection.php
@@ -264,7 +264,7 @@ trait AccountCollection
$date->subSecond();
Log::debug(sprintf('accountBalanceIs: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
$balance = Steam::finalAccountBalance($account, $date);
- $result = bccomp($balance['balance'], $value);
+ $result = bccomp((string) $balance['balance'], $value);
Log::debug(sprintf('"%s" vs "%s" is %d', $balance['balance'], $value, $result));
switch ($operator) {
diff --git a/app/Helpers/Collector/Extensions/AttachmentCollection.php b/app/Helpers/Collector/Extensions/AttachmentCollection.php
index 2217b40c83..7738fd305f 100644
--- a/app/Helpers/Collector/Extensions/AttachmentCollection.php
+++ b/app/Helpers/Collector/Extensions/AttachmentCollection.php
@@ -51,8 +51,8 @@ trait AttachmentCollection
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) {
- $result = str_contains(strtolower($attachment['filename']), strtolower($name)) || str_contains(
- strtolower($attachment['title']),
+ $result = str_contains(strtolower((string) $attachment['filename']), strtolower($name)) || str_contains(
+ strtolower((string) $attachment['title']),
strtolower($name)
);
if (true === $result) {
@@ -131,8 +131,8 @@ trait AttachmentCollection
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) {
- $result = !str_contains(strtolower($attachment['filename']), strtolower($name)) && !str_contains(
- strtolower($attachment['title']),
+ $result = !str_contains(strtolower((string) $attachment['filename']), strtolower($name)) && !str_contains(
+ strtolower((string) $attachment['title']),
strtolower($name)
);
if (true === $result) {
@@ -166,8 +166,8 @@ trait AttachmentCollection
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) {
- $result = !str_ends_with(strtolower($attachment['filename']), strtolower($name)) && !str_ends_with(
- strtolower($attachment['title']),
+ $result = !str_ends_with(strtolower((string) $attachment['filename']), strtolower($name)) && !str_ends_with(
+ strtolower((string) $attachment['title']),
strtolower($name)
);
if (true === $result) {
@@ -201,8 +201,8 @@ trait AttachmentCollection
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) {
- $result = !str_starts_with(strtolower($attachment['filename']), strtolower($name)) && !str_starts_with(
- strtolower($attachment['title']),
+ $result = !str_starts_with(strtolower((string) $attachment['filename']), strtolower($name)) && !str_starts_with(
+ strtolower((string) $attachment['title']),
strtolower($name)
);
if (true === $result) {
@@ -227,8 +227,8 @@ trait AttachmentCollection
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) {
- $result = str_ends_with(strtolower($attachment['filename']), strtolower($name)) || str_ends_with(
- strtolower($attachment['title']),
+ $result = str_ends_with(strtolower((string) $attachment['filename']), strtolower($name)) || str_ends_with(
+ strtolower((string) $attachment['title']),
strtolower($name)
);
if (true === $result) {
@@ -299,8 +299,8 @@ trait AttachmentCollection
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) {
- $result = str_starts_with(strtolower($attachment['filename']), strtolower($name)) || str_starts_with(
- strtolower($attachment['title']),
+ $result = str_starts_with(strtolower((string) $attachment['filename']), strtolower($name)) || str_starts_with(
+ strtolower((string) $attachment['title']),
strtolower($name)
);
if (true === $result) {
diff --git a/app/Helpers/Collector/Extensions/MetaCollection.php b/app/Helpers/Collector/Extensions/MetaCollection.php
index f1cad62f17..ab6c37bccb 100644
--- a/app/Helpers/Collector/Extensions/MetaCollection.php
+++ b/app/Helpers/Collector/Extensions/MetaCollection.php
@@ -492,7 +492,7 @@ trait MetaCollection
'notes',
static function (JoinClause $join): void {
$join->on('notes.noteable_id', '=', 'transaction_journals.id');
- $join->where('notes.noteable_type', '=', 'FireflyIII\Models\TransactionJournal');
+ $join->where('notes.noteable_type', '=', \FireflyIII\Models\TransactionJournal::class);
$join->whereNull('notes.deleted_at');
}
);
@@ -601,8 +601,8 @@ trait MetaCollection
return false;
}
foreach ($transaction['tags'] as $tag) {
- Log::debug(sprintf('"%s" versus', strtolower($tag['name'])), $list);
- if (in_array(strtolower($tag['name']), $list, true)) {
+ Log::debug(sprintf('"%s" versus', strtolower((string) $tag['name'])), $list);
+ if (in_array(strtolower((string) $tag['name']), $list, true)) {
app('log')->debug(sprintf('Transaction has tag "%s" so count++.', $tag['name']));
++$foundTagCount;
$journalId = $transaction['transaction_journal_id'];
@@ -779,8 +779,8 @@ trait MetaCollection
Log::debug(sprintf('Now in setTags(%s) filter', implode(', ', $list)));
foreach ($object['transactions'] as $transaction) {
foreach ($transaction['tags'] as $tag) {
- Log::debug(sprintf('"%s" versus', strtolower($tag['name'])), $list);
- if (in_array(strtolower($tag['name']), $list, true)) {
+ Log::debug(sprintf('"%s" versus', strtolower((string) $tag['name'])), $list);
+ if (in_array(strtolower((string) $tag['name']), $list, true)) {
app('log')->debug(sprintf('Transaction has tag "%s" so return true.', $tag['name']));
return true;
@@ -811,8 +811,8 @@ trait MetaCollection
foreach ($object['transactions'] as $transaction) {
app('log')->debug(sprintf('Transaction has %d tag(s)', count($transaction['tags'])));
foreach ($transaction['tags'] as $tag) {
- Log::debug(sprintf('"%s" versus', strtolower($tag['name'])), $list);
- if (in_array(strtolower($tag['name']), $list, true)) {
+ Log::debug(sprintf('"%s" versus', strtolower((string) $tag['name'])), $list);
+ if (in_array(strtolower((string) $tag['name']), $list, true)) {
app('log')->debug(sprintf('Transaction has tag "%s", but should not have it, return false.', $tag['name']));
return false;
diff --git a/app/Helpers/Collector/GroupCollector.php b/app/Helpers/Collector/GroupCollector.php
index 828da5f3a3..d47ac0d155 100644
--- a/app/Helpers/Collector/GroupCollector.php
+++ b/app/Helpers/Collector/GroupCollector.php
@@ -593,7 +593,7 @@ class GroupCollector implements GroupCollectorInterface
if (array_key_exists('meta_name', $result) && in_array($result['meta_name'], $dates, true)) {
$name = $result['meta_name'];
if (array_key_exists('meta_data', $result) && '' !== (string) $result['meta_data']) {
- $result[$name] = Carbon::createFromFormat('!Y-m-d', substr(\Safe\json_decode($result['meta_data']), 0, 10));
+ $result[$name] = Carbon::createFromFormat('!Y-m-d', substr((string) \Safe\json_decode($result['meta_data']), 0, 10));
}
}
@@ -743,8 +743,8 @@ class GroupCollector implements GroupCollectorInterface
$groups[$groudId]['sums'][$currencyId]['amount'] = '0';
$groups[$groudId]['sums'][$currencyId]['native_amount'] = '0';
}
- $groups[$groudId]['sums'][$currencyId]['amount'] = bcadd($groups[$groudId]['sums'][$currencyId]['amount'], $transaction['amount']);
- $groups[$groudId]['sums'][$currencyId]['native_amount'] = bcadd($groups[$groudId]['sums'][$currencyId]['native_amount'], $nativeAmount);
+ $groups[$groudId]['sums'][$currencyId]['amount'] = bcadd((string) $groups[$groudId]['sums'][$currencyId]['amount'], $transaction['amount']);
+ $groups[$groudId]['sums'][$currencyId]['native_amount'] = bcadd((string) $groups[$groudId]['sums'][$currencyId]['native_amount'], $nativeAmount);
if (null !== $transaction['foreign_amount'] && null !== $transaction['foreign_currency_id']) {
$currencyId = (int) $transaction['foreign_currency_id'];
@@ -758,7 +758,7 @@ class GroupCollector implements GroupCollectorInterface
$groups[$groudId]['sums'][$currencyId]['amount'] = '0';
$groups[$groudId]['sums'][$currencyId]['native_amount'] = '0';
}
- $groups[$groudId]['sums'][$currencyId]['amount'] = bcadd($groups[$groudId]['sums'][$currencyId]['amount'], $foreignAmount);
+ $groups[$groudId]['sums'][$currencyId]['amount'] = bcadd((string) $groups[$groudId]['sums'][$currencyId]['amount'], $foreignAmount);
$groups[$groudId]['sums'][$currencyId]['native_amount'] = bcadd($groups[$groudId]['sums'][$currencyId]['amount'], $nativeForeignAmount);
}
}
diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php
index 48d41acc0f..4f300d8924 100644
--- a/app/Http/Controllers/HomeController.php
+++ b/app/Http/Controllers/HomeController.php
@@ -67,7 +67,7 @@ class HomeController extends Controller
try {
$stringStart = e((string) $request->get('start'));
$start = Carbon::createFromFormat('Y-m-d', $stringStart);
- } catch (InvalidFormatException $e) {
+ } catch (InvalidFormatException) {
app('log')->error(sprintf('Start: could not parse date string "%s" so ignore it.', $stringStart));
$start = Carbon::now()->startOfMonth();
}
diff --git a/app/Support/Search/OperatorQuerySearch.php b/app/Support/Search/OperatorQuerySearch.php
index 96cfbcd422..79794d85e3 100644
--- a/app/Support/Search/OperatorQuerySearch.php
+++ b/app/Support/Search/OperatorQuerySearch.php
@@ -57,24 +57,24 @@ use Illuminate\Support\Collection;
class OperatorQuerySearch implements SearchInterface
{
protected Carbon $date;
- private AccountRepositoryInterface $accountRepository;
- private BillRepositoryInterface $billRepository;
- private BudgetRepositoryInterface $budgetRepository;
- private CategoryRepositoryInterface $categoryRepository;
+ private readonly AccountRepositoryInterface $accountRepository;
+ private readonly BillRepositoryInterface $billRepository;
+ private readonly BudgetRepositoryInterface $budgetRepository;
+ private readonly CategoryRepositoryInterface $categoryRepository;
private GroupCollectorInterface $collector;
- private CurrencyRepositoryInterface $currencyRepository;
+ private readonly CurrencyRepositoryInterface $currencyRepository;
private array $excludeTags;
private array $includeAnyTags;
// added to fix #8632
private array $includeTags;
private array $invalidOperators;
private int $limit;
- private Collection $operators;
+ private readonly Collection $operators;
private int $page;
private array $prohibitedWords;
- private float $startTime;
- private TagRepositoryInterface $tagRepository;
- private array $validOperators;
+ private readonly float $startTime;
+ private readonly TagRepositoryInterface $tagRepository;
+ private readonly array $validOperators;
private array $words;
/**
@@ -149,7 +149,7 @@ class OperatorQuerySearch implements SearchInterface
/** @var QueryParserInterface $parser */
$parser = app(QueryParserInterface::class);
- app('log')->debug(sprintf('Using %s as implementation for QueryParserInterface', get_class($parser)));
+ app('log')->debug(sprintf('Using %s as implementation for QueryParserInterface', $parser::class));
try {
$parsedQuery = $parser->parse($query);
@@ -177,7 +177,7 @@ class OperatorQuerySearch implements SearchInterface
*/
private function handleSearchNode(Node $node, bool $flipProhibitedFlag): void
{
- app('log')->debug(sprintf('Now in handleSearchNode(%s)', get_class($node)));
+ app('log')->debug(sprintf('Now in handleSearchNode(%s)', $node::class));
switch (true) {
case $node instanceof StringNode:
@@ -196,9 +196,9 @@ class OperatorQuerySearch implements SearchInterface
break;
default:
- app('log')->error(sprintf('Cannot handle node %s', get_class($node)));
+ app('log')->error(sprintf('Cannot handle node %s', $node::class));
- throw new FireflyException(sprintf('Firefly III search can\'t handle "%s"-nodes', get_class($node)));
+ throw new FireflyException(sprintf('Firefly III search can\'t handle "%s"-nodes', $node::class));
}
}
@@ -2009,9 +2009,7 @@ class OperatorQuerySearch implements SearchInterface
}
app('log')->debug(sprintf('Found %d accounts, will filter.', $accounts->count()));
$filtered = $accounts->filter(
- static function (Account $account) use ($value, $stringMethod) {
- return $stringMethod(strtolower($account->name), strtolower($value));
- }
+ static fn(Account $account) => $stringMethod(strtolower($account->name), strtolower($value))
);
if (0 === $filtered->count()) {
@@ -2095,7 +2093,7 @@ class OperatorQuerySearch implements SearchInterface
/** @var AccountMeta $meta */
foreach ($account->accountMeta as $meta) {
- if ('account_number' === $meta->name && $stringMethod(strtolower($meta->data), strtolower($value))) {
+ if ('account_number' === $meta->name && $stringMethod(strtolower((string) $meta->data), strtolower($value))) {
$accountNrMatch = true;
}
}
@@ -2146,7 +2144,7 @@ class OperatorQuerySearch implements SearchInterface
try {
$parsedDate = $parser->parseDate($value);
- } catch (FireflyException $e) {
+ } catch (FireflyException) {
app('log')->debug(sprintf('Could not parse date "%s", will return empty array.', $value));
$this->invalidOperators[] = [
'type' => $type,
diff --git a/app/TransactionRules/Engine/SearchRuleEngine.php b/app/TransactionRules/Engine/SearchRuleEngine.php
index fc5b1749d6..ce1398b3fc 100644
--- a/app/TransactionRules/Engine/SearchRuleEngine.php
+++ b/app/TransactionRules/Engine/SearchRuleEngine.php
@@ -109,8 +109,8 @@ class SearchRuleEngine implements RuleEngineInterface
continue;
}
$contextSearch = $ruleTrigger->trigger_type;
- if (str_starts_with($ruleTrigger->trigger_type, '-')) {
- $contextSearch = substr($ruleTrigger->trigger_type, 1);
+ if (str_starts_with((string) $ruleTrigger->trigger_type, '-')) {
+ $contextSearch = substr((string) $ruleTrigger->trigger_type, 1);
}
// if the trigger needs no context, value is different:
diff --git a/app/Transformers/AccountTransformer.php b/app/Transformers/AccountTransformer.php
index e48f0205b4..935bc3104d 100644
--- a/app/Transformers/AccountTransformer.php
+++ b/app/Transformers/AccountTransformer.php
@@ -201,7 +201,7 @@ class AccountTransformer extends AbstractTransformer
}
$monthlyPaymentDate = $object->toAtomString();
}
- if (10 !== strlen($monthlyPaymentDate)) {
+ if (10 !== strlen((string) $monthlyPaymentDate)) {
$monthlyPaymentDate = Carbon::parse($monthlyPaymentDate, config('app.timezone'))->toAtomString();
}
}
diff --git a/app/Transformers/TransactionGroupTransformer.php b/app/Transformers/TransactionGroupTransformer.php
index e8239ac828..af5bf4815f 100644
--- a/app/Transformers/TransactionGroupTransformer.php
+++ b/app/Transformers/TransactionGroupTransformer.php
@@ -118,7 +118,7 @@ class TransactionGroupTransformer extends AbstractTransformer
// amount:
$amount = app('steam')->positive((string) ($transaction['amount'] ?? '0'));
$foreignAmount = null;
- if (null !== $transaction['foreign_amount'] && '' !== $transaction['foreign_amount'] && 0 !== bccomp('0', $transaction['foreign_amount'])) {
+ if (null !== $transaction['foreign_amount'] && '' !== $transaction['foreign_amount'] && 0 !== bccomp('0', (string) $transaction['foreign_amount'])) {
$foreignAmount = app('steam')->positive($transaction['foreign_amount']);
}
$type = $this->stringFromArray($transaction, 'transaction_type_type', TransactionTypeEnum::WITHDRAWAL->value);
@@ -132,7 +132,7 @@ class TransactionGroupTransformer extends AbstractTransformer
return [
'user' => (string) $transaction['user_id'],
'transaction_journal_id' => (string) $transaction['transaction_journal_id'],
- 'type' => strtolower($type),
+ 'type' => strtolower((string) $type),
'date' => $transaction['date']->toAtomString(),
'order' => $transaction['order'],
@@ -296,7 +296,7 @@ class TransactionGroupTransformer extends AbstractTransformer
$type = $journal->transactionType->type;
$currency = $source->transactionCurrency;
$amount = app('steam')->bcround($this->getAmount($source->amount), $currency->decimal_places ?? 0);
- $foreignAmount = $this->getForeignAmount(null === $source->foreign_amount ? null : $source->foreign_amount);
+ $foreignAmount = $this->getForeignAmount($source->foreign_amount ?? null);
$metaFieldData = $this->groupRepos->getMetaFields($journal->id, $this->metaFields);
$metaDates = $this->getDates($this->groupRepos->getMetaDateFields($journal->id, $this->metaDateFields));
$foreignCurrency = $this->getForeignCurrency($source->foreignCurrency);
@@ -321,7 +321,7 @@ class TransactionGroupTransformer extends AbstractTransformer
return [
'user' => $journal->user_id,
'transaction_journal_id' => (string) $journal->id,
- 'type' => strtolower($type),
+ 'type' => strtolower((string) $type),
'date' => $journal->date->toAtomString(),
'order' => $journal->order,
diff --git a/app/Transformers/V2/AccountTransformer.php b/app/Transformers/V2/AccountTransformer.php
index 175a6121c1..c416a83ecc 100644
--- a/app/Transformers/V2/AccountTransformer.php
+++ b/app/Transformers/V2/AccountTransformer.php
@@ -198,8 +198,8 @@ class AccountTransformer extends AbstractTransformer
$id = $account->id;
if (array_key_exists($id, $bStart) && array_key_exists($id, $bEnd)) {
$this->balanceDifferences[$id] = [
- 'balance' => bcsub($bEnd[$id]['balance'], $bStart[$id]['balance']),
- 'native_balance' => bcsub($bEnd[$id]['native_balance'], $bStart[$id]['native_balance']),
+ 'balance' => bcsub((string) $bEnd[$id]['balance'], (string) $bStart[$id]['balance']),
+ 'native_balance' => bcsub((string) $bEnd[$id]['native_balance'], (string) $bStart[$id]['native_balance']),
];
}
}
@@ -351,7 +351,7 @@ class AccountTransformer extends AbstractTransformer
$nativeBalance = $this->convertedBalances[$id]['native_balance'] ?? null;
// no order for some accounts:
- if (!in_array(strtolower($accountType), ['liability', 'liabilities', 'asset'], true)) {
+ if (!in_array(strtolower((string) $accountType), ['liability', 'liabilities', 'asset'], true)) {
$order = null;
}
@@ -381,7 +381,7 @@ class AccountTransformer extends AbstractTransformer
'name' => $account->name,
'iban' => '' === (string) $account->iban ? null : $account->iban,
'account_number' => $this->accountMeta[$id]['account_number'] ?? null,
- 'type' => strtolower($accountType),
+ 'type' => strtolower((string) $accountType),
'account_role' => $accountRole,
'currency_id' => (string) $currency->id,
'currency_code' => $currency->code,
diff --git a/app/Transformers/V2/PiggyBankTransformer.php b/app/Transformers/V2/PiggyBankTransformer.php
index 7d0b5a3287..7f9befb640 100644
--- a/app/Transformers/V2/PiggyBankTransformer.php
+++ b/app/Transformers/V2/PiggyBankTransformer.php
@@ -196,9 +196,9 @@ class PiggyBankTransformer extends AbstractTransformer
$group = $this->groups[$piggyBank->id] ?? null;
if (0 !== bccomp($targetAmount, '0')) { // target amount is not 0.00
- $leftToSave = bcsub($targetAmount, $currentAmount);
+ $leftToSave = bcsub($targetAmount, (string) $currentAmount);
$nativeLeftToSave = $this->converter->convert($this->default, $currency, today(), $leftToSave);
- $percentage = (int) bcmul(bcdiv($currentAmount, $targetAmount), '100');
+ $percentage = (int) bcmul(bcdiv((string) $currentAmount, $targetAmount), '100');
$savePerMonth = $this->getSuggestedMonthlyAmount($currentAmount, $targetAmount, $piggyBank->start_date, $piggyBank->target_date);
$nativeSavePerMonth = $this->converter->convert($this->default, $currency, today(), $savePerMonth);
}
diff --git a/app/Transformers/V2/TransactionGroupTransformer.php b/app/Transformers/V2/TransactionGroupTransformer.php
index 2c3625e57c..1a30321466 100644
--- a/app/Transformers/V2/TransactionGroupTransformer.php
+++ b/app/Transformers/V2/TransactionGroupTransformer.php
@@ -219,7 +219,7 @@ class TransactionGroupTransformer extends AbstractTransformer
/** @var Transaction $transaction */
foreach ($journal->transactions as $transaction) {
- if (-1 === bccomp($transaction->amount, '0')) {
+ if (-1 === bccomp((string) $transaction->amount, '0')) {
// only collect source account info
$account = $transaction->account;
$this->accountTypes[$account->account_type_id] ??= $account->accountType->type;
@@ -349,7 +349,7 @@ class TransactionGroupTransformer extends AbstractTransformer
'user' => (string) $transaction['user_id'],
'user_group' => (string) $transaction['user_group_id'],
'transaction_journal_id' => (string) $transaction['transaction_journal_id'],
- 'type' => strtolower($type),
+ 'type' => strtolower((string) $type),
'date' => $transaction['date']->toAtomString(),
'order' => $transaction['order'],
'amount' => $amount,
diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php
index 7faa885731..6f9ae81c09 100644
--- a/app/Validation/FireflyValidator.php
+++ b/app/Validation/FireflyValidator.php
@@ -418,7 +418,7 @@ class FireflyValidator extends Validator
// check transaction type.
// TODO create a helper to automatically return these.
if ('transaction_type' === $triggerType) {
- $count = TransactionType::where('type', ucfirst($value))->count();
+ $count = TransactionType::where('type', ucfirst((string) $value))->count();
return 1 === $count;
}
diff --git a/app/Validation/TransactionValidation.php b/app/Validation/TransactionValidation.php
index 26cf199834..5b5a01a525 100644
--- a/app/Validation/TransactionValidation.php
+++ b/app/Validation/TransactionValidation.php
@@ -593,7 +593,7 @@ trait TransactionValidation
/** @var null|TransactionJournal $journal */
$journal = TransactionJournal::with(['transactionType'])->find($journalId);
if (null !== $journal) {
- return strtolower($journal->transactionType->type);
+ return strtolower((string) $journal->transactionType->type);
}
return 'invalid';
diff --git a/config/broadcasting.php b/config/broadcasting.php
index a7949f03ad..b735673ab4 100644
--- a/config/broadcasting.php
+++ b/config/broadcasting.php
@@ -57,7 +57,7 @@ return [
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
- 'host' => null !== env('PUSHER_HOST') ? env('PUSHER_HOST') : 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com',
+ 'host' => env('PUSHER_HOST') ?? 'api-' . env('PUSHER_APP_CLUSTER', 'mt1') . '.pusher.com',
'port' => env('PUSHER_PORT', 443),
'scheme' => env('PUSHER_SCHEME', 'https'),
'encrypted' => true,
diff --git a/config/mail.php b/config/mail.php
index 08356c7a3a..7558f4f936 100644
--- a/config/mail.php
+++ b/config/mail.php
@@ -46,7 +46,7 @@ return [
'timeout' => null,
'scheme' => env('MAIL_SCHEME'),
'url' => env('MAIL_URL'),
- 'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url(env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
+ 'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url((string) env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
'verify_peer' => env('MAIL_VERIFY_PEER', true),
'allow_self_signed' => env('MAIL_ALLOW_SELF_SIGNED', false),
'verify_peer_name' => env('MAIL_VERIFY_PEER_NAME', true),
diff --git a/routes/breadcrumbs.php b/routes/breadcrumbs.php
index 46682f8ba3..2ea63de4d2 100644
--- a/routes/breadcrumbs.php
+++ b/routes/breadcrumbs.php
@@ -1202,7 +1202,7 @@ Breadcrumbs::for(
static function (Generator $breadcrumbs, TransactionGroup $group): void {
/** @var TransactionJournal $first */
$first = $group->transactionJournals()->first();
- $type = strtolower($first->transactionType->type);
+ $type = strtolower((string) $first->transactionType->type);
$title = limitStringLength($first->description);
if ($group->transactionJournals()->count() > 1) {
$title = limitStringLength((string)$group->title);
@@ -1241,7 +1241,7 @@ Breadcrumbs::for(
'transactions.mass.edit',
static function (Generator $breadcrumbs, array $journals): void {
if (0 !== count($journals)) {
- $objectType = strtolower(reset($journals)['transaction_type_type']);
+ $objectType = strtolower((string) reset($journals)['transaction_type_type']);
$breadcrumbs->parent('transactions.index', $objectType);
$breadcrumbs->push(trans('firefly.mass_edit_journals'), route('transactions.mass.edit', ['']));
@@ -1254,7 +1254,7 @@ Breadcrumbs::for(
Breadcrumbs::for(
'transactions.mass.delete',
static function (Generator $breadcrumbs, array $journals): void {
- $objectType = strtolower(reset($journals)['transaction_type_type']);
+ $objectType = strtolower((string) reset($journals)['transaction_type_type']);
$breadcrumbs->parent('transactions.index', $objectType);
$breadcrumbs->push(trans('firefly.mass_edit_journals'), route('transactions.mass.delete', ['']));
}
@@ -1267,7 +1267,7 @@ Breadcrumbs::for(
if (0 !== count($journals)) {
$ids = Arr::pluck($journals, 'transaction_journal_id');
$first = reset($journals);
- $breadcrumbs->parent('transactions.index', strtolower($first['transaction_type_type']));
+ $breadcrumbs->parent('transactions.index', strtolower((string) $first['transaction_type_type']));
$breadcrumbs->push(trans('firefly.mass_bulk_journals'), route('transactions.bulk.edit', $ids));
return;
diff --git a/tests/integration/Api/About/AboutControllerTest.php b/tests/integration/Api/About/AboutControllerTest.php
index 55bd769e52..77f0402c87 100644
--- a/tests/integration/Api/About/AboutControllerTest.php
+++ b/tests/integration/Api/About/AboutControllerTest.php
@@ -40,6 +40,7 @@ final class AboutControllerTest extends TestCase
use RefreshDatabase;
private $user;
+ #[\Override]
protected function setUp(): void
{
parent::setUp();
diff --git a/tests/integration/Api/Autocomplete/BillControllerTest.php b/tests/integration/Api/Autocomplete/BillControllerTest.php
index 134f3517e4..41ca56d6ef 100644
--- a/tests/integration/Api/Autocomplete/BillControllerTest.php
+++ b/tests/integration/Api/Autocomplete/BillControllerTest.php
@@ -44,6 +44,7 @@ final class BillControllerTest extends TestCase
*/
use RefreshDatabase;
+ #[\Override]
protected function createAuthenticatedUser(): User
{
$userGroup = UserGroup::create(['title' => 'Test Group']);
@@ -65,8 +66,8 @@ final class BillControllerTest extends TestCase
'user_id' => $user->id,
'name' => 'Bill '.$i,
'user_group_id' => $user->user_group_id,
- 'amount_min' => rand(1, 100), // random amount
- 'amount_max' => rand(101, 200), // random amount
+ 'amount_min' => random_int(1, 100), // random amount
+ 'amount_max' => random_int(101, 200), // random amount
'match' => 'MIGRATED_TO_RULES',
'date' => '2024-01-01',
'repeat_freq' => 'monthly',
diff --git a/tests/integration/Api/Autocomplete/BudgetControllerTest.php b/tests/integration/Api/Autocomplete/BudgetControllerTest.php
index 542cc4fc70..fe247ddd5b 100644
--- a/tests/integration/Api/Autocomplete/BudgetControllerTest.php
+++ b/tests/integration/Api/Autocomplete/BudgetControllerTest.php
@@ -44,6 +44,7 @@ final class BudgetControllerTest extends TestCase
*/
use RefreshDatabase;
+ #[\Override]
protected function createAuthenticatedUser(): User
{
$userGroup = UserGroup::create(['title' => 'Test Group']);
diff --git a/tests/integration/Api/Autocomplete/CategoryControllerTest.php b/tests/integration/Api/Autocomplete/CategoryControllerTest.php
index 7cdc632c9d..66eccc7bf7 100644
--- a/tests/integration/Api/Autocomplete/CategoryControllerTest.php
+++ b/tests/integration/Api/Autocomplete/CategoryControllerTest.php
@@ -44,6 +44,7 @@ final class CategoryControllerTest extends TestCase
*/
use RefreshDatabase;
+ #[\Override]
protected function createAuthenticatedUser(): User
{
$userGroup = UserGroup::create(['title' => 'Test Group']);
diff --git a/tests/integration/Api/Autocomplete/CurrencyControllerTest.php b/tests/integration/Api/Autocomplete/CurrencyControllerTest.php
index 6b61462192..1122503bb9 100644
--- a/tests/integration/Api/Autocomplete/CurrencyControllerTest.php
+++ b/tests/integration/Api/Autocomplete/CurrencyControllerTest.php
@@ -44,6 +44,7 @@ final class CurrencyControllerTest extends TestCase
*/
use RefreshDatabase;
+ #[\Override]
protected function createAuthenticatedUser(): User
{
$userGroup = UserGroup::create(['title' => 'Test Group']);
diff --git a/tests/integration/Api/Autocomplete/ObjectGroupControllerTest.php b/tests/integration/Api/Autocomplete/ObjectGroupControllerTest.php
index 189290e319..74ad04420f 100644
--- a/tests/integration/Api/Autocomplete/ObjectGroupControllerTest.php
+++ b/tests/integration/Api/Autocomplete/ObjectGroupControllerTest.php
@@ -44,6 +44,7 @@ final class ObjectGroupControllerTest extends TestCase
*/
use RefreshDatabase;
+ #[\Override]
protected function createAuthenticatedUser(): User
{
$userGroup = UserGroup::create(['title' => 'Test Group']);
diff --git a/tests/integration/Support/Models/BillDateCalculatorTest.php b/tests/integration/Support/Models/BillDateCalculatorTest.php
index bb65b1d0ac..0120555ba5 100644
--- a/tests/integration/Support/Models/BillDateCalculatorTest.php
+++ b/tests/integration/Support/Models/BillDateCalculatorTest.php
@@ -37,7 +37,7 @@ use Tests\integration\TestCase;
*/
final class BillDateCalculatorTest extends TestCase
{
- private BillDateCalculator $calculator;
+ private readonly BillDateCalculator $calculator;
public function __construct(string $name)
{
diff --git a/tests/unit/Support/Calendar/CalculatorProvider.php b/tests/unit/Support/Calendar/CalculatorProvider.php
index 3a7337f65c..0c18c63360 100644
--- a/tests/unit/Support/Calendar/CalculatorProvider.php
+++ b/tests/unit/Support/Calendar/CalculatorProvider.php
@@ -30,17 +30,11 @@ use Tests\unit\Support\Calendar\Periodicity\IntervalProvider;
readonly class CalculatorProvider
{
- public IntervalProvider $intervalProvider;
public string $label;
- public Periodicity $periodicity;
- public int $skip;
- private function __construct(IntervalProvider $intervalProvider, Periodicity $periodicity, int $skip = 0)
+ private function __construct(public IntervalProvider $intervalProvider, public Periodicity $periodicity, public int $skip = 0)
{
- $this->skip = $skip;
- $this->intervalProvider = $intervalProvider;
- $this->periodicity = $periodicity;
- $this->label = "{$periodicity->name} {$intervalProvider->label}";
+ $this->label = "{$this->periodicity->name} {$this->intervalProvider->label}";
}
public static function providePeriodicityWithSkippedIntervals(): \Generator
diff --git a/tests/unit/Support/Calendar/Periodicity/IntervalProvider.php b/tests/unit/Support/Calendar/Periodicity/IntervalProvider.php
index efd14eb627..b095ea6680 100644
--- a/tests/unit/Support/Calendar/Periodicity/IntervalProvider.php
+++ b/tests/unit/Support/Calendar/Periodicity/IntervalProvider.php
@@ -28,14 +28,10 @@ use Carbon\Carbon;
readonly class IntervalProvider
{
- public Carbon $epoch;
- public Carbon $expected;
public string $label;
- public function __construct(Carbon $epoch, Carbon $expected)
+ public function __construct(public Carbon $epoch, public Carbon $expected)
{
- $this->epoch = $epoch;
- $this->expected = $expected;
- $this->label = "given {$epoch->toDateString()} expects {$expected->toDateString()}";
+ $this->label = "given {$this->epoch->toDateString()} expects {$this->expected->toDateString()}";
}
}
diff --git a/tests/unit/Support/NavigationAddPeriodTest.php b/tests/unit/Support/NavigationAddPeriodTest.php
index 018258d2bf..4b1f301e64 100644
--- a/tests/unit/Support/NavigationAddPeriodTest.php
+++ b/tests/unit/Support/NavigationAddPeriodTest.php
@@ -40,7 +40,7 @@ use Tests\integration\TestCase;
*/
final class NavigationAddPeriodTest extends TestCase
{
- private Navigation $navigation;
+ private readonly Navigation $navigation;
public function __construct(string $name)
{
diff --git a/tests/unit/Support/NavigationEndOfPeriodTest.php b/tests/unit/Support/NavigationEndOfPeriodTest.php
index 278b2e7897..e58b78061d 100644
--- a/tests/unit/Support/NavigationEndOfPeriodTest.php
+++ b/tests/unit/Support/NavigationEndOfPeriodTest.php
@@ -39,7 +39,7 @@ use Tests\integration\TestCase;
*/
final class NavigationEndOfPeriodTest extends TestCase
{
- private Navigation $navigation;
+ private readonly Navigation $navigation;
public function __construct(string $name)
{
diff --git a/tests/unit/Support/NavigationPreferredCarbonFormatByPeriodTest.php b/tests/unit/Support/NavigationPreferredCarbonFormatByPeriodTest.php
index 1a6007870d..34f20b66e1 100644
--- a/tests/unit/Support/NavigationPreferredCarbonFormatByPeriodTest.php
+++ b/tests/unit/Support/NavigationPreferredCarbonFormatByPeriodTest.php
@@ -38,7 +38,7 @@ use Tests\integration\TestCase;
*/
final class NavigationPreferredCarbonFormatByPeriodTest extends TestCase
{
- private Navigation $navigation;
+ private readonly Navigation $navigation;
public function __construct(string $name)
{
diff --git a/tests/unit/Support/NavigationPreferredCarbonFormatTest.php b/tests/unit/Support/NavigationPreferredCarbonFormatTest.php
index 2cb4e0d074..4c8dcef46f 100644
--- a/tests/unit/Support/NavigationPreferredCarbonFormatTest.php
+++ b/tests/unit/Support/NavigationPreferredCarbonFormatTest.php
@@ -39,7 +39,7 @@ use Tests\integration\TestCase;
*/
final class NavigationPreferredCarbonFormatTest extends TestCase
{
- private Navigation $navigation;
+ private readonly Navigation $navigation;
public function __construct(string $name)
{
diff --git a/tests/unit/Support/NavigationPreferredEndOfPeriodTest.php b/tests/unit/Support/NavigationPreferredEndOfPeriodTest.php
index f951a9a6a2..ba3d68d90a 100644
--- a/tests/unit/Support/NavigationPreferredEndOfPeriodTest.php
+++ b/tests/unit/Support/NavigationPreferredEndOfPeriodTest.php
@@ -39,7 +39,7 @@ use Tests\integration\TestCase;
*/
final class NavigationPreferredEndOfPeriodTest extends TestCase
{
- private Navigation $navigation;
+ private readonly Navigation $navigation;
public function __construct(string $name)
{
diff --git a/tests/unit/Support/NavigationPreferredRangeFormatTest.php b/tests/unit/Support/NavigationPreferredRangeFormatTest.php
index 21c2dea91d..48941ef4de 100644
--- a/tests/unit/Support/NavigationPreferredRangeFormatTest.php
+++ b/tests/unit/Support/NavigationPreferredRangeFormatTest.php
@@ -39,7 +39,7 @@ use Tests\integration\TestCase;
*/
final class NavigationPreferredRangeFormatTest extends TestCase
{
- private Navigation $navigation;
+ private readonly Navigation $navigation;
public function __construct(string $name)
{
diff --git a/tests/unit/Support/NavigationPreferredSqlFormatTest.php b/tests/unit/Support/NavigationPreferredSqlFormatTest.php
index 9dce8d5d33..a2127f9d14 100644
--- a/tests/unit/Support/NavigationPreferredSqlFormatTest.php
+++ b/tests/unit/Support/NavigationPreferredSqlFormatTest.php
@@ -39,7 +39,7 @@ use Tests\integration\TestCase;
*/
final class NavigationPreferredSqlFormatTest extends TestCase
{
- private Navigation $navigation;
+ private readonly Navigation $navigation;
public function __construct(string $name)
{
diff --git a/tests/unit/Support/NavigationStartOfPeriodTest.php b/tests/unit/Support/NavigationStartOfPeriodTest.php
index fe9f5117b0..a1c060003c 100644
--- a/tests/unit/Support/NavigationStartOfPeriodTest.php
+++ b/tests/unit/Support/NavigationStartOfPeriodTest.php
@@ -40,7 +40,7 @@ use Tests\integration\TestCase;
*/
final class NavigationStartOfPeriodTest extends TestCase
{
- private Navigation $navigation;
+ private readonly Navigation $navigation;
public function __construct(string $name)
{