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

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

View File

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

View File

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

View File

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

View File

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