Import statements and update configuration.

This commit is contained in:
James Cole
2025-05-27 16:57:36 +02:00
parent 7c04c4c2bc
commit c074fec0a7
165 changed files with 530 additions and 335 deletions

View File

@@ -42,6 +42,7 @@ use FireflyIII\Support\Facades\Amount;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use ValueError;
class CorrectsAmounts extends Command
{
@@ -234,7 +235,7 @@ class CorrectsAmounts extends Command
{
try {
$check = bccomp((string) $item->trigger_value, '0');
} catch (\ValueError) {
} catch (ValueError) {
$this->friendlyError(sprintf('Rule #%d contained invalid %s-trigger "%s". The trigger has been removed, and the rule is disabled.', $item->rule_id, $item->trigger_type, $item->trigger_value));
$item->rule->active = false;
$item->rule->save();

View File

@@ -34,6 +34,8 @@ use FireflyIII\Support\Models\AccountBalanceCalculator;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use ValueError;
use stdClass;
class CorrectsUnevenAmount extends Command
{
@@ -135,7 +137,7 @@ class CorrectsUnevenAmount extends Command
->get(['transaction_journal_id', DB::raw('SUM(amount) AS the_sum')])
;
/** @var \stdClass $entry */
/** @var stdClass $entry */
foreach ($journals as $entry) {
$sum = (string) $entry->the_sum;
if (!is_numeric($sum)
@@ -157,7 +159,7 @@ class CorrectsUnevenAmount extends Command
try {
$res = bccomp($sum, '0');
} catch (\ValueError $e) {
} catch (ValueError $e) {
$this->friendlyError(sprintf('Could not bccomp("%s", "0").', $sum));
Log::error($e->getMessage());
Log::error($e->getTraceAsString());

View File

@@ -28,6 +28,7 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User;
use Illuminate\Console\Command;
use Exception;
class CreatesAccessTokens extends Command
{
@@ -40,7 +41,7 @@ class CreatesAccessTokens extends Command
/**
* Execute the console command.
*
* @throws \Exception
* @throws Exception
*/
public function handle(): int
{

View File

@@ -27,6 +27,7 @@ namespace FireflyIII\Console\Commands\Correction;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Models\TransactionGroup;
use Illuminate\Console\Command;
use Exception;
class RemovesEmptyGroups extends Command
{
@@ -38,7 +39,7 @@ class RemovesEmptyGroups extends Command
/**
* Execute the console command.
*
* @throws \Exception
* @throws Exception
*/
public function handle(): int
{

View File

@@ -28,6 +28,8 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use Illuminate\Console\Command;
use Exception;
use stdClass;
/**
* Deletes transactions where the journal has been deleted.
@@ -43,7 +45,7 @@ class RemovesOrphanedTransactions extends Command
/**
* Execute the console command.
*
* @throws \Exception
* @throws Exception
*/
public function handle(): int
{
@@ -85,7 +87,7 @@ class RemovesOrphanedTransactions extends Command
}
/**
* @throws \Exception
* @throws Exception
*/
private function deleteOrphanedTransactions(): void
{
@@ -102,7 +104,7 @@ class RemovesOrphanedTransactions extends Command
)
;
/** @var \stdClass $entry */
/** @var stdClass $entry */
foreach ($set as $entry) {
$transaction = Transaction::find((int) $entry->transaction_id);
if (null !== $transaction) {

View File

@@ -35,6 +35,8 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Support\Export\ExportDataGenerator;
use Illuminate\Console\Command;
use Illuminate\Support\Collection;
use Exception;
use InvalidArgumentException;
class ExportsData extends Command
{
@@ -139,7 +141,7 @@ class ExportsData extends Command
/**
* @throws FireflyException
* @throws \Exception
* @throws Exception
*/
private function parseOptions(): array
{
@@ -169,7 +171,7 @@ class ExportsData extends Command
}
/**
* @throws \Exception
* @throws Exception
*/
private function getDateParameter(string $field): Carbon
{
@@ -183,7 +185,7 @@ class ExportsData extends Command
if (is_string($this->option($field))) {
try {
$date = Carbon::createFromFormat('!Y-m-d', $this->option($field));
} catch (\InvalidArgumentException $e) {
} catch (InvalidArgumentException $e) {
app('log')->error($e->getMessage());
$this->friendlyError(sprintf('%s date "%s" must be formatted YYYY-MM-DD. Field will be ignored.', $field, $this->option('start')));
$error = true;

View File

@@ -30,6 +30,7 @@ use FireflyIII\Models\Budget;
use FireflyIII\Models\Category;
use FireflyIII\Models\Tag;
use Illuminate\Console\Command;
use stdClass;
class ReportsEmptyObjects extends Command
{
@@ -66,7 +67,7 @@ class ReportsEmptyObjects extends Command
->get(['budgets.id', 'budgets.name', 'budgets.user_id', 'users.email'])
;
/** @var \stdClass $entry */
/** @var stdClass $entry */
foreach ($set as $entry) {
$line = sprintf(
'User #%d (%s) has budget #%d ("%s") which has no transaction journals.',
@@ -92,7 +93,7 @@ class ReportsEmptyObjects extends Command
->get(['categories.id', 'categories.name', 'categories.user_id', 'users.email'])
;
/** @var \stdClass $entry */
/** @var stdClass $entry */
foreach ($set as $entry) {
$line = sprintf(
'User #%d (%s) has category #%d ("%s") which has no transaction journals.',
@@ -115,7 +116,7 @@ class ReportsEmptyObjects extends Command
->get(['tags.id', 'tags.tag', 'tags.user_id', 'users.email'])
;
/** @var \stdClass $entry */
/** @var stdClass $entry */
foreach ($set as $entry) {
$line = sprintf(
'User #%d (%s) has tag #%d ("%s") which has no transaction journals.',
@@ -142,7 +143,7 @@ class ReportsEmptyObjects extends Command
)
;
/** @var \stdClass $entry */
/** @var stdClass $entry */
foreach ($set as $entry) {
$line = 'User #%d (%s) has account #%d ("%s") which has no transactions.';
$line = sprintf($line, $entry->user_id, $entry->email, $entry->id, $entry->name);

View File

@@ -27,6 +27,7 @@ namespace FireflyIII\Console\Commands\System;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use Illuminate\Console\Command;
use PDO;
use PDOException;
class CreatesDatabase extends Command
{
@@ -53,15 +54,15 @@ class CreatesDatabase extends Command
$this->friendlyLine(sprintf('DSN is %s', $dsn));
$options = [
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
\PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
// when it fails, display error
try {
$pdo = new \PDO($dsn, (string) env('DB_USERNAME'), (string) env('DB_PASSWORD'), $options);
} catch (\PDOException $e) {
$pdo = new PDO($dsn, (string) env('DB_USERNAME'), (string) env('DB_PASSWORD'), $options);
} catch (PDOException $e) {
$this->friendlyError(sprintf('Error when connecting to DB: %s', $e->getMessage()));
return 1;

View File

@@ -34,6 +34,7 @@ use FireflyIII\Support\Cronjobs\RecurringCronjob;
use FireflyIII\Support\Cronjobs\UpdateCheckCronjob;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use InvalidArgumentException;
class Cron extends Command
{
@@ -62,7 +63,7 @@ class Cron extends Command
try {
$date = new Carbon($this->option('date'));
} catch (\InvalidArgumentException $e) {
} catch (InvalidArgumentException $e) {
$this->friendlyError(sprintf('"%s" is not a valid date', $this->option('date')));
}
$force = (bool) $this->option('force'); // @phpstan-ignore-line

View File

@@ -31,6 +31,8 @@ use Illuminate\Console\Command;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\DB;
use JsonException;
use stdClass;
class RemovesDatabaseDecryption extends Command
{
@@ -105,13 +107,13 @@ class RemovesDatabaseDecryption extends Command
{
$rows = DB::table($table)->get(['id', $field]);
/** @var \stdClass $row */
/** @var stdClass $row */
foreach ($rows as $row) {
$this->decryptRow($table, $field, $row);
}
}
private function decryptRow(string $table, string $field, \stdClass $row): void
private function decryptRow(string $table, string $field, stdClass $row): void
{
$original = $row->{$field};
if (null === $original) {
@@ -168,7 +170,7 @@ class RemovesDatabaseDecryption extends Command
// try to json_decrypt the value.
try {
$newValue = \Safe\json_decode($value, true, 512, JSON_THROW_ON_ERROR) ?? $value;
} catch (\JsonException $e) {
} 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);
app('log')->warning($message);

View File

@@ -36,6 +36,7 @@ use FireflyIII\Services\Internal\Destroy\JournalDestroyService;
use Illuminate\Console\Command;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use Exception;
class UpgradesToGroups extends Command
{
@@ -103,7 +104,7 @@ class UpgradesToGroups extends Command
}
/**
* @throws \Exception
* @throws Exception
*/
private function makeGroupsFromSplitJournals(): void
{
@@ -119,7 +120,7 @@ class UpgradesToGroups extends Command
}
/**
* @throws \Exception
* @throws Exception
*/
private function makeMultiGroup(TransactionJournal $journal): void
{