Update configuration and fix some files.

This commit is contained in:
James Cole
2025-05-27 17:02:18 +02:00
parent c074fec0a7
commit d8f512ca3a
31 changed files with 154 additions and 111 deletions

View File

@@ -120,7 +120,7 @@ class AddsTransactionIdentifiers extends Command
/** @var Transaction $transaction */
foreach ($transactions as $transaction) {
$opposing = $this->findOpposing($transaction, $exclude);
if (null !== $opposing) {
if ($opposing instanceof Transaction) {
// give both a new identifier:
$transaction->identifier = $identifier;
$opposing->identifier = $identifier;

View File

@@ -34,6 +34,8 @@ use Illuminate\Support\Facades\DB;
use JsonException;
use stdClass;
use function Safe\json_decode;
class RemovesDatabaseDecryption extends Command
{
use ShowsFriendlyMessages;
@@ -169,7 +171,7 @@ class RemovesDatabaseDecryption extends Command
{
// try to json_decrypt the value.
try {
$newValue = \Safe\json_decode($value, true, 512, JSON_THROW_ON_ERROR) ?? $value;
$newValue = json_decode($value, true, 512, JSON_THROW_ON_ERROR) ?? $value;
} catch (JsonException $e) {
$message = sprintf('Could not JSON decode preference row #%d: %s. This does not have to be a problem.', $id, $e->getMessage());
$this->friendlyError($message);

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Console\Commands\Upgrade;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Enums\AccountTypeEnum;
use FireflyIII\Exceptions\FireflyException;
@@ -141,7 +142,7 @@ class UpgradesAccountCurrencies extends Command
return;
}
// do not match and opening balance id is not null.
if ($accountCurrency !== $obCurrency && null !== $openingBalance) {
if ($accountCurrency !== $obCurrency && $openingBalance instanceof TransactionJournal) {
// update opening balance:
$openingBalance->transaction_currency_id = $accountCurrency;
$openingBalance->save();

View File

@@ -123,7 +123,7 @@ class UpgradesBillsToRules extends Command
$groupTitle = (string) trans('firefly.rulegroup_for_bills_title', [], $language);
$ruleGroup = $this->ruleGroupRepository->findByTitle($groupTitle);
if (null === $ruleGroup) {
if (!$ruleGroup instanceof RuleGroup) {
$ruleGroup = $this->ruleGroupRepository->store(
[
'title' => (string) trans('firefly.rulegroup_for_bills_title', [], $language),

View File

@@ -27,8 +27,10 @@ namespace FireflyIII\Console\Commands\Upgrade;
use Illuminate\Support\Facades\Log;
use Safe\Exceptions\InfoException;
use function Safe\set_time_limit;
try {
\Safe\set_time_limit(0);
set_time_limit(0);
} catch (InfoException) {
Log::warning('set_time_limit returned false. This could be an issue, unless you also run XDebug.');
}

View File

@@ -122,7 +122,7 @@ class UpgradesLiabilities extends Command
{
$source = $this->getSourceTransaction($openingBalance);
$destination = $this->getDestinationTransaction($openingBalance);
if (null === $source || null === $destination) {
if (!$source instanceof Transaction || !$destination instanceof Transaction) {
return;
}
// source MUST be the liability.

View File

@@ -30,6 +30,8 @@ use FireflyIII\Models\RecurrenceMeta;
use FireflyIII\Models\RecurrenceTransactionMeta;
use Illuminate\Console\Command;
use function Safe\json_encode;
class UpgradesRecurrenceMetaData extends Command
{
use ShowsFriendlyMessages;
@@ -100,7 +102,7 @@ class UpgradesRecurrenceMetaData extends Command
if ('tags' === $meta->name) {
$array = explode(',', $meta->value);
$value = \Safe\json_encode($array, JSON_THROW_ON_ERROR);
$value = json_encode($array, JSON_THROW_ON_ERROR);
}
RecurrenceTransactionMeta::create(

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Console\Commands\Upgrade;
use Carbon\Carbon;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Factory\TransactionGroupFactory;
use FireflyIII\Models\Budget;
@@ -192,7 +193,7 @@ class UpgradesToGroups extends Command
app('log')->debug(sprintf('Now going to add transaction #%d to the array.', $transaction->id));
$opposingTr = $this->findOpposingTransaction($journal, $transaction);
if (null === $opposingTr) {
if (!$opposingTr instanceof Transaction) {
$this->friendlyError(
sprintf(
'Journal #%d has no opposing transaction for transaction #%d. Cannot upgrade this entry.',
@@ -367,8 +368,8 @@ class UpgradesToGroups extends Command
{
$groupId = DB::table('transaction_groups')->insertGetId(
[
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
'updated_at' => Carbon::now()->format('Y-m-d H:i:s'),
'title' => null,
'user_id' => $array['user_id'],
]

View File

@@ -202,7 +202,7 @@ class UpgradesTransferCurrencies extends Command
{
$this->sourceTransaction = $this->getSourceTransaction($journal);
$this->sourceAccount = $this->sourceTransaction?->account;
$this->sourceCurrency = null === $this->sourceAccount ? null : $this->getCurrency($this->sourceAccount);
$this->sourceCurrency = $this->sourceAccount instanceof Account ? $this->getCurrency($this->sourceAccount) : null;
}
private function getSourceTransaction(TransactionJournal $transfer): ?Transaction
@@ -221,7 +221,7 @@ class UpgradesTransferCurrencies extends Command
return $this->accountCurrencies[$accountId];
}
$currency = $this->accountRepos->getAccountCurrency($account);
if (null === $currency) {
if (!$currency instanceof TransactionCurrency) {
$this->accountCurrencies[$accountId] = 0;
return null;
@@ -238,7 +238,7 @@ class UpgradesTransferCurrencies extends Command
{
$this->destinationTransaction = $this->getDestinationTransaction($journal);
$this->destinationAccount = $this->destinationTransaction?->account;
$this->destinationCurrency = null === $this->destinationAccount ? null : $this->getCurrency($this->destinationAccount);
$this->destinationCurrency = $this->destinationAccount instanceof Account ? $this->getCurrency($this->destinationAccount) : null;
}
private function getDestinationTransaction(TransactionJournal $transfer): ?Transaction
@@ -252,15 +252,15 @@ class UpgradesTransferCurrencies extends Command
*/
private function isEmptyTransactions(): bool
{
return null === $this->sourceTransaction || null === $this->destinationTransaction
|| null === $this->sourceAccount
|| null === $this->destinationAccount;
return !$this->sourceTransaction instanceof Transaction || !$this->destinationTransaction instanceof Transaction
|| !$this->sourceAccount instanceof Account
|| !$this->destinationAccount instanceof Account;
}
private function isNoCurrencyPresent(): bool
{
// source account must have a currency preference.
if (null === $this->sourceCurrency) {
if (!$this->sourceCurrency instanceof TransactionCurrency) {
$message = sprintf('Account #%d ("%s") must have currency preference but has none.', $this->sourceAccount->id, $this->sourceAccount->name);
app('log')->error($message);
$this->friendlyError($message);
@@ -269,7 +269,7 @@ class UpgradesTransferCurrencies extends Command
}
// destination account must have a currency preference.
if (null === $this->destinationCurrency) {
if (!$this->destinationCurrency instanceof TransactionCurrency) {
$message = sprintf(
'Account #%d ("%s") must have currency preference but has none.',
$this->destinationAccount->id,
@@ -290,7 +290,7 @@ class UpgradesTransferCurrencies extends Command
*/
private function fixSourceNoCurrency(): void
{
if (null === $this->sourceTransaction->transaction_currency_id && null !== $this->sourceCurrency) {
if (null === $this->sourceTransaction->transaction_currency_id && $this->sourceCurrency instanceof TransactionCurrency) {
$this->sourceTransaction
->transaction_currency_id
= $this->sourceCurrency->id
@@ -312,7 +312,7 @@ class UpgradesTransferCurrencies extends Command
*/
private function fixSourceUnmatchedCurrency(): void
{
if (null !== $this->sourceCurrency
if ($this->sourceCurrency instanceof TransactionCurrency
&& null === $this->sourceTransaction->foreign_amount
&& (int) $this->sourceTransaction->transaction_currency_id !== $this->sourceCurrency->id
) {
@@ -336,7 +336,7 @@ class UpgradesTransferCurrencies extends Command
*/
private function fixDestNoCurrency(): void
{
if (null === $this->destinationTransaction->transaction_currency_id && null !== $this->destinationCurrency) {
if (null === $this->destinationTransaction->transaction_currency_id && $this->destinationCurrency instanceof TransactionCurrency) {
$this->destinationTransaction
->transaction_currency_id
= $this->destinationCurrency->id
@@ -358,7 +358,7 @@ class UpgradesTransferCurrencies extends Command
*/
private function fixDestinationUnmatchedCurrency(): void
{
if (null !== $this->destinationCurrency
if ($this->destinationCurrency instanceof TransactionCurrency
&& null === $this->destinationTransaction->foreign_amount
&& (int) $this->destinationTransaction->transaction_currency_id !== $this->destinationCurrency->id
) {

View File

@@ -120,7 +120,7 @@ class UpgradesVariousCurrencyInformation extends Command
$leadTransaction = $this->getLeadTransaction($journal);
if (null === $leadTransaction) {
if (!$leadTransaction instanceof Transaction) {
$this->friendlyError(sprintf('Could not reliably determine which transaction is in the lead for transaction journal #%d.', $journal->id));
return;
@@ -129,7 +129,7 @@ class UpgradesVariousCurrencyInformation extends Command
$account = $leadTransaction->account;
$currency = $this->getCurrency($account);
$isMultiCurrency = $this->isMultiCurrency($account);
if (null === $currency) {
if (!$currency instanceof TransactionCurrency) {
$this->friendlyError(
sprintf(
'Account #%d ("%s") has no currency preference, so transaction journal #%d can\'t be corrected',
@@ -227,7 +227,7 @@ class UpgradesVariousCurrencyInformation extends Command
return $this->accountCurrencies[$accountId];
}
$currency = $this->accountRepos->getAccountCurrency($account);
if (null === $currency) {
if (!$currency instanceof TransactionCurrency) {
$this->accountCurrencies[$accountId] = 0;
return null;