Skip to content

Firefly III: a personal finances manager

Fix various phpstan issues.

James Cole0220cf97846d
diff --git a/.ci/phpstan.neon b/.ci/phpstan.neon
index 5f63b86612..93daf3b3e1 100644
--- a/.ci/phpstan.neon
+++ b/.ci/phpstan.neon
@@ -8,7 +8,10 @@ parameters:
universalObjectCratesClasses:
- Illuminate\Database\Eloquent\Model
reportUnmatchedIgnoredErrors: false
+ checkGenericClassInNonGenericObjectType: false # remove this rule when all other issues are solved.
ignoreErrors:
+ - '#with no value type specified in iterable type array#' # remove this rule when all other issues are solved.
+ - '#has no value type specified in iterable type array#' # remove this rule when all other issues are solved.
- '#is not allowed to extend#'
- '#is neither abstract nor final#'
- '#has a nullable return type declaration#'
@@ -74,5 +77,5 @@ parameters:
- ../bootstrap/app.php
# The level 8 is the highest level. original was 5
- level: 4
+ level: 7
diff --git a/app/Api/V1/Controllers/Autocomplete/AccountController.php b/app/Api/V1/Controllers/Autocomplete/AccountController.php
index ecbfba6e61..ec5b9e614a 100644
--- a/app/Api/V1/Controllers/Autocomplete/AccountController.php
+++ b/app/Api/V1/Controllers/Autocomplete/AccountController.php
@@ -41,6 +41,7 @@ class AccountController extends Controller
{
use AccountFilter;
+ /** @var array<int, string> */
private array $balanceTypes;
private AccountRepositoryInterface $repository;
diff --git a/app/Api/V1/Controllers/Controller.php b/app/Api/V1/Controllers/Controller.php
index 2faaf43bfc..5c38c5cd80 100644
--- a/app/Api/V1/Controllers/Controller.php
+++ b/app/Api/V1/Controllers/Controller.php
@@ -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()
)
);
diff --git a/app/Api/V1/Controllers/Data/Bulk/TransactionController.php b/app/Api/V1/Controllers/Data/Bulk/TransactionController.php
index 56afbde1cd..711bec1972 100644
--- a/app/Api/V1/Controllers/Data/Bulk/TransactionController.php
+++ b/app/Api/V1/Controllers/Data/Bulk/TransactionController.php
@@ -89,7 +89,7 @@ class TransactionController extends Controller
}
/**
- * @param array $params
+ * @param array $params<array<string, array<string, int|string>>>
*
* @return bool
*/
diff --git a/app/Api/V1/Controllers/Data/DestroyController.php b/app/Api/V1/Controllers/Data/DestroyController.php
index 0c769ec26b..8c697d8aab 100644
--- a/app/Api/V1/Controllers/Data/DestroyController.php
+++ b/app/Api/V1/Controllers/Data/DestroyController.php
@@ -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
{
diff --git a/app/Api/V1/Controllers/Models/Transaction/StoreController.php b/app/Api/V1/Controllers/Models/Transaction/StoreController.php
index 13f900e8b9..f33b725f5b 100644
--- a/app/Api/V1/Controllers/Models/Transaction/StoreController.php
+++ b/app/Api/V1/Controllers/Models/Transaction/StoreController.php
@@ -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;
diff --git a/app/Api/V1/Controllers/Models/TransactionCurrency/ListController.php b/app/Api/V1/Controllers/Models/TransactionCurrency/ListController.php
index 5360c6ead8..f4a2fa05b3 100644
--- a/app/Api/V1/Controllers/Models/TransactionCurrency/ListController.php
+++ b/app/Api/V1/Controllers/Models/TransactionCurrency/ListController.php
@@ -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) {
diff --git a/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php b/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php
index 8bbb327886..bfd273969d 100644
--- a/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php
+++ b/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php
@@ -77,7 +77,7 @@ class StoreRequest extends FormRequest
* Returns the transaction data as it is found in the submitted data. It's a complex method according to code
* standards but it just has a lot of ??-statements because of the fields that may or may not exist.
*
- * @return array|null
+ * @return array
*/
private function getTransactionData(): array
{
diff --git a/app/Api/V1/Requests/Models/Rule/StoreRequest.php b/app/Api/V1/Requests/Models/Rule/StoreRequest.php
index 299aa3139d..74a08c019e 100644
--- a/app/Api/V1/Requests/Models/Rule/StoreRequest.php
+++ b/app/Api/V1/Requests/Models/Rule/StoreRequest.php
@@ -198,6 +198,7 @@ class StoreRequest extends FormRequest
protected function atLeastOneActiveTrigger(Validator $validator): void
{
$data = $validator->getData();
+ /** @var string|int|array|null $triggers */
$triggers = $data['triggers'] ?? [];
// need at least one trigger
if (!is_countable($triggers) || 0 === count($triggers)) {
@@ -227,6 +228,7 @@ class StoreRequest extends FormRequest
protected function atLeastOneActiveAction(Validator $validator): void
{
$data = $validator->getData();
+ /** @var string|int|array|null $actions */
$actions = $data['actions'] ?? [];
// need at least one trigger
if (!is_countable($actions) || 0 === count($actions)) {
diff --git a/app/Api/V1/Requests/Models/Rule/TestRequest.php b/app/Api/V1/Requests/Models/Rule/TestRequest.php
index 331c4922c3..0d67c5d16e 100644
--- a/app/Api/V1/Requests/Models/Rule/TestRequest.php
+++ b/app/Api/V1/Requests/Models/Rule/TestRequest.php
@@ -66,7 +66,11 @@ class TestRequest extends FormRequest
*/
private function getDate(string $field): ?Carbon
{
- return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', $this->query($field));
+ $result = null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr((string)$this->query($field), 0, 10));
+ if(false === $result) {
+ return null;
+ }
+ return $result;
}
/**
diff --git a/app/Api/V1/Requests/Models/Rule/TriggerRequest.php b/app/Api/V1/Requests/Models/Rule/TriggerRequest.php
index 12785842c1..72e8a86765 100644
--- a/app/Api/V1/Requests/Models/Rule/TriggerRequest.php
+++ b/app/Api/V1/Requests/Models/Rule/TriggerRequest.php
@@ -56,7 +56,11 @@ class TriggerRequest extends FormRequest
*/
private function getDate(string $field): ?Carbon
{
- return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($this->query($field), 0, 10));
+ $result = null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr((string)$this->query($field), 0, 10));
+ if(false === $result) {
+ return null;
+ }
+ return $result;
}
/**
diff --git a/app/Api/V1/Requests/Models/RuleGroup/TriggerRequest.php b/app/Api/V1/Requests/Models/RuleGroup/TriggerRequest.php
index 4d9514307a..8374af4812 100644
--- a/app/Api/V1/Requests/Models/RuleGroup/TriggerRequest.php
+++ b/app/Api/V1/Requests/Models/RuleGroup/TriggerRequest.php
@@ -56,7 +56,11 @@ class TriggerRequest extends FormRequest
*/
private function getDate(string $field): ?Carbon
{
- return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', $this->query($field));
+ $result = null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr((string)$this->query($field), 0, 10));
+ if(false === $result) {
+ return null;
+ }
+ return $result;
}
/**
diff --git a/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php b/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php
index b125663cde..133fe9f67d 100644
--- a/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php
+++ b/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php
@@ -159,12 +159,15 @@ class UpdateRequest extends FormRequest
app('log')->debug(sprintf('Now in %s', __METHOD__));
$return = [];
- if (!is_countable($this->get('transactions'))) {
+ /** @var array|null $transactions */
+ $transactions = $this->get('transactions');
+
+ if (!is_countable($transactions)) {
return $return;
}
/** @var array $transaction */
- foreach ($this->get('transactions') as $transaction) {
+ foreach ($transactions as $transaction) {
if (!is_array($transaction)) {
throw new FireflyException('Invalid data submitted: transaction is not array.');
}
diff --git a/app/Api/V2/Controllers/Model/Transaction/StoreController.php b/app/Api/V2/Controllers/Model/Transaction/StoreController.php
index 4dc062cb0e..eb60af6921 100644
--- a/app/Api/V2/Controllers/Model/Transaction/StoreController.php
+++ b/app/Api/V2/Controllers/Model/Transaction/StoreController.php
@@ -82,19 +82,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;
diff --git a/app/Console/Commands/System/ForceDecimalSize.php b/app/Console/Commands/System/ForceDecimalSize.php
index a5c7e008ec..685324f20c 100644
--- a/app/Console/Commands/System/ForceDecimalSize.php
+++ b/app/Console/Commands/System/ForceDecimalSize.php
@@ -239,7 +239,7 @@ class ForceDecimalSize extends Command
$query->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression) {
foreach ($fields as $field) {
$q->orWhere(
- DB::raw(sprintf('CAST(accounts.%s AS %s)', $field, $cast)),
+ DB::raw(sprintf('CAST(accounts.%s AS %s)', $field, $cast)), // @phpstan-ignore-line
$operator,
DB::raw(sprintf($regularExpression, $currency->decimal_places))
);
@@ -288,7 +288,7 @@ class ForceDecimalSize extends Command
static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression) {
foreach ($fields as $field) {
$q->orWhere(
- DB::raw(sprintf('CAST(%s AS %s)', $field, $cast)),
+ DB::raw(sprintf('CAST(%s AS %s)', $field, $cast)), // @phpstan-ignore-line
$operator,
DB::raw(sprintf($regularExpression, $currency->decimal_places))
);
@@ -341,7 +341,7 @@ class ForceDecimalSize extends Command
->where(static function (Builder $q) use ($fields, $currency, $cast, $operator, $regularExpression) {
foreach ($fields as $field) {
$q->orWhere(
- DB::raw(sprintf('CAST(piggy_bank_events.%s AS %s)', $field, $cast)),
+ DB::raw(sprintf('CAST(piggy_bank_events.%s AS %s)', $field, $cast)), // @phpstan-ignore-line
$operator,
DB::raw(sprintf($regularExpression, $currency->decimal_places))
);
@@ -395,7 +395,7 @@ class ForceDecimalSize extends Command
->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression) {
foreach ($fields as $field) {
$q->orWhere(
- DB::raw(sprintf('CAST(piggy_bank_repetitions.%s AS %s)', $field, $cast)),
+ DB::raw(sprintf('CAST(piggy_bank_repetitions.%s AS %s)', $field, $cast)), // @phpstan-ignore-line
$operator,
DB::raw(sprintf($regularExpression, $currency->decimal_places))
);
@@ -448,7 +448,7 @@ class ForceDecimalSize extends Command
->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression) {
foreach ($fields as $field) {
$q->orWhere(
- DB::raw(sprintf('CAST(piggy_banks.%s AS %s)', $field, $cast)),
+ DB::raw(sprintf('CAST(piggy_banks.%s AS %s)', $field, $cast)), // @phpstan-ignore-line
$operator,
DB::raw(sprintf($regularExpression, $currency->decimal_places))
);
@@ -489,7 +489,7 @@ class ForceDecimalSize extends Command
// select all transactions with this currency and issue.
/** @var Builder $query */
$query = Transaction::where('transaction_currency_id', $currency->id)->where(
- DB::raw(sprintf('CAST(amount as %s)', $this->cast)),
+ DB::raw(sprintf('CAST(amount as %s)', $this->cast)), // @phpstan-ignore-line
$this->operator,
DB::raw(sprintf($this->regularExpression, $currency->decimal_places))
);
@@ -515,7 +515,7 @@ class ForceDecimalSize extends Command
// select all transactions with this FOREIGN currency and issue.
/** @var Builder $query */
$query = Transaction::where('foreign_currency_id', $currency->id)->where(
- DB::raw(sprintf('CAST(foreign_amount as %s)', $this->cast)),
+ DB::raw(sprintf('CAST(foreign_amount as %s)', $this->cast)), // @phpstan-ignore-line
$this->operator,
DB::raw(sprintf($this->regularExpression, $currency->decimal_places))
);
diff --git a/app/Console/Commands/Upgrade/AppendBudgetLimitPeriods.php b/app/Console/Commands/Upgrade/AppendBudgetLimitPeriods.php
index 0f9265a941..3c1fceff09 100644
--- a/app/Console/Commands/Upgrade/AppendBudgetLimitPeriods.php
+++ b/app/Console/Commands/Upgrade/AppendBudgetLimitPeriods.php
@@ -98,7 +98,7 @@ class AppendBudgetLimitPeriods extends Command
/**
* @param BudgetLimit $limit
*/
- private function fixLimit(BudgetLimit $limit)
+ private function fixLimit(BudgetLimit $limit): void
{
$period = $this->getLimitPeriod($limit);
diff --git a/app/Console/Commands/Upgrade/MigrateToRules.php b/app/Console/Commands/Upgrade/MigrateToRules.php
index 6e8c804894..d35610d6d5 100644
--- a/app/Console/Commands/Upgrade/MigrateToRules.php
+++ b/app/Console/Commands/Upgrade/MigrateToRules.php
@@ -56,16 +56,12 @@ class MigrateToRules extends Command
*
* @var string
*/
- protected $signature = 'firefly-iii:bills-to-rules {--F|force : Force the execution of this command.}';
- /** @var BillRepositoryInterface */
- private $billRepository;
- private $count;
- /** @var RuleGroupRepositoryInterface */
- private $ruleGroupRepository;
- /** @var RuleRepositoryInterface */
- private $ruleRepository;
- /** @var UserRepositoryInterface */
- private $userRepository;
+ protected $signature = 'firefly-iii:bills-to-rules {--F|force : Force the execution of this command.}';
+ private BillRepositoryInterface $billRepository;
+ private int $count;
+ private RuleGroupRepositoryInterface $ruleGroupRepository;
+ private RuleRepositoryInterface $ruleRepository;
+ private UserRepositoryInterface $userRepository;
/**
* Execute the console command.
diff --git a/app/Console/Commands/Upgrade/UpgradeLiabilitiesEight.php b/app/Console/Commands/Upgrade/UpgradeLiabilitiesEight.php
index 196d3dee33..f1f23df484 100644
--- a/app/Console/Commands/Upgrade/UpgradeLiabilitiesEight.php
+++ b/app/Console/Commands/Upgrade/UpgradeLiabilitiesEight.php
@@ -219,11 +219,11 @@ class UpgradeLiabilitiesEight extends Command
}
/**
- * @param $account
+ * @param Account $account
*
* @return int
*/
- private function deleteTransactions($account): int
+ private function deleteTransactions(Account $account): int
{
$count = 0;
$journals = TransactionJournal::leftJoin('transactions', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
diff --git a/app/Events/ActuallyLoggedIn.php b/app/Events/ActuallyLoggedIn.php
index 557dad3b38..598077fe0a 100644
--- a/app/Events/ActuallyLoggedIn.php
+++ b/app/Events/ActuallyLoggedIn.php
@@ -25,6 +25,7 @@ declare(strict_types=1);
namespace FireflyIII\Events;
use FireflyIII\User;
+use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Queue\SerializesModels;
/**
@@ -37,10 +38,13 @@ class ActuallyLoggedIn extends Event
public User $user;
/**
- * @param User $user
+ * @param User|Authenticatable|null $user
*/
- public function __construct(User $user)
+ public function __construct(User | Authenticatable | null $user)
{
- $this->user = $user;
+ if ($user instanceof User) {
+ $this->user = $user;
+ }
+
}
}
diff --git a/app/Exceptions/IntervalException.php b/app/Exceptions/IntervalException.php
index d67fcab253..6c14be925e 100644
--- a/app/Exceptions/IntervalException.php
+++ b/app/Exceptions/IntervalException.php
@@ -37,9 +37,10 @@ final class IntervalException extends Exception
public array $availableIntervals;
public Periodicity $periodicity;
- protected $message = 'The periodicity %s is unknown. Choose one of available periodicity: %s';
+ /** @var string */
+ protected $message = 'The periodicity %s is unknown. Choose one of available periodicity: %s';
- public function __construct(string $message = "", int $code = 0, ?Throwable $previous = null)
+ public function __construct(string $message = '', int $code = 0, ?Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
$this->availableIntervals = [];
diff --git a/app/Helpers/Collector/Extensions/AccountCollection.php b/app/Helpers/Collector/Extensions/AccountCollection.php
index afb2466ea4..2981ae44dc 100644
--- a/app/Helpers/Collector/Extensions/AccountCollection.php
+++ b/app/Helpers/Collector/Extensions/AccountCollection.php
@@ -103,7 +103,7 @@ trait AccountCollection
if ($accounts->count() > 0) {
$accountIds = $accounts->pluck('id')->toArray();
$this->query->where(
- static function (EloquentBuilder $query) use ($accountIds) {
+ static function (EloquentBuilder $query) use ($accountIds) { // @phpstan-ignore-line
$query->whereIn('source.account_id', $accountIds);
$query->orWhereIn('destination.account_id', $accountIds);
}
@@ -126,7 +126,7 @@ trait AccountCollection
if ($accounts->count() > 0) {
$accountIds = $accounts->pluck('id')->toArray();
$this->query->where(
- static function (EloquentBuilder $query) use ($accountIds) {
+ static function (EloquentBuilder $query) use ($accountIds) { // @phpstan-ignore-line
$query->whereIn('source.account_id', $accountIds);
$query->whereIn('destination.account_id', $accountIds);
}
@@ -168,7 +168,7 @@ trait AccountCollection
if ($accounts->count() > 0) {
$accountIds = $accounts->pluck('id')->toArray();
$this->query->where(
- static function (EloquentBuilder $query) use ($accountIds) {
+ static function (EloquentBuilder $query) use ($accountIds) { // @phpstan-ignore-line
$query->whereNotIn('source.account_id', $accountIds);
$query->whereNotIn('destination.account_id', $accountIds);
}
@@ -210,7 +210,7 @@ trait AccountCollection
if ($accounts->count() > 0) {
$accountIds = $accounts->pluck('id')->toArray();
$this->query->where(
- static function (EloquentBuilder $q1) use ($accountIds) {
+ static function (EloquentBuilder $q1) use ($accountIds) { // @phpstan-ignore-line
// sourceAccount is in the set, and destination is NOT.
$q1->where(
diff --git a/app/Helpers/Collector/Extensions/AmountCollection.php b/app/Helpers/Collector/Extensions/AmountCollection.php
index 7e71d6e422..9635a46568 100644
--- a/app/Helpers/Collector/Extensions/AmountCollection.php
+++ b/app/Helpers/Collector/Extensions/AmountCollection.php
@@ -42,7 +42,7 @@ trait AmountCollection
public function amountIs(string $amount): GroupCollectorInterface
{
$this->query->where(
- static function (EloquentBuilder $q) use ($amount) {
+ static function (EloquentBuilder $q) use ($amount) { // @phpstan-ignore-line
$q->where('source.amount', app('steam')->negative($amount));
}
);
@@ -56,7 +56,7 @@ trait AmountCollection
public function amountIsNot(string $amount): GroupCollectorInterface
{
$this->query->where(
- static function (EloquentBuilder $q) use ($amount) {
+ static function (EloquentBuilder $q) use ($amount) { // @phpstan-ignore-line
$q->where('source.amount', '!=', app('steam')->negative($amount));
}
);
@@ -74,7 +74,7 @@ trait AmountCollection
public function amountLess(string $amount): GroupCollectorInterface
{
$this->query->where(
- function (EloquentBuilder $q) use ($amount) {
+ function (EloquentBuilder $q) use ($amount) { // @phpstan-ignore-line
$q->where('destination.amount', '<=', app('steam')->positive($amount));
}
);
@@ -92,7 +92,7 @@ trait AmountCollection
public function amountMore(string $amount): GroupCollectorInterface
{
$this->query->where(
- function (EloquentBuilder $q) use ($amount) {
+ function (EloquentBuilder $q) use ($amount) { // @phpstan-ignore-line
$q->where('destination.amount', '>=', app('steam')->positive($amount));
}
);
@@ -110,7 +110,7 @@ trait AmountCollection
public function foreignAmountIs(string $amount): GroupCollectorInterface
{
$this->query->where(
- static function (EloquentBuilder $q) use ($amount) {
+ static function (EloquentBuilder $q) use ($amount) { // @phpstan-ignore-line
$q->whereNotNull('source.foreign_amount');
$q->where('source.foreign_amount', app('steam')->negative($amount));
}
@@ -129,7 +129,7 @@ trait AmountCollection
public function foreignAmountIsNot(string $amount): GroupCollectorInterface
{
$this->query->where(
- static function (EloquentBuilder $q) use ($amount) {
+ static function (EloquentBuilder $q) use ($amount) { // @phpstan-ignore-line
$q->whereNull('source.foreign_amount');
$q->orWhere('source.foreign_amount', '!=', app('steam')->negative($amount));
}
@@ -148,7 +148,7 @@ trait AmountCollection
public function foreignAmountLess(string $amount): GroupCollectorInterface
{
$this->query->where(
- function (EloquentBuilder $q) use ($amount) {
+ function (EloquentBuilder $q) use ($amount) { // @phpstan-ignore-line
$q->whereNotNull('destination.foreign_amount');
$q->where('destination.foreign_amount', '<=', app('steam')->positive($amount));
}
@@ -167,7 +167,7 @@ trait AmountCollection
public function foreignAmountMore(string $amount): GroupCollectorInterface
{
$this->query->where(
- function (EloquentBuilder $q) use ($amount) {
+ function (EloquentBuilder $q) use ($amount) { // @phpstan-ignore-line
$q->whereNotNull('destination.foreign_amount');
$q->where('destination.foreign_amount', '>=', app('steam')->positive($amount));
}
diff --git a/app/Helpers/Collector/Extensions/AttachmentCollection.php b/app/Helpers/Collector/Extensions/AttachmentCollection.php
index b2118615cb..0d8aa4b162 100644
--- a/app/Helpers/Collector/Extensions/AttachmentCollection.php
+++ b/app/Helpers/Collector/Extensions/AttachmentCollection.php
@@ -90,7 +90,7 @@ trait AttachmentCollection
$this->hasJoinedAttTables = true;
$this->query->leftJoin('attachments', 'attachments.attachable_id', '=', 'transaction_journals.id')
->where(
- static function (EloquentBuilder $q1) {
+ static function (EloquentBuilder $q1) { // @phpstan-ignore-line
$q1->where('attachments.attachable_type', TransactionJournal::class);
$q1->where('attachments.uploaded', true);
$q1->whereNull('attachments.deleted_at');
@@ -544,7 +544,7 @@ trait AttachmentCollection
app('log')->debug('Add filter on no attachments.');
$this->joinAttachmentTables();
- $this->query->where(function (Builder $q1) {
+ $this->query->where(function (Builder $q1) { // @phpstan-ignore-line
$q1
->whereNull('attachments.attachable_id')
->orWhere(function (Builder $q2) {
diff --git a/app/Helpers/Collector/Extensions/MetaCollection.php b/app/Helpers/Collector/Extensions/MetaCollection.php
index a8217a4b0a..7e867bae00 100644
--- a/app/Helpers/Collector/Extensions/MetaCollection.php
+++ b/app/Helpers/Collector/Extensions/MetaCollection.php
@@ -45,7 +45,7 @@ trait MetaCollection
public function excludeBills(Collection $bills): GroupCollectorInterface
{
$this->withBillInformation();
- $this->query->where(static function (EloquentBuilder $q1) use ($bills) {
+ $this->query->where(static function (EloquentBuilder $q1) use ($bills) { // @phpstan-ignore-line
$q1->whereNotIn('transaction_journals.bill_id', $bills->pluck('id')->toArray());
$q1->orWhereNull('transaction_journals.bill_id');
});
@@ -83,7 +83,7 @@ trait MetaCollection
{
$this->withBudgetInformation();
- $this->query->where(static function (EloquentBuilder $q2) use ($budget) {
+ $this->query->where(static function (EloquentBuilder $q2) use ($budget) { // @phpstan-ignore-line
$q2->where('budgets.id', '!=', $budget->id);
$q2->orWhereNull('budgets.id');
});
@@ -119,7 +119,7 @@ trait MetaCollection
{
if ($budgets->count() > 0) {
$this->withBudgetInformation();
- $this->query->where(static function (EloquentBuilder $q1) use ($budgets) {
+ $this->query->where(static function (EloquentBuilder $q1) use ($budgets) { // @phpstan-ignore-line
$q1->whereNotIn('budgets.id', $budgets->pluck('id')->toArray());
$q1->orWhereNull('budgets.id');
});
@@ -135,7 +135,7 @@ trait MetaCollection
{
if ($categories->count() > 0) {
$this->withCategoryInformation();
- $this->query->where(static function (EloquentBuilder $q1) use ($categories) {
+ $this->query->where(static function (EloquentBuilder $q1) use ($categories) { // @phpstan-ignore-line
$q1->whereNotIn('categories.id', $categories->pluck('id')->toArray());
$q1->orWhereNull('categories.id');
});
@@ -176,7 +176,7 @@ trait MetaCollection
{
$this->withCategoryInformation();
- $this->query->where(static function (EloquentBuilder $q2) use ($category) {
+ $this->query->where(static function (EloquentBuilder $q2) use ($category) { // @phpstan-ignore-line
$q2->where('categories.id', '!=', $category->id);
$q2->orWhereNull('categories.id');
});
@@ -618,7 +618,7 @@ trait MetaCollection
public function notesDoNotContain(string $value): GroupCollectorInterface
{
$this->withNotes();
- $this->query->where(static function (Builder $q) use ($value) {
+ $this->query->where(static function (Builder $q) use ($value) { // @phpstan-ignore-line
$q->whereNull('notes.text');
$q->orWhere('notes.text', 'NOT LIKE', sprintf('%%%s%%', $value));
});
@@ -634,7 +634,7 @@ trait MetaCollection
public function notesDontEndWith(string $value): GroupCollectorInterface
{
$this->withNotes();
- $this->query->where(static function (Builder $q) use ($value) {
+ $this->query->where(static function (Builder $q) use ($value) { // @phpstan-ignore-line
$q->whereNull('notes.text');
$q->orWhere('notes.text', 'NOT LIKE', sprintf('%%%s', $value));
});
@@ -650,7 +650,7 @@ trait MetaCollection
public function notesDontStartWith(string $value): GroupCollectorInterface
{
$this->withNotes();
- $this->query->where(static function (Builder $q) use ($value) {
+ $this->query->where(static function (Builder $q) use ($value) { // @phpstan-ignore-line
$q->whereNull('notes.text');
$q->orWhere('notes.text', 'NOT LIKE', sprintf('%s%%', $value));
});
@@ -692,7 +692,7 @@ trait MetaCollection
public function notesExactlyNot(string $value): GroupCollectorInterface
{
$this->withNotes();
- $this->query->where(static function (Builder $q) use ($value) {
+ $this->query->where(static function (Builder $q) use ($value) { // @phpstan-ignore-line
$q->whereNull('notes.text');
$q->orWhere('notes.text', '!=', sprintf('%s', $value));
});
@@ -1050,7 +1050,7 @@ trait MetaCollection
{
$this->joinMetaDataTables();
// TODO not sure if this will work properly.
- $this->query->where(function (Builder $q1) {
+ $this->query->where(function (Builder $q1) { // @phpstan-ignore-line
$q1->where(function (Builder $q2) {
$q2->where('journal_meta.name', '=', 'external_id');
$q2->whereNull('journal_meta.data');
@@ -1071,7 +1071,7 @@ trait MetaCollection
{
$this->joinMetaDataTables();
// TODO not sure if this will work properly.
- $this->query->where(function (Builder $q1) {
+ $this->query->where(function (Builder $q1) { // @phpstan-ignore-line
$q1->where(function (Builder $q2) {
$q2->where('journal_meta.name', '=', 'external_url');
$q2->whereNull('journal_meta.data');
@@ -1091,7 +1091,7 @@ trait MetaCollection
public function withoutNotes(): GroupCollectorInterface
{
$this->withNotes();
- $this->query->where(function (Builder $q) {
+ $this->query->where(function (Builder $q) { // @phpstan-ignore-line
$q->whereNull('notes.text');
$q->orWhere('notes.text', '');
});
diff --git a/app/Helpers/Collector/GroupCollector.php b/app/Helpers/Collector/GroupCollector.php
index 5236559e00..a5596ec208 100644
--- a/app/Helpers/Collector/GroupCollector.php
+++ b/app/Helpers/Collector/GroupCollector.php
@@ -151,7 +151,7 @@ class GroupCollector implements GroupCollectorInterface
public function descriptionDoesNotEnd(array $array): GroupCollectorInterface
{
$this->query->where(
- static function (EloquentBuilder $q) use ($array) {
+ static function (EloquentBuilder $q) use ($array) { // @phpstan-ignore-line
$q->where(
static function (EloquentBuilder $q1) use ($array) {
foreach ($array as $word) {
@@ -181,7 +181,7 @@ class GroupCollector implements GroupCollectorInterface
public function descriptionDoesNotStart(array $array): GroupCollectorInterface
{
$this->query->where(
- static function (EloquentBuilder $q) use ($array) {
+ static function (EloquentBuilder $q) use ($array) { // @phpstan-ignore-line
$q->where(
static function (EloquentBuilder $q1) use ($array) {
foreach ($array as $word) {
@@ -211,7 +211,7 @@ class GroupCollector implements GroupCollectorInterface
public function descriptionEnds(array $array): GroupCollectorInterface
{
$this->query->where(
- static function (EloquentBuilder $q) use ($array) {
+ static function (EloquentBuilder $q) use ($array) { // @phpstan-ignore-line
$q->where(
static function (EloquentBuilder $q1) use ($array) {
foreach ($array as $word) {
@@ -240,7 +240,7 @@ class GroupCollector implements GroupCollectorInterface
public function descriptionIs(string $value): GroupCollectorInterface
{
$this->query->where(
- static function (EloquentBuilder $q) use ($value) {
+ static function (EloquentBuilder $q) use ($value) { // @phpstan-ignore-line
$q->where('transaction_journals.description', '=', $value);
$q->orWhere('transaction_groups.title', '=', $value);
}
@@ -255,7 +255,7 @@ class GroupCollector implements GroupCollectorInterface
public function descriptionIsNot(string $value): GroupCollectorInterface
{
$this->query->where(
- static function (EloquentBuilder $q) use ($value) {
+ static function (EloquentBuilder $q) use ($value) { // @phpstan-ignore-line
$q->where('transaction_journals.description', '!=', $value);
$q->where(
static function (EloquentBuilder $q2) use ($value) {
@@ -275,7 +275,7 @@ class GroupCollector implements GroupCollectorInterface
public function descriptionStarts(array $array): GroupCollectorInterface
{
$this->query->where(
- static function (EloquentBuilder $q) use ($array) {
+ static function (EloquentBuilder $q) use ($array) { // @phpstan-ignore-line
$q->where(
static function (EloquentBuilder $q1) use ($array) {
foreach ($array as $word) {
@@ -341,7 +341,7 @@ class GroupCollector implements GroupCollectorInterface
public function excludeCurrency(TransactionCurrency $currency): GroupCollectorInterface
{
$this->query->where(
- static function (EloquentBuilder $q) use ($currency) {
+ static function (EloquentBuilder $q) use ($currency) { // @phpstan-ignore-line
$q->where('source.transaction_currency_id', '!=', $currency->id);
$q->where(
static function (EloquentBuilder $q2) use ($currency) {
@@ -360,7 +360,7 @@ class GroupCollector implements GroupCollectorInterface
*/
public function excludeForeignCurrency(TransactionCurrency $currency): GroupCollectorInterface
{
- $this->query->where(static function (EloquentBuilder $q2) use ($currency) {
+ $this->query->where(static function (EloquentBuilder $q2) use ($currency) { // @phpstan-ignore-line
$q2->where('source.foreign_currency_id', '!=', $currency->id);
$q2->orWhereNull('source.foreign_currency_id');
});
@@ -415,7 +415,7 @@ class GroupCollector implements GroupCollectorInterface
return $this;
}
$this->query->where(
- static function (EloquentBuilder $q) use ($array) {
+ static function (EloquentBuilder $q) use ($array) { // @phpstan-ignore-line
$q->where(
static function (EloquentBuilder $q1) use ($array) {
foreach ($array as $word) {
@@ -903,7 +903,7 @@ class GroupCollector implements GroupCollectorInterface
public function setCurrency(TransactionCurrency $currency): GroupCollectorInterface
{
$this->query->where(
- static function (EloquentBuilder $q) use ($currency) {
+ static function (EloquentBuilder $q) use ($currency) { // @phpstan-ignore-line
$q->where('source.transaction_currency_id', $currency->id);
$q->orWhere('source.foreign_currency_id', $currency->id);
}
@@ -915,9 +915,10 @@ class GroupCollector implements GroupCollectorInterface
/**
* @param bool $expandGroupSearch
*/
- public function setExpandGroupSearch(bool $expandGroupSearch): void
+ public function setExpandGroupSearch(bool $expandGroupSearch): GroupCollectorInterface
{
$this->expandGroupSearch = $expandGroupSearch;
+ return $this;
}
/**
@@ -993,7 +994,7 @@ class GroupCollector implements GroupCollectorInterface
return $this;
}
$this->query->where(
- static function (EloquentBuilder $q) use ($array) {
+ static function (EloquentBuilder $q) use ($array) { // @phpstan-ignore-line
$q->where(
static function (EloquentBuilder $q1) use ($array) {
foreach ($array as $word) {
diff --git a/app/Helpers/Collector/GroupCollectorInterface.php b/app/Helpers/Collector/GroupCollectorInterface.php
index 49880b7cf2..05d12d63d7 100644
--- a/app/Helpers/Collector/GroupCollectorInterface.php
+++ b/app/Helpers/Collector/GroupCollectorInterface.php
@@ -1090,7 +1090,7 @@ interface GroupCollectorInterface
/**
* @param bool $expandGroupSearch
*/
- public function setExpandGroupSearch(bool $expandGroupSearch);
+ public function setExpandGroupSearch(bool $expandGroupSearch): GroupCollectorInterface;
/**
* Look for specific external ID's.
diff --git a/app/Http/Controllers/AttachmentController.php b/app/Http/Controllers/AttachmentController.php
index 6f45458f30..75da44d68f 100644
--- a/app/Http/Controllers/AttachmentController.php
+++ b/app/Http/Controllers/AttachmentController.php
@@ -41,8 +41,7 @@ use Illuminate\View\View;
*/
class AttachmentController extends Controller
{
- /** @var AttachmentRepositoryInterface Attachment repository */
- private $repository;
+ private AttachmentRepositoryInterface $repository;
/**
* AttachmentController constructor.
@@ -128,7 +127,7 @@ class AttachmentController extends Controller
->header('Expires', '0')
->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
->header('Pragma', 'public')
- ->header('Content-Length', strlen($content));
+ ->header('Content-Length', (string) strlen($content));
return $response;
}
diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php
index f4ab78dcbd..650a9000b3 100644
--- a/app/Http/Controllers/Auth/LoginController.php
+++ b/app/Http/Controllers/Auth/LoginController.php
@@ -34,6 +34,7 @@ use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Foundation\Auth\ThrottlesLogins;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
@@ -81,10 +82,10 @@ class LoginController extends Controller
/**
* Handle a login request to the application.
*
- *
+ * @return JsonResponse|RedirectResponse
* @throws ValidationException
*/
- public function login(Request $request)
+ public function login(Request $request): JsonResponse | RedirectResponse
{
Log::channel('audit')->info(sprintf('User is trying to login using "%s"', $request->get($this->username())));
app('log')->info('User is trying to login.');
diff --git a/app/Http/Controllers/Bill/IndexController.php b/app/Http/Controllers/Bill/IndexController.php
index bcc0a202d1..bec711efb0 100644
--- a/app/Http/Controllers/Bill/IndexController.php
+++ b/app/Http/Controllers/Bill/IndexController.php
@@ -30,6 +30,9 @@ use FireflyIII\Models\Bill;
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\Repositories\ObjectGroup\OrganisesObjectGroups;
use FireflyIII\Transformers\BillTransformer;
+use Illuminate\Contracts\View\Factory;
+use Illuminate\Contracts\View\View;
+use Illuminate\Foundation\Application;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Psr\Container\ContainerExceptionInterface;
@@ -68,7 +71,7 @@ class IndexController extends Controller
/**
* Show all bills.
*/
- public function index()
+ public function index(): View | Application | Factory | \Illuminate\Contracts\Foundation\Application
{
$this->cleanupObjectGroups();
$this->repository->correctOrder();
diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.php
index 1d350f2ad6..163d321fcb 100644
--- a/app/Http/Controllers/DebugController.php
+++ b/app/Http/Controllers/DebugController.php
@@ -270,7 +270,7 @@ class DebugController extends Controller
$userAgent = request()->header('user-agent');
// set languages, see what happens:
- $original = setlocale(LC_ALL, 0);
+ $original = setlocale(LC_ALL, '0');
$localeAttempts = [];
$parts = app('steam')->getLocaleArray(app('steam')->getLocale());
foreach ($parts as $code) {
diff --git a/app/Http/Controllers/Export/IndexController.php b/app/Http/Controllers/Export/IndexController.php
index 0c1e84f4a3..c7e3cdbb45 100644
--- a/app/Http/Controllers/Export/IndexController.php
+++ b/app/Http/Controllers/Export/IndexController.php
@@ -102,7 +102,7 @@ class IndexController extends Controller
->header('Expires', '0')
->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
->header('Pragma', 'public')
- ->header('Content-Length', strlen($result['transactions']));
+ ->header('Content-Length', (string) strlen($result['transactions']));
// return CSV file made from 'transactions' array.
return $response;
diff --git a/app/Http/Controllers/Json/BoxController.php b/app/Http/Controllers/Json/BoxController.php
index bb3449bd94..880405105f 100644
--- a/app/Http/Controllers/Json/BoxController.php
+++ b/app/Http/Controllers/Json/BoxController.php
@@ -73,7 +73,7 @@ class BoxController extends Controller
$cache->addProperty($today);
$cache->addProperty('box-available');
if ($cache->has()) {
- //return response()->json($cache->get());
+ return response()->json($cache->get());
}
$leftPerDayAmount = '0';
$leftToSpendAmount = '0';
@@ -83,7 +83,7 @@ class BoxController extends Controller
$availableBudgets = $abRepository->getAvailableBudgetsByExactDate($start, $end);
app('log')->debug(sprintf('Found %d available budget(s)', $availableBudgets->count()));
$availableBudgets = $availableBudgets->filter(
- static function (AvailableBudget $availableBudget) use ($currency) {
+ static function (AvailableBudget $availableBudget) use ($currency) { // @phpstan-ignore-line
if ($availableBudget->transaction_currency_id === $currency->id) {
app('log')->debug(sprintf(
'Will include AB #%d: from %s-%s amount %s',
diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php
index 5e48aa7cfc..322929bc3d 100644
--- a/app/Http/Controllers/TagController.php
+++ b/app/Http/Controllers/TagController.php
@@ -180,9 +180,11 @@ class TagController extends Controller
}
/**
+ * @param Request $request
*
+ * @return RedirectResponse
*/
- public function massDestroy(Request $request)
+ public function massDestroy(Request $request): RedirectResponse
{
$tags = $request->get('tags');
if (null === $tags || !is_array($tags)) {
diff --git a/app/Jobs/MailError.php b/app/Jobs/MailError.php
index a31354e378..d5e59a080f 100644
--- a/app/Jobs/MailError.php
+++ b/app/Jobs/MailError.php
@@ -70,9 +70,8 @@ class MailError extends Job implements ShouldQueue
/**
* Execute the job.
*
- * @throws FireflyException
*/
- public function handle()
+ public function handle(): void
{
$email = (string)config('firefly.site_owner');
$args = $this->exception;
diff --git a/app/Models/Bill.php b/app/Models/Bill.php
index 546186428a..ab17abbb30 100644
--- a/app/Models/Bill.php
+++ b/app/Models/Bill.php
@@ -31,6 +31,8 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphMany;
+use Illuminate\Database\Eloquent\Relations\MorphTo;
+use Illuminate\Database\Eloquent\Relations\MorphToMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
use Carbon\Carbon;
@@ -192,9 +194,9 @@ class Bill extends Model
}
/**
- * Get all of the tags for the post.
+ * Get all the tags for the post.
*/
- public function objectGroups()
+ public function objectGroups(): MorphToMany
{
return $this->morphToMany(ObjectGroup::class, 'object_groupable');
}
diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php
index d8c6d4d38a..b05a653e46 100644
--- a/app/Repositories/Account/AccountRepository.php
+++ b/app/Repositories/Account/AccountRepository.php
@@ -116,7 +116,7 @@ class AccountRepository implements AccountRepositoryInterface
->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
->where('accounts.active', true)
->where(
- function (EloquentBuilder $q1) use ($number) {
+ function (EloquentBuilder $q1) use ($number) { // @phpstan-ignore-line
$json = json_encode($number);
$q1->where('account_meta.name', '=', 'account_number');
$q1->where('account_meta.data', '=', $json);
@@ -728,7 +728,7 @@ class AccountRepository implements AccountRepositoryInterface
foreach ($parts as $part) {
$search = sprintf('%%%s%%', $part);
$dbQuery->where(
- function (EloquentBuilder $q1) use ($search) {
+ function (EloquentBuilder $q1) use ($search) { // @phpstan-ignore-line
$q1->where('accounts.iban', 'LIKE', $search);
$q1->orWhere(
function (EloquentBuilder $q2) use ($search) {
diff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.php
index 4e71af2b63..df8e3ec943 100644
--- a/app/Repositories/Account/AccountRepositoryInterface.php
+++ b/app/Repositories/Account/AccountRepositoryInterface.php
@@ -123,7 +123,7 @@ interface AccountRepositoryInterface
public function getAccountsById(array $accountIds): Collection;
/**
- * @param array $types
+ * @param array<int, string> $types
* @param array|null $sort
*
* @return Collection
diff --git a/app/Repositories/Budget/AvailableBudgetRepository.php b/app/Repositories/Budget/AvailableBudgetRepository.php
index 4aedcc6608..61c1930715 100644
--- a/app/Repositories/Budget/AvailableBudgetRepository.php
+++ b/app/Repositories/Budget/AvailableBudgetRepository.php
@@ -72,7 +72,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
$query = $this->user->availableBudgets()->with(['transactionCurrency']);
if (null !== $start && null !== $end) {
$query->where(
- static function (Builder $q1) use ($start, $end) {
+ static function (Builder $q1) use ($start, $end) { // @phpstan-ignore-line
$q1->where('start_date', '=', $start->format('Y-m-d'));
$q1->where('end_date', '=', $end->format('Y-m-d'));
}
diff --git a/app/Repositories/Budget/BudgetLimitRepository.php b/app/Repositories/Budget/BudgetLimitRepository.php
index 005e817fdc..0446dff6dc 100644
--- a/app/Repositories/Budget/BudgetLimitRepository.php
+++ b/app/Repositories/Budget/BudgetLimitRepository.php
@@ -240,7 +240,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
// when both dates are set:
return $budget->budgetlimits()
->where(
- static function (Builder $q5) use ($start, $end) {
+ static function (Builder $q5) use ($start, $end) { // @phpstan-ignore-line
$q5->where(
static function (Builder $q1) use ($start, $end) {
// budget limit ends within period
@@ -397,7 +397,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
$limits = $budget->budgetlimits()
->where('budget_limits.start_date', $start->format('Y-m-d 00:00:00'))
->where('budget_limits.end_date', $end->format('Y-m-d 00:00:00'))
- ->count(['budget_limits.*']);
+ ->count('budget_limits.*');
app('log')->debug(sprintf('Found %d budget limits.', $limits));
// there might be a budget limit for these dates:
diff --git a/app/Repositories/Recurring/RecurringRepository.php b/app/Repositories/Recurring/RecurringRepository.php
index 606e4eaeaf..f49c7d1b92 100644
--- a/app/Repositories/Recurring/RecurringRepository.php
+++ b/app/Repositories/Recurring/RecurringRepository.php
@@ -238,7 +238,7 @@ class RecurringRepository implements RecurringRepositoryInterface
if (null !== $end) {
$query->where('transaction_journals.date', '<=', $end->format('Y-m-d 00:00:00'));
}
- return $query->count(['transaction_journals.id']);
+ return $query->count('transaction_journals.id');
}
/**
diff --git a/app/Repositories/UserGroup/UserGroupRepository.php b/app/Repositories/UserGroup/UserGroupRepository.php
index 3a03563ae1..b7483e0528 100644
--- a/app/Repositories/UserGroup/UserGroupRepository.php
+++ b/app/Repositories/UserGroup/UserGroupRepository.php
@@ -220,7 +220,7 @@ class UserGroupRepository implements UserGroupRepositoryInterface
return $userGroup;
}
// count the number of members in the group right now:
- $membershipCount = $userGroup->groupMemberships()->distinct()->count(['group_memberships.user_id']);
+ $membershipCount = $userGroup->groupMemberships()->distinct()->count('group_memberships.user_id');
// if it's 1:
if (1 === $membershipCount) {
diff --git a/app/Services/Internal/Support/AccountServiceTrait.php b/app/Services/Internal/Support/AccountServiceTrait.php
index 053a41e70d..afefb43d4f 100644
--- a/app/Services/Internal/Support/AccountServiceTrait.php
+++ b/app/Services/Internal/Support/AccountServiceTrait.php
@@ -433,7 +433,7 @@ trait AccountServiceTrait
// if exists, update:
$currency = $this->accountRepository->getAccountCurrency($account);
if (null === $currency) {
- $currency = app('amount')->getDefaultCurrencyByUserGroup($account->user);
+ $currency = app('amount')->getDefaultCurrencyByUserGroup($account->user->userGroup);
}
// simply grab the first journal and change it:
diff --git a/app/Services/Internal/Update/CategoryUpdateService.php b/app/Services/Internal/Update/CategoryUpdateService.php
index 308de72e91..b64cde974a 100644
--- a/app/Services/Internal/Update/CategoryUpdateService.php
+++ b/app/Services/Internal/Update/CategoryUpdateService.php
@@ -29,6 +29,7 @@ use FireflyIII\Models\Note;
use FireflyIII\Models\RecurrenceTransactionMeta;
use FireflyIII\Models\RuleAction;
use FireflyIII\Models\RuleTrigger;
+use FireflyIII\User;
/**
* Class CategoryUpdateService
@@ -37,7 +38,7 @@ use FireflyIII\Models\RuleTrigger;
*/
class CategoryUpdateService
{
- private $user;
+ private User $user;
/**
* Constructor.
@@ -45,7 +46,9 @@ class CategoryUpdateService
public function __construct()
{
if (auth()->check()) {
- $this->user = auth()->user();
+ /** @var User $user */
+ $user = auth()->user();
+ $this->user = $user;
}
}
diff --git a/app/Support/Authentication/RemoteUserGuard.php b/app/Support/Authentication/RemoteUserGuard.php
index 07422754b8..8dc0640a3a 100644
--- a/app/Support/Authentication/RemoteUserGuard.php
+++ b/app/Support/Authentication/RemoteUserGuard.php
@@ -40,7 +40,9 @@ use Psr\Container\NotFoundExceptionInterface;
class RemoteUserGuard implements Guard
{
protected Application $application;
+ /** @var UserProvider */
protected $provider;
+ /** @var User|null */
protected $user;
/**
@@ -166,10 +168,14 @@ class RemoteUserGuard implements Guard
/**
* @inheritDoc
*/
- public function setUser(Authenticatable $user)
+ public function setUser(Authenticatable | User | null $user)
{
app('log')->debug(sprintf('Now at %s', __METHOD__));
- $this->user = $user;
+ if ($user instanceof User) {
+ $this->user = $user;
+ return;
+ }
+ app('log')->error(sprintf('Did not set user at %s', __METHOD__));
}
/**
diff --git a/app/Support/NullArrayObject.php b/app/Support/NullArrayObject.php
index 035488f626..4685abb517 100644
--- a/app/Support/NullArrayObject.php
+++ b/app/Support/NullArrayObject.php
@@ -32,6 +32,7 @@ use ArrayObject;
*/
class NullArrayObject extends ArrayObject
{
+ /** @var mixed|null */
public $default = null;
/**
diff --git a/app/Support/Preferences.php b/app/Support/Preferences.php
index 9aa647b04b..dc4d913817 100644
--- a/app/Support/Preferences.php
+++ b/app/Support/Preferences.php
@@ -78,12 +78,12 @@ class Preferences
/**
* @param User $user
* @param string $name
- * @param null|string|int $default
+ * @param null|string|int|bool|array $default
*
* @return Preference|null
* @throws FireflyException
*/
- public function getForUser(User $user, string $name, $default = null): ?Preference
+ public function getForUser(User $user, string $name, string|int|bool|null|array $default = null): ?Preference
{
if ('currencyPreference' === $name) {
throw new FireflyException('No longer supports "currencyPreference", please refactor me.');
diff --git a/app/Support/Request/ConvertsDataTypes.php b/app/Support/Request/ConvertsDataTypes.php
index 6f8d62ecf1..178f45d62b 100644
--- a/app/Support/Request/ConvertsDataTypes.php
+++ b/app/Support/Request/ConvertsDataTypes.php
@@ -274,6 +274,10 @@ trait ConvertsDataTypes
return null;
}
+ if(false === $carbon) {
+ app('log')->error(sprintf('[2] "%s" is of an invalid format.', $value));
+ return null;
+ }
return $carbon;
}
// is an atom string, I hope?
diff --git a/app/Support/Search/AccountSearch.php b/app/Support/Search/AccountSearch.php
index b333023473..6ab13e967f 100644
--- a/app/Support/Search/AccountSearch.php
+++ b/app/Support/Search/AccountSearch.php
@@ -69,7 +69,7 @@ class AccountSearch implements GenericSearchInterface
default:
case self::SEARCH_ALL:
$searchQuery->where(
- static function (Builder $q) use ($like) {
+ static function (Builder $q) use ($like) { // @phpstan-ignore-line
$q->where('accounts.id', 'LIKE', $like);
$q->orWhere('accounts.name', 'LIKE', $like);
$q->orWhere('accounts.iban', 'LIKE', $like);
@@ -77,7 +77,7 @@ class AccountSearch implements GenericSearchInterface
);
// meta data:
$searchQuery->orWhere(
- static function (Builder $q) use ($originalQuery) {
+ static function (Builder $q) use ($originalQuery) { // @phpstan-ignore-line
$json = json_encode($originalQuery, JSON_THROW_ON_ERROR);
$q->where('account_meta.name', '=', 'account_number');
$q->where('account_meta.data', 'LIKE', $json);
@@ -96,7 +96,7 @@ class AccountSearch implements GenericSearchInterface
case self::SEARCH_NUMBER:
// meta data:
$searchQuery->Where(
- static function (Builder $q) use ($originalQuery) {
+ static function (Builder $q) use ($originalQuery) { // @phpstan-ignore-line
$json = json_encode($originalQuery, JSON_THROW_ON_ERROR);
$q->where('account_meta.name', 'account_number');
$q->where('account_meta.data', $json);
diff --git a/app/Support/Search/OperatorQuerySearch.php b/app/Support/Search/OperatorQuerySearch.php
index e7572f239d..211ad4d559 100644
--- a/app/Support/Search/OperatorQuerySearch.php
+++ b/app/Support/Search/OperatorQuerySearch.php
@@ -148,7 +148,7 @@ class OperatorQuerySearch implements SearchInterface
* @inheritDoc
* @throws FireflyException
*/
- public function parseQuery(string $query)
+ public function parseQuery(string $query): void
{
app('log')->debug(sprintf('Now in parseQuery(%s)', $query));
$parser = new QueryParser();
@@ -1671,7 +1671,7 @@ class OperatorQuerySearch implements SearchInterface
*
* @throws FireflyException
*/
- private function setDateAfterParams(array $range, bool $prohibited = false)
+ private function setDateAfterParams(array $range, bool $prohibited = false): void
{
/**
* @var string $key
diff --git a/app/Support/Search/SearchInterface.php b/app/Support/Search/SearchInterface.php
index 100168f36e..3ce60fd9bf 100644
--- a/app/Support/Search/SearchInterface.php
+++ b/app/Support/Search/SearchInterface.php
@@ -61,7 +61,7 @@ interface SearchInterface
/**
* @param string $query
*/
- public function parseQuery(string $query);
+ public function parseQuery(string $query): void;
/**
* @return float
@@ -91,5 +91,5 @@ interface SearchInterface
/**
* @param User $user
*/
- public function setUser(User $user);
+ public function setUser(User $user): void;
}
diff --git a/app/TransactionRules/Actions/AppendDescriptionToNotes.php b/app/TransactionRules/Actions/AppendDescriptionToNotes.php
index 837744a7bb..1b16a24ae9 100644
--- a/app/TransactionRules/Actions/AppendDescriptionToNotes.php
+++ b/app/TransactionRules/Actions/AppendDescriptionToNotes.php
@@ -52,11 +52,11 @@ class AppendDescriptionToNotes implements ActionInterface
*/
public function actOnArray(array $journal): bool
{
- /** @var TransactionJournal $journal */
+ /** @var TransactionJournal|null $object */
$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
if (null === $object) {
app('log')->error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id']));
- event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_other_user')));
+ event(new RuleActionFailedOnArray($this->action, $journal, (string) trans('rules.journal_other_user')));
return false;
}
$note = $object->notes()->first();
diff --git a/app/TransactionRules/Actions/ConvertToTransfer.php b/app/TransactionRules/Actions/ConvertToTransfer.php
index fe371a2788..b4720bc2e7 100644
--- a/app/TransactionRules/Actions/ConvertToTransfer.php
+++ b/app/TransactionRules/Actions/ConvertToTransfer.php
@@ -157,7 +157,7 @@ class ConvertToTransfer implements ActionInterface
*/
private function getSourceType(int $journalId): string
{
- /** @var TransactionJournal $journal */
+ /** @var TransactionJournal|null $journal */
$journal = TransactionJournal::find($journalId);
if (null === $journal) {
app('log')->error(sprintf('Journal #%d does not exist. Cannot convert to transfer.', $journalId));
diff --git a/app/Transformers/V2/BillTransformer.php b/app/Transformers/V2/BillTransformer.php
index 965eb2137e..5dff9fedae 100644
--- a/app/Transformers/V2/BillTransformer.php
+++ b/app/Transformers/V2/BillTransformer.php
@@ -119,7 +119,7 @@ class BillTransformer extends AbstractTransformer
app('log')->debug(sprintf('Processing journal #%d', $journal->id));
$transaction = $transactions[(int)$journal->id] ?? [];
$billId = (int)$journal->bill_id;
- $currencyId = (int)$transaction['transaction_currency_id'] ?? 0;
+ $currencyId = (int)($transaction['transaction_currency_id'] ?? 0);
$currencies[$currencyId] = $currencies[$currencyId] ?? TransactionCurrency::find($currencyId);
// foreign currency
diff --git a/app/Validation/AutoBudget/ValidatesAutoBudgetRequest.php b/app/Validation/AutoBudget/ValidatesAutoBudgetRequest.php
index ca5cf1db76..c7abe0fdbc 100644
--- a/app/Validation/AutoBudget/ValidatesAutoBudgetRequest.php
+++ b/app/Validation/AutoBudget/ValidatesAutoBudgetRequest.php
@@ -54,9 +54,6 @@ trait ValidatesAutoBudgetRequest
return;
}
- if ('' === (string) $amount) {
- $validator->errors()->add('auto_budget_amount', (string)trans('validation.amount_required_for_auto_budget'));
- }
if (1 !== bccomp((string)$amount, '0')) {
$validator->errors()->add('auto_budget_amount', (string)trans('validation.auto_budget_amount_positive'));
}
diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php
index 22a603d6c7..ca0c9f0087 100644
--- a/app/Validation/FireflyValidator.php
+++ b/app/Validation/FireflyValidator.php
@@ -671,12 +671,12 @@ class FireflyValidator extends Validator
}
/**
- * @param $attribute
- * @param $value
+ * @param string|null $attribute
+ * @param string|null $value
*
* @return bool
*/
- public function validateUniqueCurrencyCode($attribute, $value): bool
+ public function validateUniqueCurrencyCode(string|null $attribute, string|null $value): bool
{
return $this->validateUniqueCurrency('code', (string)$attribute, (string)$value);
}
@@ -694,23 +694,23 @@ class FireflyValidator extends Validator
}
/**
- * @param $attribute
- * @param $value
+ * @param string|null $attribute
+ * @param string|null $value
*
* @return bool
*/
- public function validateUniqueCurrencyName($attribute, $value): bool
+ public function validateUniqueCurrencyName(string|null $attribute, string|null $value): bool
{
return $this->validateUniqueCurrency('name', (string)$attribute, (string)$value);
}
/**
- * @param $attribute
- * @param $value
+ * @param string|null $attribute
+ * @param string|null $value
*
* @return bool
*/
- public function validateUniqueCurrencySymbol($attribute, $value): bool
+ public function validateUniqueCurrencySymbol(string|null $attribute, string|null $value): bool
{
return $this->validateUniqueCurrency('symbol', (string)$attribute, (string)$value);
}
diff --git a/app/Validation/GroupValidation.php b/app/Validation/GroupValidation.php
index dd5fe2ee81..bdfe6c4e1c 100644
--- a/app/Validation/GroupValidation.php
+++ b/app/Validation/GroupValidation.php
@@ -106,7 +106,7 @@ trait GroupValidation
$count = Transaction::leftJoin('transaction_journals', 'transaction_journals.id', 'transactions.transaction_journal_id')
->leftJoin('transaction_groups', 'transaction_groups.id', 'transaction_journals.transaction_group_id')
->where('transaction_journals.transaction_group_id', $transactionGroup->id)
- ->where('transactions.reconciled', 1)->where('transactions.amount', '<', 0)->count(['transactions.id']);
+ ->where('transactions.reconciled', 1)->where('transactions.amount', '<', 0)->count('transactions.id');
if (0 === $count) {
app('log')->debug(sprintf('Transaction is not reconciled, done with %s', __METHOD__));
return;
diff --git a/app/Validation/TransactionValidation.php b/app/Validation/TransactionValidation.php
index 22c773fc6f..d4db3effc8 100644
--- a/app/Validation/TransactionValidation.php
+++ b/app/Validation/TransactionValidation.php
@@ -324,7 +324,7 @@ trait TransactionValidation
*/
private function isLiability(Account $account): bool
{
- $type = $account->accountType?->type;
+ $type = $account->accountType->type;
if (in_array($type, config('firefly.valid_liabilities'), true)) {
return true;
}
@@ -338,7 +338,7 @@ trait TransactionValidation
*/
private function isAsset(Account $account): bool
{
- $type = $account->accountType?->type;
+ $type = $account->accountType->type;
return $type === AccountType::ASSET;
}
diff --git a/bootstrap/app.php b/bootstrap/app.php
index cd8a24b28d..d340c986dd 100644
--- a/bootstrap/app.php
+++ b/bootstrap/app.php
@@ -37,11 +37,11 @@ bcscale(12);
if (!function_exists('envNonEmpty')) {
/**
* @param string $key
- * @param null $default
+ * @param string|int|bool|null $default
*
* @return mixed|null
*/
- function envNonEmpty(string $key, $default = null)
+ function envNonEmpty(string $key, string|int|bool|null $default = null)
{
$result = env($key, $default);
if ('' === $result) {
diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php
index 8c18621566..bdce19f553 100644
--- a/database/seeders/DatabaseSeeder.php
+++ b/database/seeders/DatabaseSeeder.php
@@ -33,7 +33,7 @@ class DatabaseSeeder extends Seeder
/**
* Run the database seeds.
*/
- public function run()
+ public function run(): void
{
$this->call(AccountTypeSeeder::class);
$this->call(TransactionCurrencySeeder::class);
diff --git a/database/seeders/ExchangeRateSeeder.php b/database/seeders/ExchangeRateSeeder.php
index b5f3ff7350..188159187f 100644
--- a/database/seeders/ExchangeRateSeeder.php
+++ b/database/seeders/ExchangeRateSeeder.php
@@ -35,8 +35,6 @@ use Illuminate\Support\Collection;
*/
class ExchangeRateSeeder extends Seeder
{
- private Collection $users;
-
/**
* @return void
*/
diff --git a/database/seeders/LinkTypeSeeder.php b/database/seeders/LinkTypeSeeder.php
index 45a68d1149..e115bb2ad8 100644
--- a/database/seeders/LinkTypeSeeder.php
+++ b/database/seeders/LinkTypeSeeder.php
@@ -32,7 +32,10 @@ use PDOException;
*/
class LinkTypeSeeder extends Seeder
{
- public function run()
+ /**
+ * @return void
+ */
+ public function run(): void
{
$types = [
[
diff --git a/database/seeders/PermissionSeeder.php b/database/seeders/PermissionSeeder.php
index 019abbaa48..29ff77d72f 100644
--- a/database/seeders/PermissionSeeder.php
+++ b/database/seeders/PermissionSeeder.php
@@ -32,7 +32,7 @@ use PDOException;
*/
class PermissionSeeder extends Seeder
{
- public function run()
+ public function run(): void
{
$roles = [
[
diff --git a/database/seeders/TransactionCurrencySeeder.php b/database/seeders/TransactionCurrencySeeder.php
index 21a691f48d..b13752fad8 100644
--- a/database/seeders/TransactionCurrencySeeder.php
+++ b/database/seeders/TransactionCurrencySeeder.php
@@ -34,7 +34,7 @@ class TransactionCurrencySeeder extends Seeder
{
/**
*/
- public function run()
+ public function run(): void
{
$currencies = [];
// european currencies
diff --git a/database/seeders/TransactionTypeSeeder.php b/database/seeders/TransactionTypeSeeder.php
index 517b5d15ed..da0db936fd 100644
--- a/database/seeders/TransactionTypeSeeder.php
+++ b/database/seeders/TransactionTypeSeeder.php
@@ -32,7 +32,7 @@ use PDOException;
*/
class TransactionTypeSeeder extends Seeder
{
- public function run()
+ public function run(): void
{
$types = [
TransactionType::WITHDRAWAL,