Clean up and fix phpstan issues.

This commit is contained in:
James Cole
2025-09-07 14:28:58 +02:00
parent 3152f635dd
commit cce5a73dd2
4 changed files with 77 additions and 81 deletions

View File

@@ -7,21 +7,19 @@ parameters:
- ../bootstrap/app.php
universalObjectCratesClasses:
- Illuminate\Database\Eloquent\Model
# TODO: slowly remove these parameters and fix the issues found.
reportUnmatchedIgnoredErrors: true
ignoreErrors:
# TODO: slowly remove these exceptions and fix the issues found.
- identifier: varTag.type
# all errors below I will never fix.
- '#expects view-string\|null, string given#'
- '#expects view-string, string given#'
- "#Parameter \\#[1-2] \\$num[1-2] of function bc[a-z]+ expects numeric-string, [a-z\\-|&]+ given#"
- identifier: missingType.generics # not interesting enough to fix.
-
identifier: larastan.noEnvCallsOutsideOfConfig
path: ../app/Console/Commands/System/CreatesDatabase.php
- identifier: missingType.iterableValue # not interesting enough to fix.
- identifier: missingType.generics # not interesting enough to fix.
- "#Parameter \\#[1-2] \\$num[1-2] of function bc[a-z]+ expects numeric-string, [a-z\\-|&]+ given#"
- '#expects view-string, string given#'
- '#expects view-string\|null, string given#'
# phpstan can't handle this so we ignore them.
- identifier: varTag.type # needs a custom extension for every repository, not gonna happen.
- '#Dynamic call to static method Illuminate#'
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Relations\\HasMany::before#' # is custom scope
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Relations\\HasMany::after#' # is custom scope
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Relations\\HasMany::withTrashed#' # is to allow soft delete
@@ -30,5 +28,5 @@ parameters:
# The level 8 is the highest level. original was 5
# 7 is more than enough, higher just leaves NULL things.
level: 7
level: 8

View File

@@ -250,7 +250,9 @@ class BudgetController extends Controller
// var_dump($return);
/** @var array $journal */
foreach ($currentBudgetArray['transaction_journals'] as $journal) {
$return[$currencyId]['spent'] = bcadd($return[$currencyId]['spent'], (string)$journal['amount']);
/** @var numeric-string $amount */
$amount= (string)$journal['amount'];
$return[$currencyId]['spent'] = bcadd($return[$currencyId]['spent'], $amount);
}
}

View File

@@ -35,6 +35,9 @@ class StoreByDateRequest extends FormRequest
use ChecksLogin;
use ConvertsDataTypes;
/**
* @return array<string, mixed>
*/
public function getAll(): array
{
return [
@@ -50,6 +53,7 @@ class StoreByDateRequest extends FormRequest
/**
* The rules that the incoming request must be matched against.
* @return array<string, string>
*/
public function rules(): array
{

View File

@@ -26,6 +26,7 @@ namespace FireflyIII\Helpers\Collector;
use Carbon\Carbon;
use Carbon\Exceptions\InvalidFormatException;
use Closure;
use Exception;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Exceptions\FireflyException;
@@ -45,9 +46,7 @@ use Illuminate\Database\Query\JoinClause;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Closure;
use Override;
use function Safe\json_decode;
/**
@@ -1075,8 +1074,7 @@ class GroupCollector implements GroupCollectorInterface
'transactions as source',
static function (JoinClause $join): void {
$join->on('source.transaction_journal_id', '=', 'transaction_journals.id')
->where('source.amount', '<', 0)
;
->where('source.amount', '<', 0);
}
)
// join destination transaction
@@ -1084,8 +1082,7 @@ class GroupCollector implements GroupCollectorInterface
'transactions as destination',
static function (JoinClause $join): void {
$join->on('destination.transaction_journal_id', '=', 'transaction_journals.id')
->where('destination.amount', '>', 0)
;
->where('destination.amount', '>', 0);
}
)
// left join transaction type.
@@ -1098,15 +1095,13 @@ class GroupCollector implements GroupCollectorInterface
// #10507 ignore opening balance.
->where('transaction_types.type', '!=', TransactionTypeEnum::OPENING_BALANCE->value)
->whereNotNull('transaction_groups.id')
->whereNull('destination.deleted_at')
->orderBy('transaction_journals.date', 'DESC')
->orderBy('transaction_journals.order', 'ASC')
->orderBy('transaction_journals.id', 'DESC')
->orderBy('transaction_journals.description', 'DESC')
->orderBy('source.amount', 'DESC')
;
->orderBy('source.amount', 'DESC');
}
/**
@@ -1137,8 +1132,7 @@ class GroupCollector implements GroupCollectorInterface
'transactions as source',
static function (JoinClause $join): void {
$join->on('source.transaction_journal_id', '=', 'transaction_journals.id')
->where('source.amount', '<', 0)
;
->where('source.amount', '<', 0);
}
)
// join destination transaction
@@ -1146,8 +1140,7 @@ class GroupCollector implements GroupCollectorInterface
'transactions as destination',
static function (JoinClause $join): void {
$join->on('destination.transaction_journal_id', '=', 'transaction_journals.id')
->where('destination.amount', '>', 0)
;
->where('destination.amount', '>', 0);
}
)
// left join transaction type.
@@ -1162,8 +1155,7 @@ class GroupCollector implements GroupCollectorInterface
->orderBy('transaction_journals.order', 'ASC')
->orderBy('transaction_journals.id', 'DESC')
->orderBy('transaction_journals.description', 'DESC')
->orderBy('source.amount', 'DESC')
;
->orderBy('source.amount', 'DESC');
}
/**
@@ -1178,9 +1170,9 @@ class GroupCollector implements GroupCollectorInterface
// include budget ID + name (if any)
->withBudgetInformation()
// include bill ID + name (if any)
->withBillInformation()
;
->withBillInformation();
return $this;
}
}