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

@@ -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();
}
}

View File

@@ -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,

View File

@@ -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,

View File

@@ -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);
}

View File

@@ -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,