mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-18 10:39:28 +00:00
Fix various phpstan issues.
This commit is contained in:
24
.ci/phpmd/composer.lock
generated
24
.ci/phpmd/composer.lock
generated
@@ -472,16 +472,16 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/dependency-injection",
|
||||
"version": "v7.0.0",
|
||||
"version": "v7.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/dependency-injection.git",
|
||||
"reference": "71c053f3284a57d611e11bd7d7f1a76de8514a07"
|
||||
"reference": "f6667642954bce638733f254c39e5b5700b47ba4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/dependency-injection/zipball/71c053f3284a57d611e11bd7d7f1a76de8514a07",
|
||||
"reference": "71c053f3284a57d611e11bd7d7f1a76de8514a07",
|
||||
"url": "https://api.github.com/repos/symfony/dependency-injection/zipball/f6667642954bce638733f254c39e5b5700b47ba4",
|
||||
"reference": "f6667642954bce638733f254c39e5b5700b47ba4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -532,7 +532,7 @@
|
||||
"description": "Allows you to standardize and centralize the way objects are constructed in your application",
|
||||
"homepage": "https://symfony.com",
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/dependency-injection/tree/v7.0.0"
|
||||
"source": "https://github.com/symfony/dependency-injection/tree/v7.0.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -548,7 +548,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2023-11-15T15:38:56+00:00"
|
||||
"time": "2023-12-01T15:10:06+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/deprecation-contracts",
|
||||
@@ -929,16 +929,16 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/var-exporter",
|
||||
"version": "v7.0.0",
|
||||
"version": "v7.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/var-exporter.git",
|
||||
"reference": "d97726e8d254a2d5512b2b4ba204735d84e7167d"
|
||||
"reference": "a3d7c877414fcd59ab7075ecdc3b8f9c00f7bcc3"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/var-exporter/zipball/d97726e8d254a2d5512b2b4ba204735d84e7167d",
|
||||
"reference": "d97726e8d254a2d5512b2b4ba204735d84e7167d",
|
||||
"url": "https://api.github.com/repos/symfony/var-exporter/zipball/a3d7c877414fcd59ab7075ecdc3b8f9c00f7bcc3",
|
||||
"reference": "a3d7c877414fcd59ab7075ecdc3b8f9c00f7bcc3",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -983,7 +983,7 @@
|
||||
"serialize"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/var-exporter/tree/v7.0.0"
|
||||
"source": "https://github.com/symfony/var-exporter/tree/v7.0.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -999,7 +999,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2023-11-29T08:40:23+00:00"
|
||||
"time": "2023-11-30T11:38:21+00:00"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
|
@@ -71,7 +71,8 @@
|
||||
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength">
|
||||
<properties>
|
||||
<!-- TODO we want to be at a value of 40. But we start high, and drop the bar slowly. -->
|
||||
<property name="minimum" value="1000"/>
|
||||
<property name="minimum" value="100"/>
|
||||
<property name="ignore-whitespace" value="true"/>
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="rulesets/codesize.xml/ExcessiveParameterList">
|
||||
|
@@ -55,6 +55,6 @@ parameters:
|
||||
- ../bootstrap/app.php
|
||||
|
||||
# The level 8 is the highest level. original was 5
|
||||
# TODO: slowly up the level and fix the issues found.
|
||||
# 7 is more than enough, higher just leaves NULL things.
|
||||
level: 7
|
||||
|
||||
|
@@ -66,135 +66,34 @@ class DestroyController extends Controller
|
||||
{
|
||||
$objects = $request->getObjects();
|
||||
$this->unused = $request->boolean('unused', false);
|
||||
switch ($objects) {
|
||||
default:
|
||||
throw new FireflyException(sprintf('200033: This endpoint can\'t handle object "%s"', $objects));
|
||||
case 'budgets':
|
||||
$this->destroyBudgets();
|
||||
break;
|
||||
case 'bills':
|
||||
$this->destroyBills();
|
||||
break;
|
||||
case 'piggy_banks':
|
||||
$this->destroyPiggyBanks();
|
||||
break;
|
||||
case 'rules':
|
||||
$this->destroyRules();
|
||||
break;
|
||||
case 'recurring':
|
||||
$this->destroyRecurringTransactions();
|
||||
break;
|
||||
case 'categories':
|
||||
$this->destroyCategories();
|
||||
break;
|
||||
case 'tags':
|
||||
$this->destroyTags();
|
||||
break;
|
||||
case 'object_groups':
|
||||
$this->destroyObjectGroups();
|
||||
break;
|
||||
case 'not_assets_liabilities':
|
||||
$this->destroyAccounts(
|
||||
[
|
||||
AccountType::BENEFICIARY,
|
||||
AccountType::CASH,
|
||||
AccountType::CREDITCARD,
|
||||
AccountType::DEFAULT,
|
||||
AccountType::EXPENSE,
|
||||
AccountType::IMPORT,
|
||||
AccountType::INITIAL_BALANCE,
|
||||
AccountType::LIABILITY_CREDIT,
|
||||
AccountType::RECONCILIATION,
|
||||
AccountType::REVENUE,
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'accounts':
|
||||
$this->destroyAccounts(
|
||||
[
|
||||
AccountType::ASSET,
|
||||
AccountType::BENEFICIARY,
|
||||
AccountType::CASH,
|
||||
AccountType::CREDITCARD,
|
||||
AccountType::DEBT,
|
||||
AccountType::DEFAULT,
|
||||
AccountType::EXPENSE,
|
||||
AccountType::IMPORT,
|
||||
AccountType::INITIAL_BALANCE,
|
||||
AccountType::LIABILITY_CREDIT,
|
||||
AccountType::LOAN,
|
||||
AccountType::MORTGAGE,
|
||||
AccountType::RECONCILIATION,
|
||||
AccountType::REVENUE,
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'asset_accounts':
|
||||
$this->destroyAccounts(
|
||||
[
|
||||
AccountType::ASSET,
|
||||
AccountType::DEFAULT,
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'expense_accounts':
|
||||
$this->destroyAccounts(
|
||||
[
|
||||
AccountType::BENEFICIARY,
|
||||
AccountType::EXPENSE,
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'revenue_accounts':
|
||||
$this->destroyAccounts(
|
||||
[
|
||||
AccountType::REVENUE,
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'liabilities':
|
||||
$this->destroyAccounts(
|
||||
[
|
||||
AccountType::DEBT,
|
||||
AccountType::LOAN,
|
||||
AccountType::MORTGAGE,
|
||||
AccountType::CREDITCARD,
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'transactions':
|
||||
$this->destroyTransactions(
|
||||
[
|
||||
TransactionType::WITHDRAWAL,
|
||||
TransactionType::DEPOSIT,
|
||||
TransactionType::TRANSFER,
|
||||
TransactionType::RECONCILIATION,
|
||||
TransactionType::OPENING_BALANCE,
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'withdrawals':
|
||||
$this->destroyTransactions(
|
||||
[
|
||||
TransactionType::WITHDRAWAL,
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'deposits':
|
||||
$this->destroyTransactions(
|
||||
[
|
||||
TransactionType::DEPOSIT,
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'transfers':
|
||||
$this->destroyTransactions(
|
||||
[
|
||||
TransactionType::TRANSFER,
|
||||
]
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
$allExceptAssets = [AccountType::BENEFICIARY, AccountType::CASH, AccountType::CREDITCARD, AccountType::DEFAULT, AccountType::EXPENSE, AccountType::IMPORT, AccountType::INITIAL_BALANCE, AccountType::LIABILITY_CREDIT, AccountType::RECONCILIATION, AccountType::REVENUE,];
|
||||
$all = [AccountType::ASSET, AccountType::BENEFICIARY, AccountType::CASH, AccountType::CREDITCARD, AccountType::DEBT, AccountType::DEFAULT, AccountType::EXPENSE, AccountType::IMPORT, AccountType::INITIAL_BALANCE, AccountType::LIABILITY_CREDIT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::RECONCILIATION,];
|
||||
$liabilities = [AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD];
|
||||
$transactions = [TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::TRANSFER, TransactionType::RECONCILIATION, TransactionType::OPENING_BALANCE,];
|
||||
|
||||
match ($objects) {
|
||||
'budgets' => $this->destroyBudgets(),
|
||||
'bills' => $this->destroyBills(),
|
||||
'piggy_banks' => $this->destroyPiggyBanks(),
|
||||
'rules' => $this->destroyRules(),
|
||||
'recurring' => $this->destroyRecurringTransactions(),
|
||||
'categories' => $this->destroyCategories(),
|
||||
'tags' => $this->destroyTags(),
|
||||
'object_groups' => $this->destroyObjectGroups(),
|
||||
'not_assets_liabilities' => $this->destroyAccounts($allExceptAssets),
|
||||
'accounts' => $this->destroyAccounts($all),
|
||||
'asset_accounts' => $this->destroyAccounts([AccountType::ASSET, AccountType::DEFAULT]),
|
||||
'expense_accounts' => $this->destroyAccounts([AccountType::BENEFICIARY, AccountType::EXPENSE]),
|
||||
'revenue_accounts' => $this->destroyAccounts([AccountType::REVENUE]),
|
||||
'liabilities' => $this->destroyAccounts($liabilities),
|
||||
'transactions' => $this->destroyTransactions($transactions),
|
||||
'withdrawals' => $this->destroyTransactions([TransactionType::WITHDRAWAL]),
|
||||
'deposits' => $this->destroyTransactions([TransactionType::DEPOSIT]),
|
||||
'transfers' => $this->destroyTransactions([TransactionType::TRANSFER]),
|
||||
default => throw new FireflyException(sprintf('200033: This endpoint can\'t handle object "%s"', $objects)),
|
||||
};
|
||||
|
||||
app('preferences')->mark();
|
||||
|
||||
return response()->json([], 204);
|
||||
|
@@ -98,7 +98,7 @@ class StoreRequest extends FormRequest
|
||||
'foreign_amount' => $this->clearString((string)$object['foreign_amount']),
|
||||
|
||||
// description.
|
||||
'description' => $this->clearString($object['description'], false),
|
||||
'description' => $this->clearString($object['description']),
|
||||
|
||||
// source of transaction. If everything is null, assume cash account.
|
||||
'source_id' => $this->integerFromValue((string)$object['source_id']),
|
||||
|
@@ -131,8 +131,7 @@ class UserEventHandler
|
||||
$group = null;
|
||||
|
||||
// create a new group.
|
||||
while (true === $groupExists) {
|
||||
/** @phpstan-ignore-line */
|
||||
while (true === $groupExists) { // @phpstan-ignore-line
|
||||
$groupExists = UserGroup::where('title', $groupTitle)->count() > 0;
|
||||
if (false === $groupExists) {
|
||||
$group = UserGroup::create(['title' => $groupTitle]);
|
||||
@@ -206,8 +205,7 @@ class UserEventHandler
|
||||
if (false === $entry['notified']) {
|
||||
try {
|
||||
Notification::send($user, new UserLogin($ipAddress));
|
||||
} catch (Exception $e) {
|
||||
/** @phpstan-ignore-line */
|
||||
} catch (Exception $e) {// @phpstan-ignore-line
|
||||
$message = $e->getMessage();
|
||||
if (str_contains($message, 'Bcc')) {
|
||||
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
@@ -241,8 +239,7 @@ class UserEventHandler
|
||||
if ($repository->hasRole($user, 'owner')) {
|
||||
try {
|
||||
Notification::send($user, new AdminRegistrationNotification($event->user));
|
||||
} catch (Exception $e) {
|
||||
/** @phpstan-ignore-line */
|
||||
} catch (Exception $e) { // @phpstan-ignore-line
|
||||
$message = $e->getMessage();
|
||||
if (str_contains($message, 'Bcc')) {
|
||||
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
@@ -319,8 +316,7 @@ class UserEventHandler
|
||||
{
|
||||
try {
|
||||
Notification::send($event->user, new UserNewPassword(route('password.reset', [$event->token])));
|
||||
} catch (Exception $e) {
|
||||
/** @phpstan-ignore-line */
|
||||
} catch (Exception $e) { // @phpstan-ignore-line
|
||||
$message = $e->getMessage();
|
||||
if (str_contains($message, 'Bcc')) {
|
||||
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
@@ -368,8 +364,7 @@ class UserEventHandler
|
||||
if ($sendMail) {
|
||||
try {
|
||||
Notification::send($event->user, new UserRegistrationNotification());
|
||||
} catch (Exception $e) {
|
||||
/** @phpstan-ignore-line */
|
||||
} catch (Exception $e) { // @phpstan-ignore-line
|
||||
$message = $e->getMessage();
|
||||
if (str_contains($message, 'Bcc')) {
|
||||
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
|
||||
|
@@ -832,7 +832,6 @@ class GroupCollector implements GroupCollectorInterface
|
||||
// and save it (or not) in the new collection.
|
||||
// that new collection is the next current collection
|
||||
/**
|
||||
* @var int $ii
|
||||
* @var array $item
|
||||
*/
|
||||
foreach ($currentCollection as $item) {
|
||||
|
@@ -272,8 +272,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
'currency_code' => $journal['currency_code'],
|
||||
'currency_decimal_places' => $journal['currency_decimal_places'],
|
||||
];
|
||||
$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->$direction($journal['amount']));
|
||||
/** @phpstan-ignore-line */
|
||||
$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->$direction($journal['amount']));// @phpstan-ignore-line
|
||||
|
||||
// also do foreign amount:
|
||||
$foreignId = (int)$journal['foreign_currency_id'];
|
||||
|
@@ -181,8 +181,7 @@ trait ConvertsDataTypes
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
|
||||
if (method_exists($this, 'validateUserGroup')) {
|
||||
/** @phpstan-ignore-line */
|
||||
if (method_exists($this, 'validateUserGroup')) { // @phpstan-ignore-line
|
||||
$userGroup = $this->validateUserGroup($this);
|
||||
if (null !== $userGroup) {
|
||||
$repository->setUserGroup($userGroup);
|
||||
|
@@ -1449,7 +1449,7 @@ class OperatorQuerySearch implements SearchInterface
|
||||
*/
|
||||
private function searchAccountNr(string $value, SearchDirection $searchDirection, StringPosition $stringPosition, bool $prohibited = false): void
|
||||
{
|
||||
app('log')->debug(sprintf('searchAccountNr(%s, %d, %d)', $value, $searchDirection, $stringPosition));
|
||||
app('log')->debug(sprintf('searchAccountNr(%s, %d, %d)', $value, $searchDirection->name, $stringPosition->name));
|
||||
|
||||
// search direction (default): for source accounts
|
||||
$searchTypes = [AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT, AccountType::REVENUE];
|
||||
|
@@ -229,8 +229,7 @@ class FireflyValidator extends Validator
|
||||
}
|
||||
try {
|
||||
$checksum = bcmod($iban, '97');
|
||||
} catch (ValueError $e) {
|
||||
/** @phpstan-ignore-line */
|
||||
} catch (ValueError $e) { // @phpstan-ignore-line
|
||||
$message = sprintf('Could not validate IBAN check value "%s" (IBAN "%s")', $iban, $value);
|
||||
app('log')->error($message);
|
||||
app('log')->error($e->getTraceAsString());
|
||||
|
Reference in New Issue
Block a user