diff --git a/app/Support/JsonApi/Enrichments/AccountEnrichment.php b/app/Support/JsonApi/Enrichments/AccountEnrichment.php index 109fad9854..39ed776f69 100644 --- a/app/Support/JsonApi/Enrichments/AccountEnrichment.php +++ b/app/Support/JsonApi/Enrichments/AccountEnrichment.php @@ -440,7 +440,7 @@ class AccountEnrichment implements EnrichmentInterface private function sortData(): void { $dbParams = config('firefly.allowed_db_sort_parameters.Account', []); - /** @var array $parameter */ + /** @var array $parameter */ foreach ($this->sort as $parameter) { if (in_array($parameter[0], $dbParams, true)) { continue; diff --git a/app/Support/JsonApi/Enrichments/AvailableBudgetEnrichment.php b/app/Support/JsonApi/Enrichments/AvailableBudgetEnrichment.php index b8ad52e31a..4b36dd7e47 100644 --- a/app/Support/JsonApi/Enrichments/AvailableBudgetEnrichment.php +++ b/app/Support/JsonApi/Enrichments/AvailableBudgetEnrichment.php @@ -40,9 +40,8 @@ use Override; class AvailableBudgetEnrichment implements EnrichmentInterface { - private User $user; - private UserGroup $userGroup; - private TransactionCurrency $primaryCurrency; + private User $user; // @phpstan-ignore-line + private UserGroup $userGroup; // @phpstan-ignore-line private bool $convertToPrimary; private array $ids = []; private array $currencyIds = []; @@ -57,12 +56,9 @@ class AvailableBudgetEnrichment implements EnrichmentInterface private readonly BudgetRepositoryInterface $repository; - private ?Carbon $start = null; - private ?Carbon $end = null; - public function __construct() { - $this->primaryCurrency = Amount::getPrimaryCurrency(); + //$this->primaryCurrency = Amount::getPrimaryCurrency(); $this->convertToPrimary = Amount::convertToPrimary(); $this->noBudgetRepository = app(NoBudgetRepositoryInterface::class); $this->opsRepository = app(OperationsRepositoryInterface::class); @@ -124,8 +120,8 @@ class AvailableBudgetEnrichment implements EnrichmentInterface $start = $this->collection->min('start_date') ?? Carbon::now()->startOfMonth(); $end = $this->collection->max('end_date') ?? Carbon::now()->endOfMonth(); $allActive = $this->repository->getActiveBudgets(); - $spentInBudgets = $this->opsRepository->collectExpenses($start, $end, null, $allActive, null); - $spentOutsideBudgets = $this->noBudgetRepository->collectExpenses($start, $end, null, null, null); + $spentInBudgets = $this->opsRepository->collectExpenses($start, $end, null, $allActive); + $spentOutsideBudgets = $this->noBudgetRepository->collectExpenses($start, $end); foreach ($this->collection as $availableBudget) { $id = (int)$availableBudget->id; $currencyId = $this->currencyIds[$id]; diff --git a/app/Support/JsonApi/Enrichments/BudgetEnrichment.php b/app/Support/JsonApi/Enrichments/BudgetEnrichment.php index 426fb70490..29c7a4d3a8 100644 --- a/app/Support/JsonApi/Enrichments/BudgetEnrichment.php +++ b/app/Support/JsonApi/Enrichments/BudgetEnrichment.php @@ -43,8 +43,6 @@ use Illuminate\Support\Facades\Log; class BudgetEnrichment implements EnrichmentInterface { private Collection $collection; - private bool $convertToPrimary; - private TransactionCurrency $primaryCurrency; private User $user; private UserGroup $userGroup; private array $ids = []; @@ -60,8 +58,6 @@ class BudgetEnrichment implements EnrichmentInterface public function __construct() { - $this->convertToPrimary = Amount::convertToPrimary(); - $this->primaryCurrency = Amount::getPrimaryCurrency(); } public function enrich(Collection $collection): Collection diff --git a/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php b/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php index 3ca2c5a508..bd32855412 100644 --- a/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php +++ b/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php @@ -41,7 +41,7 @@ use Illuminate\Support\Facades\Log; class BudgetLimitEnrichment implements EnrichmentInterface { private User $user; - private UserGroup $userGroup; + private UserGroup $userGroup; // @phpstan-ignore-line private Collection $collection; private array $ids = []; private array $notes = []; diff --git a/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php b/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php index 5133b2ef40..b6b1e7d120 100644 --- a/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php +++ b/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php @@ -43,8 +43,8 @@ use Illuminate\Support\Facades\Log; class PiggyBankEnrichment implements EnrichmentInterface { - private User $user; - private UserGroup $userGroup; + private User $user; // @phpstan-ignore-line + private UserGroup $userGroup; // @phpstan-ignore-line private Collection $collection; private array $ids = []; private array $currencyIds = []; @@ -55,6 +55,8 @@ class PiggyBankEnrichment implements EnrichmentInterface private array $mappedObjects = []; private TransactionCurrency $primaryCurrency; private array $amounts = []; + private array $accounts= []; + private array $objectGroups= []; public function __construct() { diff --git a/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php b/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php index e70bfb226f..196bed56d0 100644 --- a/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php +++ b/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php @@ -39,8 +39,8 @@ use Illuminate\Support\Facades\Log; class PiggyBankEventEnrichment implements EnrichmentInterface { - private User $user; - private UserGroup $userGroup; + private User $user; // @phpstan-ignore-line + private UserGroup $userGroup; // @phpstan-ignore-line private Collection $collection; private array $ids = []; private array $journalIds = []; diff --git a/app/Support/JsonApi/Enrichments/RecurringEnrichment.php b/app/Support/JsonApi/Enrichments/RecurringEnrichment.php index 43d244a3dd..ba890ff082 100644 --- a/app/Support/JsonApi/Enrichments/RecurringEnrichment.php +++ b/app/Support/JsonApi/Enrichments/RecurringEnrichment.php @@ -57,7 +57,7 @@ class RecurringEnrichment implements EnrichmentInterface { private Collection $collection; private array $ids = []; - private array $transactionTypeIds = []; +// private array $transactionTypeIds = []; // private array $transactionTypes = []; private array $notes = []; private array $repetitions = []; @@ -123,9 +123,9 @@ class RecurringEnrichment implements EnrichmentInterface /** @var Recurrence $recurrence */ foreach ($this->collection as $recurrence) { $id = (int)$recurrence->id; - $typeId = (int)$recurrence->transaction_type_id; +// $typeId = (int)$recurrence->transaction_type_id; $this->ids[] = $id; - $this->transactionTypeIds[$id] = $typeId; + //$this->transactionTypeIds[$id] = $typeId; } $this->ids = array_unique($this->ids); @@ -410,7 +410,7 @@ class RecurringEnrichment implements EnrichmentInterface // this should refer to another array, were rtIds can be used to find the recurrence. $recurrenceId = $this->recurrenceIds[$transactionId] ?? 0; - $name = (string)$entry->name ?? ''; + $name = (string)($entry->name ?? ''); if (0 === $recurrenceId) { Log::error(sprintf('Could not find recurrence ID for recurrence transaction ID %d', $transactionId)); diff --git a/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php b/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php index 1797d086e6..c623d08cf5 100644 --- a/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php +++ b/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php @@ -27,6 +27,8 @@ namespace FireflyIII\Support\JsonApi\Enrichments; use Carbon\Carbon; use Carbon\CarbonInterface; +use Carbon\Exceptions\InvalidFormatException; +use Carbon\Exceptions\ParseErrorException; use FireflyIII\Models\Bill; use FireflyIII\Models\Note; use FireflyIII\Models\ObjectGroup; @@ -46,7 +48,7 @@ use Illuminate\Support\Facades\Log; class SubscriptionEnrichment implements EnrichmentInterface { private User $user; - private UserGroup $userGroup; + private UserGroup $userGroup; // @phpstan-ignore-line private Collection $collection; private bool $convertToPrimary; private ?Carbon $start = null; @@ -85,11 +87,11 @@ class SubscriptionEnrichment implements EnrichmentInterface $paidDates = $this->paidDates; $payDates = $this->payDates; $this->collection = $this->collection->map(function (Bill $item) use ($notes, $objectGroups, $paidDates, $payDates) { - $id = (int) $item->id; - $currency = $item->transactionCurrency; - $nem = $this->getNextExpectedMatch($payDates[$id] ?? []); + $id = (int)$item->id; + $currency = $item->transactionCurrency; + $nem = $this->getNextExpectedMatch($payDates[$id] ?? []); - $meta = [ + $meta = [ 'notes' => null, 'object_group_id' => null, 'object_group_title' => null, @@ -100,7 +102,7 @@ class SubscriptionEnrichment implements EnrichmentInterface 'nem' => $nem, 'nem_diff' => $this->getNextExpectedMatchDiff($nem, $payDates[$id] ?? []), ]; - $amounts = [ + $amounts = [ 'amount_min' => Steam::bcround($item->amount_min, $currency->decimal_places), 'amount_max' => Steam::bcround($item->amount_max, $currency->decimal_places), 'average' => Steam::bcround(bcdiv(bcadd($item->amount_min, $item->amount_max), '2'), $currency->decimal_places), @@ -122,7 +124,7 @@ class SubscriptionEnrichment implements EnrichmentInterface // add object group if available if (array_key_exists($id, $this->mappedObjects)) { $key = $this->mappedObjects[$id]; - $meta['object_group_id'] = (string) $objectGroups[$key]['id']; + $meta['object_group_id'] = (string)$objectGroups[$key]['id']; $meta['object_group_title'] = $objectGroups[$key]['title']; $meta['object_group_order'] = $objectGroups[$key]['order']; } @@ -153,12 +155,11 @@ class SubscriptionEnrichment implements EnrichmentInterface private function collectNotes(): void { $notes = Note::query()->whereIn('noteable_id', $this->subscriptionIds) - ->whereNotNull('notes.text') - ->where('notes.text', '!=', '') - ->where('noteable_type', Bill::class)->get(['notes.noteable_id', 'notes.text'])->toArray() - ; + ->whereNotNull('notes.text') + ->where('notes.text', '!=', '') + ->where('noteable_type', Bill::class)->get(['notes.noteable_id', 'notes.text'])->toArray(); foreach ($notes as $note) { - $this->notes[(int) $note['noteable_id']] = (string) $note['text']; + $this->notes[(int)$note['noteable_id']] = (string)$note['text']; } Log::debug(sprintf('Enrich with %d note(s)', count($this->notes))); } @@ -178,30 +179,29 @@ class SubscriptionEnrichment implements EnrichmentInterface { /** @var Bill $bill */ foreach ($this->collection as $bill) { - $this->subscriptionIds[] = (int) $bill->id; + $this->subscriptionIds[] = (int)$bill->id; } $this->subscriptionIds = array_unique($this->subscriptionIds); } private function collectObjectGroups(): void { - $set = DB::table('object_groupables') - ->whereIn('object_groupable_id', $this->subscriptionIds) - ->where('object_groupable_type', Bill::class) - ->get(['object_groupable_id', 'object_group_id']) - ; + $set = DB::table('object_groupables') + ->whereIn('object_groupable_id', $this->subscriptionIds) + ->where('object_groupable_type', Bill::class) + ->get(['object_groupable_id', 'object_group_id']); - $ids = array_unique($set->pluck('object_group_id')->toArray()); + $ids = array_unique($set->pluck('object_group_id')->toArray()); foreach ($set as $entry) { - $this->mappedObjects[(int) $entry->object_groupable_id] = (int) $entry->object_group_id; + $this->mappedObjects[(int)$entry->object_groupable_id] = (int)$entry->object_group_id; } $groups = ObjectGroup::whereIn('id', $ids)->get(['id', 'title', 'order'])->toArray(); foreach ($groups as $group) { - $group['id'] = (int) $group['id']; - $group['order'] = (int) $group['order']; - $this->objectGroups[(int) $group['id']] = $group; + $group['id'] = (int)$group['id']; + $group['order'] = (int)$group['order']; + $this->objectGroups[(int)$group['id']] = $group; } } @@ -219,13 +219,13 @@ class SubscriptionEnrichment implements EnrichmentInterface // 2023-07-18 this particular date is used to search for the last paid date. // 2023-07-18 the cloned $searchDate is used to grab the correct transactions. /** @var Carbon $start */ - $start = clone $this->start; - $searchStart = clone $start; + $start = clone $this->start; + $searchStart = clone $start; $start->subDay(); /** @var Carbon $end */ - $end = clone $this->end; - $searchEnd = clone $end; + $end = clone $this->end; + $searchEnd = clone $end; // move the search dates to the start of the day. $searchStart->startOfDay(); @@ -234,13 +234,13 @@ class SubscriptionEnrichment implements EnrichmentInterface Log::debug(sprintf('Search parameters are: start: %s, end: %s', $searchStart->format('Y-m-d H:i:s'), $searchEnd->format('Y-m-d H:i:s'))); // Get from database when bills were paid. - $set = $this->user->transactionJournals() - ->whereIn('bill_id', $this->subscriptionIds) - ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') - ->leftJoin('transaction_currencies AS currency', 'currency.id', '=', 'transactions.transaction_currency_id') - ->leftJoin('transaction_currencies AS foreign_currency', 'foreign_currency.id', '=', 'transactions.foreign_currency_id') - ->where('transactions.amount', '>', 0) - ->before($searchEnd)->after($searchStart)->get( + $set = $this->user->transactionJournals() + ->whereIn('bill_id', $this->subscriptionIds) + ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') + ->leftJoin('transaction_currencies AS currency', 'currency.id', '=', 'transactions.transaction_currency_id') + ->leftJoin('transaction_currencies AS foreign_currency', 'foreign_currency.id', '=', 'transactions.foreign_currency_id') + ->where('transactions.amount', '>', 0) + ->before($searchEnd)->after($searchStart)->get( [ 'transaction_journals.id', 'transaction_journals.date', @@ -257,74 +257,74 @@ class SubscriptionEnrichment implements EnrichmentInterface 'transactions.amount', 'transactions.foreign_amount', ] - ) - ; + ); Log::debug(sprintf('Count %d entries in set', $set->count())); // for each bill, do a loop. - $converter = new ExchangeRateConverter(); + $converter = new ExchangeRateConverter(); /** @var Bill $subscription */ foreach ($this->collection as $subscription) { // Grab from array the most recent payment. If none exist, fall back to the start date and pretend *that* was the last paid date. Log::debug(sprintf('Grab last paid date from function, return %s if it comes up with nothing.', $start->format('Y-m-d'))); - $lastPaidDate = $this->lastPaidDate($subscription, $set, $start); + $lastPaidDate = $this->lastPaidDate($subscription, $set, $start); Log::debug(sprintf('Result of lastPaidDate is %s', $lastPaidDate->format('Y-m-d'))); // At this point the "next match" is exactly after the last time the bill was paid. - $result = []; - $filtered = $set->filter(function (TransactionJournal $journal) use ($subscription) { - return (int) $journal->bill_id === (int) $subscription->id; + $result = []; + $filtered = $set->filter(function (TransactionJournal $journal) use ($subscription) { + return (int)$journal->bill_id === (int)$subscription->id; }); foreach ($filtered as $entry) { - $array = [ - 'transaction_group_id' => (string) $entry->transaction_group_id, - 'transaction_journal_id' => (string) $entry->id, - 'date' => $entry->date->toAtomString(), - 'date_object' => $entry->date, - 'subscription_id' => (string) $entry->bill_id, - 'currency_id' => (string) $entry->transaction_currency_id, - 'currency_code' => $entry->transaction_currency_code, - 'currency_symbol' => $entry->transaction_currency_symbol, - 'currency_decimal_places' => $entry->transaction_currency_decimal_places, - 'primary_currency_id' => (string) $this->primaryCurrency->id, - 'primary_currency_code' => $this->primaryCurrency->code, - 'primary_currency_symbol' => $this->primaryCurrency->symbol, - 'primary_currency_decimal_places' => $this->primaryCurrency->decimal_places, - 'amount' => Steam::bcround($entry->amount, $entry->transaction_currency_decimal_places), - 'pc_amount' => null, - 'foreign_amount' => null, - 'pc_foreign_amount' => null, + $array = [ + 'transaction_group_id' => (string)$entry->transaction_group_id, + 'transaction_journal_id' => (string)$entry->id, + 'date' => $entry->date->toAtomString(), + 'date_object' => $entry->date, + 'subscription_id' => (string)$entry->bill_id, + 'currency_id' => (string)$entry->transaction_currency_id, + 'currency_code' => $entry->transaction_currency_code, + 'currency_symbol' => $entry->transaction_currency_symbol, + 'currency_decimal_places' => $entry->transaction_currency_decimal_places, + 'primary_currency_id' => (string)$this->primaryCurrency->id, + 'primary_currency_code' => $this->primaryCurrency->code, + 'primary_currency_symbol' => $this->primaryCurrency->symbol, + 'primary_currency_decimal_places' => $this->primaryCurrency->decimal_places, + 'amount' => Steam::bcround($entry->amount, $entry->transaction_currency_decimal_places), + 'pc_amount' => null, + 'foreign_amount' => null, + 'pc_foreign_amount' => null, ]; if (null !== $entry->foreign_amount && null !== $entry->foreign_currency_code) { - $array['foreign_currency_id'] = (string) $entry->foreign_currency_id; + $array['foreign_currency_id'] = (string)$entry->foreign_currency_id; $array['foreign_currency_code'] = $entry->foreign_currency_code; $array['foreign_currency_symbol'] = $entry->foreign_currency_symbol; $array['foreign_currency_decimal_places'] = $entry->foreign_currency_decimal_places; $array['foreign_amount'] = Steam::bcround($entry->foreign_amount, $entry->foreign_currency_decimal_places); } // convert to primary, but is already primary. - if ($this->convertToPrimary && (int) $entry->transaction_currency_id === $this->primaryCurrency->id) { + if ($this->convertToPrimary && (int)$entry->transaction_currency_id === $this->primaryCurrency->id) { $array['pc_amount'] = $array['amount']; } // convert to primary, but is NOT already primary. - if ($this->convertToPrimary && (int) $entry->transaction_currency_id !== $this->primaryCurrency->id) { + if ($this->convertToPrimary && (int)$entry->transaction_currency_id !== $this->primaryCurrency->id) { $array['pc_amount'] = $converter->convert($entry->transactionCurrency, $this->primaryCurrency, $entry->date, $entry->amount); } // convert to primary, but foreign is already primary. - if ($this->convertToPrimary && (int) $entry->foreign_currency_id === $this->primaryCurrency->id) { + if ($this->convertToPrimary && (int)$entry->foreign_currency_id === $this->primaryCurrency->id) { $array['pc_foreign_amount'] = $array['foreign_amount']; } // convert to primary, but foreign is NOT already primary. - if ($this->convertToPrimary && null !== $entry->foreign_currency_id && (int) $entry->foreign_currency_id !== $this->primaryCurrency->id) { + if ($this->convertToPrimary && null !== $entry->foreign_currency_id && (int)$entry->foreign_currency_id !== $this->primaryCurrency->id) { // TODO this is very database intensive. + /** @var TransactionCurrency $foreignCurrency */ $foreignCurrency = TransactionCurrency::find($entry->foreign_currency_id); $array['pc_foreign_amount'] = $converter->convert($foreignCurrency, $this->primaryCurrency, $entry->date, $entry->amount); } $result[] = $array; } - $this->paidDates[(int) $subscription->id] = $result; + $this->paidDates[(int)$subscription->id] = $result; } } @@ -345,14 +345,14 @@ class SubscriptionEnrichment implements EnrichmentInterface protected function lastPaidDate(Bill $subscription, Collection $dates, Carbon $default): Carbon { $filtered = $dates->filter(function (TransactionJournal $journal) use ($subscription) { - return (int) $journal->bill_id === (int) $subscription->id; + return (int)$journal->bill_id === (int)$subscription->id; }); Log::debug(sprintf('Filtered down from %d to %d entries for bill #%d.', $dates->count(), $filtered->count(), $subscription->id)); if (0 === $filtered->count()) { return $default; } - $latest = $filtered->first()->date; + $latest = $filtered->first()->date; /** @var TransactionJournal $journal */ foreach ($filtered as $journal) { @@ -398,12 +398,12 @@ class SubscriptionEnrichment implements EnrichmentInterface /** @var Bill $subscription */ foreach ($this->collection as $subscription) { - $id = (int) $subscription->id; - $lastPaidDate = $this->getLastPaidDate($paidDates[$id] ?? []); - $payDates = $this->calculator->getPayDates($this->start, $this->end, $subscription->date, $subscription->repeat_freq, $subscription->skip, $lastPaidDate); - $payDatesFormatted = []; + $id = (int)$subscription->id; + $lastPaidDate = $this->getLastPaidDate($this->paidDates[$id] ?? []); + $payDates = $this->calculator->getPayDates($this->start, $this->end, $subscription->date, $subscription->repeat_freq, $subscription->skip, $lastPaidDate); + $payDatesFormatted = []; foreach ($payDates as $string) { - $date = Carbon::createFromFormat('!Y-m-d', $string, config('app.timezone')); + $date = Carbon::createFromFormat('!Y-m-d', $string, config('app.timezone')); if (!$date instanceof Carbon) { $date = today(config('app.timezone')); } @@ -429,11 +429,12 @@ class SubscriptionEnrichment implements EnrichmentInterface $firstPayDate = $payDates[0] ?? null; if (null !== $firstPayDate) { - $nemDate = Carbon::parse($firstPayDate, config('app.timezone')); - if (!$nemDate instanceof Carbon) { + try { + $nemDate = Carbon::parse($firstPayDate, config('app.timezone')); + } catch (InvalidFormatException) { $nemDate = today(config('app.timezone')); } - $nem = $nemDate; + $nem = $nemDate; // nullify again when it's outside the current view range. if ( @@ -462,8 +463,9 @@ class SubscriptionEnrichment implements EnrichmentInterface $current = $payDates[0] ?? null; if (null !== $current && !$nem->isToday()) { - $temp2 = Carbon::parse($current, config('app.timezone')); - if (!$temp2 instanceof Carbon) { + try { + $temp2 = Carbon::parse($current, config('app.timezone')); + } catch (InvalidFormatException) { $temp2 = today(config('app.timezone')); } $nemDiff = trans('firefly.bill_expected_date', ['date' => $temp2->diffForHumans(today(config('app.timezone')), CarbonInterface::DIFF_RELATIVE_TO_NOW)]); diff --git a/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php b/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php index 340d928304..7ff47ca207 100644 --- a/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php +++ b/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php @@ -53,9 +53,9 @@ class TransactionGroupEnrichment implements EnrichmentInterface private array $metaData = []; private array $notes = []; private array $tags = []; - private User $user; + private User $user; // @phpstan-ignore-line private readonly TransactionCurrency $primaryCurrency; - private UserGroup $userGroup; + private UserGroup $userGroup; // @phpstan-ignore-line public function __construct() { @@ -177,7 +177,7 @@ class TransactionGroupEnrichment implements EnrichmentInterface ->whereIn('attachable_id', $this->journalIds) ->where('attachable_type', TransactionJournal::class) ->groupBy('attachable_id') - ->get(['attachable_id', DB::raw('COUNT(id) as nr_of_attachments')]) // @phpstan-ignore-line + ->get(['attachable_id', DB::raw('COUNT(id) as nr_of_attachments')]) ->toArray() ; foreach ($attachments as $row) { diff --git a/app/Support/JsonApi/Enrichments/WebhookEnrichment.php b/app/Support/JsonApi/Enrichments/WebhookEnrichment.php index 10658c0106..ed14659cfb 100644 --- a/app/Support/JsonApi/Enrichments/WebhookEnrichment.php +++ b/app/Support/JsonApi/Enrichments/WebhookEnrichment.php @@ -43,8 +43,8 @@ use stdClass; class WebhookEnrichment implements EnrichmentInterface { private Collection $collection; - private User $user; - private UserGroup $userGroup; + private User $user; // @phpstan-ignore-line + private UserGroup $userGroup; // @phpstan-ignore-line private array $ids = []; private array $deliveries = []; private array $responses = []; diff --git a/app/Support/ParseDateString.php b/app/Support/ParseDateString.php index 90a2ac6d88..fd625ebc9c 100644 --- a/app/Support/ParseDateString.php +++ b/app/Support/ParseDateString.php @@ -88,7 +88,7 @@ class ParseDateString // if regex for YYYY-MM-DD: $pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12]\d|3[01])$/'; $result = preg_match($pattern, $date); - if (false !== $result && 0 !== $result) { + if (0 !== $result) { return $this->parseDefaultDate($date); } @@ -259,7 +259,7 @@ class ParseDateString { $pattern = '/^xxxx-xx-(0[1-9]|[12]\d|3[01])$/'; $result = preg_match($pattern, $date); - if (false !== $result && 0 !== $result) { + if (0 !== $result) { app('log')->debug(sprintf('"%s" is a day range.', $date)); return true; @@ -286,7 +286,7 @@ class ParseDateString // if regex for xxxx-MM-xx: $pattern = '/^xxxx-(0[1-9]|1[012])-xx$/'; $result = preg_match($pattern, $date); - if (false !== $result && 0 !== $result) { + if (0 !== $result) { app('log')->debug(sprintf('"%s" is a month range.', $date)); return true; @@ -314,7 +314,7 @@ class ParseDateString // if regex for YYYY-xx-xx: $pattern = '/^(19|20)\d\d-xx-xx$/'; $result = preg_match($pattern, $date); - if (false !== $result && 0 !== $result) { + if (0 !== $result) { app('log')->debug(sprintf('"%s" is a year range.', $date)); return true; @@ -342,7 +342,7 @@ class ParseDateString // if regex for xxxx-MM-DD: $pattern = '/^xxxx-(0[1-9]|1[012])-(0[1-9]|[12]\d|3[01])$/'; $result = preg_match($pattern, $date); - if (false !== $result && 0 !== $result) { + if (0 !== $result) { app('log')->debug(sprintf('"%s" is a month/day range.', $date)); return true; @@ -371,7 +371,7 @@ class ParseDateString // if regex for YYYY-xx-DD: $pattern = '/^(19|20)\d\d-xx-(0[1-9]|[12]\d|3[01])$/'; $result = preg_match($pattern, $date); - if (false !== $result && 0 !== $result) { + if (0 !== $result) { app('log')->debug(sprintf('"%s" is a day/year range.', $date)); return true; @@ -400,7 +400,7 @@ class ParseDateString // if regex for YYYY-MM-xx: $pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-xx$/'; $result = preg_match($pattern, $date); - if (false !== $result && 0 !== $result) { + if (0 !== $result) { app('log')->debug(sprintf('"%s" is a month/year range.', $date)); return true; diff --git a/app/Support/Request/ConvertsDataTypes.php b/app/Support/Request/ConvertsDataTypes.php index 70a40a6d57..2d16024f31 100644 --- a/app/Support/Request/ConvertsDataTypes.php +++ b/app/Support/Request/ConvertsDataTypes.php @@ -146,7 +146,7 @@ trait ConvertsDataTypes // clear zalgo text (TODO also in API v2) $string = preg_replace('/(\pM{2})\pM+/u', '\1', $string); - return trim((string)$string); + return trim($string); } public function convertIban(string $field): string