diff --git a/.ci/phpmd/phpmd.xml b/.ci/phpmd/phpmd.xml
index c2c1d23000..9db62a683d 100644
--- a/.ci/phpmd/phpmd.xml
+++ b/.ci/phpmd/phpmd.xml
@@ -27,12 +27,12 @@
Firefly III ruleset.
-
+
-
+
@@ -49,11 +49,9 @@
-
-
-
+
@@ -73,22 +71,22 @@
-
+
-
-
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/app/Enums/SearchDirection.php b/app/Enums/SearchDirection.php
new file mode 100644
index 0000000000..969af28eb2
--- /dev/null
+++ b/app/Enums/SearchDirection.php
@@ -0,0 +1,32 @@
+.
+ */
+
+declare(strict_types=1);
+
+namespace FireflyIII\Enums;
+
+enum SearchDirection: int
+{
+ case SOURCE = 1;
+ case DESTINATION = 2;
+ case BOTH = 3;
+
+}
diff --git a/app/Enums/StringPosition.php b/app/Enums/StringPosition.php
new file mode 100644
index 0000000000..1ef5b5d85d
--- /dev/null
+++ b/app/Enums/StringPosition.php
@@ -0,0 +1,37 @@
+.
+ */
+
+declare(strict_types=1);
+
+namespace FireflyIII\Enums;
+
+/**
+ * Class StringPosition
+ *
+ * stringPosition: 1 = start (default), 2 = end, 3 = contains, 4 = is
+ */
+enum StringPosition: int
+{
+ case STARTS = 1;
+ case ENDS = 2;
+ case CONTAINS = 3;
+ case IS = 4;
+}
diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php
index 333a1a95ad..48bf694d22 100644
--- a/app/Http/Controllers/Chart/BudgetController.php
+++ b/app/Http/Controllers/Chart/BudgetController.php
@@ -429,6 +429,9 @@ class BudgetController extends Controller
/**
* Shows a budget overview chart (spent and budgeted).
*
+ * Suppress warning because this method will be replaced by API calls.
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
+ *
* @param Budget $budget
* @param TransactionCurrency $currency
* @param Collection $accounts
diff --git a/app/Repositories/Account/OperationsRepository.php b/app/Repositories/Account/OperationsRepository.php
index d5c232951b..4779166571 100644
--- a/app/Repositories/Account/OperationsRepository.php
+++ b/app/Repositories/Account/OperationsRepository.php
@@ -151,6 +151,7 @@ class OperationsRepository implements OperationsRepositoryInterface
/**
* @inheritDoc
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function sumExpenses(
Carbon $start,
@@ -158,7 +159,8 @@ class OperationsRepository implements OperationsRepositoryInterface
?Collection $accounts = null,
?Collection $expense = null,
?TransactionCurrency $currency = null
- ): array {
+ ): array
+ {
$journals = $this->getTransactionsForSum(TransactionType::WITHDRAWAL, $start, $end, $accounts, $expense, $currency);
return $this->groupByCurrency($journals, 'negative');
@@ -173,6 +175,7 @@ class OperationsRepository implements OperationsRepositoryInterface
* @param string $type
*
* @return array
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
private function getTransactionsForSum(
string $type,
@@ -181,7 +184,8 @@ class OperationsRepository implements OperationsRepositoryInterface
?Collection $accounts = null,
?Collection $opposing = null,
?TransactionCurrency $currency = null
- ): array {
+ ): array
+ {
$start->startOfDay();
$end->endOfDay();
@@ -268,7 +272,8 @@ 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'];
@@ -290,6 +295,7 @@ class OperationsRepository implements OperationsRepositoryInterface
/**
* @inheritDoc
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function sumExpensesByDestination(
Carbon $start,
@@ -297,7 +303,8 @@ class OperationsRepository implements OperationsRepositoryInterface
?Collection $accounts = null,
?Collection $expense = null,
?TransactionCurrency $currency = null
- ): array {
+ ): array
+ {
$journals = $this->getTransactionsForSum(TransactionType::WITHDRAWAL, $start, $end, $accounts, $expense, $currency);
return $this->groupByDirection($journals, 'destination', 'negative');
@@ -352,6 +359,7 @@ class OperationsRepository implements OperationsRepositoryInterface
/**
* @inheritDoc
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function sumExpensesBySource(
Carbon $start,
@@ -359,7 +367,8 @@ class OperationsRepository implements OperationsRepositoryInterface
?Collection $accounts = null,
?Collection $expense = null,
?TransactionCurrency $currency = null
- ): array {
+ ): array
+ {
$journals = $this->getTransactionsForSum(TransactionType::WITHDRAWAL, $start, $end, $accounts, $expense, $currency);
return $this->groupByDirection($journals, 'source', 'negative');
@@ -367,6 +376,7 @@ class OperationsRepository implements OperationsRepositoryInterface
/**
* @inheritDoc
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function sumIncome(
Carbon $start,
@@ -374,7 +384,8 @@ class OperationsRepository implements OperationsRepositoryInterface
?Collection $accounts = null,
?Collection $revenue = null,
?TransactionCurrency $currency = null
- ): array {
+ ): array
+ {
$journals = $this->getTransactionsForSum(TransactionType::DEPOSIT, $start, $end, $accounts, $revenue, $currency);
return $this->groupByCurrency($journals, 'positive');
@@ -382,6 +393,7 @@ class OperationsRepository implements OperationsRepositoryInterface
/**
* @inheritDoc
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function sumIncomeByDestination(
Carbon $start,
@@ -389,7 +401,8 @@ class OperationsRepository implements OperationsRepositoryInterface
?Collection $accounts = null,
?Collection $revenue = null,
?TransactionCurrency $currency = null
- ): array {
+ ): array
+ {
$journals = $this->getTransactionsForSum(TransactionType::DEPOSIT, $start, $end, $accounts, $revenue, $currency);
return $this->groupByDirection($journals, 'destination', 'positive');
@@ -397,6 +410,7 @@ class OperationsRepository implements OperationsRepositoryInterface
/**
* @inheritDoc
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function sumIncomeBySource(
Carbon $start,
@@ -404,7 +418,8 @@ class OperationsRepository implements OperationsRepositoryInterface
?Collection $accounts = null,
?Collection $revenue = null,
?TransactionCurrency $currency = null
- ): array {
+ ): array
+ {
$journals = $this->getTransactionsForSum(TransactionType::DEPOSIT, $start, $end, $accounts, $revenue, $currency);
return $this->groupByDirection($journals, 'source', 'positive');
diff --git a/app/Repositories/Account/OperationsRepositoryInterface.php b/app/Repositories/Account/OperationsRepositoryInterface.php
index 3e02b58cb8..43c6d65905 100644
--- a/app/Repositories/Account/OperationsRepositoryInterface.php
+++ b/app/Repositories/Account/OperationsRepositoryInterface.php
@@ -75,6 +75,7 @@ interface OperationsRepositoryInterface
* @param TransactionCurrency|null $currency
*
* @return array
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function sumExpenses(
Carbon $start,
@@ -95,6 +96,7 @@ interface OperationsRepositoryInterface
* @param TransactionCurrency|null $currency
*
* @return array
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function sumExpensesByDestination(
Carbon $start,
@@ -115,6 +117,7 @@ interface OperationsRepositoryInterface
* @param TransactionCurrency|null $currency
*
* @return array
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function sumExpensesBySource(
Carbon $start,
@@ -134,6 +137,7 @@ interface OperationsRepositoryInterface
* @param TransactionCurrency|null $currency
*
* @return array
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function sumIncome(
Carbon $start,
@@ -154,6 +158,7 @@ interface OperationsRepositoryInterface
* @param TransactionCurrency|null $currency
*
* @return array
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function sumIncomeByDestination(
Carbon $start,
@@ -174,6 +179,7 @@ interface OperationsRepositoryInterface
* @param TransactionCurrency|null $currency
*
* @return array
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function sumIncomeBySource(
Carbon $start,
diff --git a/app/Repositories/Budget/OperationsRepository.php b/app/Repositories/Budget/OperationsRepository.php
index 3ee62ff3c0..a2313e51be 100644
--- a/app/Repositories/Budget/OperationsRepository.php
+++ b/app/Repositories/Budget/OperationsRepository.php
@@ -228,6 +228,7 @@ class OperationsRepository implements OperationsRepositoryInterface
* @param TransactionCurrency|null $currency
*
* @return array
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function sumExpenses(
Carbon $start,
@@ -235,7 +236,8 @@ class OperationsRepository implements OperationsRepositoryInterface
?Collection $accounts = null,
?Collection $budgets = null,
?TransactionCurrency $currency = null
- ): array {
+ ): array
+ {
//app('log')->debug(sprintf('Now in %s', __METHOD__));
$start->startOfDay();
$end->endOfDay();
diff --git a/app/Repositories/Budget/OperationsRepositoryInterface.php b/app/Repositories/Budget/OperationsRepositoryInterface.php
index 40348997ec..bed08af39f 100644
--- a/app/Repositories/Budget/OperationsRepositoryInterface.php
+++ b/app/Repositories/Budget/OperationsRepositoryInterface.php
@@ -81,8 +81,9 @@ interface OperationsRepositoryInterface
* @param Collection|null $accounts
* @param Collection|null $budgets
* @param TransactionCurrency|null $currency
- * @return array
*
+ * @return array
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function sumExpenses(
Carbon $start,
diff --git a/app/Support/Models/BillDateCalculator.php b/app/Support/Models/BillDateCalculator.php
index d511a1e77e..c64cee19f0 100644
--- a/app/Support/Models/BillDateCalculator.php
+++ b/app/Support/Models/BillDateCalculator.php
@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Support\Models;
use Carbon\Carbon;
-use FireflyIII\Models\Bill;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
@@ -36,9 +35,12 @@ class BillDateCalculator
* @param Carbon $earliest
* @param Carbon $latest
* @param Carbon $billStart
+ * @param string $period
+ * @param int $skip
* @param Carbon|null $lastPaid
*
* @return array
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function getPayDates(Carbon $earliest, Carbon $latest, Carbon $billStart, string $period, int $skip, ?Carbon $lastPaid): array
{
diff --git a/app/Support/Repositories/Recurring/CalculateXOccurrencesSince.php b/app/Support/Repositories/Recurring/CalculateXOccurrencesSince.php
index 7be047bf3d..66139faa7e 100644
--- a/app/Support/Repositories/Recurring/CalculateXOccurrencesSince.php
+++ b/app/Support/Repositories/Recurring/CalculateXOccurrencesSince.php
@@ -72,6 +72,7 @@ trait CalculateXOccurrencesSince
* @param string $moment
*
* @return array
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
protected function getXMonthlyOccurrencesSince(Carbon $date, Carbon $afterDate, int $count, int $skipMod, string $moment): array
{
@@ -115,6 +116,7 @@ trait CalculateXOccurrencesSince
* @param string $moment
*
* @return array
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
protected function getXNDomOccurrencesSince(Carbon $date, Carbon $afterDate, int $count, int $skipMod, string $moment): array
{
@@ -155,6 +157,7 @@ trait CalculateXOccurrencesSince
* @param string $moment
*
* @return array
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
protected function getXWeeklyOccurrencesSince(Carbon $date, Carbon $afterDate, int $count, int $skipMod, string $moment): array
{
@@ -200,6 +203,7 @@ trait CalculateXOccurrencesSince
* @param string $moment
*
* @return array
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
protected function getXYearlyOccurrencesSince(Carbon $date, Carbon $afterDate, int $count, int $skipMod, string $moment): array
{
diff --git a/app/Support/Search/OperatorQuerySearch.php b/app/Support/Search/OperatorQuerySearch.php
index e24663153b..036a3e5388 100644
--- a/app/Support/Search/OperatorQuerySearch.php
+++ b/app/Support/Search/OperatorQuerySearch.php
@@ -24,6 +24,8 @@ declare(strict_types=1);
namespace FireflyIII\Support\Search;
use Carbon\Carbon;
+use FireflyIII\Enums\SearchDirection;
+use FireflyIII\Enums\StringPosition;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\Account;
@@ -55,6 +57,7 @@ use Gdbots\QueryParser\QueryParser;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
use LogicException;
+use PragmaRX\Random\Generators\StringGenerator;
use TypeError;
/**
@@ -247,6 +250,7 @@ class OperatorQuerySearch implements SearchInterface
/**
*
* @throws FireflyException
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
private function updateCollector(string $operator, string $value, bool $prohibited): bool
{
@@ -273,100 +277,100 @@ class OperatorQuerySearch implements SearchInterface
// all account related searches:
//
case 'account_is':
- $this->searchAccount($value, 3, 4);
+ $this->searchAccount($value, SearchDirection::BOTH, StringPosition::IS);
break;
case '-account_is':
- $this->searchAccount($value, 3, 4, true);
+ $this->searchAccount($value, SearchDirection::BOTH, StringPosition::IS, true);
break;
case 'account_contains':
- $this->searchAccount($value, 3, 3);
+ $this->searchAccount($value, SearchDirection::BOTH, StringPosition::CONTAINS);
break;
case '-account_contains':
- $this->searchAccount($value, 3, 3, true);
+ $this->searchAccount($value, SearchDirection::BOTH, StringPosition::CONTAINS, true);
break;
case 'account_ends':
- $this->searchAccount($value, 3, 2);
+ $this->searchAccount($value, SearchDirection::BOTH, StringPosition::ENDS);
break;
case '-account_ends':
- $this->searchAccount($value, 3, 2, true);
+ $this->searchAccount($value, SearchDirection::BOTH, StringPosition::ENDS, true);
break;
case 'account_starts':
- $this->searchAccount($value, 3, 1);
+ $this->searchAccount($value, SearchDirection::BOTH, StringPosition::STARTS);
break;
case '-account_starts':
- $this->searchAccount($value, 3, 1, true);
+ $this->searchAccount($value, SearchDirection::BOTH, StringPosition::STARTS, true);
break;
case 'account_nr_is':
- $this->searchAccountNr($value, 3, 4);
+ $this->searchAccountNr($value, SearchDirection::BOTH, StringPosition::IS);
break;
case '-account_nr_is':
- $this->searchAccountNr($value, 3, 4, true);
+ $this->searchAccountNr($value, SearchDirection::BOTH, StringPosition::IS, true);
break;
case 'account_nr_contains':
- $this->searchAccountNr($value, 3, 3);
+ $this->searchAccountNr($value, SearchDirection::BOTH, StringPosition::CONTAINS);
break;
case '-account_nr_contains':
- $this->searchAccountNr($value, 3, 3, true);
+ $this->searchAccountNr($value, SearchDirection::BOTH, StringPosition::CONTAINS, true);
break;
case 'account_nr_ends':
- $this->searchAccountNr($value, 3, 2);
+ $this->searchAccountNr($value, SearchDirection::BOTH, StringPosition::ENDS);
break;
case '-account_nr_ends':
- $this->searchAccountNr($value, 3, 2, true);
+ $this->searchAccountNr($value, SearchDirection::BOTH, StringPosition::ENDS, true);
break;
case 'account_nr_starts':
- $this->searchAccountNr($value, 3, 1);
+ $this->searchAccountNr($value, SearchDirection::BOTH, StringPosition::STARTS);
break;
case '-account_nr_starts':
- $this->searchAccountNr($value, 3, 1, true);
+ $this->searchAccountNr($value, SearchDirection::BOTH, StringPosition::STARTS, true);
break;
case 'source_account_starts':
- $this->searchAccount($value, 1, 1);
+ $this->searchAccount($value, SearchDirection::SOURCE, StringPosition::STARTS);
break;
case '-source_account_starts':
- $this->searchAccount($value, 1, 1, true);
+ $this->searchAccount($value, SearchDirection::SOURCE, StringPosition::STARTS, true);
break;
case 'source_account_ends':
- $this->searchAccount($value, 1, 2);
+ $this->searchAccount($value, SearchDirection::SOURCE, StringPosition::ENDS);
break;
case '-source_account_ends':
- $this->searchAccount($value, 1, 2, true);
+ $this->searchAccount($value, SearchDirection::SOURCE, StringPosition::ENDS, true);
break;
case 'source_account_is':
- $this->searchAccount($value, 1, 4);
+ $this->searchAccount($value, SearchDirection::SOURCE, StringPosition::IS);
break;
case '-source_account_is':
- $this->searchAccount($value, 1, 4, true);
+ $this->searchAccount($value, SearchDirection::SOURCE, StringPosition::IS, true);
break;
case 'source_account_nr_starts':
- $this->searchAccountNr($value, 1, 1);
+ $this->searchAccountNr($value, SearchDirection::SOURCE, StringPosition::STARTS);
break;
case '-source_account_nr_starts':
- $this->searchAccountNr($value, 1, 1, true);
+ $this->searchAccountNr($value, SearchDirection::SOURCE, StringPosition::STARTS, true);
break;
case 'source_account_nr_ends':
- $this->searchAccountNr($value, 1, 2);
+ $this->searchAccountNr($value, SearchDirection::SOURCE, StringPosition::ENDS);
break;
case '-source_account_nr_ends':
- $this->searchAccountNr($value, 1, 2, true);
+ $this->searchAccountNr($value, SearchDirection::SOURCE, StringPosition::ENDS, true);
break;
case 'source_account_nr_is':
- $this->searchAccountNr($value, 1, 4);
+ $this->searchAccountNr($value, SearchDirection::SOURCE, StringPosition::IS);
break;
case '-source_account_nr_is':
- $this->searchAccountNr($value, 1, 4, true);
+ $this->searchAccountNr($value, SearchDirection::SOURCE, StringPosition::IS, true);
break;
case 'source_account_nr_contains':
- $this->searchAccountNr($value, 1, 3);
+ $this->searchAccountNr($value, SearchDirection::SOURCE, StringPosition::CONTAINS);
break;
case '-source_account_nr_contains':
- $this->searchAccountNr($value, 1, 3, true);
+ $this->searchAccountNr($value, SearchDirection::SOURCE, StringPosition::CONTAINS, true);
break;
case 'source_account_contains':
- $this->searchAccount($value, 1, 3);
+ $this->searchAccount($value, SearchDirection::SOURCE, StringPosition::CONTAINS);
break;
case '-source_account_contains':
- $this->searchAccount($value, 1, 3, true);
+ $this->searchAccount($value, SearchDirection::SOURCE, StringPosition::CONTAINS, true);
break;
case 'source_account_id':
$account = $this->accountRepository->find((int)$value);
@@ -405,52 +409,52 @@ class OperatorQuerySearch implements SearchInterface
$this->collector->excludeIds($parts);
break;
case 'destination_account_starts':
- $this->searchAccount($value, 2, 1);
+ $this->searchAccount($value, SearchDirection::DESTINATION, StringPosition::STARTS);
break;
case '-destination_account_starts':
- $this->searchAccount($value, 2, 1, true);
+ $this->searchAccount($value, SearchDirection::DESTINATION, StringPosition::STARTS, true);
break;
case 'destination_account_ends':
- $this->searchAccount($value, 2, 2);
+ $this->searchAccount($value, SearchDirection::DESTINATION, StringPosition::ENDS);
break;
case '-destination_account_ends':
- $this->searchAccount($value, 2, 2, true);
+ $this->searchAccount($value, SearchDirection::DESTINATION, StringPosition::ENDS, true);
break;
case 'destination_account_nr_starts':
- $this->searchAccountNr($value, 2, 1);
+ $this->searchAccountNr($value, SearchDirection::DESTINATION, StringPosition::STARTS);
break;
case '-destination_account_nr_starts':
- $this->searchAccountNr($value, 2, 1, true);
+ $this->searchAccountNr($value, SearchDirection::DESTINATION, StringPosition::STARTS, true);
break;
case 'destination_account_nr_ends':
- $this->searchAccountNr($value, 2, 2);
+ $this->searchAccountNr($value, SearchDirection::DESTINATION, StringPosition::ENDS);
break;
case '-destination_account_nr_ends':
- $this->searchAccountNr($value, 2, 2, true);
+ $this->searchAccountNr($value, SearchDirection::DESTINATION, StringPosition::ENDS, true);
break;
case 'destination_account_nr_is':
- $this->searchAccountNr($value, 2, 4);
+ $this->searchAccountNr($value, SearchDirection::DESTINATION, StringPosition::IS);
break;
case '-destination_account_nr_is':
- $this->searchAccountNr($value, 2, 4, true);
+ $this->searchAccountNr($value, SearchDirection::DESTINATION, StringPosition::IS, true);
break;
case 'destination_account_is':
- $this->searchAccount($value, 2, 4);
+ $this->searchAccount($value, SearchDirection::DESTINATION, StringPosition::IS);
break;
case '-destination_account_is':
- $this->searchAccount($value, 2, 4, true);
+ $this->searchAccount($value, SearchDirection::DESTINATION, StringPosition::IS, true);
break;
case 'destination_account_nr_contains':
- $this->searchAccountNr($value, 2, 3);
+ $this->searchAccountNr($value, SearchDirection::DESTINATION, StringPosition::CONTAINS);
break;
case '-destination_account_nr_contains':
- $this->searchAccountNr($value, 2, 3, true);
+ $this->searchAccountNr($value, SearchDirection::DESTINATION, StringPosition::CONTAINS, true);
break;
case 'destination_account_contains':
- $this->searchAccount($value, 2, 3);
+ $this->searchAccount($value, SearchDirection::DESTINATION, StringPosition::CONTAINS);
break;
case '-destination_account_contains':
- $this->searchAccount($value, 2, 3, true);
+ $this->searchAccount($value, SearchDirection::DESTINATION, StringPosition::CONTAINS, true);
break;
case 'destination_account_id':
$account = $this->accountRepository->find((int)$value);
@@ -1359,13 +1363,13 @@ class OperatorQuerySearch implements SearchInterface
* searchDirection: 1 = source (default), 2 = destination, 3 = both
* stringPosition: 1 = start (default), 2 = end, 3 = contains, 4 = is
*
- * @param string $value
- * @param int $searchDirection
- * @param int $stringPosition
- * @param bool $prohibited
+ * @param string $value
+ * @param SearchDirection $searchDirection
+ * @param StringPosition $stringPosition
+ * @param bool $prohibited
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*/
- private function searchAccount(string $value, int $searchDirection, int $stringPosition, bool $prohibited = false): void
+ private function searchAccount(string $value, SearchDirection $searchDirection, StringPosition $stringPosition, bool $prohibited = false): void
{
app('log')->debug(sprintf('searchAccount("%s", %d, %d)', $value, $stringPosition, $searchDirection));
@@ -1377,7 +1381,7 @@ class OperatorQuerySearch implements SearchInterface
}
// search direction: for destination accounts
- if (2 === $searchDirection) {
+ if (SearchDirection::DESTINATION === $searchDirection) { // destination
// destination can be
$searchTypes = [AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT, AccountType::EXPENSE];
$collectorMethod = 'setDestinationAccounts';
@@ -1386,7 +1390,7 @@ class OperatorQuerySearch implements SearchInterface
}
}
// either account could be:
- if (3 === $searchDirection) {
+ if (SearchDirection::BOTH === $searchDirection) {
$searchTypes = [AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT, AccountType::EXPENSE, AccountType::REVENUE];
$collectorMethod = 'setAccounts';
if ($prohibited) {
@@ -1397,13 +1401,13 @@ class OperatorQuerySearch implements SearchInterface
$stringMethod = 'str_starts_with';
// string position: ends with:
- if (2 === $stringPosition) {
+ if (StringPosition::ENDS === $stringPosition) {
$stringMethod = 'str_ends_with';
}
- if (3 === $stringPosition) {
+ if (StringPosition::CONTAINS === $stringPosition) {
$stringMethod = 'str_contains';
}
- if (4 === $stringPosition) {
+ if (StringPosition::IS === $stringPosition) {
$stringMethod = 'stringIsEqual';
}
@@ -1437,13 +1441,13 @@ class OperatorQuerySearch implements SearchInterface
* searchDirection: 1 = source (default), 2 = destination, 3 = both
* stringPosition: 1 = start (default), 2 = end, 3 = contains, 4 = is
*
- * @param string $value
- * @param int $searchDirection
- * @param int $stringPosition
- * @param bool $prohibited
+ * @param string $value
+ * @param SearchDirection $searchDirection
+ * @param StringPosition $stringPosition
+ * @param bool $prohibited
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*/
- private function searchAccountNr(string $value, int $searchDirection, int $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));
@@ -1455,7 +1459,7 @@ class OperatorQuerySearch implements SearchInterface
}
// search direction: for destination accounts
- if (2 === $searchDirection) {
+ if (SearchDirection::DESTINATION === $searchDirection) {
// destination can be
$searchTypes = [AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT, AccountType::EXPENSE];
$collectorMethod = 'setDestinationAccounts';
@@ -1465,7 +1469,7 @@ class OperatorQuerySearch implements SearchInterface
}
// either account could be:
- if (3 === $searchDirection) {
+ if (SearchDirection::BOTH === $searchDirection) {
$searchTypes = [AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT, AccountType::EXPENSE, AccountType::REVENUE];
$collectorMethod = 'setAccounts';
if (true === $prohibited) {
@@ -1477,13 +1481,13 @@ class OperatorQuerySearch implements SearchInterface
$stringMethod = 'str_starts_with';
// string position: ends with:
- if (2 === $stringPosition) {
+ if (StringPosition::ENDS === $stringPosition) {
$stringMethod = 'str_ends_with';
}
- if (3 === $stringPosition) {
+ if (StringPosition::CONTAINS === $stringPosition) {
$stringMethod = 'str_contains';
}
- if (4 === $stringPosition) {
+ if (StringPosition::IS === $stringPosition) {
$stringMethod = 'stringIsEqual';
}
diff --git a/app/Validation/TransactionValidation.php b/app/Validation/TransactionValidation.php
index 3e225cbb5a..871b33816f 100644
--- a/app/Validation/TransactionValidation.php
+++ b/app/Validation/TransactionValidation.php
@@ -61,8 +61,8 @@ trait TransactionValidation
app('log')->debug(sprintf('Going to loop %d transaction(s)', count($transactions)));
/**
- * @var int|null $index
- * @var array $transaction
+ * @var int|null $index
+ * @var array $transaction
*/
foreach ($transactions as $index => $transaction) {
$transaction['user'] = $user;
@@ -169,6 +169,7 @@ trait TransactionValidation
* @param array $destination
*
* @return void
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
protected function sanityCheckReconciliation(Validator $validator, string $transactionType, int $index, array $source, array $destination): void
{
@@ -204,6 +205,7 @@ trait TransactionValidation
* @param int $index
*
* @return void
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
private function sanityCheckForeignCurrency(
Validator $validator,
@@ -211,7 +213,8 @@ trait TransactionValidation
array $transaction,
string $transactionType,
int $index
- ): void {
+ ): void
+ {
app('log')->debug('Now in sanityCheckForeignCurrency()');
if (0 !== $validator->errors()->count()) {
app('log')->debug('Already have errors, return');
@@ -377,8 +380,8 @@ trait TransactionValidation
$transactions = $this->getTransactionsArray($validator);
/**
- * @var int|null $index
- * @var array $transaction
+ * @var int|null $index
+ * @var array $transaction
*/
foreach ($transactions as $index => $transaction) {
if (!is_int($index)) {
@@ -488,7 +491,7 @@ trait TransactionValidation
*/
private function getTransactionType(TransactionGroup $group, array $transactions): string
{
- return $transactions[0]['type'] ?? strtolower((string) $group->transactionJournals()->first()?->transactionType->type);
+ return $transactions[0]['type'] ?? strtolower((string)$group->transactionJournals()->first()?->transactionType->type);
}
/**
diff --git a/database/seeders/ExchangeRateSeeder.php b/database/seeders/ExchangeRateSeeder.php
index 188159187f..164473461e 100644
--- a/database/seeders/ExchangeRateSeeder.php
+++ b/database/seeders/ExchangeRateSeeder.php
@@ -28,7 +28,6 @@ use FireflyIII\Models\CurrencyExchangeRate;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\User;
use Illuminate\Database\Seeder;
-use Illuminate\Support\Collection;
/**
* Class ExchangeRateSeeder
@@ -109,6 +108,7 @@ class ExchangeRateSeeder extends Seeder
* @param float $rate
*
* @return void
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
private function addRate(User $user, TransactionCurrency $from, TransactionCurrency $to, string $date, float $rate): void
{