Fix phpstan issues.

This commit is contained in:
James Cole
2025-09-07 06:25:26 +02:00
parent bf53f5d6b7
commit b87b99a755
19 changed files with 81 additions and 115 deletions

View File

@@ -25,6 +25,8 @@ declare(strict_types=1);
namespace FireflyIII\Console\Commands\System; namespace FireflyIII\Console\Commands\System;
use function Safe\file_put_contents;
use function Safe\json_encode;
use FireflyIII\Console\Commands\ShowsFriendlyMessages; use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Symfony\Component\Console\Command\Command as CommandAlias; use Symfony\Component\Console\Command\Command as CommandAlias;

View File

@@ -78,8 +78,8 @@ class ScansAttachments extends Command
} }
$tempFileName = tempnam(sys_get_temp_dir(), 'FireflyIII'); $tempFileName = tempnam(sys_get_temp_dir(), 'FireflyIII');
file_put_contents($tempFileName, $decryptedContent); file_put_contents($tempFileName, $decryptedContent);
$attachment->md5 = (string)md5_file($tempFileName); $attachment->md5 = md5_file($tempFileName);
$attachment->mime = (string)mime_content_type($tempFileName); $attachment->mime = mime_content_type($tempFileName);
$attachment->save(); $attachment->save();
$this->friendlyInfo(sprintf('Fixed attachment #%d', $attachment->id)); $this->friendlyInfo(sprintf('Fixed attachment #%d', $attachment->id));
} }

View File

@@ -1,43 +0,0 @@
<?php
/*
* DestroyedTransactionLink.php
* Copyright (c) 2020 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Events;
use FireflyIII\Models\TransactionJournalLink;
use Illuminate\Queue\SerializesModels;
/**
* Class DestroyedTransactionLink
*/
class DestroyedTransactionLink extends Event
{
use SerializesModels;
// @phpstan-ignore-line
/**
* DestroyedTransactionLink constructor.
*/
public function __construct(private TransactionJournalLink $link) {}
}

View File

@@ -282,7 +282,7 @@ class PiggyBankFactory
// create event: // create event:
Log::debug('linkToAccountIds: Trigger change for positive amount [b].'); Log::debug('linkToAccountIds: Trigger change for positive amount [b].');
event(new ChangedAmount($piggyBank, $toBeLinked[$account->id]['current_amount'], null, null)); event(new ChangedAmount($piggyBank, $toBeLinked[$account->id]['current_amount'] ?? '0', null, null));
} }
if (!array_key_exists('current_amount', $info)) { if (!array_key_exists('current_amount', $info)) {
$toBeLinked[$account->id] ??= []; $toBeLinked[$account->id] ??= [];

View File

@@ -184,6 +184,7 @@ class StandardMessageGenerator implements MessageGeneratorInterface
if ($model instanceof Budget) { if ($model instanceof Budget) {
$enrichment = new BudgetEnrichment(); $enrichment = new BudgetEnrichment();
$enrichment->setUser($model->user); $enrichment->setUser($model->user);
/** @var Budget $model */
$model = $enrichment->enrichSingle($model); $model = $enrichment->enrichSingle($model);
$transformer = new BudgetTransformer(); $transformer = new BudgetTransformer();
$basicMessage['content'] = $transformer->transform($model); $basicMessage['content'] = $transformer->transform($model);
@@ -196,7 +197,7 @@ class StandardMessageGenerator implements MessageGeneratorInterface
$parameters = new ParameterBag(); $parameters = new ParameterBag();
$parameters->set('start', $model->start_date); $parameters->set('start', $model->start_date);
$parameters->set('end', $model->end_date); $parameters->set('end', $model->end_date);
/** @var BudgetLimit $model */
$model = $enrichment->enrichSingle($model); $model = $enrichment->enrichSingle($model);
$transformer = new BudgetLimitTransformer(); $transformer = new BudgetLimitTransformer();
$transformer->setParameters($parameters); $transformer->setParameters($parameters);
@@ -295,7 +296,7 @@ class StandardMessageGenerator implements MessageGeneratorInterface
$this->webhooks = $webhooks; $this->webhooks = $webhooks;
} }
private function getRelevantResponse(array $triggers, WebhookResponseModel $response, $class): string private function getRelevantResponse(array $triggers, WebhookResponseModel $response, string $class): string
{ {
// return none if none. // return none if none.
if (WebhookResponse::NONE->name === $response->title) { if (WebhookResponse::NONE->name === $response->title) {

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Handlers\Events; namespace FireflyIII\Handlers\Events;
use function Safe\json_encode;
use Exception; use Exception;
use FireflyIII\Events\Model\Bill\WarnUserAboutBill; use FireflyIII\Events\Model\Bill\WarnUserAboutBill;
use FireflyIII\Events\Model\Bill\WarnUserAboutOverdueSubscriptions; use FireflyIII\Events\Model\Bill\WarnUserAboutOverdueSubscriptions;

View File

@@ -35,6 +35,8 @@ use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Support\MessageBag; use Illuminate\Support\MessageBag;
use Safe\Exceptions\FileinfoException;
use Safe\Exceptions\FilesystemException;
use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\File\UploadedFile;
use function Safe\tmpfile; use function Safe\tmpfile;
@@ -126,9 +128,10 @@ class AttachmentHelper implements AttachmentHelperInterface
public function saveAttachmentFromApi(Attachment $attachment, string $content): bool public function saveAttachmentFromApi(Attachment $attachment, string $content): bool
{ {
Log::debug(sprintf('Now in %s', __METHOD__)); Log::debug(sprintf('Now in %s', __METHOD__));
try {
$resource = tmpfile(); $resource = tmpfile();
if (false === $resource) { } catch (FilesystemException $e) {
Log::error('Cannot create temp-file for file upload.'); Log::error(sprintf('Cannot create temp-file for file upload: %s', $e->getMessage()));
return false; return false;
} }
@@ -141,17 +144,18 @@ class AttachmentHelper implements AttachmentHelperInterface
$path = stream_get_meta_data($resource)['uri']; $path = stream_get_meta_data($resource)['uri'];
Log::debug(sprintf('Path is %s', $path)); Log::debug(sprintf('Path is %s', $path));
try {
$result = fwrite($resource, $content); $result = fwrite($resource, $content);
if (false === $result) { } catch (FilesystemException $e) {
Log::error('Could not write temp file.'); Log::error(sprintf('Could not write to temp file: %s', $e->getMessage()));
return false; return false;
} }
Log::debug(sprintf('Wrote %d bytes to temp file.', $result)); Log::debug(sprintf('Wrote %d bytes to temp file.', $result));
try {
$finfo = finfo_open(FILEINFO_MIME_TYPE); $finfo = finfo_open(FILEINFO_MIME_TYPE);
if (false === $finfo) { } catch (FileinfoException $e) {
Log::error('Could not open finfo.'); Log::error(sprintf('Could not open finfo handler: %s', $e->getMessage()));
fclose($resource);
return false; return false;
} }
@@ -171,7 +175,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$this->uploadDisk->put($file, $content); $this->uploadDisk->put($file, $content);
// update attachment. // update attachment.
$attachment->md5 = (string) md5_file($path); $attachment->md5 = md5_file($path);
$attachment->mime = $mime; $attachment->mime = $mime;
$attachment->size = strlen($content); $attachment->size = strlen($content);
$attachment->uploaded = true; $attachment->uploaded = true;
@@ -233,7 +237,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$attachment = new Attachment(); // create Attachment object. $attachment = new Attachment(); // create Attachment object.
$attachment->user()->associate($user); $attachment->user()->associate($user);
$attachment->attachable()->associate($model); $attachment->attachable()->associate($model);
$attachment->md5 = (string) md5_file($file->getRealPath()); $attachment->md5 = md5_file($file->getRealPath());
$attachment->filename = $file->getClientOriginalName(); $attachment->filename = $file->getClientOriginalName();
$attachment->mime = $file->getMimeType(); $attachment->mime = $file->getMimeType();
$attachment->size = $file->getSize(); $attachment->size = $file->getSize();

View File

@@ -199,7 +199,7 @@ trait MetaCollection
public function excludeInternalReference(string $internalReference): GroupCollectorInterface public function excludeInternalReference(string $internalReference): GroupCollectorInterface
{ {
$internalReference = (string) json_encode($internalReference); $internalReference = json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"')); $internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables(); $this->joinMetaDataTables();
@@ -220,7 +220,7 @@ trait MetaCollection
public function externalIdContains(string $externalId): GroupCollectorInterface public function externalIdContains(string $externalId): GroupCollectorInterface
{ {
$externalId = (string) json_encode($externalId); $externalId = json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"')); $externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables(); $this->joinMetaDataTables();
@@ -232,7 +232,7 @@ trait MetaCollection
public function externalIdDoesNotContain(string $externalId): GroupCollectorInterface public function externalIdDoesNotContain(string $externalId): GroupCollectorInterface
{ {
$externalId = (string) json_encode($externalId); $externalId = json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"')); $externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables(); $this->joinMetaDataTables();
@@ -244,7 +244,7 @@ trait MetaCollection
public function externalIdDoesNotEnd(string $externalId): GroupCollectorInterface public function externalIdDoesNotEnd(string $externalId): GroupCollectorInterface
{ {
$externalId = (string) json_encode($externalId); $externalId = json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"')); $externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables(); $this->joinMetaDataTables();
@@ -256,7 +256,7 @@ trait MetaCollection
public function externalIdDoesNotStart(string $externalId): GroupCollectorInterface public function externalIdDoesNotStart(string $externalId): GroupCollectorInterface
{ {
$externalId = (string) json_encode($externalId); $externalId = json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"')); $externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables(); $this->joinMetaDataTables();
@@ -268,7 +268,7 @@ trait MetaCollection
public function externalIdEnds(string $externalId): GroupCollectorInterface public function externalIdEnds(string $externalId): GroupCollectorInterface
{ {
$externalId = (string) json_encode($externalId); $externalId = json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"')); $externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables(); $this->joinMetaDataTables();
@@ -280,7 +280,7 @@ trait MetaCollection
public function externalIdStarts(string $externalId): GroupCollectorInterface public function externalIdStarts(string $externalId): GroupCollectorInterface
{ {
$externalId = (string) json_encode($externalId); $externalId = json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"')); $externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables(); $this->joinMetaDataTables();
@@ -293,7 +293,7 @@ trait MetaCollection
public function externalUrlContains(string $url): GroupCollectorInterface public function externalUrlContains(string $url): GroupCollectorInterface
{ {
$this->joinMetaDataTables(); $this->joinMetaDataTables();
$url = (string) json_encode($url); $url = json_encode($url);
$url = str_replace('\\', '\\\\', trim($url, '"')); $url = str_replace('\\', '\\\\', trim($url, '"'));
$this->query->where('journal_meta.name', '=', 'external_url'); $this->query->where('journal_meta.name', '=', 'external_url');
$this->query->whereLike('journal_meta.data', sprintf('%%%s%%', $url)); $this->query->whereLike('journal_meta.data', sprintf('%%%s%%', $url));
@@ -304,7 +304,7 @@ trait MetaCollection
public function externalUrlDoesNotContain(string $url): GroupCollectorInterface public function externalUrlDoesNotContain(string $url): GroupCollectorInterface
{ {
$this->joinMetaDataTables(); $this->joinMetaDataTables();
$url = (string) json_encode($url); $url = json_encode($url);
$url = str_replace('\\', '\\\\', trim($url, '"')); $url = str_replace('\\', '\\\\', trim($url, '"'));
$this->query->where('journal_meta.name', '=', 'external_url'); $this->query->where('journal_meta.name', '=', 'external_url');
$this->query->whereNotLike('journal_meta.data', sprintf('%%%s%%', $url)); $this->query->whereNotLike('journal_meta.data', sprintf('%%%s%%', $url));
@@ -315,7 +315,7 @@ trait MetaCollection
public function externalUrlDoesNotEnd(string $url): GroupCollectorInterface public function externalUrlDoesNotEnd(string $url): GroupCollectorInterface
{ {
$this->joinMetaDataTables(); $this->joinMetaDataTables();
$url = (string) json_encode($url); $url = json_encode($url);
$url = str_replace('\\', '\\\\', ltrim($url, '"')); $url = str_replace('\\', '\\\\', ltrim($url, '"'));
$this->query->where('journal_meta.name', '=', 'external_url'); $this->query->where('journal_meta.name', '=', 'external_url');
$this->query->whereNotLike('journal_meta.data', sprintf('%%%s', $url)); $this->query->whereNotLike('journal_meta.data', sprintf('%%%s', $url));
@@ -326,7 +326,7 @@ trait MetaCollection
public function externalUrlDoesNotStart(string $url): GroupCollectorInterface public function externalUrlDoesNotStart(string $url): GroupCollectorInterface
{ {
$this->joinMetaDataTables(); $this->joinMetaDataTables();
$url = (string) json_encode($url); $url = json_encode($url);
$url = str_replace('\\', '\\\\', rtrim($url, '"')); $url = str_replace('\\', '\\\\', rtrim($url, '"'));
// var_dump($url); // var_dump($url);
@@ -339,7 +339,7 @@ trait MetaCollection
public function externalUrlEnds(string $url): GroupCollectorInterface public function externalUrlEnds(string $url): GroupCollectorInterface
{ {
$this->joinMetaDataTables(); $this->joinMetaDataTables();
$url = (string) json_encode($url); $url = json_encode($url);
$url = str_replace('\\', '\\\\', ltrim($url, '"')); $url = str_replace('\\', '\\\\', ltrim($url, '"'));
$this->query->where('journal_meta.name', '=', 'external_url'); $this->query->where('journal_meta.name', '=', 'external_url');
$this->query->whereLike('journal_meta.data', sprintf('%%%s', $url)); $this->query->whereLike('journal_meta.data', sprintf('%%%s', $url));
@@ -350,7 +350,7 @@ trait MetaCollection
public function externalUrlStarts(string $url): GroupCollectorInterface public function externalUrlStarts(string $url): GroupCollectorInterface
{ {
$this->joinMetaDataTables(); $this->joinMetaDataTables();
$url = (string) json_encode($url); $url = json_encode($url);
$url = str_replace('\\', '\\\\', rtrim($url, '"')); $url = str_replace('\\', '\\\\', rtrim($url, '"'));
// var_dump($url); // var_dump($url);
@@ -401,7 +401,7 @@ trait MetaCollection
public function internalReferenceContains(string $internalReference): GroupCollectorInterface public function internalReferenceContains(string $internalReference): GroupCollectorInterface
{ {
$internalReference = (string) json_encode($internalReference); $internalReference = json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"')); $internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
// var_dump($internalReference); // var_dump($internalReference);
// exit; // exit;
@@ -416,7 +416,7 @@ trait MetaCollection
public function internalReferenceDoesNotContain(string $internalReference): GroupCollectorInterface public function internalReferenceDoesNotContain(string $internalReference): GroupCollectorInterface
{ {
$internalReference = (string) json_encode($internalReference); $internalReference = json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"')); $internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables(); $this->joinMetaDataTables();
@@ -429,7 +429,7 @@ trait MetaCollection
public function internalReferenceDoesNotEnd(string $internalReference): GroupCollectorInterface public function internalReferenceDoesNotEnd(string $internalReference): GroupCollectorInterface
{ {
$internalReference = (string) json_encode($internalReference); $internalReference = json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"')); $internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables(); $this->joinMetaDataTables();
@@ -442,7 +442,7 @@ trait MetaCollection
public function internalReferenceDoesNotStart(string $internalReference): GroupCollectorInterface public function internalReferenceDoesNotStart(string $internalReference): GroupCollectorInterface
{ {
$internalReference = (string) json_encode($internalReference); $internalReference = json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"')); $internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables(); $this->joinMetaDataTables();
@@ -455,7 +455,7 @@ trait MetaCollection
public function internalReferenceEnds(string $internalReference): GroupCollectorInterface public function internalReferenceEnds(string $internalReference): GroupCollectorInterface
{ {
$internalReference = (string) json_encode($internalReference); $internalReference = json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"')); $internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables(); $this->joinMetaDataTables();
@@ -468,7 +468,7 @@ trait MetaCollection
public function internalReferenceStarts(string $internalReference): GroupCollectorInterface public function internalReferenceStarts(string $internalReference): GroupCollectorInterface
{ {
$internalReference = (string) json_encode($internalReference); $internalReference = json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"')); $internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables(); $this->joinMetaDataTables();
@@ -724,7 +724,7 @@ trait MetaCollection
public function setInternalReference(string $internalReference): GroupCollectorInterface public function setInternalReference(string $internalReference): GroupCollectorInterface
{ {
$internalReference = (string) json_encode($internalReference); $internalReference = json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"')); $internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables(); $this->joinMetaDataTables();

View File

@@ -51,7 +51,7 @@ class NetWorth implements NetWorthInterface
private AccountRepositoryInterface $accountRepository; private AccountRepositoryInterface $accountRepository;
private CurrencyRepositoryInterface $currencyRepos; private CurrencyRepositoryInterface $currencyRepos;
private User $user; // @phpstan-ignore-line private User $user; // @phpstan-ignore-line
private ?UserGroup $userGroup = null; // @phpstan-ignore-line private ?UserGroup $userGroup = null;
/** /**
* This method collects the user's net worth in ALL the user's currencies * This method collects the user's net worth in ALL the user's currencies

View File

@@ -34,6 +34,7 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\View\View; use Illuminate\View\View;
use Safe\Exceptions\UrlException;
use function Safe\parse_url; use function Safe\parse_url;
/** /**
@@ -103,8 +104,12 @@ class ForgotPasswordController extends Controller
*/ */
private function validateHost(): void private function validateHost(): void
{ {
try {
$configuredHost = parse_url((string)config('app.url'), PHP_URL_HOST); $configuredHost = parse_url((string)config('app.url'), PHP_URL_HOST);
if (false === $configuredHost || null === $configuredHost) { } catch (UrlException $e) {
throw new FireflyException('Please set a valid and correct Firefly III URL in the APP_URL environment variable.',0, $e);
}
if (!is_string( $configuredHost)) {
throw new FireflyException('Please set a valid and correct Firefly III URL in the APP_URL environment variable.'); throw new FireflyException('Please set a valid and correct Firefly III URL in the APP_URL environment variable.');
} }
$host = request()->host(); $host = request()->host();

View File

@@ -249,8 +249,8 @@ class LoginController extends Controller
$allowReset = false; $allowReset = false;
} }
$email = $request?->old('email'); $email = $request->old('email');
$remember = $request?->old('remember'); $remember = $request->old('remember');
$storeInCookie = config('google2fa.store_in_cookie', false); $storeInCookie = config('google2fa.store_in_cookie', false);
if (false !== $storeInCookie) { if (false !== $storeInCookie) {

View File

@@ -330,6 +330,7 @@ class AccountController extends Controller
/** @var array $journal */ /** @var array $journal */
foreach ($journals as $journal) { foreach ($journals as $journal) {
$key = sprintf('%d-%d', $journal['category_id'], $journal['currency_id']); $key = sprintf('%d-%d', $journal['category_id'], $journal['currency_id']);
$field = 'amount';
if (!array_key_exists($key, $result)) { if (!array_key_exists($key, $result)) {
// currency info: // currency info:
@@ -338,7 +339,6 @@ class AccountController extends Controller
$currencySymbol = $journal['currency_symbol']; $currencySymbol = $journal['currency_symbol'];
$currencyCode = $journal['currency_code']; $currencyCode = $journal['currency_code'];
$currencyDecimalPlaces = $journal['currency_decimal_places']; $currencyDecimalPlaces = $journal['currency_decimal_places'];
$field = 'amount';
if ($this->convertToPrimary && $this->primaryCurrency->id !== $currencyId) { if ($this->convertToPrimary && $this->primaryCurrency->id !== $currencyId) {
$field = 'pc_amount'; $field = 'pc_amount';
$currencyName = $this->primaryCurrency->name; $currencyName = $this->primaryCurrency->name;
@@ -437,6 +437,7 @@ class AccountController extends Controller
/** @var array $journal */ /** @var array $journal */
foreach ($journals as $journal) { foreach ($journals as $journal) {
$key = sprintf('%d-%d', $journal['category_id'], $journal['currency_id']); $key = sprintf('%d-%d', $journal['category_id'], $journal['currency_id']);
$field = 'amount';
if (!array_key_exists($key, $result)) { if (!array_key_exists($key, $result)) {
// currency info: // currency info:
@@ -445,7 +446,6 @@ class AccountController extends Controller
$currencySymbol = $journal['currency_symbol']; $currencySymbol = $journal['currency_symbol'];
$currencyCode = $journal['currency_code']; $currencyCode = $journal['currency_code'];
$currencyDecimalPlaces = $journal['currency_decimal_places']; $currencyDecimalPlaces = $journal['currency_decimal_places'];
$field = 'amount';
if ($this->convertToPrimary && $this->primaryCurrency->id !== $currencyId) { if ($this->convertToPrimary && $this->primaryCurrency->id !== $currencyId) {
$field = 'pc_amount'; $field = 'pc_amount';
$currencyName = $this->primaryCurrency->name; $currencyName = $this->primaryCurrency->name;

View File

@@ -23,7 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\LinkType; namespace FireflyIII\Repositories\LinkType;
use FireflyIII\Events\DestroyedTransactionLink; use Exception;
use FireflyIII\Models\LinkType; use FireflyIII\Models\LinkType;
use FireflyIII\Models\Note; use FireflyIII\Models\Note;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
@@ -31,7 +31,6 @@ use FireflyIII\Models\TransactionJournalLink;
use FireflyIII\Support\Repositories\UserGroup\UserGroupInterface; use FireflyIII\Support\Repositories\UserGroup\UserGroupInterface;
use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait; use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Exception;
/** /**
* Class LinkTypeRepository. * Class LinkTypeRepository.
@@ -76,7 +75,6 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface, UserGroupInterf
*/ */
public function destroyLink(TransactionJournalLink $link): bool public function destroyLink(TransactionJournalLink $link): bool
{ {
event(new DestroyedTransactionLink($link));
$link->delete(); $link->delete();
return true; return true;
@@ -122,8 +120,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface, UserGroupInterf
->where('source_journals.user_id', $this->user->id) ->where('source_journals.user_id', $this->user->id)
->where('dest_journals.user_id', $this->user->id) ->where('dest_journals.user_id', $this->user->id)
->whereNull('source_journals.deleted_at') ->whereNull('source_journals.deleted_at')
->whereNull('dest_journals.deleted_at') ->whereNull('dest_journals.deleted_at');
;
if ($linkType instanceof LinkType) { if ($linkType instanceof LinkType) {
$query->where('journal_links.link_type_id', $linkType->id); $query->where('journal_links.link_type_id', $linkType->id);
@@ -233,8 +230,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface, UserGroupInterf
{ {
return TransactionJournalLink::where('link_type_id', $linkType->id) return TransactionJournalLink::where('link_type_id', $linkType->id)
->where('source_id', $inward->id) ->where('source_id', $inward->id)
->where('destination_id', $outward->id)->first() ->where('destination_id', $outward->id)->first();
;
} }
/** /**

View File

@@ -25,9 +25,9 @@ declare(strict_types=1);
namespace FireflyIII\Support\JsonApi\Enrichments; namespace FireflyIII\Support\JsonApi\Enrichments;
use function Safe\json_decode;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Enums\RecurrenceRepetitionWeekend; use FireflyIII\Enums\RecurrenceRepetitionWeekend;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Factory\CategoryFactory; use FireflyIII\Factory\CategoryFactory;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
@@ -42,7 +42,6 @@ use FireflyIII\Models\RecurrenceRepetition;
use FireflyIII\Models\RecurrenceTransaction; use FireflyIII\Models\RecurrenceTransaction;
use FireflyIII\Models\RecurrenceTransactionMeta; use FireflyIII\Models\RecurrenceTransactionMeta;
use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionType;
use FireflyIII\Models\UserGroup; use FireflyIII\Models\UserGroup;
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface; use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
use FireflyIII\Support\Facades\Amount; use FireflyIII\Support\Facades\Amount;
@@ -73,7 +72,7 @@ class RecurringEnrichment implements EnrichmentInterface
private array $accounts = []; private array $accounts = [];
private array $currencies = []; private array $currencies = [];
private array $recurrenceIds = []; private array $recurrenceIds = [];
private TransactionCurrency $primaryCurrency; private readonly TransactionCurrency $primaryCurrency;
private bool $convertToPrimary = false; private bool $convertToPrimary = false;
public function __construct() public function __construct()
@@ -147,9 +146,7 @@ class RecurringEnrichment implements EnrichmentInterface
/** @var RecurrenceRepetition $repetition */ /** @var RecurrenceRepetition $repetition */
foreach ($set as $repetition) { foreach ($set as $repetition) {
$recurrence = $this->collection->filter(function (Recurrence $item) use ($repetition) { $recurrence = $this->collection->filter(fn(Recurrence $item) => (int)$item->id === (int)$repetition->recurrence_id)->first();
return (int)$item->id === (int)$repetition->recurrence_id;
})->first();
$fromDate = clone ($recurrence->latest_date ?? $recurrence->first_date); $fromDate = clone ($recurrence->latest_date ?? $recurrence->first_date);
$id = (int)$repetition->recurrence_id; $id = (int)$repetition->recurrence_id;
$repId = (int)$repetition->id; $repId = (int)$repetition->id;

View File

@@ -27,7 +27,6 @@ namespace Tests\integration\Api\Autocomplete;
use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionCurrency;
use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\integration\TestCase; use Tests\integration\TestCase;
use FireflyIII\User;
/** /**
* Class CurrencyControllerTest * Class CurrencyControllerTest

View File

@@ -39,6 +39,7 @@ final class AccountControllerTest extends TestCase
private $user; private $user;
#[Override] #[Override]
#[\Override]
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp(); parent::setUp();

View File

@@ -39,6 +39,7 @@ final class BalanceControllerTest extends TestCase
private $user; private $user;
#[Override] #[Override]
#[\Override]
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp(); parent::setUp();

View File

@@ -39,6 +39,7 @@ final class BudgetControllerTest extends TestCase
private $user; private $user;
#[Override] #[Override]
#[\Override]
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp(); parent::setUp();

View File

@@ -39,6 +39,7 @@ final class CategoryControllerTest extends TestCase
private $user; private $user;
#[Override] #[Override]
#[\Override]
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp(); parent::setUp();