mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Various code cleanup and fixed alignments.
This commit is contained in:
@@ -37,7 +37,7 @@ class CreateDatabase extends Command
|
||||
|
||||
protected $description = 'Tries to create the database if it doesn\'t exist yet.';
|
||||
|
||||
protected $signature = 'firefly-iii:create-database';
|
||||
protected $signature = 'firefly-iii:create-database';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -52,8 +52,8 @@ class CreateDatabase extends Command
|
||||
return 0;
|
||||
}
|
||||
// try to set up a raw connection:
|
||||
$exists = false;
|
||||
$dsn = sprintf('mysql:host=%s;port=%d;charset=utf8mb4', env('DB_HOST', 'localhost'), env('DB_PORT', '3306'));
|
||||
$exists = false;
|
||||
$dsn = sprintf('mysql:host=%s;port=%d;charset=utf8mb4', env('DB_HOST', 'localhost'), env('DB_PORT', '3306'));
|
||||
|
||||
if ('' !== env('DB_SOCKET', '')) {
|
||||
$dsn = sprintf('mysql:unix_socket=%s;charset=utf8mb4', env('DB_SOCKET', ''));
|
||||
@@ -78,7 +78,7 @@ class CreateDatabase extends Command
|
||||
// only continue when no error.
|
||||
// with PDO, try to list DB's (
|
||||
/** @var array $stmt */
|
||||
$stmt = $pdo->query('SHOW DATABASES;');
|
||||
$stmt = $pdo->query('SHOW DATABASES;');
|
||||
// slightly more complex but less error-prone.
|
||||
foreach ($stmt as $row) {
|
||||
$name = $row['Database'] ?? false;
|
||||
|
@@ -38,7 +38,7 @@ class CreateFirstUser extends Command
|
||||
|
||||
protected $description = 'Creates a new user and gives admin rights. Outputs the password on the command line. Strictly for testing.';
|
||||
|
||||
protected $signature = 'firefly-iii:create-first-user {email}';
|
||||
protected $signature = 'firefly-iii:create-first-user {email}';
|
||||
private UserRepositoryInterface $repository;
|
||||
|
||||
/**
|
||||
@@ -52,7 +52,7 @@ class CreateFirstUser extends Command
|
||||
return 1;
|
||||
}
|
||||
$this->stupidLaravel();
|
||||
$count = $this->repository->count();
|
||||
$count = $this->repository->count();
|
||||
if ($count > 0) {
|
||||
$this->friendlyError('Already have more than zero users in DB.');
|
||||
|
||||
|
@@ -53,8 +53,8 @@ class ForceDecimalSize extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'This command resizes DECIMAL columns in MySQL or PostgreSQL and correct amounts (only MySQL).';
|
||||
protected $signature = 'firefly-iii:force-decimal-size';
|
||||
protected $description = 'This command resizes DECIMAL columns in MySQL or PostgreSQL and correct amounts (only MySQL).';
|
||||
protected $signature = 'firefly-iii:force-decimal-size';
|
||||
private string $cast;
|
||||
private array $classes
|
||||
= [
|
||||
@@ -73,7 +73,7 @@ class ForceDecimalSize extends Command
|
||||
private string $operator;
|
||||
private string $regularExpression;
|
||||
private array $tables
|
||||
= [
|
||||
= [
|
||||
'accounts' => ['virtual_balance'],
|
||||
'auto_budgets' => ['amount'],
|
||||
'available_budgets' => ['amount'],
|
||||
@@ -233,7 +233,7 @@ class ForceDecimalSize extends Command
|
||||
$regularExpression = $this->regularExpression;
|
||||
|
||||
/** @var Builder $query */
|
||||
$query = Account::leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
|
||||
$query = Account::leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
|
||||
->where('account_meta.name', 'currency_id')
|
||||
->where('account_meta.data', json_encode((string)$currency->id))
|
||||
;
|
||||
@@ -246,7 +246,7 @@ class ForceDecimalSize extends Command
|
||||
);
|
||||
}
|
||||
});
|
||||
$result = $query->get(['accounts.*']);
|
||||
$result = $query->get(['accounts.*']);
|
||||
if (0 === $result->count()) {
|
||||
$this->friendlyPositive(sprintf('All accounts in %s are OK', $currency->code));
|
||||
|
||||
@@ -257,7 +257,7 @@ class ForceDecimalSize extends Command
|
||||
foreach ($result as $account) {
|
||||
/** @var string $field */
|
||||
foreach ($fields as $field) {
|
||||
$value = $account->{$field};
|
||||
$value = $account->{$field};
|
||||
if (null === $value) {
|
||||
continue;
|
||||
}
|
||||
@@ -282,7 +282,7 @@ class ForceDecimalSize extends Command
|
||||
$regularExpression = $this->regularExpression;
|
||||
|
||||
/** @var Builder $query */
|
||||
$query = $class::where('transaction_currency_id', $currency->id)->where(
|
||||
$query = $class::where('transaction_currency_id', $currency->id)->where(
|
||||
static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void {
|
||||
/** @var string $field */
|
||||
foreach ($fields as $field) {
|
||||
@@ -295,7 +295,7 @@ class ForceDecimalSize extends Command
|
||||
}
|
||||
);
|
||||
|
||||
$result = $query->get(['*']);
|
||||
$result = $query->get(['*']);
|
||||
if (0 === $result->count()) {
|
||||
$this->friendlyPositive(sprintf('All %s in %s are OK', $table, $currency->code));
|
||||
|
||||
@@ -306,7 +306,7 @@ class ForceDecimalSize extends Command
|
||||
foreach ($result as $item) {
|
||||
/** @var string $field */
|
||||
foreach ($fields as $field) {
|
||||
$value = $item->{$field};
|
||||
$value = $item->{$field};
|
||||
if (null === $value) {
|
||||
continue;
|
||||
}
|
||||
@@ -329,7 +329,7 @@ class ForceDecimalSize extends Command
|
||||
$regularExpression = $this->regularExpression;
|
||||
|
||||
/** @var Builder $query */
|
||||
$query = PiggyBankEvent::leftJoin('piggy_banks', 'piggy_bank_events.piggy_bank_id', '=', 'piggy_banks.id')
|
||||
$query = PiggyBankEvent::leftJoin('piggy_banks', 'piggy_bank_events.piggy_bank_id', '=', 'piggy_banks.id')
|
||||
->leftJoin('accounts', 'piggy_banks.account_id', '=', 'accounts.id')
|
||||
->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
|
||||
->where('account_meta.name', 'currency_id')
|
||||
@@ -345,7 +345,7 @@ class ForceDecimalSize extends Command
|
||||
})
|
||||
;
|
||||
|
||||
$result = $query->get(['piggy_bank_events.*']);
|
||||
$result = $query->get(['piggy_bank_events.*']);
|
||||
if (0 === $result->count()) {
|
||||
$this->friendlyPositive(sprintf('All piggy bank events in %s are OK', $currency->code));
|
||||
|
||||
@@ -356,7 +356,7 @@ class ForceDecimalSize extends Command
|
||||
foreach ($result as $item) {
|
||||
/** @var string $field */
|
||||
foreach ($fields as $field) {
|
||||
$value = $item->{$field};
|
||||
$value = $item->{$field};
|
||||
if (null === $value) {
|
||||
continue;
|
||||
}
|
||||
@@ -382,7 +382,7 @@ class ForceDecimalSize extends Command
|
||||
|
||||
// select all piggy bank repetitions with this currency and issue.
|
||||
/** @var Builder $query */
|
||||
$query = PiggyBankRepetition::leftJoin('piggy_banks', 'piggy_bank_repetitions.piggy_bank_id', '=', 'piggy_banks.id')
|
||||
$query = PiggyBankRepetition::leftJoin('piggy_banks', 'piggy_bank_repetitions.piggy_bank_id', '=', 'piggy_banks.id')
|
||||
->leftJoin('accounts', 'piggy_banks.account_id', '=', 'accounts.id')
|
||||
->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
|
||||
->where('account_meta.name', 'currency_id')
|
||||
@@ -398,7 +398,7 @@ class ForceDecimalSize extends Command
|
||||
})
|
||||
;
|
||||
|
||||
$result = $query->get(['piggy_bank_repetitions.*']);
|
||||
$result = $query->get(['piggy_bank_repetitions.*']);
|
||||
if (0 === $result->count()) {
|
||||
$this->friendlyPositive(sprintf('All piggy bank repetitions in %s', $currency->code));
|
||||
|
||||
@@ -409,7 +409,7 @@ class ForceDecimalSize extends Command
|
||||
foreach ($result as $item) {
|
||||
/** @var string $field */
|
||||
foreach ($fields as $field) {
|
||||
$value = $item->{$field};
|
||||
$value = $item->{$field};
|
||||
if (null === $value) {
|
||||
continue;
|
||||
}
|
||||
@@ -434,7 +434,7 @@ class ForceDecimalSize extends Command
|
||||
$regularExpression = $this->regularExpression;
|
||||
|
||||
/** @var Builder $query */
|
||||
$query = PiggyBank::leftJoin('accounts', 'piggy_banks.account_id', '=', 'accounts.id')
|
||||
$query = PiggyBank::leftJoin('accounts', 'piggy_banks.account_id', '=', 'accounts.id')
|
||||
->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
|
||||
->where('account_meta.name', 'currency_id')
|
||||
->where('account_meta.data', json_encode((string)$currency->id))
|
||||
@@ -449,7 +449,7 @@ class ForceDecimalSize extends Command
|
||||
})
|
||||
;
|
||||
|
||||
$result = $query->get(['piggy_banks.*']);
|
||||
$result = $query->get(['piggy_banks.*']);
|
||||
if (0 === $result->count()) {
|
||||
$this->friendlyPositive(sprintf('All piggy banks in %s are OK', $currency->code));
|
||||
|
||||
@@ -460,7 +460,7 @@ class ForceDecimalSize extends Command
|
||||
foreach ($result as $item) {
|
||||
/** @var string $field */
|
||||
foreach ($fields as $field) {
|
||||
$value = $item->{$field};
|
||||
$value = $item->{$field};
|
||||
if (null === $value) {
|
||||
continue;
|
||||
}
|
||||
@@ -480,7 +480,7 @@ class ForceDecimalSize extends Command
|
||||
{
|
||||
// select all transactions with this currency and issue.
|
||||
/** @var Builder $query */
|
||||
$query = Transaction::where('transaction_currency_id', $currency->id)->where(
|
||||
$query = Transaction::where('transaction_currency_id', $currency->id)->where(
|
||||
DB::raw(sprintf('CAST(amount as %s)', $this->cast)), // @phpstan-ignore-line
|
||||
$this->operator,
|
||||
DB::raw(sprintf($this->regularExpression, $currency->decimal_places))
|
||||
@@ -493,7 +493,7 @@ class ForceDecimalSize extends Command
|
||||
|
||||
/** @var Transaction $item */
|
||||
foreach ($result as $item) {
|
||||
$value = $item->amount;
|
||||
$value = $item->amount;
|
||||
if ('' === $value) {
|
||||
continue;
|
||||
}
|
||||
@@ -506,7 +506,7 @@ class ForceDecimalSize extends Command
|
||||
|
||||
// select all transactions with this FOREIGN currency and issue.
|
||||
/** @var Builder $query */
|
||||
$query = Transaction::where('foreign_currency_id', $currency->id)->where(
|
||||
$query = Transaction::where('foreign_currency_id', $currency->id)->where(
|
||||
DB::raw(sprintf('CAST(foreign_amount as %s)', $this->cast)), // @phpstan-ignore-line
|
||||
$this->operator,
|
||||
DB::raw(sprintf($this->regularExpression, $currency->decimal_places))
|
||||
@@ -521,7 +521,7 @@ class ForceDecimalSize extends Command
|
||||
|
||||
/** @var Transaction $item */
|
||||
foreach ($result as $item) {
|
||||
$value = $item->foreign_amount;
|
||||
$value = $item->foreign_amount;
|
||||
if (null === $value) {
|
||||
continue;
|
||||
}
|
||||
|
@@ -42,7 +42,7 @@ class ForceMigration extends Command
|
||||
|
||||
protected $description = 'This command will force-run all database migrations.';
|
||||
|
||||
protected $signature = 'firefly-iii:force-migrations
|
||||
protected $signature = 'firefly-iii:force-migrations
|
||||
{--user=1 : The user ID.}
|
||||
{--token= : The user\'s access token.}';
|
||||
|
||||
|
@@ -33,7 +33,7 @@ class OutputVersion extends Command
|
||||
{
|
||||
protected $description = 'Outputs the Firefly III version';
|
||||
|
||||
protected $signature = 'firefly-iii:output-version';
|
||||
protected $signature = 'firefly-iii:output-version';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
|
@@ -37,7 +37,7 @@ class ScanAttachments extends Command
|
||||
|
||||
protected $description = 'Rescan all attachments and re-set the correct MD5 hash and mime.';
|
||||
|
||||
protected $signature = 'firefly-iii:scan-attachments';
|
||||
protected $signature = 'firefly-iii:scan-attachments';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -63,7 +63,7 @@ class ScanAttachments extends Command
|
||||
app('log')->error(sprintf('Could not decrypt data of attachment #%d: %s', $attachment->id, $e->getMessage()));
|
||||
$decryptedContent = $encryptedContent;
|
||||
}
|
||||
$tempFileName = tempnam(sys_get_temp_dir(), 'FireflyIII');
|
||||
$tempFileName = tempnam(sys_get_temp_dir(), 'FireflyIII');
|
||||
if (false === $tempFileName) {
|
||||
app('log')->error(sprintf('Could not create temporary file for attachment #%d', $attachment->id));
|
||||
|
||||
|
@@ -36,7 +36,7 @@ class SetLatestVersion extends Command
|
||||
|
||||
protected $description = 'Set latest version in DB.';
|
||||
|
||||
protected $signature = 'firefly-iii:set-latest-version {--james-is-cool}';
|
||||
protected $signature = 'firefly-iii:set-latest-version {--james-is-cool}';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
|
@@ -35,7 +35,7 @@ class UpgradeFireflyInstructions extends Command
|
||||
|
||||
protected $description = 'Instructions in case of upgrade trouble.';
|
||||
|
||||
protected $signature = 'firefly:instructions {task}';
|
||||
protected $signature = 'firefly:instructions {task}';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -61,8 +61,8 @@ class UpgradeFireflyInstructions extends Command
|
||||
$version = (string)config('firefly.version');
|
||||
|
||||
/** @var array $config */
|
||||
$config = config('upgrade.text.upgrade');
|
||||
$text = '';
|
||||
$config = config('upgrade.text.upgrade');
|
||||
$text = '';
|
||||
|
||||
/** @var string $compare */
|
||||
foreach (array_keys($config) as $compare) {
|
||||
@@ -99,8 +99,8 @@ class UpgradeFireflyInstructions extends Command
|
||||
*/
|
||||
private function showLogo(): void
|
||||
{
|
||||
$today = date('m-d');
|
||||
$month = date('m');
|
||||
$today = date('m-d');
|
||||
$month = date('m');
|
||||
// variation in colors and effects just because I can!
|
||||
// default is Ukraine flag:
|
||||
$colors = ['blue', 'blue', 'blue', 'yellow', 'yellow', 'yellow', 'default', 'default'];
|
||||
@@ -171,8 +171,8 @@ class UpgradeFireflyInstructions extends Command
|
||||
$version = (string)config('firefly.version');
|
||||
|
||||
/** @var array $config */
|
||||
$config = config('upgrade.text.install');
|
||||
$text = '';
|
||||
$config = config('upgrade.text.install');
|
||||
$text = '';
|
||||
|
||||
/** @var string $compare */
|
||||
foreach (array_keys($config) as $compare) {
|
||||
|
@@ -38,7 +38,7 @@ class VerifySecurityAlerts extends Command
|
||||
|
||||
protected $description = 'Verify security alerts';
|
||||
|
||||
protected $signature = 'firefly-iii:verify-security-alerts';
|
||||
protected $signature = 'firefly-iii:verify-security-alerts';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
|
Reference in New Issue
Block a user