mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Various code cleanup.
This commit is contained in:
@@ -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
|
||||
|
@@ -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(
|
||||
|
@@ -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
|
||||
{
|
||||
|
@@ -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.');
|
||||
|
@@ -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));
|
||||
|
||||
|
@@ -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
|
||||
{
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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
|
||||
|
@@ -100,7 +100,6 @@ class UpgradesAccountCurrencies extends Command
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function updateCurrenciesForUser(User $user): void
|
||||
{
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
{
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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
|
||||
|
@@ -65,7 +65,6 @@ trait VerifiesAccessToken
|
||||
/**
|
||||
* Returns false when given token does not match given user token.
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
protected function verifyAccessToken(): bool
|
||||
{
|
||||
|
Reference in New Issue
Block a user