Final set of php8.4 changes.

This commit is contained in:
James Cole
2025-05-04 13:50:20 +02:00
parent 51e86448c7
commit 194d22ad90
58 changed files with 151 additions and 157 deletions

View File

@@ -193,7 +193,7 @@ class BudgetController extends Controller
// var_dump($return); // var_dump($return);
/** @var array $journal */ /** @var array $journal */
foreach ($currentBudgetArray['transaction_journals'] as $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); $result = $this->processExpenses($budget->id, $filtered, $limit->start_date, $end);
if (1 === count($result)) { 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) { if (1 === $compare) {
// convert this amount into the native currency: // 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) { 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']));
} }
} }

View File

@@ -96,7 +96,7 @@ class CategoryController extends Controller
$currencyId = (int) $journal['currency_id']; $currencyId = (int) $journal['currency_id'];
$currency = $currencies[$currencyId] ?? $this->currencyRepos->find($currencyId); $currency = $currencies[$currencyId] ?? $this->currencyRepos->find($currencyId);
$currencies[$currencyId] = $currency; $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']); $amount = app('steam')->positive($journal['amount']);
$key = sprintf('%s-%s', $categoryName, $currency->code); $key = sprintf('%s-%s', $categoryName, $currency->code);
// create arrays // create arrays
@@ -114,7 +114,7 @@ class CategoryController extends Controller
]; ];
// add monies // add monies
$return[$key]['amount'] = bcadd($return[$key]['amount'], $amount); $return[$key]['amount'] = bcadd($return[$key]['amount'], (string) $amount);
} }
$return = array_values($return); $return = array_values($return);

View File

@@ -89,7 +89,7 @@ class ExportController extends Controller
->header('Expires', '0') ->header('Expires', '0')
->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0') ->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
->header('Pragma', 'public') ->header('Pragma', 'public')
->header('Content-Length', (string) strlen($data[$key])) ->header('Content-Length', (string) strlen((string) $data[$key]))
; ;
return $response; return $response;

View File

@@ -160,7 +160,7 @@ class TagController extends Controller
'currency_id' => (string) $currencyId, 'currency_id' => (string) $currencyId,
'currency_code' => $journal['currency_code'], '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. $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_id' => (string) $foreignCurrencyId,
'currency_code' => $journal['foreign_currency_code'], '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. $response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference']; // float but on purpose.
} }
} }

View File

@@ -75,7 +75,7 @@ class PeriodController extends Controller
'currency_id' => (string) $currencyId, 'currency_id' => (string) $currencyId,
'currency_code' => $currencyCode, '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. $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // float but on purpose.
} }

View File

@@ -100,7 +100,7 @@ class TagController extends Controller
'currency_id' => (string) $currencyId, 'currency_id' => (string) $currencyId,
'currency_code' => $currencyCode, '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']; $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
} }
@@ -154,7 +154,7 @@ class TagController extends Controller
'currency_id' => (string) $currencyId, 'currency_id' => (string) $currencyId,
'currency_code' => $journal['currency_code'], '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']; $response[$key]['difference_float'] = (float) $response[$key]['difference'];
} }
@@ -167,8 +167,8 @@ class TagController extends Controller
'currency_code' => $journal['foreign_currency_code'], 'currency_code' => $journal['foreign_currency_code'],
]; ];
$response[$foreignKey]['difference'] = bcadd( $response[$foreignKey]['difference'] = bcadd(
$response[$foreignKey]['difference'], (string) $response[$foreignKey]['difference'],
app('steam')->positive($journal['foreign_amount']) (string) app('steam')->positive($journal['foreign_amount'])
); );
$response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference']; $response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference'];
} }

View File

@@ -75,7 +75,7 @@ class PeriodController extends Controller
'currency_id' => (string) $currencyId, 'currency_id' => (string) $currencyId,
'currency_code' => $currencyCode, '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']; $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
} }

View File

@@ -99,7 +99,7 @@ class TagController extends Controller
'currency_id' => (string) $currencyId, 'currency_id' => (string) $currencyId,
'currency_code' => $currencyCode, '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']; $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
} }
@@ -153,7 +153,7 @@ class TagController extends Controller
'currency_id' => (string) $currencyId, 'currency_id' => (string) $currencyId,
'currency_code' => $journal['currency_code'], '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']; $response[$key]['difference_float'] = (float) $response[$key]['difference'];
} }
@@ -166,8 +166,8 @@ class TagController extends Controller
'currency_code' => $journal['foreign_currency_code'], 'currency_code' => $journal['foreign_currency_code'],
]; ];
$response[$foreignKey]['difference'] = bcadd( $response[$foreignKey]['difference'] = bcadd(
$response[$foreignKey]['difference'], (string) $response[$foreignKey]['difference'],
app('steam')->positive($journal['foreign_amount']) (string) app('steam')->positive($journal['foreign_amount'])
); );
$response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference']; // intentional float $response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference']; // intentional float
} }

View File

@@ -191,14 +191,14 @@ class BasicController extends Controller
// if it is the native currency already. // if it is the native currency already.
if ($entry['currency_id'] === $default->id) { 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 // don't forget to add it to newExpenses and newIncome
if (0 === $index) { 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) { 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; continue;
@@ -229,7 +229,7 @@ class BasicController extends Controller
'currency_decimal_places' => $entry['currency_decimal_places'], 'currency_decimal_places' => $entry['currency_decimal_places'],
'sum' => '0', '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) { if (0 === $index) {
// paid amount // paid amount
if ($currencyId === $this->nativeCurrency->id) { 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; continue;
} }
@@ -374,7 +374,7 @@ class BasicController extends Controller
} }
// unpaid amount // unpaid amount
if ($currencyId === $this->nativeCurrency->id) { 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; continue;
} }
@@ -397,7 +397,7 @@ class BasicController extends Controller
* @var array $info * @var array $info
*/ */
foreach ($paidAmount as $info) { foreach ($paidAmount as $info) {
$amount = bcmul($info['sum'], '-1'); $amount = bcmul((string) $info['sum'], '-1');
$return[] = [ $return[] = [
'key' => sprintf('bills-paid-in-%s', $info['code']), 'key' => sprintf('bills-paid-in-%s', $info['code']),
'title' => trans('firefly.box_bill_paid_in_currency', ['currency' => $info['symbol']]), 'title' => trans('firefly.box_bill_paid_in_currency', ['currency' => $info['symbol']]),
@@ -416,7 +416,7 @@ class BasicController extends Controller
* @var array $info * @var array $info
*/ */
foreach ($unpaidAmount as $info) { foreach ($unpaidAmount as $info) {
$amount = bcmul($info['sum'], '-1'); $amount = bcmul((string) $info['sum'], '-1');
$return[] = [ $return[] = [
'key' => sprintf('bills-unpaid-in-%s', $info['code']), 'key' => sprintf('bills-unpaid-in-%s', $info['code']),
'title' => trans('firefly.box_bill_unpaid_in_currency', ['currency' => $info['symbol']]), 'title' => trans('firefly.box_bill_unpaid_in_currency', ['currency' => $info['symbol']]),
@@ -513,7 +513,7 @@ class BasicController extends Controller
continue; continue;
} }
$spentInCurrency = $row['sum']; $spentInCurrency = $row['sum'];
$leftToSpend = bcadd($amount, $spentInCurrency); $leftToSpend = bcadd($amount, (string) $spentInCurrency);
$perDay = '0'; $perDay = '0';
if (0 !== $days && bccomp($leftToSpend, '0') > -1) { if (0 !== $days && bccomp($leftToSpend, '0') > -1) {
$perDay = bcdiv($leftToSpend, (string) $days); $perDay = bcdiv($leftToSpend, (string) $days);
@@ -549,8 +549,8 @@ class BasicController extends Controller
$currencyId = (int) $row['currency_id']; $currencyId = (int) $row['currency_id'];
$spentInCurrency = $row['sum']; $spentInCurrency = $row['sum'];
$perDay = '0'; $perDay = '0';
if (0 !== $days && -1 === bccomp($spentInCurrency, '0')) { if (0 !== $days && -1 === bccomp((string) $spentInCurrency, '0')) {
$perDay = bcdiv($spentInCurrency, (string) $days); $perDay = bcdiv((string) $spentInCurrency, (string) $days);
} }
Log::debug(sprintf('Spent %s %s', $row['currency_code'], $row['sum'])); Log::debug(sprintf('Spent %s %s', $row['currency_code'], $row['sum']));
@@ -631,7 +631,7 @@ class BasicController extends Controller
continue; continue;
} }
$amount = $data['balance']; $amount = $data['balance'];
if (0 === bccomp($amount, '0')) { if (0 === bccomp((string) $amount, '0')) {
continue; continue;
} }
// return stuff // return stuff

View File

@@ -212,13 +212,13 @@ class BudgetController extends Controller
foreach ($currentBudgetArray['transaction_journals'] as $journal) { foreach ($currentBudgetArray['transaction_journals'] as $journal) {
// convert the amount to the native currency. // convert the amount to the native currency.
$rate = $converter->getCurrencyRate($this->currencies[$currencyId], $this->currency, $journal['date']); $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) { if ($journal['foreign_currency_id'] === $this->currency->id) {
$convertedAmount = $journal['foreign_amount']; $convertedAmount = $journal['foreign_amount'];
} }
$return[$currencyId]['spent'] = bcadd($return[$currencyId]['spent'], $journal['amount']); $return[$currencyId]['spent'] = bcadd($return[$currencyId]['spent'], (string) $journal['amount']);
$return[$currencyId]['native_spent'] = bcadd($return[$currencyId]['native_spent'], $convertedAmount); $return[$currencyId]['native_spent'] = bcadd($return[$currencyId]['native_spent'], (string) $convertedAmount);
} }
} }
$converter->summarize(); $converter->summarize();
@@ -275,15 +275,15 @@ class BudgetController extends Controller
} }
$result = $this->processExpenses($budget->id, $filtered, $limit->start_date, $end); $result = $this->processExpenses($budget->id, $filtered, $limit->start_date, $end);
if (1 === count($result)) { 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) { if (1 === $compare) {
// convert this amount into the native currency: // 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']);
$result[$limitCurrencyId]['native_left'] = bcadd($convertedLimitAmount, $result[$limitCurrencyId]['native_spent']); $result[$limitCurrencyId]['native_left'] = bcadd($convertedLimitAmount, (string) $result[$limitCurrencyId]['native_spent']);
} }
if ($compare <= 0) { 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']));
$result[$limitCurrencyId]['native_overspent'] = app('steam')->positive(bcadd($convertedLimitAmount, $result[$limitCurrencyId]['native_spent'])); $result[$limitCurrencyId]['native_overspent'] = app('steam')->positive(bcadd($convertedLimitAmount, (string) $result[$limitCurrencyId]['native_spent']));
} }
} }
$converter->summarize(); $converter->summarize();

View File

@@ -100,7 +100,7 @@ class CategoryController extends Controller
$currencyId = (int) $journal['currency_id']; $currencyId = (int) $journal['currency_id'];
$currency = $currencies[$currencyId] ?? $this->currencyRepos->find($currencyId); $currency = $currencies[$currencyId] ?? $this->currencyRepos->find($currencyId);
$currencies[$currencyId] = $currency; $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']); $amount = app('steam')->positive($journal['amount']);
$nativeAmount = $converter->convert($default, $currency, $journal['date'], $amount); $nativeAmount = $converter->convert($default, $currency, $journal['date'], $amount);
$key = sprintf('%s-%s', $categoryName, $currency->code); $key = sprintf('%s-%s', $categoryName, $currency->code);
@@ -128,8 +128,8 @@ class CategoryController extends Controller
]; ];
// add monies // add monies
$return[$key]['amount'] = bcadd($return[$key]['amount'], $amount); $return[$key]['amount'] = bcadd($return[$key]['amount'], (string) $amount);
$return[$key]['native_amount'] = bcadd($return[$key]['native_amount'], $nativeAmount); $return[$key]['native_amount'] = bcadd($return[$key]['native_amount'], (string) $nativeAmount);
} }
$return = array_values($return); $return = array_values($return);

View File

@@ -174,8 +174,8 @@ class BasicController extends Controller
* @var array $info * @var array $info
*/ */
foreach ($paidAmount as $info) { foreach ($paidAmount as $info) {
$amount = bcmul($info['sum'], '-1'); $amount = bcmul((string) $info['sum'], '-1');
$nativeAmount = bcmul($info['native_sum'], '-1'); $nativeAmount = bcmul((string) $info['native_sum'], '-1');
$return[] = [ $return[] = [
'key' => sprintf('bills-paid-in-%s', $info['currency_code']), 'key' => sprintf('bills-paid-in-%s', $info['currency_code']),
'value' => $amount, 'value' => $amount,
@@ -198,8 +198,8 @@ class BasicController extends Controller
* @var array $info * @var array $info
*/ */
foreach ($unpaidAmount as $info) { foreach ($unpaidAmount as $info) {
$amount = bcmul($info['sum'], '-1'); $amount = bcmul((string) $info['sum'], '-1');
$nativeAmount = bcmul($info['native_sum'], '-1'); $nativeAmount = bcmul((string) $info['native_sum'], '-1');
$return[] = [ $return[] = [
'key' => sprintf('bills-unpaid-in-%s', $info['currency_code']), 'key' => sprintf('bills-unpaid-in-%s', $info['currency_code']),
'value' => $amount, 'value' => $amount,
@@ -279,8 +279,8 @@ class BasicController extends Controller
if ((int) $journal['foreign_currency_id'] === $default->id) { if ((int) $journal['foreign_currency_id'] === $default->id) {
$amountNative = $journal['foreign_amount']; $amountNative = $journal['foreign_amount'];
} }
$spent = bcadd($spent, $amount); $spent = bcadd($spent, (string) $amount);
$spentNative = bcadd($spentNative, $amountNative); $spentNative = bcadd($spentNative, (string) $amountNative);
} }
app('log')->debug(sprintf('Total spent in budget "%s" is %s', $budget['name'], $spent)); app('log')->debug(sprintf('Total spent in budget "%s" is %s', $budget['name'], $spent));
} }

View File

@@ -48,8 +48,8 @@ class CorrectsLongDescriptions extends Command
/** @var TransactionJournal $journal */ /** @var TransactionJournal $journal */
foreach ($journals as $journal) { foreach ($journals as $journal) {
if (strlen($journal->description) > self::MAX_LENGTH) { if (strlen((string) $journal->description) > self::MAX_LENGTH) {
$journal->description = substr($journal->description, 0, self::MAX_LENGTH); $journal->description = substr((string) $journal->description, 0, self::MAX_LENGTH);
$journal->save(); $journal->save();
$this->friendlyWarning(sprintf('Truncated description of transaction journal #%d', $journal->id)); $this->friendlyWarning(sprintf('Truncated description of transaction journal #%d', $journal->id));
++$count; ++$count;
@@ -61,7 +61,7 @@ class CorrectsLongDescriptions extends Command
/** @var TransactionGroup $group */ /** @var TransactionGroup $group */
foreach ($groups as $group) { foreach ($groups as $group) {
if (strlen((string) $group->title) > self::MAX_LENGTH) { 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(); $group->save();
$this->friendlyWarning(sprintf('Truncated description of transaction group #%d', $group->id)); $this->friendlyWarning(sprintf('Truncated description of transaction group #%d', $group->id));
++$count; ++$count;

View File

@@ -100,7 +100,7 @@ class CorrectsRecurringTransactions extends Command
$destination = $transaction->destinationAccount; $destination = $transaction->destinationAccount;
$type = $recurrence->transactionType; $type = $recurrence->transactionType;
$link = config(sprintf('firefly.account_to_transaction.%s.%s', $source->accountType->type, $destination->accountType->type)); $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( $this->friendlyWarning(
sprintf('Recurring transaction #%d should be a "%s" but is a "%s" and will be corrected.', $recurrence->id, $link, $type->type) sprintf('Recurring transaction #%d should be a "%s" but is a "%s" and will be corrected.', $recurrence->id, $link, $type->type)
); );

View File

@@ -184,7 +184,7 @@ class CorrectsUnevenAmount extends Command
return; return;
} }
$amount = bcmul('-1', $source->amount); $amount = bcmul('-1', (string) $source->amount);
// fix amount of destination: // fix amount of destination:
/** @var null|Transaction $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('[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))); // 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 && $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 && (int) $destination->transaction_currency_id === (int) $source->foreign_currency_id
) { ) {
return true; return true;

View File

@@ -78,8 +78,8 @@ class UpgradesRuleActions extends Command
/** @var RuleAction $action */ /** @var RuleAction $action */
foreach ($actions as $action) { foreach ($actions as $action) {
if (str_starts_with($action->action_value, '=')) { if (str_starts_with((string) $action->action_value, '=')) {
$action->action_value = sprintf('%s%s', '\=', substr($action->action_value, 1)); $action->action_value = sprintf('%s%s', '\=', substr((string) $action->action_value, 1));
$action->save(); $action->save();
++$count; ++$count;
} }

View File

@@ -234,7 +234,7 @@ class UpgradesToGroups extends Command
$categoryId = $this->getTransactionCategory($transaction, $opposingTr) ?? $categoryId; $categoryId = $this->getTransactionCategory($transaction, $opposingTr) ?? $categoryId;
return [ return [
'type' => strtolower($journal->transactionType->type), 'type' => strtolower((string) $journal->transactionType->type),
'date' => $journal->date, 'date' => $journal->date,
'user' => $journal->user, 'user' => $journal->user,
'user_group' => $journal->user->userGroup, 'user_group' => $journal->user->userGroup,

View File

@@ -218,7 +218,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
return redirect(route('accounts.index', ['asset'])); return redirect(route('accounts.index', ['asset']));
} }
return redirect(route('transactions.index', [strtolower($type)])); return redirect(route('transactions.index', [strtolower((string) $type)]));
} }
/** /**

View File

@@ -44,7 +44,7 @@ class AttachmentFactory
public function create(array $data): ?Attachment public function create(array $data): ?Attachment
{ {
// append if necessary. // 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']; : $data['attachable_type'];
// get journal instead of transaction. // get journal instead of transaction.

View File

@@ -59,7 +59,7 @@ class RecurrenceFactory
public function create(array $data): Recurrence public function create(array $data): Recurrence
{ {
try { try {
$type = $this->findTransactionType(ucfirst($data['recurrence']['type'])); $type = $this->findTransactionType(ucfirst((string) $data['recurrence']['type']));
} catch (FireflyException $e) { } catch (FireflyException $e) {
$message = sprintf('Cannot make a recurring transaction of type "%s"', $data['recurrence']['type']); $message = sprintf('Cannot make a recurring transaction of type "%s"', $data['recurrence']['type']);
app('log')->error($message); app('log')->error($message);

View File

@@ -77,7 +77,7 @@ class TagFactory
$array = [ $array = [
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'user_group_id' => $this->userGroup->id, 'user_group_id' => $this->userGroup->id,
'tag' => trim($data['tag']), 'tag' => trim((string) $data['tag']),
'tagMode' => 'nothing', 'tagMode' => 'nothing',
'date' => $data['date'], 'date' => $data['date'],
'description' => $data['description'], 'description' => $data['description'],

View File

@@ -71,7 +71,7 @@ class TransactionGroupFactory
$title = '' === $title ? null : $title; $title = '' === $title ? null : $title;
if (null !== $title) { if (null !== $title) {
$title = substr($title, 0, 1000); $title = substr((string) $title, 0, 1000);
} }
if (0 === $collection->count()) { if (0 === $collection->count()) {
throw new FireflyException('Created zero transaction journals.'); throw new FireflyException('Created zero transaction journals.');

View File

@@ -159,7 +159,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
} }
} }
$newBalance = bcadd($startBalance, $transactionAmount); $newBalance = bcadd((string) $startBalance, (string) $transactionAmount);
$journals[$index]['balance_after'] = $newBalance; $journals[$index]['balance_after'] = $newBalance;
$startBalance = $newBalance; $startBalance = $newBalance;

View File

@@ -194,12 +194,12 @@ class BudgetLimitHandler
// if both equal each other, amount from this BL must be added to the AB // if both equal each other, amount from this BL must be added to the AB
if ($limitPeriod->equals($abPeriod)) { if ($limitPeriod->equals($abPeriod)) {
Log::debug('This budget limit is equal to the available budget period.'); 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 budget limit period is inside AB period, it can be added in full.
if (!$limitPeriod->equals($abPeriod) && $abPeriod->contains($limitPeriod)) { if (!$limitPeriod->equals($abPeriod) && $abPeriod->contains($limitPeriod)) {
Log::debug('This budget limit is smaller than the available budget period.'); 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)) { if (!$limitPeriod->equals($abPeriod) && !$abPeriod->contains($limitPeriod) && $abPeriod->overlapsWith($limitPeriod)) {
Log::debug('This budget limit is something else entirely!'); Log::debug('This budget limit is something else entirely!');

View File

@@ -264,7 +264,7 @@ trait AccountCollection
$date->subSecond(); $date->subSecond();
Log::debug(sprintf('accountBalanceIs: Call finalAccountBalance with date/time "%s"', $date->toIso8601String())); Log::debug(sprintf('accountBalanceIs: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
$balance = Steam::finalAccountBalance($account, $date); $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)); Log::debug(sprintf('"%s" vs "%s" is %d', $balance['balance'], $value, $result));
switch ($operator) { switch ($operator) {

View File

@@ -51,8 +51,8 @@ trait AttachmentCollection
foreach ($object['transactions'] as $transaction) { foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */ /** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) { foreach ($transaction['attachments'] as $attachment) {
$result = str_contains(strtolower($attachment['filename']), strtolower($name)) || str_contains( $result = str_contains(strtolower((string) $attachment['filename']), strtolower($name)) || str_contains(
strtolower($attachment['title']), strtolower((string) $attachment['title']),
strtolower($name) strtolower($name)
); );
if (true === $result) { if (true === $result) {
@@ -131,8 +131,8 @@ trait AttachmentCollection
foreach ($object['transactions'] as $transaction) { foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */ /** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) { foreach ($transaction['attachments'] as $attachment) {
$result = !str_contains(strtolower($attachment['filename']), strtolower($name)) && !str_contains( $result = !str_contains(strtolower((string) $attachment['filename']), strtolower($name)) && !str_contains(
strtolower($attachment['title']), strtolower((string) $attachment['title']),
strtolower($name) strtolower($name)
); );
if (true === $result) { if (true === $result) {
@@ -166,8 +166,8 @@ trait AttachmentCollection
foreach ($object['transactions'] as $transaction) { foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */ /** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) { foreach ($transaction['attachments'] as $attachment) {
$result = !str_ends_with(strtolower($attachment['filename']), strtolower($name)) && !str_ends_with( $result = !str_ends_with(strtolower((string) $attachment['filename']), strtolower($name)) && !str_ends_with(
strtolower($attachment['title']), strtolower((string) $attachment['title']),
strtolower($name) strtolower($name)
); );
if (true === $result) { if (true === $result) {
@@ -201,8 +201,8 @@ trait AttachmentCollection
foreach ($object['transactions'] as $transaction) { foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */ /** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) { foreach ($transaction['attachments'] as $attachment) {
$result = !str_starts_with(strtolower($attachment['filename']), strtolower($name)) && !str_starts_with( $result = !str_starts_with(strtolower((string) $attachment['filename']), strtolower($name)) && !str_starts_with(
strtolower($attachment['title']), strtolower((string) $attachment['title']),
strtolower($name) strtolower($name)
); );
if (true === $result) { if (true === $result) {
@@ -227,8 +227,8 @@ trait AttachmentCollection
foreach ($object['transactions'] as $transaction) { foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */ /** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) { foreach ($transaction['attachments'] as $attachment) {
$result = str_ends_with(strtolower($attachment['filename']), strtolower($name)) || str_ends_with( $result = str_ends_with(strtolower((string) $attachment['filename']), strtolower($name)) || str_ends_with(
strtolower($attachment['title']), strtolower((string) $attachment['title']),
strtolower($name) strtolower($name)
); );
if (true === $result) { if (true === $result) {
@@ -299,8 +299,8 @@ trait AttachmentCollection
foreach ($object['transactions'] as $transaction) { foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */ /** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) { foreach ($transaction['attachments'] as $attachment) {
$result = str_starts_with(strtolower($attachment['filename']), strtolower($name)) || str_starts_with( $result = str_starts_with(strtolower((string) $attachment['filename']), strtolower($name)) || str_starts_with(
strtolower($attachment['title']), strtolower((string) $attachment['title']),
strtolower($name) strtolower($name)
); );
if (true === $result) { if (true === $result) {

View File

@@ -492,7 +492,7 @@ trait MetaCollection
'notes', 'notes',
static function (JoinClause $join): void { static function (JoinClause $join): void {
$join->on('notes.noteable_id', '=', 'transaction_journals.id'); $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'); $join->whereNull('notes.deleted_at');
} }
); );
@@ -601,8 +601,8 @@ trait MetaCollection
return false; return false;
} }
foreach ($transaction['tags'] as $tag) { foreach ($transaction['tags'] as $tag) {
Log::debug(sprintf('"%s" versus', strtolower($tag['name'])), $list); Log::debug(sprintf('"%s" versus', strtolower((string) $tag['name'])), $list);
if (in_array(strtolower($tag['name']), $list, true)) { if (in_array(strtolower((string) $tag['name']), $list, true)) {
app('log')->debug(sprintf('Transaction has tag "%s" so count++.', $tag['name'])); app('log')->debug(sprintf('Transaction has tag "%s" so count++.', $tag['name']));
++$foundTagCount; ++$foundTagCount;
$journalId = $transaction['transaction_journal_id']; $journalId = $transaction['transaction_journal_id'];
@@ -779,8 +779,8 @@ trait MetaCollection
Log::debug(sprintf('Now in setTags(%s) filter', implode(', ', $list))); Log::debug(sprintf('Now in setTags(%s) filter', implode(', ', $list)));
foreach ($object['transactions'] as $transaction) { foreach ($object['transactions'] as $transaction) {
foreach ($transaction['tags'] as $tag) { foreach ($transaction['tags'] as $tag) {
Log::debug(sprintf('"%s" versus', strtolower($tag['name'])), $list); Log::debug(sprintf('"%s" versus', strtolower((string) $tag['name'])), $list);
if (in_array(strtolower($tag['name']), $list, true)) { if (in_array(strtolower((string) $tag['name']), $list, true)) {
app('log')->debug(sprintf('Transaction has tag "%s" so return true.', $tag['name'])); app('log')->debug(sprintf('Transaction has tag "%s" so return true.', $tag['name']));
return true; return true;
@@ -811,8 +811,8 @@ trait MetaCollection
foreach ($object['transactions'] as $transaction) { foreach ($object['transactions'] as $transaction) {
app('log')->debug(sprintf('Transaction has %d tag(s)', count($transaction['tags']))); app('log')->debug(sprintf('Transaction has %d tag(s)', count($transaction['tags'])));
foreach ($transaction['tags'] as $tag) { foreach ($transaction['tags'] as $tag) {
Log::debug(sprintf('"%s" versus', strtolower($tag['name'])), $list); Log::debug(sprintf('"%s" versus', strtolower((string) $tag['name'])), $list);
if (in_array(strtolower($tag['name']), $list, true)) { 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'])); app('log')->debug(sprintf('Transaction has tag "%s", but should not have it, return false.', $tag['name']));
return false; return false;

View File

@@ -593,7 +593,7 @@ class GroupCollector implements GroupCollectorInterface
if (array_key_exists('meta_name', $result) && in_array($result['meta_name'], $dates, true)) { if (array_key_exists('meta_name', $result) && in_array($result['meta_name'], $dates, true)) {
$name = $result['meta_name']; $name = $result['meta_name'];
if (array_key_exists('meta_data', $result) && '' !== (string) $result['meta_data']) { 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]['amount'] = '0';
$groups[$groudId]['sums'][$currencyId]['native_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]['amount'] = bcadd((string) $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]['native_amount'] = bcadd((string) $groups[$groudId]['sums'][$currencyId]['native_amount'], $nativeAmount);
if (null !== $transaction['foreign_amount'] && null !== $transaction['foreign_currency_id']) { if (null !== $transaction['foreign_amount'] && null !== $transaction['foreign_currency_id']) {
$currencyId = (int) $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]['amount'] = '0';
$groups[$groudId]['sums'][$currencyId]['native_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); $groups[$groudId]['sums'][$currencyId]['native_amount'] = bcadd($groups[$groudId]['sums'][$currencyId]['amount'], $nativeForeignAmount);
} }
} }

View File

@@ -67,7 +67,7 @@ class HomeController extends Controller
try { try {
$stringStart = e((string) $request->get('start')); $stringStart = e((string) $request->get('start'));
$start = Carbon::createFromFormat('Y-m-d', $stringStart); $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)); app('log')->error(sprintf('Start: could not parse date string "%s" so ignore it.', $stringStart));
$start = Carbon::now()->startOfMonth(); $start = Carbon::now()->startOfMonth();
} }

View File

@@ -57,24 +57,24 @@ use Illuminate\Support\Collection;
class OperatorQuerySearch implements SearchInterface class OperatorQuerySearch implements SearchInterface
{ {
protected Carbon $date; protected Carbon $date;
private AccountRepositoryInterface $accountRepository; private readonly AccountRepositoryInterface $accountRepository;
private BillRepositoryInterface $billRepository; private readonly BillRepositoryInterface $billRepository;
private BudgetRepositoryInterface $budgetRepository; private readonly BudgetRepositoryInterface $budgetRepository;
private CategoryRepositoryInterface $categoryRepository; private readonly CategoryRepositoryInterface $categoryRepository;
private GroupCollectorInterface $collector; private GroupCollectorInterface $collector;
private CurrencyRepositoryInterface $currencyRepository; private readonly CurrencyRepositoryInterface $currencyRepository;
private array $excludeTags; private array $excludeTags;
private array $includeAnyTags; private array $includeAnyTags;
// added to fix #8632 // added to fix #8632
private array $includeTags; private array $includeTags;
private array $invalidOperators; private array $invalidOperators;
private int $limit; private int $limit;
private Collection $operators; private readonly Collection $operators;
private int $page; private int $page;
private array $prohibitedWords; private array $prohibitedWords;
private float $startTime; private readonly float $startTime;
private TagRepositoryInterface $tagRepository; private readonly TagRepositoryInterface $tagRepository;
private array $validOperators; private readonly array $validOperators;
private array $words; private array $words;
/** /**
@@ -149,7 +149,7 @@ class OperatorQuerySearch implements SearchInterface
/** @var QueryParserInterface $parser */ /** @var QueryParserInterface $parser */
$parser = app(QueryParserInterface::class); $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 { try {
$parsedQuery = $parser->parse($query); $parsedQuery = $parser->parse($query);
@@ -177,7 +177,7 @@ class OperatorQuerySearch implements SearchInterface
*/ */
private function handleSearchNode(Node $node, bool $flipProhibitedFlag): void 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) { switch (true) {
case $node instanceof StringNode: case $node instanceof StringNode:
@@ -196,9 +196,9 @@ class OperatorQuerySearch implements SearchInterface
break; break;
default: 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())); app('log')->debug(sprintf('Found %d accounts, will filter.', $accounts->count()));
$filtered = $accounts->filter( $filtered = $accounts->filter(
static function (Account $account) use ($value, $stringMethod) { static fn(Account $account) => $stringMethod(strtolower($account->name), strtolower($value))
return $stringMethod(strtolower($account->name), strtolower($value));
}
); );
if (0 === $filtered->count()) { if (0 === $filtered->count()) {
@@ -2095,7 +2093,7 @@ class OperatorQuerySearch implements SearchInterface
/** @var AccountMeta $meta */ /** @var AccountMeta $meta */
foreach ($account->accountMeta as $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; $accountNrMatch = true;
} }
} }
@@ -2146,7 +2144,7 @@ class OperatorQuerySearch implements SearchInterface
try { try {
$parsedDate = $parser->parseDate($value); $parsedDate = $parser->parseDate($value);
} catch (FireflyException $e) { } catch (FireflyException) {
app('log')->debug(sprintf('Could not parse date "%s", will return empty array.', $value)); app('log')->debug(sprintf('Could not parse date "%s", will return empty array.', $value));
$this->invalidOperators[] = [ $this->invalidOperators[] = [
'type' => $type, 'type' => $type,

View File

@@ -109,8 +109,8 @@ class SearchRuleEngine implements RuleEngineInterface
continue; continue;
} }
$contextSearch = $ruleTrigger->trigger_type; $contextSearch = $ruleTrigger->trigger_type;
if (str_starts_with($ruleTrigger->trigger_type, '-')) { if (str_starts_with((string) $ruleTrigger->trigger_type, '-')) {
$contextSearch = substr($ruleTrigger->trigger_type, 1); $contextSearch = substr((string) $ruleTrigger->trigger_type, 1);
} }
// if the trigger needs no context, value is different: // if the trigger needs no context, value is different:

View File

@@ -201,7 +201,7 @@ class AccountTransformer extends AbstractTransformer
} }
$monthlyPaymentDate = $object->toAtomString(); $monthlyPaymentDate = $object->toAtomString();
} }
if (10 !== strlen($monthlyPaymentDate)) { if (10 !== strlen((string) $monthlyPaymentDate)) {
$monthlyPaymentDate = Carbon::parse($monthlyPaymentDate, config('app.timezone'))->toAtomString(); $monthlyPaymentDate = Carbon::parse($monthlyPaymentDate, config('app.timezone'))->toAtomString();
} }
} }

View File

@@ -118,7 +118,7 @@ class TransactionGroupTransformer extends AbstractTransformer
// amount: // amount:
$amount = app('steam')->positive((string) ($transaction['amount'] ?? '0')); $amount = app('steam')->positive((string) ($transaction['amount'] ?? '0'));
$foreignAmount = null; $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']); $foreignAmount = app('steam')->positive($transaction['foreign_amount']);
} }
$type = $this->stringFromArray($transaction, 'transaction_type_type', TransactionTypeEnum::WITHDRAWAL->value); $type = $this->stringFromArray($transaction, 'transaction_type_type', TransactionTypeEnum::WITHDRAWAL->value);
@@ -132,7 +132,7 @@ class TransactionGroupTransformer extends AbstractTransformer
return [ return [
'user' => (string) $transaction['user_id'], 'user' => (string) $transaction['user_id'],
'transaction_journal_id' => (string) $transaction['transaction_journal_id'], 'transaction_journal_id' => (string) $transaction['transaction_journal_id'],
'type' => strtolower($type), 'type' => strtolower((string) $type),
'date' => $transaction['date']->toAtomString(), 'date' => $transaction['date']->toAtomString(),
'order' => $transaction['order'], 'order' => $transaction['order'],
@@ -296,7 +296,7 @@ class TransactionGroupTransformer extends AbstractTransformer
$type = $journal->transactionType->type; $type = $journal->transactionType->type;
$currency = $source->transactionCurrency; $currency = $source->transactionCurrency;
$amount = app('steam')->bcround($this->getAmount($source->amount), $currency->decimal_places ?? 0); $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); $metaFieldData = $this->groupRepos->getMetaFields($journal->id, $this->metaFields);
$metaDates = $this->getDates($this->groupRepos->getMetaDateFields($journal->id, $this->metaDateFields)); $metaDates = $this->getDates($this->groupRepos->getMetaDateFields($journal->id, $this->metaDateFields));
$foreignCurrency = $this->getForeignCurrency($source->foreignCurrency); $foreignCurrency = $this->getForeignCurrency($source->foreignCurrency);
@@ -321,7 +321,7 @@ class TransactionGroupTransformer extends AbstractTransformer
return [ return [
'user' => $journal->user_id, 'user' => $journal->user_id,
'transaction_journal_id' => (string) $journal->id, 'transaction_journal_id' => (string) $journal->id,
'type' => strtolower($type), 'type' => strtolower((string) $type),
'date' => $journal->date->toAtomString(), 'date' => $journal->date->toAtomString(),
'order' => $journal->order, 'order' => $journal->order,

View File

@@ -198,8 +198,8 @@ class AccountTransformer extends AbstractTransformer
$id = $account->id; $id = $account->id;
if (array_key_exists($id, $bStart) && array_key_exists($id, $bEnd)) { if (array_key_exists($id, $bStart) && array_key_exists($id, $bEnd)) {
$this->balanceDifferences[$id] = [ $this->balanceDifferences[$id] = [
'balance' => bcsub($bEnd[$id]['balance'], $bStart[$id]['balance']), 'balance' => bcsub((string) $bEnd[$id]['balance'], (string) $bStart[$id]['balance']),
'native_balance' => bcsub($bEnd[$id]['native_balance'], $bStart[$id]['native_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; $nativeBalance = $this->convertedBalances[$id]['native_balance'] ?? null;
// no order for some accounts: // 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; $order = null;
} }
@@ -381,7 +381,7 @@ class AccountTransformer extends AbstractTransformer
'name' => $account->name, 'name' => $account->name,
'iban' => '' === (string) $account->iban ? null : $account->iban, 'iban' => '' === (string) $account->iban ? null : $account->iban,
'account_number' => $this->accountMeta[$id]['account_number'] ?? null, 'account_number' => $this->accountMeta[$id]['account_number'] ?? null,
'type' => strtolower($accountType), 'type' => strtolower((string) $accountType),
'account_role' => $accountRole, 'account_role' => $accountRole,
'currency_id' => (string) $currency->id, 'currency_id' => (string) $currency->id,
'currency_code' => $currency->code, 'currency_code' => $currency->code,

View File

@@ -196,9 +196,9 @@ class PiggyBankTransformer extends AbstractTransformer
$group = $this->groups[$piggyBank->id] ?? null; $group = $this->groups[$piggyBank->id] ?? null;
if (0 !== bccomp($targetAmount, '0')) { // target amount is not 0.00 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); $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); $savePerMonth = $this->getSuggestedMonthlyAmount($currentAmount, $targetAmount, $piggyBank->start_date, $piggyBank->target_date);
$nativeSavePerMonth = $this->converter->convert($this->default, $currency, today(), $savePerMonth); $nativeSavePerMonth = $this->converter->convert($this->default, $currency, today(), $savePerMonth);
} }

View File

@@ -219,7 +219,7 @@ class TransactionGroupTransformer extends AbstractTransformer
/** @var Transaction $transaction */ /** @var Transaction $transaction */
foreach ($journal->transactions as $transaction) { foreach ($journal->transactions as $transaction) {
if (-1 === bccomp($transaction->amount, '0')) { if (-1 === bccomp((string) $transaction->amount, '0')) {
// only collect source account info // only collect source account info
$account = $transaction->account; $account = $transaction->account;
$this->accountTypes[$account->account_type_id] ??= $account->accountType->type; $this->accountTypes[$account->account_type_id] ??= $account->accountType->type;
@@ -349,7 +349,7 @@ class TransactionGroupTransformer extends AbstractTransformer
'user' => (string) $transaction['user_id'], 'user' => (string) $transaction['user_id'],
'user_group' => (string) $transaction['user_group_id'], 'user_group' => (string) $transaction['user_group_id'],
'transaction_journal_id' => (string) $transaction['transaction_journal_id'], 'transaction_journal_id' => (string) $transaction['transaction_journal_id'],
'type' => strtolower($type), 'type' => strtolower((string) $type),
'date' => $transaction['date']->toAtomString(), 'date' => $transaction['date']->toAtomString(),
'order' => $transaction['order'], 'order' => $transaction['order'],
'amount' => $amount, 'amount' => $amount,

View File

@@ -418,7 +418,7 @@ class FireflyValidator extends Validator
// check transaction type. // check transaction type.
// TODO create a helper to automatically return these. // TODO create a helper to automatically return these.
if ('transaction_type' === $triggerType) { if ('transaction_type' === $triggerType) {
$count = TransactionType::where('type', ucfirst($value))->count(); $count = TransactionType::where('type', ucfirst((string) $value))->count();
return 1 === $count; return 1 === $count;
} }

View File

@@ -593,7 +593,7 @@ trait TransactionValidation
/** @var null|TransactionJournal $journal */ /** @var null|TransactionJournal $journal */
$journal = TransactionJournal::with(['transactionType'])->find($journalId); $journal = TransactionJournal::with(['transactionType'])->find($journalId);
if (null !== $journal) { if (null !== $journal) {
return strtolower($journal->transactionType->type); return strtolower((string) $journal->transactionType->type);
} }
return 'invalid'; return 'invalid';

View File

@@ -57,7 +57,7 @@ return [
'app_id' => env('PUSHER_APP_ID'), 'app_id' => env('PUSHER_APP_ID'),
'options' => [ 'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'), '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), 'port' => env('PUSHER_PORT', 443),
'scheme' => env('PUSHER_SCHEME', 'https'), 'scheme' => env('PUSHER_SCHEME', 'https'),
'encrypted' => true, 'encrypted' => true,

View File

@@ -46,7 +46,7 @@ return [
'timeout' => null, 'timeout' => null,
'scheme' => env('MAIL_SCHEME'), 'scheme' => env('MAIL_SCHEME'),
'url' => env('MAIL_URL'), '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), 'verify_peer' => env('MAIL_VERIFY_PEER', true),
'allow_self_signed' => env('MAIL_ALLOW_SELF_SIGNED', false), 'allow_self_signed' => env('MAIL_ALLOW_SELF_SIGNED', false),
'verify_peer_name' => env('MAIL_VERIFY_PEER_NAME', true), 'verify_peer_name' => env('MAIL_VERIFY_PEER_NAME', true),

View File

@@ -1202,7 +1202,7 @@ Breadcrumbs::for(
static function (Generator $breadcrumbs, TransactionGroup $group): void { static function (Generator $breadcrumbs, TransactionGroup $group): void {
/** @var TransactionJournal $first */ /** @var TransactionJournal $first */
$first = $group->transactionJournals()->first(); $first = $group->transactionJournals()->first();
$type = strtolower($first->transactionType->type); $type = strtolower((string) $first->transactionType->type);
$title = limitStringLength($first->description); $title = limitStringLength($first->description);
if ($group->transactionJournals()->count() > 1) { if ($group->transactionJournals()->count() > 1) {
$title = limitStringLength((string)$group->title); $title = limitStringLength((string)$group->title);
@@ -1241,7 +1241,7 @@ Breadcrumbs::for(
'transactions.mass.edit', 'transactions.mass.edit',
static function (Generator $breadcrumbs, array $journals): void { static function (Generator $breadcrumbs, array $journals): void {
if (0 !== count($journals)) { 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->parent('transactions.index', $objectType);
$breadcrumbs->push(trans('firefly.mass_edit_journals'), route('transactions.mass.edit', [''])); $breadcrumbs->push(trans('firefly.mass_edit_journals'), route('transactions.mass.edit', ['']));
@@ -1254,7 +1254,7 @@ Breadcrumbs::for(
Breadcrumbs::for( Breadcrumbs::for(
'transactions.mass.delete', 'transactions.mass.delete',
static function (Generator $breadcrumbs, array $journals): void { 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->parent('transactions.index', $objectType);
$breadcrumbs->push(trans('firefly.mass_edit_journals'), route('transactions.mass.delete', [''])); $breadcrumbs->push(trans('firefly.mass_edit_journals'), route('transactions.mass.delete', ['']));
} }
@@ -1267,7 +1267,7 @@ Breadcrumbs::for(
if (0 !== count($journals)) { if (0 !== count($journals)) {
$ids = Arr::pluck($journals, 'transaction_journal_id'); $ids = Arr::pluck($journals, 'transaction_journal_id');
$first = reset($journals); $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)); $breadcrumbs->push(trans('firefly.mass_bulk_journals'), route('transactions.bulk.edit', $ids));
return; return;

View File

@@ -40,6 +40,7 @@ final class AboutControllerTest extends TestCase
use RefreshDatabase; use RefreshDatabase;
private $user; private $user;
#[\Override]
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp(); parent::setUp();

View File

@@ -44,6 +44,7 @@ final class BillControllerTest extends TestCase
*/ */
use RefreshDatabase; use RefreshDatabase;
#[\Override]
protected function createAuthenticatedUser(): User protected function createAuthenticatedUser(): User
{ {
$userGroup = UserGroup::create(['title' => 'Test Group']); $userGroup = UserGroup::create(['title' => 'Test Group']);
@@ -65,8 +66,8 @@ final class BillControllerTest extends TestCase
'user_id' => $user->id, 'user_id' => $user->id,
'name' => 'Bill '.$i, 'name' => 'Bill '.$i,
'user_group_id' => $user->user_group_id, 'user_group_id' => $user->user_group_id,
'amount_min' => rand(1, 100), // random amount 'amount_min' => random_int(1, 100), // random amount
'amount_max' => rand(101, 200), // random amount 'amount_max' => random_int(101, 200), // random amount
'match' => 'MIGRATED_TO_RULES', 'match' => 'MIGRATED_TO_RULES',
'date' => '2024-01-01', 'date' => '2024-01-01',
'repeat_freq' => 'monthly', 'repeat_freq' => 'monthly',

View File

@@ -44,6 +44,7 @@ final class BudgetControllerTest extends TestCase
*/ */
use RefreshDatabase; use RefreshDatabase;
#[\Override]
protected function createAuthenticatedUser(): User protected function createAuthenticatedUser(): User
{ {
$userGroup = UserGroup::create(['title' => 'Test Group']); $userGroup = UserGroup::create(['title' => 'Test Group']);

View File

@@ -44,6 +44,7 @@ final class CategoryControllerTest extends TestCase
*/ */
use RefreshDatabase; use RefreshDatabase;
#[\Override]
protected function createAuthenticatedUser(): User protected function createAuthenticatedUser(): User
{ {
$userGroup = UserGroup::create(['title' => 'Test Group']); $userGroup = UserGroup::create(['title' => 'Test Group']);

View File

@@ -44,6 +44,7 @@ final class CurrencyControllerTest extends TestCase
*/ */
use RefreshDatabase; use RefreshDatabase;
#[\Override]
protected function createAuthenticatedUser(): User protected function createAuthenticatedUser(): User
{ {
$userGroup = UserGroup::create(['title' => 'Test Group']); $userGroup = UserGroup::create(['title' => 'Test Group']);

View File

@@ -44,6 +44,7 @@ final class ObjectGroupControllerTest extends TestCase
*/ */
use RefreshDatabase; use RefreshDatabase;
#[\Override]
protected function createAuthenticatedUser(): User protected function createAuthenticatedUser(): User
{ {
$userGroup = UserGroup::create(['title' => 'Test Group']); $userGroup = UserGroup::create(['title' => 'Test Group']);

View File

@@ -37,7 +37,7 @@ use Tests\integration\TestCase;
*/ */
final class BillDateCalculatorTest extends TestCase final class BillDateCalculatorTest extends TestCase
{ {
private BillDateCalculator $calculator; private readonly BillDateCalculator $calculator;
public function __construct(string $name) public function __construct(string $name)
{ {

View File

@@ -30,17 +30,11 @@ use Tests\unit\Support\Calendar\Periodicity\IntervalProvider;
readonly class CalculatorProvider readonly class CalculatorProvider
{ {
public IntervalProvider $intervalProvider;
public string $label; 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->label = "{$this->periodicity->name} {$this->intervalProvider->label}";
$this->intervalProvider = $intervalProvider;
$this->periodicity = $periodicity;
$this->label = "{$periodicity->name} {$intervalProvider->label}";
} }
public static function providePeriodicityWithSkippedIntervals(): \Generator public static function providePeriodicityWithSkippedIntervals(): \Generator

View File

@@ -28,14 +28,10 @@ use Carbon\Carbon;
readonly class IntervalProvider readonly class IntervalProvider
{ {
public Carbon $epoch;
public Carbon $expected;
public string $label; public string $label;
public function __construct(Carbon $epoch, Carbon $expected) public function __construct(public Carbon $epoch, public Carbon $expected)
{ {
$this->epoch = $epoch; $this->label = "given {$this->epoch->toDateString()} expects {$this->expected->toDateString()}";
$this->expected = $expected;
$this->label = "given {$epoch->toDateString()} expects {$expected->toDateString()}";
} }
} }

View File

@@ -40,7 +40,7 @@ use Tests\integration\TestCase;
*/ */
final class NavigationAddPeriodTest extends TestCase final class NavigationAddPeriodTest extends TestCase
{ {
private Navigation $navigation; private readonly Navigation $navigation;
public function __construct(string $name) public function __construct(string $name)
{ {

View File

@@ -39,7 +39,7 @@ use Tests\integration\TestCase;
*/ */
final class NavigationEndOfPeriodTest extends TestCase final class NavigationEndOfPeriodTest extends TestCase
{ {
private Navigation $navigation; private readonly Navigation $navigation;
public function __construct(string $name) public function __construct(string $name)
{ {

View File

@@ -38,7 +38,7 @@ use Tests\integration\TestCase;
*/ */
final class NavigationPreferredCarbonFormatByPeriodTest extends TestCase final class NavigationPreferredCarbonFormatByPeriodTest extends TestCase
{ {
private Navigation $navigation; private readonly Navigation $navigation;
public function __construct(string $name) public function __construct(string $name)
{ {

View File

@@ -39,7 +39,7 @@ use Tests\integration\TestCase;
*/ */
final class NavigationPreferredCarbonFormatTest extends TestCase final class NavigationPreferredCarbonFormatTest extends TestCase
{ {
private Navigation $navigation; private readonly Navigation $navigation;
public function __construct(string $name) public function __construct(string $name)
{ {

View File

@@ -39,7 +39,7 @@ use Tests\integration\TestCase;
*/ */
final class NavigationPreferredEndOfPeriodTest extends TestCase final class NavigationPreferredEndOfPeriodTest extends TestCase
{ {
private Navigation $navigation; private readonly Navigation $navigation;
public function __construct(string $name) public function __construct(string $name)
{ {

View File

@@ -39,7 +39,7 @@ use Tests\integration\TestCase;
*/ */
final class NavigationPreferredRangeFormatTest extends TestCase final class NavigationPreferredRangeFormatTest extends TestCase
{ {
private Navigation $navigation; private readonly Navigation $navigation;
public function __construct(string $name) public function __construct(string $name)
{ {

View File

@@ -39,7 +39,7 @@ use Tests\integration\TestCase;
*/ */
final class NavigationPreferredSqlFormatTest extends TestCase final class NavigationPreferredSqlFormatTest extends TestCase
{ {
private Navigation $navigation; private readonly Navigation $navigation;
public function __construct(string $name) public function __construct(string $name)
{ {

View File

@@ -40,7 +40,7 @@ use Tests\integration\TestCase;
*/ */
final class NavigationStartOfPeriodTest extends TestCase final class NavigationStartOfPeriodTest extends TestCase
{ {
private Navigation $navigation; private readonly Navigation $navigation;
public function __construct(string $name) public function __construct(string $name)
{ {