mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-10 12:24:50 +00:00
Fix various phpstan issues.
This commit is contained in:
@@ -41,6 +41,7 @@ class AccountController extends Controller
|
||||
{
|
||||
use AccountFilter;
|
||||
|
||||
/** @var array<int, string> */
|
||||
private array $balanceTypes;
|
||||
private AccountRepositoryInterface $repository;
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ abstract class Controller extends BaseController
|
||||
use ValidatesRequests;
|
||||
|
||||
protected const CONTENT_TYPE = 'application/vnd.api+json';
|
||||
/** @var array<int, string> */
|
||||
protected array $allowedSort;
|
||||
protected ParameterBag $parameters;
|
||||
|
||||
@@ -107,13 +108,13 @@ abstract class Controller extends BaseController
|
||||
$obj = null;
|
||||
if (null !== $date) {
|
||||
try {
|
||||
$obj = Carbon::parse($date);
|
||||
$obj = Carbon::parse((string)$date);
|
||||
} catch (InvalidDateException | InvalidFormatException $e) {
|
||||
// don't care
|
||||
app('log')->warning(
|
||||
sprintf(
|
||||
'Ignored invalid date "%s" in API controller parameter check: %s',
|
||||
substr($date, 0, 20),
|
||||
substr((string)$date, 0, 20),
|
||||
$e->getMessage()
|
||||
)
|
||||
);
|
||||
|
||||
@@ -89,7 +89,7 @@ class TransactionController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
* @param array $params<array<string, array<string, int|string>>>
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
@@ -289,7 +289,7 @@ class DestroyController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $types
|
||||
* @param array $types<int, string>
|
||||
*/
|
||||
private function destroyAccounts(array $types): void
|
||||
{
|
||||
@@ -314,7 +314,7 @@ class DestroyController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $types
|
||||
* @param array $types<int, string>
|
||||
*/
|
||||
private function destroyTransactions(array $types): void
|
||||
{
|
||||
|
||||
@@ -92,19 +92,19 @@ class StoreController extends Controller
|
||||
|
||||
try {
|
||||
$transactionGroup = $this->groupRepository->store($data);
|
||||
} catch (DuplicateTransactionException $e) {
|
||||
} catch (DuplicateTransactionException $e) { // @phpstan-ignore-line
|
||||
app('log')->warning('Caught a duplicate transaction. Return error message.');
|
||||
$validator = Validator::make(
|
||||
['transactions' => [['description' => $e->getMessage()]]],
|
||||
['transactions.0.description' => new IsDuplicateTransaction()]
|
||||
);
|
||||
throw new ValidationException($validator, 0, $e);
|
||||
} catch (FireflyException $e) {
|
||||
throw new ValidationException($validator); // @phpstan-ignore-line
|
||||
} catch (FireflyException $e) { // @phpstan-ignore-line
|
||||
app('log')->warning('Caught an exception. Return error message.');
|
||||
app('log')->error($e->getMessage());
|
||||
$message = sprintf('Internal exception: %s', $e->getMessage());
|
||||
$validator = Validator::make(['transactions' => [['description' => $message]]], ['transactions.0.description' => new IsDuplicateTransaction()]);
|
||||
throw new ValidationException($validator, 0, $e);
|
||||
throw new ValidationException($validator); // @phpstan-ignore-line
|
||||
}
|
||||
app('preferences')->mark();
|
||||
$applyRules = $data['apply_rules'] ?? true;
|
||||
|
||||
@@ -255,8 +255,8 @@ class ListController extends Controller
|
||||
$unfiltered = $recurringRepos->getAll();
|
||||
|
||||
// filter selection
|
||||
$collection = $unfiltered->filter(
|
||||
static function (Recurrence $recurrence) use ($currency) {
|
||||
$collection = $unfiltered->filter( // @phpstan-ignore-line
|
||||
static function (Recurrence $recurrence) use ($currency) { // @phpstan-ignore-line
|
||||
/** @var RecurrenceTransaction $transaction */
|
||||
foreach ($recurrence->recurrenceTransactions as $transaction) {
|
||||
if ($transaction->transaction_currency_id === $currency->id || $transaction->foreign_currency_id === $currency->id) {
|
||||
@@ -305,8 +305,8 @@ class ListController extends Controller
|
||||
$ruleRepos = app(RuleRepositoryInterface::class);
|
||||
$unfiltered = $ruleRepos->getAll();
|
||||
|
||||
$collection = $unfiltered->filter(
|
||||
static function (Rule $rule) use ($currency) {
|
||||
$collection = $unfiltered->filter( // @phpstan-ignore-line
|
||||
static function (Rule $rule) use ($currency) { // @phpstan-ignore-line
|
||||
/** @var RuleTrigger $trigger */
|
||||
foreach ($rule->ruleTriggers as $trigger) {
|
||||
if ('currency_is' === $trigger->trigger_type && $currency->name === $trigger->trigger_value) {
|
||||
|
||||
Reference in New Issue
Block a user