mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 10:33:30 +00:00
Fix various phpstan errors
This commit is contained in:
@@ -37,7 +37,7 @@ class RenameMetaFields extends Command
|
|||||||
protected $description = 'Rename changed meta fields.';
|
protected $description = 'Rename changed meta fields.';
|
||||||
protected $signature = 'firefly-iii:rename-meta-fields';
|
protected $signature = 'firefly-iii:rename-meta-fields';
|
||||||
|
|
||||||
private int $count;
|
private int $count = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the console command.
|
* Execute the console command.
|
||||||
@@ -46,8 +46,6 @@ class RenameMetaFields extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
{
|
{
|
||||||
$this->count = 0;
|
|
||||||
|
|
||||||
$changes = [
|
$changes = [
|
||||||
'original-source' => 'original_source',
|
'original-source' => 'original_source',
|
||||||
'importHash' => 'import_hash',
|
'importHash' => 'import_hash',
|
||||||
|
@@ -54,7 +54,6 @@ class CreateDatabase extends Command
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// try to set up a raw connection:
|
// try to set up a raw connection:
|
||||||
$pdo = false;
|
|
||||||
$exists = false;
|
$exists = false;
|
||||||
$checked = false; // checked for existence of DB?
|
$checked = false; // checked for existence of DB?
|
||||||
$dsn = sprintf('mysql:host=%s;port=%d;charset=utf8mb4', env('DB_HOST', 'localhost'), env('DB_PORT', '3306'));
|
$dsn = sprintf('mysql:host=%s;port=%d;charset=utf8mb4', env('DB_HOST', 'localhost'), env('DB_PORT', '3306'));
|
||||||
@@ -79,26 +78,23 @@ class CreateDatabase extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
// only continue when no error.
|
// only continue when no error.
|
||||||
if (false !== $pdo) {
|
|
||||||
// with PDO, try to list DB's (
|
// with PDO, try to list DB's (
|
||||||
$stmt = $pdo->query('SHOW DATABASES;');
|
$stmt = $pdo->query('SHOW DATABASES;');
|
||||||
$checked = true;
|
// slightly more complex but less error-prone.
|
||||||
// slightly more complex but less error prone.
|
|
||||||
foreach ($stmt as $row) {
|
foreach ($stmt as $row) {
|
||||||
$name = $row['Database'] ?? false;
|
$name = $row['Database'] ?? false;
|
||||||
if ($name === env('DB_DATABASE')) {
|
if ($name === env('DB_DATABASE')) {
|
||||||
$exists = true;
|
$exists = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (false === $exists) {
|
||||||
if (false === $exists && true === $checked) {
|
|
||||||
$this->friendlyError(sprintf('Database "%s" does not exist.', env('DB_DATABASE')));
|
$this->friendlyError(sprintf('Database "%s" does not exist.', env('DB_DATABASE')));
|
||||||
|
|
||||||
// try to create it.
|
// try to create it.
|
||||||
$pdo->exec(sprintf('CREATE DATABASE `%s` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;', env('DB_DATABASE')));
|
$pdo->exec(sprintf('CREATE DATABASE `%s` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;', env('DB_DATABASE')));
|
||||||
$this->friendlyInfo(sprintf('Created database "%s"', env('DB_DATABASE')));
|
$this->friendlyInfo(sprintf('Created database "%s"', env('DB_DATABASE')));
|
||||||
}
|
}
|
||||||
if (true === $exists && true === $checked) {
|
if (true === $exists) {
|
||||||
$this->friendlyInfo(sprintf('Database "%s" exists.', env('DB_DATABASE')));
|
$this->friendlyInfo(sprintf('Database "%s" exists.', env('DB_DATABASE')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -25,7 +25,9 @@ namespace FireflyIII\Console\Commands\Upgrade;
|
|||||||
|
|
||||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
|
use FireflyIII\Models\Budget;
|
||||||
use FireflyIII\Models\BudgetLimit;
|
use FireflyIII\Models\BudgetLimit;
|
||||||
|
use FireflyIII\User;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
use Psr\Container\NotFoundExceptionInterface;
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
@@ -65,8 +67,10 @@ class BudgetLimitCurrency extends Command
|
|||||||
/** @var BudgetLimit $budgetLimit */
|
/** @var BudgetLimit $budgetLimit */
|
||||||
foreach ($budgetLimits as $budgetLimit) {
|
foreach ($budgetLimits as $budgetLimit) {
|
||||||
if (null === $budgetLimit->transaction_currency_id) {
|
if (null === $budgetLimit->transaction_currency_id) {
|
||||||
|
/** @var Budget|null $budget */
|
||||||
$budget = $budgetLimit->budget;
|
$budget = $budgetLimit->budget;
|
||||||
if (null !== $budget) {
|
if (null !== $budget) {
|
||||||
|
/** @var User|null $user */
|
||||||
$user = $budget->user;
|
$user = $budget->user;
|
||||||
if (null !== $user) {
|
if (null !== $user) {
|
||||||
$currency = app('amount')->getDefaultCurrencyByUserGroup($user->userGroup);
|
$currency = app('amount')->getDefaultCurrencyByUserGroup($user->userGroup);
|
||||||
|
@@ -212,7 +212,7 @@ class DecryptDatabase extends Command
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var Preference $object */
|
/** @var Preference|null $object */
|
||||||
$object = Preference::find($id);
|
$object = Preference::find($id);
|
||||||
if (null !== $object) {
|
if (null !== $object) {
|
||||||
$object->data = $newValue;
|
$object->data = $newValue;
|
||||||
|
@@ -226,7 +226,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
|||||||
// get bindable.
|
// get bindable.
|
||||||
if (TransactionJournal::class === $attachment->attachable_type) {
|
if (TransactionJournal::class === $attachment->attachable_type) {
|
||||||
// is linked to journal, get group of journal (if not also deleted)
|
// is linked to journal, get group of journal (if not also deleted)
|
||||||
/** @var TransactionJournal $journal */
|
/** @var TransactionJournal|null $journal */
|
||||||
$journal = $user->transactionJournals()->withTrashed()->find($attachment->attachable_id);
|
$journal = $user->transactionJournals()->withTrashed()->find($attachment->attachable_id);
|
||||||
if (null !== $journal) {
|
if (null !== $journal) {
|
||||||
return redirect(route('transactions.show', [$journal->transaction_group_id]));
|
return redirect(route('transactions.show', [$journal->transaction_group_id]));
|
||||||
@@ -234,7 +234,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
|||||||
}
|
}
|
||||||
if (Bill::class === $attachment->attachable_type) {
|
if (Bill::class === $attachment->attachable_type) {
|
||||||
// is linked to bill.
|
// is linked to bill.
|
||||||
/** @var Bill $bill */
|
/** @var Bill|null $bill */
|
||||||
$bill = $user->bills()->withTrashed()->find($attachment->attachable_id);
|
$bill = $user->bills()->withTrashed()->find($attachment->attachable_id);
|
||||||
if (null !== $bill) {
|
if (null !== $bill) {
|
||||||
return redirect(route('bills.show', [$bill->id]));
|
return redirect(route('bills.show', [$bill->id]));
|
||||||
|
Reference in New Issue
Block a user