mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Clean up code.
This commit is contained in:
@@ -54,8 +54,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', ''));
|
||||
@@ -79,7 +79,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;
|
||||
|
@@ -42,7 +42,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;
|
||||
|
||||
/**
|
||||
|
@@ -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
|
||||
= [
|
||||
@@ -260,7 +260,7 @@ class ForceDecimalSize extends Command
|
||||
continue;
|
||||
}
|
||||
// fix $field by rounding it down correctly.
|
||||
$pow = 10** $currency->decimal_places;
|
||||
$pow = 10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string)round($value * $pow), (string)$pow, 12);
|
||||
$this->friendlyInfo(sprintf('Account #%d has %s with value "%s", this has been corrected to "%s".', $account->id, $field, $value, $correct));
|
||||
Account::find($account->id)->update([$field => $correct]);
|
||||
@@ -313,7 +313,7 @@ class ForceDecimalSize extends Command
|
||||
continue;
|
||||
}
|
||||
// fix $field by rounding it down correctly.
|
||||
$pow = 10** $currency->decimal_places;
|
||||
$pow = 10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string)round($value * $pow), (string)$pow, 12);
|
||||
$this->friendlyWarning(sprintf('%s #%d has %s with value "%s", this has been corrected to "%s".', $table, $item->id, $field, $value, $correct));
|
||||
$class::find($item->id)->update([$field => $correct]);
|
||||
@@ -366,7 +366,7 @@ class ForceDecimalSize extends Command
|
||||
continue;
|
||||
}
|
||||
// fix $field by rounding it down correctly.
|
||||
$pow = 10** $currency->decimal_places;
|
||||
$pow = 10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string)round($value * $pow), (string)$pow, 12);
|
||||
$this->friendlyWarning(
|
||||
sprintf('Piggy bank event #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct)
|
||||
@@ -421,7 +421,7 @@ class ForceDecimalSize extends Command
|
||||
continue;
|
||||
}
|
||||
// fix $field by rounding it down correctly.
|
||||
$pow = 10** $currency->decimal_places;
|
||||
$pow = 10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string)round($value * $pow), (string)$pow, 12);
|
||||
$this->friendlyWarning(
|
||||
sprintf('Piggy bank repetition #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct)
|
||||
@@ -475,7 +475,7 @@ class ForceDecimalSize extends Command
|
||||
continue;
|
||||
}
|
||||
// fix $field by rounding it down correctly.
|
||||
$pow = 10** $currency->decimal_places;
|
||||
$pow = 10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string)round($value * $pow), (string)$pow, 12);
|
||||
$this->friendlyWarning(sprintf('Piggy bank #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct));
|
||||
PiggyBank::find($item->id)->update([$field => $correct]);
|
||||
@@ -512,7 +512,7 @@ class ForceDecimalSize extends Command
|
||||
continue;
|
||||
}
|
||||
// fix $field by rounding it down correctly.
|
||||
$pow = (float)10** $currency->decimal_places;
|
||||
$pow = (float)10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string)round((float)$value * $pow), (string)$pow, 12);
|
||||
$this->friendlyWarning(sprintf('Transaction #%d has amount with value "%s", this has been corrected to "%s".', $item->id, $value, $correct));
|
||||
Transaction::find($item->id)->update(['amount' => $correct]);
|
||||
@@ -539,7 +539,7 @@ class ForceDecimalSize extends Command
|
||||
continue;
|
||||
}
|
||||
// fix $field by rounding it down correctly.
|
||||
$pow = (float)10** $currency->decimal_places;
|
||||
$pow = (float)10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string)round((float)$value * $pow), (string)$pow, 12);
|
||||
$this->friendlyWarning(
|
||||
sprintf('Transaction #%d has foreign amount with value "%s", this has been corrected to "%s".', $item->id, $value, $correct)
|
||||
|
@@ -67,13 +67,13 @@ class ScanAttachments extends Command
|
||||
$decryptedContent = $encryptedContent;
|
||||
}
|
||||
$tempFileName = tempnam(sys_get_temp_dir(), 'FireflyIII');
|
||||
if(false === $tempFileName) {
|
||||
if (false === $tempFileName) {
|
||||
app('log')->error(sprintf('Could not create temporary file for attachment #%d', $attachment->id));
|
||||
exit(1);
|
||||
}
|
||||
file_put_contents($tempFileName, $decryptedContent);
|
||||
$attachment->md5 = (string) md5_file($tempFileName);
|
||||
$attachment->mime = (string) mime_content_type($tempFileName);
|
||||
$attachment->md5 = (string)md5_file($tempFileName);
|
||||
$attachment->mime = (string)mime_content_type($tempFileName);
|
||||
$attachment->save();
|
||||
$this->friendlyInfo(sprintf('Fixed attachment #%d', $attachment->id));
|
||||
}
|
||||
|
@@ -61,15 +61,15 @@ class UpgradeFireflyInstructions extends Command
|
||||
*/
|
||||
private function updateInstructions(): void
|
||||
{
|
||||
$version = (string) config('firefly.version');
|
||||
$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) {
|
||||
// if string starts with:
|
||||
if (str_starts_with($version, $compare)) {
|
||||
$text = (string) $config[$compare];
|
||||
$text = (string)$config[$compare];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,15 +175,15 @@ class UpgradeFireflyInstructions extends Command
|
||||
*/
|
||||
private function installInstructions(): void
|
||||
{
|
||||
$version = (string) config('firefly.version');
|
||||
$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) {
|
||||
// if string starts with:
|
||||
if (str_starts_with($version, $compare)) {
|
||||
$text = (string) $config[$compare];
|
||||
$text = (string)$config[$compare];
|
||||
}
|
||||
}
|
||||
$this->newLine();
|
||||
|
@@ -27,9 +27,7 @@ namespace FireflyIII\Console\Commands\System;
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Filesystem\FilesystemAdapter;
|
||||
use League\Flysystem\FilesystemException;
|
||||
use League\Flysystem\FilesystemReader;
|
||||
use Storage;
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user