Various code cleanup.

This commit is contained in:
James Cole
2025-10-05 12:57:58 +02:00
parent 072212c112
commit 6341743cf9
169 changed files with 482 additions and 305 deletions

View File

@@ -92,7 +92,6 @@ class ConvertsDatesToUTC extends Command
$this->friendlyInfo(sprintf('Converting field "%s" of model "%s" to UTC.', $field, $shortModel));
$items->each(
function ($item) use ($field, $timezoneField): void {
/** @var Carbon $date */
$date = Carbon::parse($item->{$field}, $item->{$timezoneField}); // @phpstan-ignore-line
$date->setTimezone('UTC');
$item->{$field} = $date->format('Y-m-d H:i:s'); // @phpstan-ignore-line

View File

@@ -135,9 +135,7 @@ class RemovesOrphanedTransactions extends Command
// delete journals
/** @var null|TransactionJournal $journal */
$journal = TransactionJournal::find($transaction->transaction_journal_id);
if (null !== $journal) {
$journal->delete();
}
$journal?->delete();
Transaction::where('transaction_journal_id', $transaction->transaction_journal_id)->delete();
$this->friendlyWarning(
sprintf(

View File

@@ -40,6 +40,7 @@ use Exception;
use Illuminate\Support\Facades\Log;
use InvalidArgumentException;
use Safe\Exceptions\FilesystemException;
use function Safe\file_put_contents;
class ExportsData extends Command
@@ -275,7 +276,11 @@ class ExportsData extends Command
}
/**
* @param array $options
* @param array $data
*
* @throws FireflyException
* @throws FilesystemException
*/
private function exportData(array $options, array $data): void
{

View File

@@ -42,7 +42,7 @@ class CallsLaravelPassportKeys extends Command
*/
public function handle(): int
{
Artisan::call('passport:keys --no-interaction', []);
Artisan::call('passport:keys --no-interaction');
$result = Artisan::output();
if (str_contains($result, 'Encryption keys already exist')) {
$this->friendlyInfo('Encryption keys exist already.');

View File

@@ -156,7 +156,6 @@ class ForcesDecimalSize extends Command
*/
private function correctAmountsByCurrency(): void
{
/** @var Collection $enabled */
$enabled = TransactionCurrency::whereEnabled(1)->get();
/** @var TransactionCurrency $currency */
@@ -301,7 +300,7 @@ class ForcesDecimalSize extends Command
}
);
$result = $query->get(['*']);
$result = $query->get();
if (0 === $result->count()) {
$this->friendlyPositive(sprintf('All %s in %s are OK', $table, $currency->code));
@@ -533,7 +532,7 @@ class ForcesDecimalSize extends Command
DB::raw(sprintf($this->regularExpression, $currency->decimal_places))
);
$result = $query->get(['*']);
$result = $query->get();
if (0 === $result->count()) {
$this->friendlyPositive(sprintf('All transactions in foreign currency %s are OK', $currency->code));

View File

@@ -31,6 +31,7 @@ use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use League\Flysystem\FilesystemException;
use Safe\Exceptions\JsonException;
use function Safe\json_decode;
class VerifySecurityAlerts extends Command
@@ -44,7 +45,9 @@ class VerifySecurityAlerts extends Command
/**
* Execute the console command.
*
* @return int
* @throws FilesystemException
* @throws JsonException
*/
public function handle(): int
{

View File

@@ -54,7 +54,6 @@ class AddsTransactionIdentifiers extends Command
* When either of these are the same amount, FF3 can't keep them apart: +3/-3, +3/-3, +3/-3. This happens more
* often than you would think. So each set gets a number (1,2,3) to keep them apart.
*
* @throws FireflyException
*/
public function handle(): int
{
@@ -101,11 +100,8 @@ class AddsTransactionIdentifiers extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool) $configVar->data;
}
return (bool)$configVar?->data;
return false;
}
/**

View File

@@ -99,11 +99,8 @@ class RemovesDatabaseDecryption extends Command
} catch (FireflyException $e) {
Log::error($e->getMessage());
}
if (null !== $configVar) {
return (bool) $configVar->data;
}
return (bool)$configVar?->data;
return false;
}
private function decryptField(string $table, string $field): void

View File

@@ -100,7 +100,6 @@ class UpgradesAccountCurrencies extends Command
}
/**
* @throws FireflyException
*/
private function updateCurrenciesForUser(User $user): void
{

View File

@@ -83,11 +83,8 @@ class UpgradesAccountMetaData extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool) $configVar->data;
}
return (bool)$configVar?->data;
return false;
}
private function markAsExecuted(): void

View File

@@ -93,11 +93,8 @@ class UpgradesAttachments extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool) $configVar->data;
}
return (bool)$configVar?->data;
return false;
}
private function markAsExecuted(): void

View File

@@ -99,17 +99,13 @@ class UpgradesBillsToRules extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool) $configVar->data;
}
return (bool)$configVar?->data;
return false;
}
/**
* Migrate bills to new rule structure for a specific user.
*
* @throws FireflyException
*/
private function migrateUser(User $user): void
{

View File

@@ -85,11 +85,8 @@ class UpgradesBudgetLimits extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool) $configVar->data;
}
return (bool)$configVar?->data;
return false;
}
private function markAsExecuted(): void

View File

@@ -66,11 +66,8 @@ class UpgradesCurrencyPreferences extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool)$configVar->data;
}
return (bool)$configVar?->data;
return false;
}
private function runUpgrade(): void

View File

@@ -87,11 +87,8 @@ class UpgradesJournalNotes extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool) $configVar->data;
}
return (bool)$configVar?->data;
return false;
}
private function markAsExecuted(): void

View File

@@ -62,11 +62,8 @@ class UpgradesLiabilities extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool) $configVar->data;
}
return (bool)$configVar?->data;
return false;
}
private function upgradeLiabilities(): void

View File

@@ -64,11 +64,8 @@ class UpgradesLiabilitiesEight extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool) $configVar->data;
}
return (bool)$configVar?->data;
return false;
}
private function upgradeLiabilities(): void

View File

@@ -65,11 +65,8 @@ class UpgradesMultiPiggyBanks extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool) $configVar->data;
}
return (bool)$configVar?->data;
return false;
}
private function upgradePiggyBanks(): void

View File

@@ -61,11 +61,8 @@ class UpgradesPrimaryCurrencyAmounts extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool) $configVar->data;
}
return (bool)$configVar?->data;
return false;
}
private function markAsExecuted(): void

View File

@@ -66,11 +66,8 @@ class UpgradesRecurrenceMetaData extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool) $configVar->data;
}
return (bool)$configVar?->data;
return false;
}
private function migrateMetaData(): int

View File

@@ -64,11 +64,8 @@ class UpgradesRuleActions extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool) $configVar->data;
}
return (bool)$configVar?->data;
return false;
}
private function replaceEqualSign(): void

View File

@@ -58,11 +58,8 @@ class UpgradesTagLocations extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool) $configVar->data;
}
return (bool)$configVar?->data;
return false;
}
private function migrateTagLocations(): void

View File

@@ -98,11 +98,8 @@ class UpgradesToGroups extends Command
private function isMigrated(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool) $configVar->data;
}
return (bool)$configVar?->data;
return false;
}
/**

View File

@@ -106,11 +106,8 @@ class UpgradesTransferCurrencies extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool) $configVar->data;
}
return (bool)$configVar?->data;
return false;
}
/**

View File

@@ -87,11 +87,8 @@ class UpgradesVariousCurrencyInformation extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool) $configVar->data;
}
return (bool)$configVar?->data;
return false;
}
/**

View File

@@ -64,11 +64,8 @@ class UpgradesWebhooks extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool)$configVar->data;
}
return (bool)$configVar?->data;
return false;
}
private function upgradeWebhooks(): void

View File

@@ -65,7 +65,6 @@ trait VerifiesAccessToken
/**
* Returns false when given token does not match given user token.
*
* @throws FireflyException
*/
protected function verifyAccessToken(): bool
{