Skip to content

Firefly III: a personal finances manager

Small changes based on Mago rule

James Cole7c4f80a360f7
diff --git a/app/Api/V1/Controllers/Autocomplete/AccountController.php b/app/Api/V1/Controllers/Autocomplete/AccountController.php
index 331c0b4cfa..6ce68253e6 100644
--- a/app/Api/V1/Controllers/Autocomplete/AccountController.php
+++ b/app/Api/V1/Controllers/Autocomplete/AccountController.php
@@ -96,7 +96,7 @@ final class AccountController extends Controller
$nameWithBalance = $account->name;
$currency = $this->repository->getAccountCurrency($account) ?? $this->primaryCurrency;
$useCurrency = $currency;
- if (in_array($account->accountType->type, $this->balanceTypes, true)) {
+ if (in_array($account->accountType->type, $this->balanceTypes, strict: true)) {
// this one is correct.
Log::debug(sprintf('accounts: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
$balance = $allBalances[$account->id] ?? [];
diff --git a/app/Api/V1/Controllers/Search/AccountController.php b/app/Api/V1/Controllers/Search/AccountController.php
index 314bab7de6..4ece03c429 100644
--- a/app/Api/V1/Controllers/Search/AccountController.php
+++ b/app/Api/V1/Controllers/Search/AccountController.php
@@ -63,7 +63,7 @@ final class AccountController extends Controller
$query = trim((string) $request->get('query'));
$field = trim((string) $request->get('field'));
$type = $request->get('type') ?? 'all';
- if ('' === $query || !in_array($field, $this->validFields, true)) {
+ if ('' === $query || !in_array($field, $this->validFields, strict: true)) {
return response(null, 422);
}
Log::debug(sprintf('Now in account search("%s", "%s")', $field, $query));
diff --git a/app/Api/V1/Requests/ApiRequest.php b/app/Api/V1/Requests/ApiRequest.php
index a4f00fb9fc..cec26a5a73 100644
--- a/app/Api/V1/Requests/ApiRequest.php
+++ b/app/Api/V1/Requests/ApiRequest.php
@@ -38,7 +38,7 @@ class ApiRequest extends FormRequest
public function handleConfig(array $config): void
{
- if (in_array('required', $config, true)) {
+ if (in_array('required', $config, strict: true)) {
$this->required = 'required';
}
}
diff --git a/app/Api/V1/Requests/Insight/GenericRequest.php b/app/Api/V1/Requests/Insight/GenericRequest.php
index 7bcfc6c03a..50c1d51b8b 100644
--- a/app/Api/V1/Requests/Insight/GenericRequest.php
+++ b/app/Api/V1/Requests/Insight/GenericRequest.php
@@ -72,7 +72,7 @@ class GenericRequest extends FormRequest
if (in_array(
$type,
[AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value],
- true
+ strict: true
)) {
$return->push($account);
}
diff --git a/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php b/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php
index 1aa3f386af..426b8d7178 100644
--- a/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php
+++ b/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php
@@ -116,7 +116,7 @@ class StoreRequest extends FormRequest
$validator->errors()->add(sprintf('accounts.%d', $index), trans('validation.invalid_account_currency'));
}
$type = $account->accountType->type;
- if (!in_array($type, $types, true)) {
+ if (!in_array($type, $types, strict: true)) {
$validator->errors()->add(sprintf('accounts.%d', $index), trans('validation.invalid_account_type'));
}
}
diff --git a/app/Api/V1/Requests/Models/Webhook/CreateRequest.php b/app/Api/V1/Requests/Models/Webhook/CreateRequest.php
index 0a630258d4..3c8e444425 100644
--- a/app/Api/V1/Requests/Models/Webhook/CreateRequest.php
+++ b/app/Api/V1/Requests/Models/Webhook/CreateRequest.php
@@ -52,7 +52,7 @@ class CreateRequest extends FormRequest
$responses = $this->get('responses', []);
$deliveries = $this->get('deliveries', []);
- if (in_array(0, [count($triggers), count($responses), count($deliveries)], true)) {
+ if (in_array(0, [count($triggers), count($responses), count($deliveries)], strict: true)) {
throw new FireflyException('Unexpectedly got no responses, triggers or deliveries.');
}
diff --git a/app/Api/V1/Requests/Models/Webhook/UpdateRequest.php b/app/Api/V1/Requests/Models/Webhook/UpdateRequest.php
index cbd0c543a9..27629cec58 100644
--- a/app/Api/V1/Requests/Models/Webhook/UpdateRequest.php
+++ b/app/Api/V1/Requests/Models/Webhook/UpdateRequest.php
@@ -53,7 +53,7 @@ class UpdateRequest extends FormRequest
$responses = $this->get('responses', []);
$deliveries = $this->get('deliveries', []);
- if (in_array(0, [count($triggers), count($responses), count($deliveries)], true)) {
+ if (in_array(0, [count($triggers), count($responses), count($deliveries)], strict: true)) {
throw new FireflyException('Unexpectedly got no responses, triggers or deliveries.');
}
diff --git a/app/Api/V1/Requests/System/UpdateRequest.php b/app/Api/V1/Requests/System/UpdateRequest.php
index 187209ff41..4d9c1d772d 100644
--- a/app/Api/V1/Requests/System/UpdateRequest.php
+++ b/app/Api/V1/Requests/System/UpdateRequest.php
@@ -56,10 +56,10 @@ class UpdateRequest extends FormRequest
public function getAll(): array
{
$name = $this->route()->parameter('dynamicConfigKey');
- if (in_array($name, $this->booleans, true)) {
+ if (in_array($name, $this->booleans, strict: true)) {
return ['value' => $this->boolean('value')];
}
- if (in_array($name, $this->integers, true)) {
+ if (in_array($name, $this->integers, strict: true)) {
return ['value' => $this->convertInteger('value')];
}
@@ -73,13 +73,13 @@ class UpdateRequest extends FormRequest
{
$name = $this->route()->parameter('configName');
- if (in_array($name, $this->booleans, true)) {
+ if (in_array($name, $this->booleans, strict: true)) {
return ['value' => ['required', new IsBoolean()]];
}
if ('configuration.permission_update_check' === $name) {
return ['value' => 'required|numeric|min:-1|max:1'];
}
- if (in_array($name, $this->integers, true)) {
+ if (in_array($name, $this->integers, strict: true)) {
return ['value' => 'required|numeric|min:464272080'];
}
diff --git a/app/Console/Commands/Correction/CorrectsAccountTypes.php b/app/Console/Commands/Correction/CorrectsAccountTypes.php
index b45c4cde82..8247db585b 100644
--- a/app/Console/Commands/Correction/CorrectsAccountTypes.php
+++ b/app/Console/Commands/Correction/CorrectsAccountTypes.php
@@ -125,7 +125,7 @@ class CorrectsAccountTypes extends Command
private function canCreateDestination(array $validDestinations): bool
{
- return in_array(AccountTypeEnum::EXPENSE->value, $validDestinations, true);
+ return in_array(AccountTypeEnum::EXPENSE->value, $validDestinations, strict: true);
}
/**
@@ -133,7 +133,7 @@ class CorrectsAccountTypes extends Command
*/
private function canCreateSource(array $validSources): bool
{
- return in_array(AccountTypeEnum::REVENUE->value, $validSources, true);
+ return in_array(AccountTypeEnum::REVENUE->value, $validSources, strict: true);
}
private function fixJournal(TransactionJournal $journal, string $transactionType, Transaction $source, Transaction $dest): void
@@ -308,7 +308,7 @@ class CorrectsAccountTypes extends Command
private function hasValidAccountType(array $validTypes, string $accountType): bool
{
- return in_array($accountType, $validTypes, true);
+ return in_array($accountType, $validTypes, strict: true);
}
private function inspectJournal(TransactionJournal $journal): void
@@ -342,7 +342,7 @@ class CorrectsAccountTypes extends Command
return;
}
$expectedTypes = $this->expected[$type][$sourceAccountType];
- if (!in_array($destAccountType, $expectedTypes, true)) {
+ if (!in_array($destAccountType, $expectedTypes, strict: true)) {
Log::debug(sprintf('[b] Going to fix journal #%d', $journal->id));
$this->fixJournal($journal, $type, $sourceTransaction, $destTransaction);
}
diff --git a/app/Console/Commands/Upgrade/UpgradesToGroups.php b/app/Console/Commands/Upgrade/UpgradesToGroups.php
index 58b92eae82..d7f57fd69c 100644
--- a/app/Console/Commands/Upgrade/UpgradesToGroups.php
+++ b/app/Console/Commands/Upgrade/UpgradesToGroups.php
@@ -86,7 +86,7 @@ class UpgradesToGroups extends Command
private function findOpposingTransaction(TransactionJournal $journal, Transaction $transaction): ?Transaction
{
$set = $journal->transactions->filter(static function (Transaction $subject) use ($transaction): bool {
- $amount = ((float) $transaction->amount * -1) === (float) $subject->amount; // intentional float
+ $amount = -(float) $transaction->amount === (float) $subject->amount; // intentional float
$identifier = $transaction->identifier === $subject->identifier;
Log::debug(sprintf('Amount the same? %s', var_export($amount, true)));
Log::debug(sprintf('ID the same? %s', var_export($identifier, true)));
diff --git a/app/Support/Chart/Category/FrontpageChartGenerator.php b/app/Support/Chart/Category/FrontpageChartGenerator.php
index e1daae4c2a..537cf81ab1 100644
--- a/app/Support/Chart/Category/FrontpageChartGenerator.php
+++ b/app/Support/Chart/Category/FrontpageChartGenerator.php
@@ -171,7 +171,7 @@ class FrontpageChartGenerator
$direction = $array['sum_float'] < 0 ? 'spent' : 'earned';
$key = sprintf('%s-%d', $direction, $array['currency_id']);
$category = $array['name'];
- $amount = $array['sum_float'] < 0 ? $array['sum_float'] * -1 : $array['sum_float'];
+ $amount = $array['sum_float'] < 0 ? -$array['sum_float'] : $array['sum_float'];
$currencyData[$key]['entries'][$category] = $amount;
}
diff --git a/app/Transformers/AccountTransformer.php b/app/Transformers/AccountTransformer.php
index 1658167ab0..6cef5ac046 100644
--- a/app/Transformers/AccountTransformer.php
+++ b/app/Transformers/AccountTransformer.php
@@ -81,7 +81,7 @@ class AccountTransformer extends AbstractTransformer
}
// no order for some accounts:
- if (!in_array(strtolower($accountType), ['liability', 'liabilities', 'asset'], true)) {
+ if (!in_array(strtolower($accountType), ['liability', 'liabilities', 'asset'], strict: true)) {
$order = null;
}
diff --git a/app/User.php b/app/User.php
index 4c80b15f6d..86a5a22c55 100644
--- a/app/User.php
+++ b/app/User.php
@@ -524,7 +524,7 @@ class User extends Authenticatable
$userGroup->id,
$userGroup->title
));
- if (in_array($membership->userRole->title, $dbRolesTitles, true)) {
+ if (in_array($membership->userRole->title, $dbRolesTitles, strict: true)) {
Log::debug(sprintf('Return true, found role "%s"', $membership->userRole->title));
return true;
diff --git a/mago.toml b/mago.toml
index 3855a2e4b9..2a1706ee06 100644
--- a/mago.toml
+++ b/mago.toml
@@ -43,7 +43,6 @@ no-literal-password = { enabled = false }
too-many-enum-cases = { enabled = false }
tagged-fixme = { enabled = false }
excessive-parameter-list = { enabled = false }
-no-redundant-math={ enabled = false }
prefer-first-class-callable={ enabled = false }
prefer-arrow-function = { enabled = false }