Fix phpstan issues

This commit is contained in:
James Cole
2025-09-07 07:31:00 +02:00
parent b87b99a755
commit 296a64e284
103 changed files with 605 additions and 617 deletions

View File

@@ -33,6 +33,7 @@ use FireflyIII\Support\Singleton\PreferencesSingleton;
use FireflyIII\User;
use Illuminate\Support\Collection;
use NumberFormatter;
use FireflyIII\Support\Facades\Steam;
/**
* Class Amount.
@@ -58,8 +59,8 @@ class Amount
*/
public function formatFlat(string $symbol, int $decimalPlaces, string $amount, ?bool $coloured = null): string
{
$locale = app('steam')->getLocale();
$rounded = app('steam')->bcround($amount, $decimalPlaces);
$locale = Steam::getLocale();
$rounded = Steam::bcround($amount, $decimalPlaces);
$coloured ??= true;
$fmt = new NumberFormatter($locale, NumberFormatter::CURRENCY);
@@ -69,10 +70,10 @@ class Amount
$result = (string)$fmt->format((float)$rounded); // intentional float
if (true === $coloured) {
if (1 === bccomp((string)$rounded, '0')) {
if (1 === bccomp($rounded, '0')) {
return sprintf('<span class="text-success money-positive">%s</span>', $result);
}
if (-1 === bccomp((string)$rounded, '0')) {
if (-1 === bccomp($rounded, '0')) {
return sprintf('<span class="text-danger money-negative">%s</span>', $result);
}
@@ -242,8 +243,8 @@ class Amount
private function getLocaleInfo(): array
{
// get config from preference, not from translation:
$locale = app('steam')->getLocale();
$array = app('steam')->getLocaleArray($locale);
$locale = Steam::getLocale();
$array = Steam::getLocaleArray($locale);
setlocale(LC_MONETARY, $array);
$info = localeconv();

View File

@@ -85,7 +85,7 @@ class ExportDataGenerator
private bool $exportTransactions;
private Carbon $start;
private User $user;
private UserGroup $userGroup;
private UserGroup $userGroup; // @phpstan-ignore-line
public function __construct()
{

View File

@@ -26,25 +26,6 @@ namespace FireflyIII\Support\Facades;
use Carbon\Carbon;
use Illuminate\Support\Facades\Facade;
/**
* Class Navigation.
*
* @method Carbon addPeriod(Carbon $theDate, string $repeatFreq, int $skip)
* @method array blockPeriods(Carbon $start, Carbon $end, string $range)
* @method Carbon endOfPeriod(Carbon $end, string $repeatFreq)
* @method Carbon endOfX(Carbon $theCurrentEnd, string $repeatFreq, Carbon $maxDate = null)
* @method array listOfPeriods(Carbon $start, Carbon $end)
* @method string periodShow(Carbon $theDate, string $repeatFrequency)
* @method string preferredCarbonFormat(Carbon $start, Carbon $end)
* @method string preferredCarbonLocalizedFormat(Carbon $start, Carbon $end)
* @method string preferredEndOfPeriod(Carbon $start, Carbon $end)
* @method string preferredRangeFormat(Carbon $start, Carbon $end)
* @method string preferredSqlFormat(Carbon $start, Carbon $end)
* @method Carbon startOfPeriod(Carbon $theDate, string $repeatFreq)
* @method Carbon subtractPeriod(Carbon $theDate, string $repeatFreq, int $subtract = 1)
* @method Carbon updateEndDate(string $range, Carbon $start)
* @method Carbon updateStartDate(string $range, Carbon $start)
*/
class Navigation extends Facade
{
/**

View File

@@ -163,7 +163,7 @@ class AccountBalanceGrouped
// get conversion rate
$rate = $this->getRate($currency, $journal['date']);
$amountConverted = bcmul((string)$amount, $rate);
$amountConverted = bcmul($amount, $rate);
// perhaps transaction already has the foreign amount in the primary currency.
if ((int)$journal['foreign_currency_id'] === $this->primary->id) {
@@ -172,11 +172,11 @@ class AccountBalanceGrouped
}
// add normal entry
$this->data[$currencyId][$period][$key] = bcadd((string)$this->data[$currencyId][$period][$key], (string)$amount);
$this->data[$currencyId][$period][$key] = bcadd((string)$this->data[$currencyId][$period][$key], $amount);
// add converted entry
$convertedKey = sprintf('pc_%s', $key);
$this->data[$currencyId][$period][$convertedKey] = bcadd((string)$this->data[$currencyId][$period][$convertedKey], (string)$amountConverted);
$this->data[$currencyId][$period][$convertedKey] = bcadd((string)$this->data[$currencyId][$period][$convertedKey], $amountConverted);
}
private function findCurrency(int $currencyId): TransactionCurrency

View File

@@ -300,7 +300,7 @@ class AccountEnrichment implements EnrichmentInterface
// collect current balances:
$currentBalance = Steam::bcround($finalBalance[$currency->code] ?? '0', $currency->decimal_places);
$openingBalance = Steam::bcround($meta['opening_balance_amount'] ?? '0', $currency->decimal_places);
$virtualBalance = Steam::bcround($account->virtual_balance ?? '0', $currency->decimal_places);
$virtualBalance = Steam::bcround($item->virtual_balance ?? '0', $currency->decimal_places);
$debtAmount = $meta['current_debt'] ?? null;
// set some pc_ default values to NULL:
@@ -440,7 +440,7 @@ class AccountEnrichment implements EnrichmentInterface
private function sortData(): void
{
$dbParams = config('firefly.allowed_db_sort_parameters.Account', []);
/** @var array<string,string> $parameter */
/** @var array<int,<string,string> $parameter */
foreach ($this->sort as $parameter) {
if (in_array($parameter[0], $dbParams, true)) {
continue;