mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 00:27:30 +00:00
run phpcs
This commit is contained in:
6
.github/workflows/sonarcloud.yml
vendored
6
.github/workflows/sonarcloud.yml
vendored
@@ -8,7 +8,7 @@ on:
|
||||
- develop
|
||||
env:
|
||||
DB_CONNECTION: sqlite
|
||||
APP_KEY: UfpBqqeXx7zpNodsC6yjYQcRfDdm4Bxh
|
||||
APP_KEY: TestTestTestTestTestTestTestTest
|
||||
jobs:
|
||||
sonarcloud:
|
||||
name: SonarCloud
|
||||
@@ -46,7 +46,9 @@ jobs:
|
||||
run: composer install --prefer-dist --no-interaction --no-progress --no-scripts
|
||||
|
||||
- name: "Create database file"
|
||||
run: touch storage/database/database.sqlite
|
||||
run: |
|
||||
touch storage/database/database.sqlite
|
||||
wget -q https://github.com/firefly-iii/test-fixtures/raw/refs/heads/main/test-database.sqlite -O storage/database/database.sqlite
|
||||
|
||||
- name: "Upgrades the database to the latest version"
|
||||
run: php artisan firefly-iii:upgrade-database
|
||||
|
@@ -25,7 +25,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Api\V1\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Carbon\Exceptions\InvalidDateException;
|
||||
use Carbon\Exceptions\InvalidFormatException;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
|
@@ -64,7 +64,7 @@ class ConvertsDatesToUTC extends Command
|
||||
|
||||
// this variable is ALWAYS en_US.
|
||||
// stops phpstan complaining about dead code.
|
||||
if (config('app.fallback_locale') === 'en_US') {
|
||||
if ('en_US' === config('app.fallback_locale')) {
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
|
@@ -111,6 +111,7 @@ class CorrectsAccountTypes extends Command
|
||||
$this->friendlyLine(sprintf('Found %d journals that need to be fixed.', $resultSet->count()));
|
||||
foreach ($resultSet as $entry) {
|
||||
app('log')->debug(sprintf('Now fixing journal #%d', $entry->id));
|
||||
|
||||
/** @var null|TransactionJournal $journal */
|
||||
$journal = TransactionJournal::find($entry->id);
|
||||
if (null !== $journal) {
|
||||
|
@@ -236,7 +236,7 @@ class CorrectsNativeAmounts extends Command
|
||||
TransactionObserver::$recalculate = false;
|
||||
foreach ($set as $item) {
|
||||
// here we are.
|
||||
/** @var Transaction|null $transaction */
|
||||
/** @var null|Transaction $transaction */
|
||||
$transaction = Transaction::find($item->id);
|
||||
$transaction?->touch();
|
||||
}
|
||||
|
@@ -66,7 +66,7 @@ class RemovesEmptyJournals extends Command
|
||||
if (1 === $count % 2) {
|
||||
// uneven number, delete journal and transactions:
|
||||
try {
|
||||
/** @var TransactionJournal|null $journal */
|
||||
/** @var null|TransactionJournal $journal */
|
||||
$journal = TransactionJournal::find($row->transaction_journal_id);
|
||||
$journal?->delete();
|
||||
} catch (QueryException $e) {
|
||||
@@ -89,11 +89,12 @@ class RemovesEmptyJournals extends Command
|
||||
$set = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->groupBy('transaction_journals.id')
|
||||
->whereNull('transactions.transaction_journal_id')
|
||||
->get(['transaction_journals.id']);
|
||||
->get(['transaction_journals.id'])
|
||||
;
|
||||
|
||||
foreach ($set as $entry) {
|
||||
try {
|
||||
/** @var TransactionJournal|null $journal */
|
||||
/** @var null|TransactionJournal $journal */
|
||||
$journal = TransactionJournal::find($entry->id);
|
||||
$journal?->delete();
|
||||
} catch (QueryException $e) {
|
||||
|
@@ -69,7 +69,7 @@ class RemovesOrphanedTransactions extends Command
|
||||
}
|
||||
$this->friendlyInfo(sprintf('Found %d orphaned journal(s).', $count));
|
||||
foreach ($set as $entry) {
|
||||
/** @var TransactionJournal|null $journal */
|
||||
/** @var null|TransactionJournal $journal */
|
||||
$journal = TransactionJournal::withTrashed()->find($entry->id);
|
||||
if (null !== $journal) {
|
||||
$journal->delete();
|
||||
@@ -131,7 +131,7 @@ class RemovesOrphanedTransactions extends Command
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($set as $transaction) {
|
||||
// delete journals
|
||||
/** @var TransactionJournal|null $journal */
|
||||
/** @var null|TransactionJournal $journal */
|
||||
$journal = TransactionJournal::find($transaction->transaction_journal_id);
|
||||
if (null !== $journal) {
|
||||
$journal->delete();
|
||||
|
@@ -264,7 +264,8 @@ class ForcesDecimalSize extends Command
|
||||
$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));
|
||||
/** @var Account|null $updateAccount */
|
||||
|
||||
/** @var null|Account $updateAccount */
|
||||
$updateAccount = Account::find($account->id);
|
||||
$updateAccount?->update([$field => $correct]);
|
||||
}
|
||||
@@ -315,7 +316,8 @@ class ForcesDecimalSize extends Command
|
||||
$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));
|
||||
/** @var Model|null $model */
|
||||
|
||||
/** @var null|Model $model */
|
||||
$model = $class::find($item->id);
|
||||
$model?->update([$field => $correct]);
|
||||
}
|
||||
@@ -369,7 +371,8 @@ class ForcesDecimalSize extends Command
|
||||
$this->friendlyWarning(
|
||||
sprintf('Piggy bank event #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct)
|
||||
);
|
||||
/** @var PiggyBankEvent|null $event */
|
||||
|
||||
/** @var null|PiggyBankEvent $event */
|
||||
$event = PiggyBankEvent::find($item->id);
|
||||
$event?->update([$field => $correct]);
|
||||
}
|
||||
@@ -424,7 +427,8 @@ class ForcesDecimalSize extends Command
|
||||
$this->friendlyWarning(
|
||||
sprintf('Piggy bank repetition #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct)
|
||||
);
|
||||
/** @var PiggyBankRepetition|null $repetition */
|
||||
|
||||
/** @var null|PiggyBankRepetition $repetition */
|
||||
$repetition = PiggyBankRepetition::find($item->id);
|
||||
$repetition->update([$field => $correct]);
|
||||
}
|
||||
@@ -475,7 +479,8 @@ class ForcesDecimalSize extends Command
|
||||
$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));
|
||||
/** @var PiggyBank|null $piggyBank */
|
||||
|
||||
/** @var null|PiggyBank $piggyBank */
|
||||
$piggyBank = PiggyBank::find($item->id);
|
||||
$piggyBank?->update([$field => $correct]);
|
||||
}
|
||||
@@ -510,7 +515,8 @@ class ForcesDecimalSize extends Command
|
||||
$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));
|
||||
/** @var Transaction|null $transaction */
|
||||
|
||||
/** @var null|Transaction $transaction */
|
||||
$transaction = Transaction::find($item->id);
|
||||
$transaction?->update(['amount' => $correct]);
|
||||
}
|
||||
@@ -542,7 +548,8 @@ class ForcesDecimalSize extends Command
|
||||
$this->friendlyWarning(
|
||||
sprintf('Transaction #%d has foreign amount with value "%s", this has been corrected to "%s".', $item->id, $value, $correct)
|
||||
);
|
||||
/** @var Transaction|null $transaction */
|
||||
|
||||
/** @var null|Transaction $transaction */
|
||||
$transaction = Transaction::find($item->id);
|
||||
$transaction?->update(['foreign_amount' => $correct]);
|
||||
}
|
||||
|
@@ -53,11 +53,13 @@ class BudgetLimitHandler
|
||||
private function updateAvailableBudget(BudgetLimit $budgetLimit): void
|
||||
{
|
||||
Log::debug(sprintf('Now in updateAvailableBudget(limit #%d)', $budgetLimit->id));
|
||||
/** @var Budget|null $budget */
|
||||
|
||||
/** @var null|Budget $budget */
|
||||
$budget = Budget::find($budgetLimit->budget_id);
|
||||
if (null === $budget) {
|
||||
Log::warning('Budget is null, probably deleted, find deleted version.');
|
||||
/** @var Budget|null $budget */
|
||||
|
||||
/** @var null|Budget $budget */
|
||||
$budget = Budget::withTrashed()->find($budgetLimit->budget_id);
|
||||
}
|
||||
if (null === $budget) {
|
||||
|
@@ -251,8 +251,9 @@ trait AccountCollection
|
||||
if (0 === $accountId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// in theory, this could lead to finding other users accounts.
|
||||
/** @var Account|null $account */
|
||||
/** @var null|Account $account */
|
||||
$account = Account::find($accountId);
|
||||
if (null === $account) {
|
||||
continue;
|
||||
|
@@ -121,6 +121,7 @@ class DebugController extends Controller
|
||||
echo sprintf('<h2>%s</h2>', $count);
|
||||
}
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
@@ -28,7 +28,6 @@ use Carbon\Carbon;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
@@ -28,7 +28,6 @@ use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Http\Requests\PiggyBankUpdateRequest;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
@@ -42,6 +42,7 @@ class CreateController extends Controller
|
||||
app('log')->debug(sprintf('Now at %s', __METHOD__));
|
||||
|
||||
return view('administrations.create') // @phpstan-ignore-line
|
||||
->with(compact('title', 'subTitle', 'mainTitleIcon'));
|
||||
->with(compact('title', 'subTitle', 'mainTitleIcon'))
|
||||
;
|
||||
}
|
||||
}
|
||||
|
@@ -43,6 +43,7 @@ class EditController extends Controller
|
||||
app('log')->debug(sprintf('Now at %s', __METHOD__));
|
||||
|
||||
return view('administrations.edit') // @phpstan-ignore-line
|
||||
->with(compact('title', 'subTitle', 'mainTitleIcon'));
|
||||
->with(compact('title', 'subTitle', 'mainTitleIcon'))
|
||||
;
|
||||
}
|
||||
}
|
||||
|
@@ -524,7 +524,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
->first(['transaction_journals.id'])
|
||||
;
|
||||
if (null !== $first) {
|
||||
/** @var TransactionJournal|null */
|
||||
/** @var null|TransactionJournal */
|
||||
return TransactionJournal::find($first->id);
|
||||
}
|
||||
|
||||
|
@@ -325,7 +325,8 @@ trait ModifiesPiggyBanks
|
||||
->where('accounts.user_id', $this->user->id)
|
||||
->where('piggy_banks.order', '<=', $newOrder)->where('piggy_banks.order', '>', $oldOrder)
|
||||
->where('piggy_banks.id', '!=', $piggyBank->id)
|
||||
->distinct()->decrement('piggy_banks.order');
|
||||
->distinct()->decrement('piggy_banks.order')
|
||||
;
|
||||
|
||||
$piggyBank->order = $newOrder;
|
||||
Log::debug(sprintf('[1] Order of piggy #%d ("%s") from %d to %d', $piggyBank->id, $piggyBank->name, $oldOrder, $newOrder));
|
||||
@@ -338,7 +339,8 @@ trait ModifiesPiggyBanks
|
||||
->where('accounts.user_id', $this->user->id)
|
||||
->where('piggy_banks.order', '>=', $newOrder)->where('piggy_banks.order', '<', $oldOrder)
|
||||
->where('piggy_banks.id', '!=', $piggyBank->id)
|
||||
->distinct()->increment('piggy_banks.order');
|
||||
->distinct()->increment('piggy_banks.order')
|
||||
;
|
||||
|
||||
$piggyBank->order = $newOrder;
|
||||
Log::debug(sprintf('[2] Order of piggy #%d ("%s") from %d to %d', $piggyBank->id, $piggyBank->name, $oldOrder, $newOrder));
|
||||
|
@@ -268,7 +268,7 @@ class UserRepository implements UserRepositoryInterface
|
||||
|
||||
public function inviteUser(null|Authenticatable|User $user, string $email): InvitedUser
|
||||
{
|
||||
if(!($user instanceof User)) {
|
||||
if (!$user instanceof User) {
|
||||
throw new FireflyException('User is not a User object.');
|
||||
}
|
||||
$now = today(config('app.timezone'));
|
||||
|
@@ -91,7 +91,8 @@ class AccountDestroyService
|
||||
$transaction->delete();
|
||||
$ibAccount->delete();
|
||||
}
|
||||
/** @var TransactionJournal|null $journal */
|
||||
|
||||
/** @var null|TransactionJournal $journal */
|
||||
$journal = TransactionJournal::find($journalId);
|
||||
if (null !== $journal) {
|
||||
/** @var JournalDestroyService $service */
|
||||
|
@@ -177,7 +177,7 @@ class Amount
|
||||
return $cache->get();
|
||||
}
|
||||
|
||||
/** @var TransactionCurrency|null $default */
|
||||
/** @var null|TransactionCurrency $default */
|
||||
$default = $userGroup->currencies()->where('group_default', true)->first();
|
||||
if (null === $default) {
|
||||
$default = $this->getSystemCurrency();
|
||||
|
@@ -50,6 +50,7 @@ class CurrencyForm
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
*
|
||||
* @phpstan-param view-string $view
|
||||
*/
|
||||
protected function currencyField(string $name, string $view, mixed $value = null, ?array $options = null): string
|
||||
|
@@ -156,7 +156,7 @@ class AccountBalanceCalculator
|
||||
* @var array $currencies
|
||||
*/
|
||||
foreach ($balances as $accountId => $currencies) {
|
||||
/** @var Account|null $account */
|
||||
/** @var null|Account $account */
|
||||
$account = Account::find($accountId);
|
||||
if (null === $account) {
|
||||
Log::error(sprintf('Could not find account #%d, will not save account balance.', $accountId));
|
||||
@@ -169,7 +169,7 @@ class AccountBalanceCalculator
|
||||
* @var array $balance
|
||||
*/
|
||||
foreach ($currencies as $currencyId => $balance) {
|
||||
/** @var TransactionCurrency|null $currency */
|
||||
/** @var null|TransactionCurrency $currency */
|
||||
$currency = TransactionCurrency::find($currencyId);
|
||||
if (null === $currency) {
|
||||
Log::error(sprintf('Could not find currency #%d, will not save account balance.', $currencyId));
|
||||
@@ -207,5 +207,4 @@ class AccountBalanceCalculator
|
||||
}
|
||||
$object->optimizedCalculation($accounts, $transactionJournal->date);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -129,6 +129,7 @@ class Steam
|
||||
|
||||
// find currency of this entry.
|
||||
$currencies[$entry->transaction_currency_id] ??= TransactionCurrency::find($entry->transaction_currency_id);
|
||||
|
||||
/** @var TransactionCurrency $entryCurrency */
|
||||
$entryCurrency = $currencies[$entry->transaction_currency_id];
|
||||
|
||||
|
@@ -174,7 +174,7 @@ class AccountTransformer extends AbstractTransformer
|
||||
|
||||
private function getBalanceDifference(Collection $accounts, Carbon $start, Carbon $end): void
|
||||
{
|
||||
if (config('app.fallback_locale') === 'en_US') {
|
||||
if ('en_US' === config('app.fallback_locale')) {
|
||||
throw new FireflyException('Used deprecated method, rethink this.');
|
||||
}
|
||||
// collect balances, start and end for both native and converted.
|
||||
|
@@ -115,7 +115,7 @@ class PiggyBankTransformer extends AbstractTransformer
|
||||
|
||||
// grab repetitions (for current amount):
|
||||
$repetitions = PiggyBankRepetition::whereIn('piggy_bank_id', $piggyBanks)->get();
|
||||
if (config('app.fallback_locale') === 'en_US') {
|
||||
if ('en_US' === config('app.fallback_locale')) {
|
||||
throw new FireflyException('[d] Piggy bank repetitions are EOL.');
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user