Fix phpstan issues (or ignore them).

This commit is contained in:
James Cole 2025-02-09 07:02:12 +01:00
parent f909f1d9ff
commit 6172d60e00
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
14 changed files with 23 additions and 18 deletions

View File

@ -25,6 +25,7 @@ declare(strict_types=1);
namespace FireflyIII\Handlers\Observer;
use FireflyIII\Models\Account;
use FireflyIII\Models\Attachment;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
use FireflyIII\Repositories\UserGroups\Account\AccountRepositoryInterface;
@ -81,6 +82,7 @@ class AccountObserver
foreach ($account->piggyBanks()->get() as $piggy) {
$piggy->accounts()->detach($account);
}
/** @var Attachment $attachment */
foreach ($account->attachments()->get() as $attachment) {
$repository->destroy($attachment);
}

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Handlers\Observer;
use FireflyIII\Models\Attachment;
use FireflyIII\Models\Bill;
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
use FireflyIII\Support\Facades\Amount;
@ -46,6 +47,7 @@ class BillObserver
$repository->setUser($bill->user);
// app('log')->debug('Observe "deleting" of a bill.');
/** @var Attachment $attachment */
foreach ($bill->attachments()->get() as $attachment) {
$repository->destroy($attachment);
}

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Handlers\Observer;
use FireflyIII\Models\Attachment;
use FireflyIII\Models\Budget;
use FireflyIII\Models\BudgetLimit;
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
@ -39,6 +40,7 @@ class BudgetObserver
$repository = app(AttachmentRepositoryInterface::class);
$repository->setUser($budget->user);
/** @var Attachment $attachment */
foreach ($budget->attachments()->get() as $attachment) {
$repository->destroy($attachment);
}

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Handlers\Observer;
use FireflyIII\Models\Attachment;
use FireflyIII\Models\Category;
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
@ -38,6 +39,7 @@ class CategoryObserver
$repository = app(AttachmentRepositoryInterface::class);
$repository->setUser($category->user);
/** @var Attachment $attachment */
foreach ($category->attachments()->get() as $attachment) {
$repository->destroy($attachment);
}

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Handlers\Observer;
use FireflyIII\Models\Attachment;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
use FireflyIII\Support\Http\Api\ExchangeRateConverter;
@ -50,6 +51,7 @@ class PiggyBankObserver
$repository = app(AttachmentRepositoryInterface::class);
$repository->setUser($piggyBank->accounts()->first()->user);
/** @var Attachment $attachment */
foreach ($piggyBank->attachments()->get() as $attachment) {
$repository->destroy($attachment);
}

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Handlers\Observer;
use FireflyIII\Models\Attachment;
use FireflyIII\Models\Recurrence;
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
@ -38,6 +39,7 @@ class RecurrenceObserver
$repository = app(AttachmentRepositoryInterface::class);
$repository->setUser($recurrence->user);
/** @var Attachment $attachment */
foreach ($recurrence->attachments()->get() as $attachment) {
$repository->destroy($attachment);
}

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Handlers\Observer;
use FireflyIII\Models\Attachment;
use FireflyIII\Models\Tag;
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
@ -38,6 +39,7 @@ class TagObserver
$repository = app(AttachmentRepositoryInterface::class);
$repository->setUser($tag->user);
/** @var Attachment $attachment */
foreach ($tag->attachments()->get() as $attachment) {
$repository->destroy($attachment);
}

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Handlers\Observer;
use FireflyIII\Models\Attachment;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
@ -45,6 +46,7 @@ class TransactionJournalObserver
$transaction->delete();
}
});
/** @var Attachment $attachment */
foreach ($transactionJournal->attachments()->get() as $attachment) {
$repository->destroy($attachment);
}

View File

@ -259,7 +259,7 @@ class DebugController extends Controller
$system = $this->getSystemInformation();
$docker = $this->getBuildInfo();
$app = $this->getAppInfo();
$user = $this->getuserInfo();
$user = $this->getUserInfo();
return (string) view('partials.debug-table', compact('system', 'docker', 'app', 'user'));
}

View File

@ -419,9 +419,7 @@ class CreateRecurringTransactions implements ShouldQueue
/** @var RecurrenceTransaction $transaction */
foreach ($transactions as $index => $transaction) {
$single = [
'type' => null === $transaction?->transactionType?->type ?
strtolower($recurrence->transactionType->type) :
strtolower($transaction->transactionType->type),
'type' => null === $transaction?->transactionType?->type ? strtolower($recurrence->transactionType->type) : strtolower($transaction->transactionType->type), // @phpstan-ignore-line
'date' => $date,
'user' => $recurrence->user_id,
'currency_id' => $transaction->transaction_currency_id,

View File

@ -63,13 +63,9 @@ abstract class Node
return false;
}
if ($compare instanceof NodeGroup) {
if ($compare instanceof NodeGroup && $this instanceof NodeGroup) {
if (count($compare->getNodes()) !== count($this->getNodes())) {
Log::debug(sprintf('Return false because node count is different. Original is %d, compare is %d', count($this->getNodes()), count($compare->getNodes())));
// var_dump($this);
// var_dump($compare);
// exit;
return false;
}
@ -80,11 +76,6 @@ abstract class Node
foreach ($this->getNodes() as $index => $node) {
if (false === $node->equals($compare->getNodes()[$index])) {
Log::debug('Return false because nodes are different!');
var_dump($this);
var_dump($compare);
exit;
return false;
}
}

View File

@ -152,12 +152,12 @@ class QueryParser implements QueryParserInterface
case ':':
$skipNext = false;
if ('' === $tokenUnderConstruction) { // @phpstan-ignore-line
if ('' === $tokenUnderConstruction) {
// In any other location, it's just a normal character
$tokenUnderConstruction .= $char;
$skipNext = true;
}
if ('' !== $tokenUnderConstruction && !$skipNext) {
if ('' !== $tokenUnderConstruction && !$skipNext) { // @phpstan-ignore-line
Log::debug(sprintf('Turns out that "%s" is a field name. Reset the token.', $tokenUnderConstruction));
// If we meet a colon with a left-hand side string, we know we're in a field and are about to set up the value
$fieldName = $tokenUnderConstruction;

View File

@ -114,7 +114,7 @@ class AmountFormat extends AbstractExtension
static function (string $amount, string $code, ?bool $coloured = null): string {
$coloured ??= true;
/** @var TransactionCurrency $currency */
/** @var TransactionCurrency|null $currency */
$currency = TransactionCurrency::whereCode($code)->first();
if (null === $currency) {
Log::error(sprintf('Could not find currency with code "%s". Fallback to native currency.', $code));

View File

@ -159,7 +159,7 @@ return new class () extends Migration {
Schema::dropIfExists('account_piggy_bank');
}
protected static function hasForeign(string $table, string $column)
protected static function hasForeign(string $table, string $column): bool
{
$foreignKeysDefinitions = Schema::getForeignKeys($table);