mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix various phpstan issues.
This commit is contained in:
parent
ef428a0226
commit
0220cf9784
@ -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
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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)) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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.');
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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))
|
||||
);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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')
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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 = [];
|
||||
|
@ -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(
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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', '');
|
||||
});
|
||||
|
@ -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) {
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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.');
|
||||
|
@ -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();
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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',
|
||||
|
@ -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)) {
|
||||
|
@ -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;
|
||||
|
@ -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');
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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'));
|
||||
}
|
||||
|
@ -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:
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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) {
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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__));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,6 +32,7 @@ use ArrayObject;
|
||||
*/
|
||||
class NullArrayObject extends ArrayObject
|
||||
{
|
||||
/** @var mixed|null */
|
||||
public $default = null;
|
||||
|
||||
/**
|
||||
|
@ -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.');
|
||||
|
@ -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?
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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));
|
||||
|
@ -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
|
||||
|
@ -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'));
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -35,8 +35,6 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
class ExchangeRateSeeder extends Seeder
|
||||
{
|
||||
private Collection $users;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
|
@ -32,7 +32,10 @@ use PDOException;
|
||||
*/
|
||||
class LinkTypeSeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$types = [
|
||||
[
|
||||
|
@ -32,7 +32,7 @@ use PDOException;
|
||||
*/
|
||||
class PermissionSeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
public function run(): void
|
||||
{
|
||||
$roles = [
|
||||
[
|
||||
|
@ -34,7 +34,7 @@ class TransactionCurrencySeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
*/
|
||||
public function run()
|
||||
public function run(): void
|
||||
{
|
||||
$currencies = [];
|
||||
// european currencies
|
||||
|
@ -32,7 +32,7 @@ use PDOException;
|
||||
*/
|
||||
class TransactionTypeSeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
public function run(): void
|
||||
{
|
||||
$types = [
|
||||
TransactionType::WITHDRAWAL,
|
||||
|
Loading…
Reference in New Issue
Block a user