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