From c2296c3ad5169489bde8507ce6b7888b08a4c729 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 17 Aug 2019 10:47:29 +0200 Subject: [PATCH] Code cleanup --- app/Import/Converter/Amount.php | 6 +- .../JobConfiguration/FakeJobConfiguration.php | 6 +- .../JobConfiguration/FileJobConfiguration.php | 6 +- .../SpectreJobConfiguration.php | 2 +- .../JobConfiguration/YnabJobConfiguration.php | 2 +- app/Import/Routine/FakeRoutine.php | 4 +- app/Import/Routine/SpectreRoutine.php | 4 +- app/Import/Specifics/AbnAmroDescription.php | 10 +- app/Import/Specifics/Belfius.php | 2 +- app/Import/Specifics/IngBelgium.php | 2 +- app/Import/Specifics/IngDescription.php | 2 +- app/Import/Specifics/RabobankDescription.php | 2 +- app/Import/Storage/ImportArrayStorage.php | 12 +- app/Jobs/CreateRecurringTransactions.php | 8 +- app/Mail/AccessTokenCreatedMail.php | 1 + app/Mail/AdminTestMail.php | 1 + app/Mail/ConfirmEmailChangeMail.php | 1 + app/Mail/OAuthTokenCreatedMail.php | 1 + app/Mail/RegisteredUser.php | 1 + app/Mail/ReportNewJournalsMail.php | 1 + app/Mail/RequestedNewPassword.php | 1 + app/Mail/UndoEmailChangeMail.php | 1 + app/Models/Transaction.php | 4 - app/Providers/EventServiceProvider.php | 2 +- app/Providers/FireflyServiceProvider.php | 8 +- .../Account/AccountRepository.php | 2 +- .../Attachment/AttachmentRepository.php | 3 +- app/Repositories/Bill/BillRepository.php | 2 +- app/Repositories/Budget/BudgetRepository.php | 26 +- .../Category/CategoryRepository.php | 10 +- .../ImportJob/ImportJobRepository.php | 2 +- .../LinkType/LinkTypeRepository.php | 6 +- .../PiggyBank/PiggyBankRepository.php | 8 +- .../Recurring/RecurringRepository.php | 7 +- app/Repositories/Rule/RuleRepository.php | 2 +- app/Repositories/Tag/TagRepository.php | 6 +- app/Repositories/User/UserRepository.php | 2 +- app/Rules/BelongsUser.php | 6 +- app/Rules/IsAssetAccountId.php | 2 - app/Rules/IsValidAttachmentModel.php | 2 - app/Rules/UniqueIban.php | 6 +- app/Rules/ValidJournals.php | 2 +- app/Rules/ValidRecurrenceRepetitionType.php | 4 +- app/Rules/ValidRecurrenceRepetitionValue.php | 6 +- app/Services/Bunq/ApiContext.php | 4 +- .../Destroy/RecurrenceDestroyService.php | 2 +- .../Internal/Support/AccountServiceTrait.php | 2 +- .../Internal/Support/JournalServiceTrait.php | 2 +- app/Services/Spectre/Object/Holder.php | 2 +- app/Services/Spectre/Object/Transaction.php | 2 +- .../Spectre/Request/ListAccountsRequest.php | 2 +- .../Spectre/Request/ListCustomersRequest.php | 2 +- .../Spectre/Request/ListLoginsRequest.php | 2 +- .../Request/ListTransactionsRequest.php | 2 +- app/Support/Amount.php | 6 +- app/Support/Binder/AccountList.php | 2 +- app/Support/Binder/BudgetList.php | 2 +- app/Support/Binder/CategoryList.php | 2 +- app/Support/Binder/ImportProvider.php | 5 +- app/Support/ExpandedForm.php | 19 +- app/Support/Form/CurrencyForm.php | 4 +- app/Support/Http/Controllers/AugumentData.php | 16 +- .../Http/Controllers/ChartGeneration.php | 4 +- .../Http/Controllers/GetConfigurationData.php | 4 +- .../Http/Controllers/PeriodOverview.php | 3 +- .../Http/Controllers/RenderPartialViews.php | 2 +- .../Http/Controllers/RequestInformation.php | 6 +- .../Controllers/TransactionCalculation.php | 4 - .../File/ConfigureMappingHandler.php | 2 +- .../File/ConfigureRolesHandler.php | 2 +- .../Spectre/ChooseAccountsHandler.php | 2 +- .../Import/Placeholder/ImportTransaction.php | 2 +- .../Routine/File/AssetAccountMapper.php | 2 +- .../Routine/File/MappedValuesValidator.php | 2 +- .../Routine/File/OpposingAccountMapper.php | 2 +- .../Spectre/StageImportDataHandler.php | 2 +- app/Support/Navigation.php | 2 +- .../Recurring/CalculateRangeOccurrences.php | 6 +- .../Recurring/FiltersWeekends.php | 4 +- app/Support/Search/Search.php | 2 +- app/TransactionRules/Actions/ClearNotes.php | 3 +- .../Actions/ConvertToDeposit.php | 7 +- .../Actions/ConvertToWithdrawal.php | 7 +- app/TransactionRules/Actions/RemoveTag.php | 4 +- app/TransactionRules/Actions/SetBudget.php | 3 +- app/TransactionRules/Actions/SetCategory.php | 1 - .../Actions/SetDestinationAccount.php | 4 +- .../Actions/SetSourceAccount.php | 4 +- app/TransactionRules/Engine/RuleEngine.php | 193 +++++---- .../Factory/TriggerFactory.php | 4 +- app/TransactionRules/Processor.php | 383 +++++++++--------- app/TransactionRules/TransactionMatcher.php | 5 +- app/Transformers/BillTransformer.php | 2 +- app/Transformers/CategoryTransformer.php | 3 - app/Validation/FireflyValidator.php | 22 +- 95 files changed, 463 insertions(+), 507 deletions(-) diff --git a/app/Import/Converter/Amount.php b/app/Import/Converter/Amount.php index 637867f32d..c87fa7cd95 100644 --- a/app/Import/Converter/Amount.php +++ b/app/Import/Converter/Amount.php @@ -33,9 +33,9 @@ class Amount implements ConverterInterface * Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. * - Jamie Zawinski. * - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - * @SuppressWarnings(PHPMD.NPathComplexity) - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * + * + * * @param $value * * @return string diff --git a/app/Import/JobConfiguration/FakeJobConfiguration.php b/app/Import/JobConfiguration/FakeJobConfiguration.php index b762b5397c..a515270a03 100644 --- a/app/Import/JobConfiguration/FakeJobConfiguration.php +++ b/app/Import/JobConfiguration/FakeJobConfiguration.php @@ -46,7 +46,7 @@ class FakeJobConfiguration implements JobConfigurationInterface * if stage is not "new", then album must be 'station to station' * * @return bool - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function configurationComplete(): bool { @@ -70,7 +70,7 @@ class FakeJobConfiguration implements JobConfigurationInterface * * @return MessageBag * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function configureJob(array $data): MessageBag { @@ -128,7 +128,7 @@ class FakeJobConfiguration implements JobConfigurationInterface * * @return string * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function getNextView(): string { diff --git a/app/Import/JobConfiguration/FileJobConfiguration.php b/app/Import/JobConfiguration/FileJobConfiguration.php index b41e8e3156..9eb1aa4f75 100644 --- a/app/Import/JobConfiguration/FileJobConfiguration.php +++ b/app/Import/JobConfiguration/FileJobConfiguration.php @@ -89,10 +89,10 @@ class FileJobConfiguration implements JobConfigurationInterface /** * Returns the view of the next step in the job configuration. * - * @throws FireflyException * @return string * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * + *@throws FireflyException */ public function getNextView(): string { @@ -132,7 +132,7 @@ class FileJobConfiguration implements JobConfigurationInterface * @return FileConfigurationInterface * @throws FireflyException * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ private function getConfigurationObject(): FileConfigurationInterface { diff --git a/app/Import/JobConfiguration/SpectreJobConfiguration.php b/app/Import/JobConfiguration/SpectreJobConfiguration.php index fde970cd58..7f9bf1dea3 100644 --- a/app/Import/JobConfiguration/SpectreJobConfiguration.php +++ b/app/Import/JobConfiguration/SpectreJobConfiguration.php @@ -111,7 +111,7 @@ class SpectreJobConfiguration implements JobConfigurationInterface * @return SpectreJobConfigurationInterface * @throws FireflyException * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ private function getHandler(): SpectreJobConfigurationInterface { diff --git a/app/Import/JobConfiguration/YnabJobConfiguration.php b/app/Import/JobConfiguration/YnabJobConfiguration.php index 1fabb496c7..803867e397 100644 --- a/app/Import/JobConfiguration/YnabJobConfiguration.php +++ b/app/Import/JobConfiguration/YnabJobConfiguration.php @@ -109,7 +109,7 @@ class YnabJobConfiguration implements JobConfigurationInterface * @return YnabJobConfigurationInterface * @throws FireflyException * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ private function getHandler(): YnabJobConfigurationInterface { diff --git a/app/Import/Routine/FakeRoutine.php b/app/Import/Routine/FakeRoutine.php index 14ed949977..e271a4b1d2 100644 --- a/app/Import/Routine/FakeRoutine.php +++ b/app/Import/Routine/FakeRoutine.php @@ -52,8 +52,8 @@ class FakeRoutine implements RoutineInterface * @return void * @throws FireflyException * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * + * */ public function run(): void { diff --git a/app/Import/Routine/SpectreRoutine.php b/app/Import/Routine/SpectreRoutine.php index 2805142ebd..1171ff5e5e 100644 --- a/app/Import/Routine/SpectreRoutine.php +++ b/app/Import/Routine/SpectreRoutine.php @@ -49,8 +49,8 @@ class SpectreRoutine implements RoutineInterface * * @throws FireflyException * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * + * */ public function run(): void { diff --git a/app/Import/Specifics/AbnAmroDescription.php b/app/Import/Specifics/AbnAmroDescription.php index 7f373d897d..68b1b1e318 100644 --- a/app/Import/Specifics/AbnAmroDescription.php +++ b/app/Import/Specifics/AbnAmroDescription.php @@ -64,7 +64,7 @@ class AbnAmroDescription implements SpecificInterface * * @return array * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function run(array $row): array { @@ -132,8 +132,8 @@ class AbnAmroDescription implements SpecificInterface * * @return bool true if the description is SEPA format, false otherwise * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * + * */ protected function parseSepaDescription(): bool { @@ -189,8 +189,8 @@ class AbnAmroDescription implements SpecificInterface * * @return bool true if the description is TRTP format, false otherwise * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * + * */ protected function parseTRTPDescription(): bool { diff --git a/app/Import/Specifics/Belfius.php b/app/Import/Specifics/Belfius.php index 714cfb9848..1a57f03bdd 100644 --- a/app/Import/Specifics/Belfius.php +++ b/app/Import/Specifics/Belfius.php @@ -61,7 +61,7 @@ class Belfius implements SpecificInterface * * @return array * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function run(array $row): array { diff --git a/app/Import/Specifics/IngBelgium.php b/app/Import/Specifics/IngBelgium.php index b77e811696..c284e33518 100644 --- a/app/Import/Specifics/IngBelgium.php +++ b/app/Import/Specifics/IngBelgium.php @@ -59,7 +59,7 @@ class IngBelgium implements SpecificInterface * * @return array * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function run(array $row): array { diff --git a/app/Import/Specifics/IngDescription.php b/app/Import/Specifics/IngDescription.php index 74d142d8d3..122437ba89 100644 --- a/app/Import/Specifics/IngDescription.php +++ b/app/Import/Specifics/IngDescription.php @@ -66,7 +66,7 @@ class IngDescription implements SpecificInterface * * @return array * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function run(array $row): array { diff --git a/app/Import/Specifics/RabobankDescription.php b/app/Import/Specifics/RabobankDescription.php index 7dea7e493a..6ef8a99560 100644 --- a/app/Import/Specifics/RabobankDescription.php +++ b/app/Import/Specifics/RabobankDescription.php @@ -59,7 +59,7 @@ class RabobankDescription implements SpecificInterface * * @return array * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function run(array $row): array { diff --git a/app/Import/Storage/ImportArrayStorage.php b/app/Import/Storage/ImportArrayStorage.php index b10c3a9f92..9ca1c863af 100644 --- a/app/Import/Storage/ImportArrayStorage.php +++ b/app/Import/Storage/ImportArrayStorage.php @@ -51,7 +51,7 @@ use Log; * * Class ImportArrayStorage * - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * */ class ImportArrayStorage { @@ -201,8 +201,8 @@ class ImportArrayStorage * @return Collection * @throws FireflyException * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * + * */ private function storeGroupArray(): Collection { @@ -388,9 +388,9 @@ class ImportArrayStorage * * @return bool * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - * @SuppressWarnings(PHPMD.NPathComplexity) + * + * + * */ private function transferExists(array $transaction): bool { diff --git a/app/Jobs/CreateRecurringTransactions.php b/app/Jobs/CreateRecurringTransactions.php index 7966641d4f..cb8dc4f88e 100644 --- a/app/Jobs/CreateRecurringTransactions.php +++ b/app/Jobs/CreateRecurringTransactions.php @@ -67,7 +67,7 @@ use Log; /** * Class CreateRecurringTransactions. - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * * */ class CreateRecurringTransactions implements ShouldQueue @@ -228,7 +228,7 @@ class CreateRecurringTransactions implements ShouldQueue * @param Carbon $date * * @return array - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * */ private function getTransactionData(Recurrence $recurrence, Carbon $date): array { @@ -441,8 +441,8 @@ class CreateRecurringTransactions implements ShouldQueue * @param Recurrence $recurrence * * @return bool - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * + * */ private function validRecurrence(Recurrence $recurrence): bool { diff --git a/app/Mail/AccessTokenCreatedMail.php b/app/Mail/AccessTokenCreatedMail.php index 65d702602e..9080d7503a 100644 --- a/app/Mail/AccessTokenCreatedMail.php +++ b/app/Mail/AccessTokenCreatedMail.php @@ -30,6 +30,7 @@ use Illuminate\Queue\SerializesModels; /** * Class AccessTokenCreatedMail + * * @codeCoverageIgnore */ class AccessTokenCreatedMail extends Mailable diff --git a/app/Mail/AdminTestMail.php b/app/Mail/AdminTestMail.php index 17e24ed50f..f132d0837c 100644 --- a/app/Mail/AdminTestMail.php +++ b/app/Mail/AdminTestMail.php @@ -30,6 +30,7 @@ use Illuminate\Queue\SerializesModels; * Class AdminTestMail. * * Sends a test mail to administrators. + * * @codeCoverageIgnore */ class AdminTestMail extends Mailable diff --git a/app/Mail/ConfirmEmailChangeMail.php b/app/Mail/ConfirmEmailChangeMail.php index 74d8c8b75e..3ac01c4bbe 100644 --- a/app/Mail/ConfirmEmailChangeMail.php +++ b/app/Mail/ConfirmEmailChangeMail.php @@ -30,6 +30,7 @@ use Illuminate\Queue\SerializesModels; * Class ConfirmEmailChangeMail * * Sends message to new address to confirm change. + * * @codeCoverageIgnore */ class ConfirmEmailChangeMail extends Mailable diff --git a/app/Mail/OAuthTokenCreatedMail.php b/app/Mail/OAuthTokenCreatedMail.php index f8729a4ce2..4146b0cfff 100644 --- a/app/Mail/OAuthTokenCreatedMail.php +++ b/app/Mail/OAuthTokenCreatedMail.php @@ -31,6 +31,7 @@ use Laravel\Passport\Client; /** * Class OAuthTokenCreatedMail + * * @codeCoverageIgnore */ class OAuthTokenCreatedMail extends Mailable diff --git a/app/Mail/RegisteredUser.php b/app/Mail/RegisteredUser.php index c66955da2b..f56b689e6b 100644 --- a/app/Mail/RegisteredUser.php +++ b/app/Mail/RegisteredUser.php @@ -31,6 +31,7 @@ use Illuminate\Queue\SerializesModels; * Sends newly registered user an email message. * * Class RegisteredUser + * * @codeCoverageIgnore */ class RegisteredUser extends Mailable diff --git a/app/Mail/ReportNewJournalsMail.php b/app/Mail/ReportNewJournalsMail.php index 5c38a2173a..0ffe29868c 100644 --- a/app/Mail/ReportNewJournalsMail.php +++ b/app/Mail/ReportNewJournalsMail.php @@ -31,6 +31,7 @@ use Illuminate\Support\Collection; * Class ReportNewJournalsMail. * * Sends a list of newly created journals to the user. + * * @codeCoverageIgnore */ class ReportNewJournalsMail extends Mailable diff --git a/app/Mail/RequestedNewPassword.php b/app/Mail/RequestedNewPassword.php index bc102856e4..53735fffa6 100644 --- a/app/Mail/RequestedNewPassword.php +++ b/app/Mail/RequestedNewPassword.php @@ -30,6 +30,7 @@ use Illuminate\Queue\SerializesModels; /** * Sends user link for new password. * Class RequestedNewPassword + * * @codeCoverageIgnore */ class RequestedNewPassword extends Mailable diff --git a/app/Mail/UndoEmailChangeMail.php b/app/Mail/UndoEmailChangeMail.php index 69deb68073..4b73f0468d 100644 --- a/app/Mail/UndoEmailChangeMail.php +++ b/app/Mail/UndoEmailChangeMail.php @@ -28,6 +28,7 @@ use Illuminate\Queue\SerializesModels; /** * Class UndoEmailChangeMail + * * @codeCoverageIgnore */ class UndoEmailChangeMail extends Mailable diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index 8591b1f2c0..9259fabb6f 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -23,13 +23,11 @@ declare(strict_types=1); namespace FireflyIII\Models; use Carbon\Carbon; -use FireflyIII\User; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\SoftDeletes; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * Class Transaction. @@ -159,8 +157,6 @@ class Transaction extends Model /** * Check if a table is joined. * - * - * * @param Builder $query * @param string $table * diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 4afe6a89c7..c5bf2a20fa 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -112,7 +112,7 @@ class EventServiceProvider extends ServiceProvider } /** - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * */ protected function registerCreateEvents(): void { diff --git a/app/Providers/FireflyServiceProvider.php b/app/Providers/FireflyServiceProvider.php index 45f2582ef9..8d15def23d 100644 --- a/app/Providers/FireflyServiceProvider.php +++ b/app/Providers/FireflyServiceProvider.php @@ -53,8 +53,8 @@ use FireflyIII\Services\IP\IPRetrievalInterface; use FireflyIII\Services\Password\PwndVerifierV3; use FireflyIII\Services\Password\Verifier; use FireflyIII\Support\Amount; -use FireflyIII\Support\FireflyConfig; use FireflyIII\Support\ExpandedForm; +use FireflyIII\Support\FireflyConfig; use FireflyIII\Support\Form\AccountForm; use FireflyIII\Support\Form\CurrencyForm; use FireflyIII\Support\Form\PiggyBankForm; @@ -63,9 +63,9 @@ use FireflyIII\Support\Navigation; use FireflyIII\Support\Preferences; use FireflyIII\Support\Steam; use FireflyIII\Support\Twig\AmountFormat; -use FireflyIII\Support\Twig\TransactionGroupTwig; use FireflyIII\Support\Twig\General; use FireflyIII\Support\Twig\Rule; +use FireflyIII\Support\Twig\TransactionGroupTwig; use FireflyIII\Support\Twig\Translation; use FireflyIII\Validation\FireflyValidator; use Illuminate\Foundation\Application; @@ -80,7 +80,7 @@ use Validator; * Class FireflyServiceProvider. * * @codeCoverageIgnore - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * */ class FireflyServiceProvider extends ServiceProvider { @@ -108,7 +108,7 @@ class FireflyServiceProvider extends ServiceProvider /** * Register stuff. * - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * */ public function register(): void { diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index 9967f08b79..55d61a41b2 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -40,7 +40,7 @@ use Log; /** * Class AccountRepository. - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * */ class AccountRepository implements AccountRepositoryInterface { diff --git a/app/Repositories/Attachment/AttachmentRepository.php b/app/Repositories/Attachment/AttachmentRepository.php index 7976c8c0fa..299c4c34a9 100644 --- a/app/Repositories/Attachment/AttachmentRepository.php +++ b/app/Repositories/Attachment/AttachmentRepository.php @@ -22,7 +22,6 @@ declare(strict_types=1); namespace FireflyIII\Repositories\Attachment; -use Carbon\Carbon; use Crypt; use Exception; use FireflyIII\Exceptions\FireflyException; @@ -38,7 +37,7 @@ use Log; /** * Class AttachmentRepository. - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * */ class AttachmentRepository implements AttachmentRepositoryInterface { diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php index 56ea6f377c..b089ceca6d 100644 --- a/app/Repositories/Bill/BillRepository.php +++ b/app/Repositories/Bill/BillRepository.php @@ -41,7 +41,7 @@ use Log; /** * Class BillRepository. - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * */ class BillRepository implements BillRepositoryInterface { diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php index 98352d264e..7117414748 100644 --- a/app/Repositories/Budget/BudgetRepository.php +++ b/app/Repositories/Budget/BudgetRepository.php @@ -46,9 +46,9 @@ use Navigation; /** * Class BudgetRepository. * - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - * @SuppressWarnings(PHPMD.TooManyPublicMethods) - * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + * + * + * */ class BudgetRepository implements BudgetRepositoryInterface { @@ -105,7 +105,7 @@ class BudgetRepository implements BudgetRepositoryInterface * * @return array * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function collectBudgetInformation(Collection $budgets, Carbon $start, Carbon $end): array { @@ -173,8 +173,8 @@ class BudgetRepository implements BudgetRepositoryInterface * @param Carbon $end * * @return Collection - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * + * */ public function getBudgetLimits(Budget $budget, Carbon $start = null, Carbon $end = null): Collection { @@ -335,8 +335,8 @@ class BudgetRepository implements BudgetRepositoryInterface * @param Budget $budget * * @return Carbon - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * + * */ public function firstUseDate(Budget $budget): ?Carbon { @@ -377,8 +377,8 @@ class BudgetRepository implements BudgetRepositoryInterface * @param Carbon $end * * @return Collection - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * + * */ public function getAllBudgetLimits(Carbon $start = null, Carbon $end = null): Collection { @@ -870,7 +870,7 @@ class BudgetRepository implements BudgetRepositoryInterface /** * @return bool - * @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's 5. + * // it's 5. */ public function cleanupBudgets(): bool { @@ -992,8 +992,8 @@ class BudgetRepository implements BudgetRepositoryInterface * @param string $amount * * @return BudgetLimit|null - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * + * */ public function updateLimitAmount(Budget $budget, Carbon $start, Carbon $end, string $amount): ?BudgetLimit { diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.php index 343b581452..b901fcff5f 100644 --- a/app/Repositories/Category/CategoryRepository.php +++ b/app/Repositories/Category/CategoryRepository.php @@ -37,9 +37,9 @@ use Navigation; /** * Class CategoryRepository. * - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - * @SuppressWarnings(PHPMD.TooManyPublicMethods) - * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + * + * + * */ class CategoryRepository implements CategoryRepositoryInterface { @@ -323,7 +323,7 @@ class CategoryRepository implements CategoryRepositoryInterface * @param Category $category * * @return Carbon|null - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function firstUseDate(Category $category): ?Carbon { @@ -365,7 +365,7 @@ class CategoryRepository implements CategoryRepositoryInterface * * @return Carbon|null * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function lastUseDate(Category $category, Collection $accounts): ?Carbon { diff --git a/app/Repositories/ImportJob/ImportJobRepository.php b/app/Repositories/ImportJob/ImportJobRepository.php index bd8bf775f7..155fd4e095 100644 --- a/app/Repositories/ImportJob/ImportJobRepository.php +++ b/app/Repositories/ImportJob/ImportJobRepository.php @@ -38,7 +38,7 @@ use Symfony\Component\HttpFoundation\File\UploadedFile; /** * Class ImportJobRepository. * - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * */ class ImportJobRepository implements ImportJobRepositoryInterface { diff --git a/app/Repositories/LinkType/LinkTypeRepository.php b/app/Repositories/LinkType/LinkTypeRepository.php index cba90c91bb..b67c1c5e02 100644 --- a/app/Repositories/LinkType/LinkTypeRepository.php +++ b/app/Repositories/LinkType/LinkTypeRepository.php @@ -34,7 +34,7 @@ use Log; /** * Class LinkTypeRepository. * - * @SuppressWarnings(PHPMD.TooManyPublicMethods) + * */ class LinkTypeRepository implements LinkTypeRepositoryInterface { @@ -252,7 +252,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface * @param TransactionJournal $outward * * @return TransactionJournalLink|null - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function storeLink(array $information, TransactionJournal $inward, TransactionJournal $outward): ?TransactionJournalLink { @@ -347,7 +347,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface * @param TransactionJournalLink $link * @param string $text * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * * @throws \Exception */ private function setNoteText(TransactionJournalLink $link, string $text): void diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php index fd80bca177..bc1fa1eb8d 100644 --- a/app/Repositories/PiggyBank/PiggyBankRepository.php +++ b/app/Repositories/PiggyBank/PiggyBankRepository.php @@ -37,8 +37,8 @@ use Log; /** * Class PiggyBankRepository. * - * @SuppressWarnings(PHPMD.TooManyPublicMethods) - * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + * + * */ class PiggyBankRepository implements PiggyBankRepositoryInterface { @@ -293,7 +293,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface * @param TransactionJournal $journal * * @return string - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function getExactAmount(PiggyBank $piggyBank, PiggyBankRepetition $repetition, TransactionJournal $journal): string { @@ -406,7 +406,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface * @param PiggyBank $piggyBank * * @return string - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function getSuggestedMonthlyAmount(PiggyBank $piggyBank): string { diff --git a/app/Repositories/Recurring/RecurringRepository.php b/app/Repositories/Recurring/RecurringRepository.php index 62c75bab04..ea85e436a3 100644 --- a/app/Repositories/Recurring/RecurringRepository.php +++ b/app/Repositories/Recurring/RecurringRepository.php @@ -234,9 +234,8 @@ class RecurringRepository implements RecurringRepositoryInterface * @param Carbon $start * @param Carbon $end * - * * @return array - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function getOccurrencesInRange(RecurrenceRepetition $repetition, Carbon $start, Carbon $end): array { @@ -366,7 +365,7 @@ class RecurringRepository implements RecurringRepositoryInterface * @param int $count * * @return array - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function getXOccurrences(RecurrenceRepetition $repetition, Carbon $date, int $count): array { @@ -400,7 +399,7 @@ class RecurringRepository implements RecurringRepositoryInterface * @param RecurrenceRepetition $repetition * * @return string - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function repetitionDescription(RecurrenceRepetition $repetition): string { diff --git a/app/Repositories/Rule/RuleRepository.php b/app/Repositories/Rule/RuleRepository.php index f86f221f30..e9a1359fd0 100644 --- a/app/Repositories/Rule/RuleRepository.php +++ b/app/Repositories/Rule/RuleRepository.php @@ -34,7 +34,7 @@ use Log; /** * Class RuleRepository. * - * @SuppressWarnings(PHPMD.TooManyPublicMethods) + * */ class RuleRepository implements RuleRepositoryInterface { diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.php index 208710f825..7ebe7ab8f1 100644 --- a/app/Repositories/Tag/TagRepository.php +++ b/app/Repositories/Tag/TagRepository.php @@ -36,7 +36,7 @@ use Log; /** * Class TagRepository. * - * @SuppressWarnings(PHPMD.TooManyPublicMethods) + * */ class TagRepository implements TagRepositoryInterface { @@ -272,7 +272,7 @@ class TagRepository implements TagRepositoryInterface * @param Carbon|null $end * * @return array - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function sumsOfTag(Tag $tag, ?Carbon $start, ?Carbon $end): array { @@ -410,7 +410,7 @@ class TagRepository implements TagRepositoryInterface * @param Collection $tags * * @return string - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ private function getMinAmount(Collection $tags): string { diff --git a/app/Repositories/User/UserRepository.php b/app/Repositories/User/UserRepository.php index 4ca7f388f3..a14ff743f3 100644 --- a/app/Repositories/User/UserRepository.php +++ b/app/Repositories/User/UserRepository.php @@ -32,7 +32,7 @@ use Log; /** * Class UserRepository. * - * @SuppressWarnings(PHPMD.TooManyPublicMethods) + * */ class UserRepository implements UserRepositoryInterface { diff --git a/app/Rules/BelongsUser.php b/app/Rules/BelongsUser.php index c9497d45dc..9faa949ffd 100644 --- a/app/Rules/BelongsUser.php +++ b/app/Rules/BelongsUser.php @@ -69,8 +69,8 @@ class BelongsUser implements Rule * @return bool * @throws FireflyException * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * + * */ public function passes($attribute, $value): bool { @@ -110,7 +110,7 @@ class BelongsUser implements Rule * * @return int * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ protected function countField(string $class, string $field, string $value): int { diff --git a/app/Rules/IsAssetAccountId.php b/app/Rules/IsAssetAccountId.php index 84c6b72bec..292035144a 100644 --- a/app/Rules/IsAssetAccountId.php +++ b/app/Rules/IsAssetAccountId.php @@ -50,8 +50,6 @@ class IsAssetAccountId implements Rule * @param mixed $value * * @return bool - * - * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function passes($attribute, $value): bool { diff --git a/app/Rules/IsValidAttachmentModel.php b/app/Rules/IsValidAttachmentModel.php index 33ff7c0d27..132c3fae26 100644 --- a/app/Rules/IsValidAttachmentModel.php +++ b/app/Rules/IsValidAttachmentModel.php @@ -74,8 +74,6 @@ class IsValidAttachmentModel implements Rule * @param mixed $value * * @return bool - * - * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function passes($attribute, $value): bool { diff --git a/app/Rules/UniqueIban.php b/app/Rules/UniqueIban.php index c3d18d4da2..e7ed37c61c 100644 --- a/app/Rules/UniqueIban.php +++ b/app/Rules/UniqueIban.php @@ -72,8 +72,8 @@ class UniqueIban implements Rule * @param mixed $value * * @return bool - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * + * */ public function passes($attribute, $value): bool { @@ -127,7 +127,7 @@ class UniqueIban implements Rule /** * @return array - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ private function getMaxOccurrences(): array { diff --git a/app/Rules/ValidJournals.php b/app/Rules/ValidJournals.php index a9b449b9f1..719d112a8d 100644 --- a/app/Rules/ValidJournals.php +++ b/app/Rules/ValidJournals.php @@ -52,7 +52,7 @@ class ValidJournals implements Rule * @param mixed $value * * @return bool - * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * */ public function passes($attribute, $value): bool { diff --git a/app/Rules/ValidRecurrenceRepetitionType.php b/app/Rules/ValidRecurrenceRepetitionType.php index c984e6b0ee..858bef0b47 100644 --- a/app/Rules/ValidRecurrenceRepetitionType.php +++ b/app/Rules/ValidRecurrenceRepetitionType.php @@ -49,8 +49,8 @@ class ValidRecurrenceRepetitionType implements Rule * @param mixed $value * * @return bool - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * + * */ public function passes($attribute, $value): bool { diff --git a/app/Rules/ValidRecurrenceRepetitionValue.php b/app/Rules/ValidRecurrenceRepetitionValue.php index 620e317e7f..bd0d59dfab 100644 --- a/app/Rules/ValidRecurrenceRepetitionValue.php +++ b/app/Rules/ValidRecurrenceRepetitionValue.php @@ -53,8 +53,8 @@ class ValidRecurrenceRepetitionValue implements Rule * @param mixed $value * * @return bool - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * + * */ public function passes($attribute, $value): bool { @@ -104,7 +104,7 @@ class ValidRecurrenceRepetitionValue implements Rule * * @return bool * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ private function validateNdom(string $value): bool { diff --git a/app/Services/Bunq/ApiContext.php b/app/Services/Bunq/ApiContext.php index a2950315d0..37b1c9f77c 100644 --- a/app/Services/Bunq/ApiContext.php +++ b/app/Services/Bunq/ApiContext.php @@ -47,9 +47,9 @@ class ApiContext * @param array $permittedIps * @param string|null $proxyUrl * - * @throws FireflyException * @return BunqApiContext|FakeApiContext - * @SuppressWarnings(PHPMD.ExcessiveParameterList) + * + *@throws FireflyException */ public function create(BunqEnumApiEnvironmentType $environmentType, string $apiKey, string $description, array $permittedIps, string $proxyUrl = null ) { diff --git a/app/Services/Internal/Destroy/RecurrenceDestroyService.php b/app/Services/Internal/Destroy/RecurrenceDestroyService.php index ebd7fd0a6c..b7fc3d8233 100644 --- a/app/Services/Internal/Destroy/RecurrenceDestroyService.php +++ b/app/Services/Internal/Destroy/RecurrenceDestroyService.php @@ -48,7 +48,7 @@ class RecurrenceDestroyService * Delete recurrence. * * @param Recurrence $recurrence - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function destroy(Recurrence $recurrence): void { diff --git a/app/Services/Internal/Support/AccountServiceTrait.php b/app/Services/Internal/Support/AccountServiceTrait.php index 5c759ad55b..d7fe590f87 100644 --- a/app/Services/Internal/Support/AccountServiceTrait.php +++ b/app/Services/Internal/Support/AccountServiceTrait.php @@ -86,7 +86,7 @@ trait AccountServiceTrait * * @param Account $account * @param array $data - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function updateMetaData(Account $account, array $data): void { diff --git a/app/Services/Internal/Support/JournalServiceTrait.php b/app/Services/Internal/Support/JournalServiceTrait.php index a4838d9a15..1e15c4634f 100644 --- a/app/Services/Internal/Support/JournalServiceTrait.php +++ b/app/Services/Internal/Support/JournalServiceTrait.php @@ -263,7 +263,7 @@ trait JournalServiceTrait * * @param TransactionJournal $journal * @param array $tags - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * * * @codeCoverageIgnore */ diff --git a/app/Services/Spectre/Object/Holder.php b/app/Services/Spectre/Object/Holder.php index 791abb5b7f..87389e714f 100644 --- a/app/Services/Spectre/Object/Holder.php +++ b/app/Services/Spectre/Object/Holder.php @@ -34,7 +34,7 @@ class Holder extends SpectreObject * Holder constructor. * * @param array $data - * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * */ public function __construct(array $data) { diff --git a/app/Services/Spectre/Object/Transaction.php b/app/Services/Spectre/Object/Transaction.php index 974bf01cc6..82167913e5 100644 --- a/app/Services/Spectre/Object/Transaction.php +++ b/app/Services/Spectre/Object/Transaction.php @@ -175,7 +175,7 @@ class Transaction extends SpectreObject * Get opposing account data. * * @return array - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function getOpposingAccountData(): array { diff --git a/app/Services/Spectre/Request/ListAccountsRequest.php b/app/Services/Spectre/Request/ListAccountsRequest.php index 469ba5e313..9df314c2ae 100644 --- a/app/Services/Spectre/Request/ListAccountsRequest.php +++ b/app/Services/Spectre/Request/ListAccountsRequest.php @@ -41,7 +41,7 @@ class ListAccountsRequest extends SpectreRequest /** * @throws FireflyException - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function call(): void { diff --git a/app/Services/Spectre/Request/ListCustomersRequest.php b/app/Services/Spectre/Request/ListCustomersRequest.php index f17caed6a1..823cb55ff5 100644 --- a/app/Services/Spectre/Request/ListCustomersRequest.php +++ b/app/Services/Spectre/Request/ListCustomersRequest.php @@ -39,7 +39,7 @@ class ListCustomersRequest extends SpectreRequest /** * * @throws \FireflyIII\Exceptions\FireflyException - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function call(): void { diff --git a/app/Services/Spectre/Request/ListLoginsRequest.php b/app/Services/Spectre/Request/ListLoginsRequest.php index 8062ef1da6..70f3097eda 100644 --- a/app/Services/Spectre/Request/ListLoginsRequest.php +++ b/app/Services/Spectre/Request/ListLoginsRequest.php @@ -43,7 +43,7 @@ class ListLoginsRequest extends SpectreRequest /** * @throws FireflyException - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function call(): void { diff --git a/app/Services/Spectre/Request/ListTransactionsRequest.php b/app/Services/Spectre/Request/ListTransactionsRequest.php index 0fd161c751..cd9c5ad1e9 100644 --- a/app/Services/Spectre/Request/ListTransactionsRequest.php +++ b/app/Services/Spectre/Request/ListTransactionsRequest.php @@ -41,7 +41,7 @@ class ListTransactionsRequest extends SpectreRequest /** * @throws FireflyException - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function call(): void { diff --git a/app/Support/Amount.php b/app/Support/Amount.php index 6f3851df4d..6155581e39 100644 --- a/app/Support/Amount.php +++ b/app/Support/Amount.php @@ -50,8 +50,6 @@ class Amount * * @return string * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public static function getAmountJsConfig(bool $sepBySpace, int $signPosn, string $sign, bool $csPrecedes): string { @@ -122,7 +120,7 @@ class Amount * @param bool $coloured * * @return string - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function formatAnything(TransactionCurrency $format, string $amount, bool $coloured = null): string { @@ -164,7 +162,7 @@ class Amount * @param bool $coloured * * @return string - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * * @noinspection MoreThanThreeArgumentsInspection */ public function formatFlat(string $symbol, int $decimalPlaces, string $amount, bool $coloured = null): string diff --git a/app/Support/Binder/AccountList.php b/app/Support/Binder/AccountList.php index b7c05fb049..a64b0c43b4 100644 --- a/app/Support/Binder/AccountList.php +++ b/app/Support/Binder/AccountList.php @@ -40,7 +40,7 @@ class AccountList implements BinderInterface * * @return Collection * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public static function routeBinder(string $value, Route $route): Collection { diff --git a/app/Support/Binder/BudgetList.php b/app/Support/Binder/BudgetList.php index 09f6188e9a..d846318390 100644 --- a/app/Support/Binder/BudgetList.php +++ b/app/Support/Binder/BudgetList.php @@ -39,7 +39,7 @@ class BudgetList implements BinderInterface * * @return Collection * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public static function routeBinder(string $value, Route $route): Collection { diff --git a/app/Support/Binder/CategoryList.php b/app/Support/Binder/CategoryList.php index 46df804e55..c68d75823d 100644 --- a/app/Support/Binder/CategoryList.php +++ b/app/Support/Binder/CategoryList.php @@ -38,7 +38,7 @@ class CategoryList implements BinderInterface * * @return Collection * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public static function routeBinder(string $value, Route $route): Collection { diff --git a/app/Support/Binder/ImportProvider.php b/app/Support/Binder/ImportProvider.php index 5a01ff38dc..517d8c2095 100644 --- a/app/Support/Binder/ImportProvider.php +++ b/app/Support/Binder/ImportProvider.php @@ -27,7 +27,6 @@ use FireflyIII\Import\Prerequisites\PrerequisitesInterface; use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\User; use Illuminate\Routing\Route; -use Log; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** @@ -37,8 +36,8 @@ class ImportProvider implements BinderInterface { /** * @return array - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * + * */ public static function getProviders(): array { diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.php index a938b73572..5f5c49e4da 100644 --- a/app/Support/ExpandedForm.php +++ b/app/Support/ExpandedForm.php @@ -23,32 +23,17 @@ declare(strict_types=1); namespace FireflyIII\Support; use Amount as Amt; -use Carbon\Carbon; use Eloquent; -use FireflyIII\Exceptions\FireflyException; -use FireflyIII\Models\Account; -use FireflyIII\Models\AccountType; -use FireflyIII\Models\PiggyBank; -use FireflyIII\Models\RuleGroup; -use FireflyIII\Models\TransactionCurrency; -use FireflyIII\Repositories\Account\AccountRepositoryInterface; -use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; -use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface; -use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface; use FireflyIII\Support\Form\FormSupport; -use Form; use Illuminate\Support\Collection; -use Illuminate\Support\HtmlString; -use Illuminate\Support\MessageBag; use Log; -use RuntimeException; use Throwable; /** * Class ExpandedForm. * * @SuppressWarnings(PHPMD.TooManyMethods) - * @SuppressWarnings(PHPMD.TooManyPublicMethods) + * * @codeCoverageIgnore */ class ExpandedForm @@ -225,7 +210,7 @@ class ExpandedForm * @param \Illuminate\Support\Collection $set * * @return array - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function makeSelectListWithEmpty(Collection $set): array { diff --git a/app/Support/Form/CurrencyForm.php b/app/Support/Form/CurrencyForm.php index 8dac83b809..268cd04221 100644 --- a/app/Support/Form/CurrencyForm.php +++ b/app/Support/Form/CurrencyForm.php @@ -117,7 +117,7 @@ class CurrencyForm * @param array $options * * @return string - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ protected function allCurrencyField(string $name, string $view, $value = null, array $options = null): string { @@ -168,7 +168,7 @@ class CurrencyForm * @param array $options * * @return string - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ protected function currencyField(string $name, string $view, $value = null, array $options = null): string { diff --git a/app/Support/Http/Controllers/AugumentData.php b/app/Support/Http/Controllers/AugumentData.php index 8dd95ae9b0..996159535e 100644 --- a/app/Support/Http/Controllers/AugumentData.php +++ b/app/Support/Http/Controllers/AugumentData.php @@ -79,8 +79,8 @@ trait AugumentData * * @return array * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * + * */ protected function earnedByCategory(Collection $assets, Collection $opposing, Carbon $start, Carbon $end): array // get data + augment with info { @@ -352,7 +352,7 @@ trait AugumentData * * @return array * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ protected function getExpensesForBudget(Collection $limits, Budget $budget, Carbon $start, Carbon $end): array // get data + augment with info { @@ -397,7 +397,7 @@ trait AugumentData * * @return array * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * * */ protected function spentInPeriodMulti(Budget $budget, Collection $limits): array // get data + augment with info @@ -586,8 +586,8 @@ trait AugumentData * @param Carbon $end * * @return array - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * + * */ protected function spentByBudget(Collection $assets, Collection $opposing, Carbon $start, Carbon $end): array // get data + augment with info { @@ -647,8 +647,8 @@ trait AugumentData * * @return array * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * + * */ protected function spentByCategory(Collection $assets, Collection $opposing, Carbon $start, Carbon $end): array // get data + augment with info { diff --git a/app/Support/Http/Controllers/ChartGeneration.php b/app/Support/Http/Controllers/ChartGeneration.php index f6e66fee9c..759c46d142 100644 --- a/app/Support/Http/Controllers/ChartGeneration.php +++ b/app/Support/Http/Controllers/ChartGeneration.php @@ -47,8 +47,8 @@ trait ChartGeneration * * @return array * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * + * */ protected function accountBalanceChart(Collection $accounts, Carbon $start, Carbon $end): array // chart helper method. { diff --git a/app/Support/Http/Controllers/GetConfigurationData.php b/app/Support/Http/Controllers/GetConfigurationData.php index 94f7472d15..49c3d558d0 100644 --- a/app/Support/Http/Controllers/GetConfigurationData.php +++ b/app/Support/Http/Controllers/GetConfigurationData.php @@ -88,7 +88,7 @@ trait GetConfigurationData * Get config for date range. * * @return array - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * */ protected function getDateRangeConfig(): array // get configuration + get preferences. { @@ -177,7 +177,7 @@ trait GetConfigurationData * @param string $specificPage * * @return array - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ protected function getSpecificSteps(string $route, string $specificPage): array // get config values { diff --git a/app/Support/Http/Controllers/PeriodOverview.php b/app/Support/Http/Controllers/PeriodOverview.php index 1826e77f2e..ce045bf2ea 100644 --- a/app/Support/Http/Controllers/PeriodOverview.php +++ b/app/Support/Http/Controllers/PeriodOverview.php @@ -28,7 +28,6 @@ use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Models\Account; use FireflyIII\Models\Category; use FireflyIII\Models\Tag; -use FireflyIII\Models\Transaction; use FireflyIII\Models\TransactionType; use FireflyIII\Support\CacheProperties; use Illuminate\Support\Collection; @@ -281,7 +280,7 @@ trait PeriodOverview * @param Carbon $theDate * * @return array - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * */ protected function getNoCategoryPeriodOverview(Carbon $theDate): array { diff --git a/app/Support/Http/Controllers/RenderPartialViews.php b/app/Support/Http/Controllers/RenderPartialViews.php index 4605e9d8eb..5a2267d475 100644 --- a/app/Support/Http/Controllers/RenderPartialViews.php +++ b/app/Support/Http/Controllers/RenderPartialViews.php @@ -83,7 +83,7 @@ trait RenderPartialViews * * @return string * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ protected function balanceAmount(array $attributes): string // generate view for report. { diff --git a/app/Support/Http/Controllers/RequestInformation.php b/app/Support/Http/Controllers/RequestInformation.php index 0a17ca3db5..b30e530e63 100644 --- a/app/Support/Http/Controllers/RequestInformation.php +++ b/app/Support/Http/Controllers/RequestInformation.php @@ -65,8 +65,8 @@ trait RequestInformation * @param string $language * * @return string - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * + * */ protected function getHelpText(string $route, string $language): string // get from internet. { @@ -213,7 +213,7 @@ trait RequestInformation * @param Carbon $date * * @return bool - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ protected function notInSessionRange(Carbon $date): bool // Validate a preference { diff --git a/app/Support/Http/Controllers/TransactionCalculation.php b/app/Support/Http/Controllers/TransactionCalculation.php index d4642e7c2a..cb2dbe5456 100644 --- a/app/Support/Http/Controllers/TransactionCalculation.php +++ b/app/Support/Http/Controllers/TransactionCalculation.php @@ -109,8 +109,6 @@ trait TransactionCalculation * @param Carbon $end * * @return array - * - * */ protected function getExpensesInCategories(Collection $accounts, Collection $categories, Carbon $start, Carbon $end): array { @@ -175,8 +173,6 @@ trait TransactionCalculation * @param Carbon $end * * @return Collection - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ protected function getIncomeForTags(Collection $accounts, Collection $tags, Carbon $start, Carbon $end): array { diff --git a/app/Support/Import/JobConfiguration/File/ConfigureMappingHandler.php b/app/Support/Import/JobConfiguration/File/ConfigureMappingHandler.php index 9eedad889a..5e71b017ce 100644 --- a/app/Support/Import/JobConfiguration/File/ConfigureMappingHandler.php +++ b/app/Support/Import/JobConfiguration/File/ConfigureMappingHandler.php @@ -272,7 +272,7 @@ class ConfigureMappingHandler implements FileConfigurationInterface * * @return array * @throws FireflyException - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function getValuesForMapping(Reader $reader, array $config, array $columnConfig): array { diff --git a/app/Support/Import/JobConfiguration/File/ConfigureRolesHandler.php b/app/Support/Import/JobConfiguration/File/ConfigureRolesHandler.php index 3d5c9ca4c4..a5fa035884 100644 --- a/app/Support/Import/JobConfiguration/File/ConfigureRolesHandler.php +++ b/app/Support/Import/JobConfiguration/File/ConfigureRolesHandler.php @@ -58,7 +58,7 @@ class ConfigureRolesHandler implements FileConfigurationInterface * @param array $config * * @return MessageBag - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function configurationComplete(array $config): MessageBag { diff --git a/app/Support/Import/JobConfiguration/Spectre/ChooseAccountsHandler.php b/app/Support/Import/JobConfiguration/Spectre/ChooseAccountsHandler.php index 3e78eb8af1..2255c29329 100644 --- a/app/Support/Import/JobConfiguration/Spectre/ChooseAccountsHandler.php +++ b/app/Support/Import/JobConfiguration/Spectre/ChooseAccountsHandler.php @@ -110,7 +110,7 @@ class ChooseAccountsHandler implements SpectreJobConfigurationInterface * * @return array * @throws FireflyException - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function getNextData(): array { diff --git a/app/Support/Import/Placeholder/ImportTransaction.php b/app/Support/Import/Placeholder/ImportTransaction.php index 2ae4d3b3f6..3882ba8066 100644 --- a/app/Support/Import/Placeholder/ImportTransaction.php +++ b/app/Support/Import/Placeholder/ImportTransaction.php @@ -132,7 +132,7 @@ class ImportTransaction * @param ColumnValue $columnValue * * @throws FireflyException - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function addColumnValue(ColumnValue $columnValue): void { diff --git a/app/Support/Import/Routine/File/AssetAccountMapper.php b/app/Support/Import/Routine/File/AssetAccountMapper.php index fa4ead0ad3..1ed799959f 100644 --- a/app/Support/Import/Routine/File/AssetAccountMapper.php +++ b/app/Support/Import/Routine/File/AssetAccountMapper.php @@ -60,7 +60,7 @@ class AssetAccountMapper * @param array $data * * @return Account - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function map(?int $accountId, array $data): Account { diff --git a/app/Support/Import/Routine/File/MappedValuesValidator.php b/app/Support/Import/Routine/File/MappedValuesValidator.php index c0bc90c704..ba0833aa23 100644 --- a/app/Support/Import/Routine/File/MappedValuesValidator.php +++ b/app/Support/Import/Routine/File/MappedValuesValidator.php @@ -81,7 +81,7 @@ class MappedValuesValidator * * @return array * @throws FireflyException - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function validate(array $mappings): array { diff --git a/app/Support/Import/Routine/File/OpposingAccountMapper.php b/app/Support/Import/Routine/File/OpposingAccountMapper.php index 817f45d54b..c65c35c6f0 100644 --- a/app/Support/Import/Routine/File/OpposingAccountMapper.php +++ b/app/Support/Import/Routine/File/OpposingAccountMapper.php @@ -45,7 +45,7 @@ class OpposingAccountMapper * @param array $data * * @return Account - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function map(?int $accountId, string $amount, array $data): Account { diff --git a/app/Support/Import/Routine/Spectre/StageImportDataHandler.php b/app/Support/Import/Routine/Spectre/StageImportDataHandler.php index e0849fff7d..f63618b648 100644 --- a/app/Support/Import/Routine/Spectre/StageImportDataHandler.php +++ b/app/Support/Import/Routine/Spectre/StageImportDataHandler.php @@ -108,7 +108,7 @@ class StageImportDataHandler * @param LocalAccount $originalSource * * @return array - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ private function convertToArray(array $transactions, SpectreAccount $spectreAccount, LocalAccount $originalSource): array { diff --git a/app/Support/Navigation.php b/app/Support/Navigation.php index d99daae6f4..66209f668f 100644 --- a/app/Support/Navigation.php +++ b/app/Support/Navigation.php @@ -104,7 +104,7 @@ class Navigation * * @return array * @throws \FireflyIII\Exceptions\FireflyException - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ public function blockPeriods(\Carbon\Carbon $start, \Carbon\Carbon $end, string $range): array { diff --git a/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php b/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php index 3763769a0c..3662fa1622 100644 --- a/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php +++ b/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php @@ -70,7 +70,7 @@ trait CalculateRangeOccurrences * @param string $moment * * @return array - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ protected function getMonthlyInRange(Carbon $start, Carbon $end, int $skipMod, string $moment): array { @@ -150,7 +150,7 @@ trait CalculateRangeOccurrences * @param string $moment * * @return array - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ protected function getWeeklyInRange(Carbon $start, Carbon $end, int $skipMod, string $moment): array { @@ -194,7 +194,7 @@ trait CalculateRangeOccurrences * @param string $moment * * @return array - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ protected function getYearlyInRange(Carbon $start, Carbon $end, int $skipMod, string $moment): array { diff --git a/app/Support/Repositories/Recurring/FiltersWeekends.php b/app/Support/Repositories/Recurring/FiltersWeekends.php index 3c91f1947f..83d5be55cc 100644 --- a/app/Support/Repositories/Recurring/FiltersWeekends.php +++ b/app/Support/Repositories/Recurring/FiltersWeekends.php @@ -42,8 +42,8 @@ trait FiltersWeekends * @param array $dates * * @return array - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * + * */ protected function filterWeekends(RecurrenceRepetition $repetition, array $dates): array { diff --git a/app/Support/Search/Search.php b/app/Support/Search/Search.php index 7d62c2cff7..32ac58a3eb 100644 --- a/app/Support/Search/Search.php +++ b/app/Support/Search/Search.php @@ -181,7 +181,7 @@ class Search implements SearchInterface * @param GroupCollectorInterface $collector * * @return GroupCollectorInterface - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * */ private function applyModifiers(GroupCollectorInterface $collector): GroupCollectorInterface { diff --git a/app/TransactionRules/Actions/ClearNotes.php b/app/TransactionRules/Actions/ClearNotes.php index 7b83617770..b5f4f1a114 100644 --- a/app/TransactionRules/Actions/ClearNotes.php +++ b/app/TransactionRules/Actions/ClearNotes.php @@ -22,6 +22,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use Exception; use FireflyIII\Models\Note; use FireflyIII\Models\RuleAction; use FireflyIII\Models\TransactionJournal; @@ -47,7 +48,7 @@ class ClearNotes implements ActionInterface * @param TransactionJournal $journal * * @return bool - * @throws \Exception + * @throws Exception */ public function act(TransactionJournal $journal): bool { diff --git a/app/TransactionRules/Actions/ConvertToDeposit.php b/app/TransactionRules/Actions/ConvertToDeposit.php index f06ce92b41..a5b49ee83c 100644 --- a/app/TransactionRules/Actions/ConvertToDeposit.php +++ b/app/TransactionRules/Actions/ConvertToDeposit.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use FireflyIII\Exceptions\FireflyException; use FireflyIII\Factory\AccountFactory; use FireflyIII\Models\Account; use FireflyIII\Models\AccountType; @@ -57,7 +58,7 @@ class ConvertToDeposit implements ActionInterface * @param TransactionJournal $journal * * @return bool - * @throws \FireflyIII\Exceptions\FireflyException + * @throws FireflyException */ public function act(TransactionJournal $journal): bool { @@ -121,7 +122,7 @@ class ConvertToDeposit implements ActionInterface * @param TransactionJournal $journal * * @return bool - * @throws \FireflyIII\Exceptions\FireflyException + * @throws FireflyException */ private function convertTransfer(TransactionJournal $journal): bool { @@ -163,7 +164,7 @@ class ConvertToDeposit implements ActionInterface * @param TransactionJournal $journal * * @return bool - * @throws \FireflyIII\Exceptions\FireflyException + * @throws FireflyException */ private function convertWithdrawal(TransactionJournal $journal): bool { diff --git a/app/TransactionRules/Actions/ConvertToWithdrawal.php b/app/TransactionRules/Actions/ConvertToWithdrawal.php index 3729ec340a..63546b2d65 100644 --- a/app/TransactionRules/Actions/ConvertToWithdrawal.php +++ b/app/TransactionRules/Actions/ConvertToWithdrawal.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use FireflyIII\Exceptions\FireflyException; use FireflyIII\Factory\AccountFactory; use FireflyIII\Models\Account; use FireflyIII\Models\AccountType; @@ -58,7 +59,7 @@ class ConvertToWithdrawal implements ActionInterface * @param TransactionJournal $journal * * @return bool - * @throws \FireflyIII\Exceptions\FireflyException + * @throws FireflyException */ public function act(TransactionJournal $journal): bool { @@ -122,7 +123,7 @@ class ConvertToWithdrawal implements ActionInterface * @param TransactionJournal $journal * * @return bool - * @throws \FireflyIII\Exceptions\FireflyException + * @throws FireflyException */ private function convertDeposit(TransactionJournal $journal): bool { @@ -175,7 +176,7 @@ class ConvertToWithdrawal implements ActionInterface * @param TransactionJournal $journal * * @return bool - * @throws \FireflyIII\Exceptions\FireflyException + * @throws FireflyException */ private function convertTransfer(TransactionJournal $journal): bool { diff --git a/app/TransactionRules/Actions/RemoveTag.php b/app/TransactionRules/Actions/RemoveTag.php index 186bc3f739..301a34baad 100644 --- a/app/TransactionRules/Actions/RemoveTag.php +++ b/app/TransactionRules/Actions/RemoveTag.php @@ -23,7 +23,6 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; use FireflyIII\Models\RuleAction; -use FireflyIII\Models\Tag; use FireflyIII\Models\TransactionJournal; use Log; @@ -47,6 +46,7 @@ class RemoveTag implements ActionInterface /** * Remove tag X + * * @param TransactionJournal $journal * * @return bool @@ -55,7 +55,7 @@ class RemoveTag implements ActionInterface { // if tag does not exist, no need to continue: $name = $this->action->action_value; - $tag = $journal->user->tags()->where('tag', $name)->first(); + $tag = $journal->user->tags()->where('tag', $name)->first(); if (null !== $tag) { Log::debug(sprintf('RuleAction RemoveTag removed tag #%d ("%s") from journal #%d.', $tag->id, $tag->tag, $journal->id)); diff --git a/app/TransactionRules/Actions/SetBudget.php b/app/TransactionRules/Actions/SetBudget.php index 94e85cb570..2782647000 100644 --- a/app/TransactionRules/Actions/SetBudget.php +++ b/app/TransactionRules/Actions/SetBudget.php @@ -47,13 +47,14 @@ class SetBudget implements ActionInterface /** * Set budget. + * * @param TransactionJournal $journal * * @return bool */ public function act(TransactionJournal $journal): bool { - $search = $this->action->action_value; + $search = $this->action->action_value; $budget = $journal->user->budgets()->where('name', $search)->first(); if (null === $budget) { diff --git a/app/TransactionRules/Actions/SetCategory.php b/app/TransactionRules/Actions/SetCategory.php index 04b1c77d23..6daeef7fba 100644 --- a/app/TransactionRules/Actions/SetCategory.php +++ b/app/TransactionRules/Actions/SetCategory.php @@ -24,7 +24,6 @@ namespace FireflyIII\TransactionRules\Actions; use FireflyIII\Factory\CategoryFactory; use FireflyIII\Models\RuleAction; -use FireflyIII\Models\Transaction; use FireflyIII\Models\TransactionJournal; use Log; diff --git a/app/TransactionRules/Actions/SetDestinationAccount.php b/app/TransactionRules/Actions/SetDestinationAccount.php index 885fc6e2ff..fc9e03b411 100644 --- a/app/TransactionRules/Actions/SetDestinationAccount.php +++ b/app/TransactionRules/Actions/SetDestinationAccount.php @@ -133,9 +133,9 @@ class SetDestinationAccount implements ActionInterface if (null === $account) { $data = [ 'name' => $this->action->action_value, - 'account_type' => 'expense', + 'account_type' => 'expense', 'account_type_id' => null, - 'virtual_balance' => 0, + 'virtual_balance' => 0, 'active' => true, 'iban' => null, ]; diff --git a/app/TransactionRules/Actions/SetSourceAccount.php b/app/TransactionRules/Actions/SetSourceAccount.php index 9622f4ea4e..a131be87f3 100644 --- a/app/TransactionRules/Actions/SetSourceAccount.php +++ b/app/TransactionRules/Actions/SetSourceAccount.php @@ -137,9 +137,9 @@ class SetSourceAccount implements ActionInterface // create new revenue account with this name: $data = [ 'name' => $this->action->action_value, - 'account_type' => 'revenue', + 'account_type' => 'revenue', 'account_type_id' => null, - 'virtual_balance' => 0, + 'virtual_balance' => 0, 'active' => true, 'iban' => null, ]; diff --git a/app/TransactionRules/Engine/RuleEngine.php b/app/TransactionRules/Engine/RuleEngine.php index aa58ff754d..170c73c371 100644 --- a/app/TransactionRules/Engine/RuleEngine.php +++ b/app/TransactionRules/Engine/RuleEngine.php @@ -45,19 +45,18 @@ class RuleEngine public const TRIGGER_STORE = 1; /** @var int */ public const TRIGGER_UPDATE = 2; - + /** @var bool */ + private $allRules; + /** @var RuleGroupRepository */ + private $ruleGroupRepository; /** @var Collection */ private $ruleGroups; /** @var array */ private $rulesToApply; - /** @var bool */ - private $allRules; - /** @var User */ - private $user; - /** @var RuleGroupRepository */ - private $ruleGroupRepository; /** @var int */ private $triggerMode; + /** @var User */ + private $user; /** * RuleEngine constructor. @@ -72,94 +71,6 @@ class RuleEngine $this->triggerMode = self::TRIGGER_STORE; } - /** - * @param int $triggerMode - */ - public function setTriggerMode(int $triggerMode): void - { - $this->triggerMode = $triggerMode; - } - - /** - * @param bool $allRules - */ - public function setAllRules(bool $allRules): void - { - Log::debug('RuleEngine will apply ALL rules.'); - $this->allRules = $allRules; - } - - - /** - * @param array $rulesToApply - */ - public function setRulesToApply(array $rulesToApply): void - { - Log::debug('RuleEngine will try rules', $rulesToApply); - $this->rulesToApply = $rulesToApply; - } - - /** - * @param User $user - */ - public function setUser(User $user): void - { - $this->user = $user; - $this->ruleGroupRepository->setUser($user); - $this->ruleGroups = $this->ruleGroupRepository->getActiveGroups(); - } - - /** - * @param TransactionJournal $transactionJournal - */ - public function processTransactionJournal(TransactionJournal $transactionJournal): void - { - Log::debug(sprintf('Will process transaction journal #%d ("%s")', $transactionJournal->id, $transactionJournal->description)); - /** @var RuleGroup $group */ - foreach ($this->ruleGroups as $group) { - Log::debug(sprintf('Now at rule group #%d', $group->id)); - $groupTriggered = false; - /** @var Rule $rule */ - foreach ($group->rules as $rule) { - Log::debug(sprintf('Now at rule #%d from rule group #%d', $rule->id, $group->id)); - $ruleTriggered = false; - // if in rule selection, or group in selection or all rules, it's included. - if ($this->includeRule($rule)) { - Log::debug(sprintf('Rule #%d is included.', $rule->id)); - /** @var Processor $processor */ - $processor = app(Processor::class); - $ruleTriggered = false; - try { - $processor->make($rule, true); - $ruleTriggered = $processor->handleTransactionJournal($transactionJournal); - } catch (FireflyException $e) { - Log::error($e->getMessage()); - } - - if ($ruleTriggered) { - Log::debug('The rule was triggered, so the group is as well!'); - $groupTriggered = true; - } - } - if (!$this->includeRule($rule)) { - Log::debug(sprintf('Rule #%d is not included.', $rule->id)); - } - - // if the rule is triggered and stop processing is true, cancel the entire group. - if ($ruleTriggered && $rule->stop_processing) { - Log::info(sprintf('Break out group #%d because rule #%d was triggered.', $group->id, $rule->id)); - break; - } - } - // if group is triggered and stop processing is true, cancel the whole thing. - if ($groupTriggered && $group->stop_processing) { - Log::info(sprintf('Break out ALL because group #%d was triggered.', $group->id)); - break; - } - } - Log::debug('Done processing this transaction journal.'); - } - /** * @param array $journal */ @@ -212,8 +123,96 @@ class RuleEngine Log::debug('Done processing this transaction journal.'); } + /** + * @param TransactionJournal $transactionJournal + */ + public function processTransactionJournal(TransactionJournal $transactionJournal): void + { + Log::debug(sprintf('Will process transaction journal #%d ("%s")', $transactionJournal->id, $transactionJournal->description)); + /** @var RuleGroup $group */ + foreach ($this->ruleGroups as $group) { + Log::debug(sprintf('Now at rule group #%d', $group->id)); + $groupTriggered = false; + /** @var Rule $rule */ + foreach ($group->rules as $rule) { + Log::debug(sprintf('Now at rule #%d from rule group #%d', $rule->id, $group->id)); + $ruleTriggered = false; + // if in rule selection, or group in selection or all rules, it's included. + if ($this->includeRule($rule)) { + Log::debug(sprintf('Rule #%d is included.', $rule->id)); + /** @var Processor $processor */ + $processor = app(Processor::class); + $ruleTriggered = false; + try { + $processor->make($rule, true); + $ruleTriggered = $processor->handleTransactionJournal($transactionJournal); + } catch (FireflyException $e) { + Log::error($e->getMessage()); + } + + if ($ruleTriggered) { + Log::debug('The rule was triggered, so the group is as well!'); + $groupTriggered = true; + } + } + if (!$this->includeRule($rule)) { + Log::debug(sprintf('Rule #%d is not included.', $rule->id)); + } + + // if the rule is triggered and stop processing is true, cancel the entire group. + if ($ruleTriggered && $rule->stop_processing) { + Log::info(sprintf('Break out group #%d because rule #%d was triggered.', $group->id, $rule->id)); + break; + } + } + // if group is triggered and stop processing is true, cancel the whole thing. + if ($groupTriggered && $group->stop_processing) { + Log::info(sprintf('Break out ALL because group #%d was triggered.', $group->id)); + break; + } + } + Log::debug('Done processing this transaction journal.'); + } + + /** + * @param bool $allRules + */ + public function setAllRules(bool $allRules): void + { + Log::debug('RuleEngine will apply ALL rules.'); + $this->allRules = $allRules; + } + + /** + * @param array $rulesToApply + */ + public function setRulesToApply(array $rulesToApply): void + { + Log::debug('RuleEngine will try rules', $rulesToApply); + $this->rulesToApply = $rulesToApply; + } + + /** + * @param int $triggerMode + */ + public function setTriggerMode(int $triggerMode): void + { + $this->triggerMode = $triggerMode; + } + + /** + * @param User $user + */ + public function setUser(User $user): void + { + $this->user = $user; + $this->ruleGroupRepository->setUser($user); + $this->ruleGroups = $this->ruleGroupRepository->getActiveGroups(); + } + /** * @param Rule $rule + * * @return bool */ private function includeRule(Rule $rule): bool @@ -224,8 +223,8 @@ class RuleEngine return false; } - $validTrigger = ('store-journal' === $trigger->trigger_value && self::TRIGGER_STORE === $this->triggerMode) || - ('update-journal' === $trigger->trigger_value && self::TRIGGER_UPDATE === $this->triggerMode); + $validTrigger = ('store-journal' === $trigger->trigger_value && self::TRIGGER_STORE === $this->triggerMode) + || ('update-journal' === $trigger->trigger_value && self::TRIGGER_UPDATE === $this->triggerMode); return $validTrigger && ($this->allRules || in_array($rule->id, $this->rulesToApply, true)); } diff --git a/app/TransactionRules/Factory/TriggerFactory.php b/app/TransactionRules/Factory/TriggerFactory.php index 4d5c10e69e..9af587d3c9 100644 --- a/app/TransactionRules/Factory/TriggerFactory.php +++ b/app/TransactionRules/Factory/TriggerFactory.php @@ -78,11 +78,11 @@ class TriggerFactory * @param string $triggerValue * @param bool $stopProcessing * - * @see TriggerFactory::getTrigger - * * @return AbstractTrigger * * @throws FireflyException + * @see TriggerFactory::getTrigger + * */ public static function makeTriggerFromStrings(string $triggerType, string $triggerValue, bool $stopProcessing): AbstractTrigger { diff --git a/app/TransactionRules/Processor.php b/app/TransactionRules/Processor.php index e57a655801..225de82a3d 100644 --- a/app/TransactionRules/Processor.php +++ b/app/TransactionRules/Processor.php @@ -22,6 +22,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules; +use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\Rule; use FireflyIII\Models\RuleAction; use FireflyIII\Models\RuleTrigger; @@ -62,16 +63,71 @@ class Processor $this->actions = new Collection; } + /** + * Return found triggers + * + * @return int + */ + public function getFoundTriggers(): int + { + return $this->foundTriggers; + } + + /** + * Set found triggers + * + * @param int $foundTriggers + */ + public function setFoundTriggers(int $foundTriggers): void + { + $this->foundTriggers = $foundTriggers; + } + /** * Returns the rule * - * @return \FireflyIII\Models\Rule + * @return Rule */ public function getRule(): Rule { return $this->rule; } + /** + * This method will scan the given transaction journal and check if it matches the triggers found in the Processor + * If so, it will also attempt to run the given actions on the journal. It returns a bool indicating if the transaction journal + * matches all of the triggers (regardless of whether the Processor could act on it). + * + * @param array $journal + * + * @return bool + * @throws FireflyException + */ + public function handleJournalArray(array $journal): bool + { + + Log::debug(sprintf('handleJournalArray for journal #%d (group #%d)', $journal['transaction_journal_id'], $journal['transaction_group_id'])); + + // grab the actual journal. + $this->journal = TransactionJournal::find($journal['transaction_journal_id']); + // get all triggers: + $triggered = $this->triggered(); + if ($triggered) { + Log::debug('Rule is triggered, go to actions.'); + if ($this->actions->count() > 0) { + Log::debug('Has more than zero actions.'); + $this->actions(); + } + if (0 === $this->actions->count()) { + Log::info('Rule has no actions!'); + } + + return true; + } + + return false; + } + /** * This method will scan the given transaction journal and check if it matches the triggers found in the Processor * If so, it will also attempt to run the given actions on the journal. It returns a bool indicating if the transaction journal @@ -80,7 +136,7 @@ class Processor * @param Transaction $transaction * * @return bool - * @throws \FireflyIII\Exceptions\FireflyException + * @throws FireflyException */ public function handleTransaction(Transaction $transaction): bool { @@ -107,6 +163,140 @@ class Processor return false; } + /** + * This method will scan the given transaction journal and check if it matches the triggers found in the Processor + * If so, it will also attempt to run the given actions on the journal. It returns a bool indicating if the transaction journal + * matches all of the triggers (regardless of whether the Processor could act on it). + * + * @param TransactionJournal $journal + * + * @return bool + * @throws FireflyException + */ + public function handleTransactionJournal(TransactionJournal $journal): bool + { + Log::debug(sprintf('handleTransactionJournal for journal %d', $journal->id)); + $this->journal = $journal; + // get all triggers: + $triggered = $this->triggered(); + if ($triggered) { + if ($this->actions->count() > 0) { + $this->actions(); + } + + return true; + } + + return false; + } + + /** + * @return bool + */ + public function isStrict(): bool + { + return $this->strict; + } + + /** + * @param bool $strict + */ + public function setStrict(bool $strict): void + { + $this->strict = $strict; + } + + /** + * This method will make a Processor that will process each transaction journal using the triggers + * and actions found in the given Rule. + * + * @param Rule $rule + * @param bool $includeActions + * + * @throws FireflyException + */ + public function make(Rule $rule, bool $includeActions = null): void + { + $includeActions = $includeActions ?? true; + Log::debug(sprintf('Making new rule from Rule %d', $rule->id)); + Log::debug(sprintf('Rule is strict: %s', var_export($rule->strict, true))); + $this->rule = $rule; + $this->strict = $rule->strict; + $triggerSet = $rule->ruleTriggers()->orderBy('order', 'ASC')->get(); + /** @var RuleTrigger $trigger */ + foreach ($triggerSet as $trigger) { + Log::debug(sprintf('Push trigger %d', $trigger->id)); + $this->triggers->push(TriggerFactory::getTrigger($trigger)); + } + if (true === $includeActions) { + $this->actions = $rule->ruleActions()->orderBy('order', 'ASC')->get(); + } + } + + /** + * This method will make a Processor that will process each transaction journal using the given + * trigger (singular!). It can only report if the transaction journal was hit by the given trigger + * and will not be able to act on it using actions. + * + * @param string $triggerName + * @param string $triggerValue + * + * @throws FireflyException + */ + public function makeFromString(string $triggerName, string $triggerValue): void + { + Log::debug(sprintf('Processor::makeFromString("%s", "%s")', $triggerName, $triggerValue)); + $trigger = TriggerFactory::makeTriggerFromStrings($triggerName, $triggerValue, false); + $this->triggers->push($trigger); + } + + /** + * This method will make a Processor that will process each transaction journal using the given + * triggers. It can only report if the transaction journal was hit by the given triggers + * and will not be able to act on it using actions. + * + * The given triggers must be in the following format: + * + * [type => xx, value => yy, stop_processing => bool], [type => xx, value => yy, stop_processing => bool], + * + * @param array $triggers + * + * @throws FireflyException + */ + public function makeFromStringArray(array $triggers): void + { + foreach ($triggers as $entry) { + $entry['value'] = $entry['value'] ?? ''; + $trigger = TriggerFactory::makeTriggerFromStrings($entry['type'], $entry['value'], $entry['stop_processing']); + $this->triggers->push($trigger); + } + + } + + /** + * Run the actions + * + * @return void + * @throws FireflyException + */ + private function actions(): void + { + /** + * @var int + * @var RuleAction $action + */ + foreach ($this->actions as $action) { + /** @var ActionInterface $actionClass */ + $actionClass = ActionFactory::getAction($action); + Log::debug(sprintf('Fire action %s on journal #%d', get_class($actionClass), $this->journal->id)); + $actionClass->act($this->journal); + if ($action->stop_processing) { + Log::debug('Stop processing now and break.'); + break; + } + } + } + /** * Method to check whether the current transaction would be triggered * by the given list of triggers. @@ -147,193 +337,4 @@ class Processor return $result; } - - /** - * Return found triggers - * - * @return int - */ - public function getFoundTriggers(): int - { - return $this->foundTriggers; - } - - /** - * Set found triggers - * - * @param int $foundTriggers - */ - public function setFoundTriggers(int $foundTriggers): void - { - $this->foundTriggers = $foundTriggers; - } - - /** - * Run the actions - * - * @return void - * @throws \FireflyIII\Exceptions\FireflyException - */ - private function actions(): void - { - /** - * @var int - * @var RuleAction $action - */ - foreach ($this->actions as $action) { - /** @var ActionInterface $actionClass */ - $actionClass = ActionFactory::getAction($action); - Log::debug(sprintf('Fire action %s on journal #%d', get_class($actionClass), $this->journal->id)); - $actionClass->act($this->journal); - if ($action->stop_processing) { - Log::debug('Stop processing now and break.'); - break; - } - } - } - - /** - * This method will scan the given transaction journal and check if it matches the triggers found in the Processor - * If so, it will also attempt to run the given actions on the journal. It returns a bool indicating if the transaction journal - * matches all of the triggers (regardless of whether the Processor could act on it). - * - * @param array $journal - * - * @return bool - * @throws \FireflyIII\Exceptions\FireflyException - */ - public function handleJournalArray(array $journal): bool - { - - Log::debug(sprintf('handleJournalArray for journal #%d (group #%d)', $journal['transaction_journal_id'], $journal['transaction_group_id'])); - - // grab the actual journal. - $this->journal = TransactionJournal::find($journal['transaction_journal_id']); - // get all triggers: - $triggered = $this->triggered(); - if ($triggered) { - Log::debug('Rule is triggered, go to actions.'); - if ($this->actions->count() > 0) { - Log::debug('Has more than zero actions.'); - $this->actions(); - } - if (0 === $this->actions->count()) { - Log::info('Rule has no actions!'); - } - - return true; - } - - return false; - } - - /** - * This method will scan the given transaction journal and check if it matches the triggers found in the Processor - * If so, it will also attempt to run the given actions on the journal. It returns a bool indicating if the transaction journal - * matches all of the triggers (regardless of whether the Processor could act on it). - * - * @param TransactionJournal $journal - * - * @return bool - * @throws \FireflyIII\Exceptions\FireflyException - */ - public function handleTransactionJournal(TransactionJournal $journal): bool - { - Log::debug(sprintf('handleTransactionJournal for journal %d', $journal->id)); - $this->journal = $journal; - // get all triggers: - $triggered = $this->triggered(); - if ($triggered) { - if ($this->actions->count() > 0) { - $this->actions(); - } - - return true; - } - - return false; - } - - /** - * @return bool - */ - public function isStrict(): bool - { - return $this->strict; - } - - /** - * @param bool $strict - */ - public function setStrict(bool $strict): void - { - $this->strict = $strict; - } - - /** - * This method will make a Processor that will process each transaction journal using the triggers - * and actions found in the given Rule. - * - * @param Rule $rule - * @param bool $includeActions - * - * @throws \FireflyIII\Exceptions\FireflyException - */ - public function make(Rule $rule, bool $includeActions = null): void - { - $includeActions = $includeActions ?? true; - Log::debug(sprintf('Making new rule from Rule %d', $rule->id)); - Log::debug(sprintf('Rule is strict: %s', var_export($rule->strict, true))); - $this->rule = $rule; - $this->strict = $rule->strict; - $triggerSet = $rule->ruleTriggers()->orderBy('order', 'ASC')->get(); - /** @var RuleTrigger $trigger */ - foreach ($triggerSet as $trigger) { - Log::debug(sprintf('Push trigger %d', $trigger->id)); - $this->triggers->push(TriggerFactory::getTrigger($trigger)); - } - if (true === $includeActions) { - $this->actions = $rule->ruleActions()->orderBy('order', 'ASC')->get(); - } - } - - /** - * This method will make a Processor that will process each transaction journal using the given - * trigger (singular!). It can only report if the transaction journal was hit by the given trigger - * and will not be able to act on it using actions. - * - * @param string $triggerName - * @param string $triggerValue - * - * @throws \FireflyIII\Exceptions\FireflyException - */ - public function makeFromString(string $triggerName, string $triggerValue): void - { - Log::debug(sprintf('Processor::makeFromString("%s", "%s")', $triggerName, $triggerValue)); - $trigger = TriggerFactory::makeTriggerFromStrings($triggerName, $triggerValue, false); - $this->triggers->push($trigger); - } - - /** - * This method will make a Processor that will process each transaction journal using the given - * triggers. It can only report if the transaction journal was hit by the given triggers - * and will not be able to act on it using actions. - * - * The given triggers must be in the following format: - * - * [type => xx, value => yy, stop_processing => bool], [type => xx, value => yy, stop_processing => bool], - * - * @param array $triggers - * - * @throws \FireflyIII\Exceptions\FireflyException - */ - public function makeFromStringArray(array $triggers): void - { - foreach ($triggers as $entry) { - $entry['value'] = $entry['value'] ?? ''; - $trigger = TriggerFactory::makeTriggerFromStrings($entry['type'], $entry['value'], $entry['stop_processing']); - $this->triggers->push($trigger); - } - - } } diff --git a/app/TransactionRules/TransactionMatcher.php b/app/TransactionRules/TransactionMatcher.php index ce7c532bbc..34c45143d6 100644 --- a/app/TransactionRules/TransactionMatcher.php +++ b/app/TransactionRules/TransactionMatcher.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules; use Carbon\Carbon; +use FireflyIII\Exceptions\FireflyException; use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Models\Rule; use FireflyIII\Models\RuleTrigger; @@ -78,7 +79,7 @@ class TransactionMatcher * triggers onto each transaction journal until enough matches are found ($limit). * * @return array - * @throws \FireflyIII\Exceptions\FireflyException + * @throws FireflyException */ public function findTransactionsByRule(): array { @@ -108,7 +109,7 @@ class TransactionMatcher * triggers onto each transaction journal until enough matches are found ($limit). * * @return array - * @throws \FireflyIII\Exceptions\FireflyException + * @throws FireflyException */ public function findTransactionsByTriggers(): array { diff --git a/app/Transformers/BillTransformer.php b/app/Transformers/BillTransformer.php index 84a4a8fe67..6f469b8824 100644 --- a/app/Transformers/BillTransformer.php +++ b/app/Transformers/BillTransformer.php @@ -127,7 +127,7 @@ class BillTransformer extends AbstractTransformer * @param Bill $bill * @param Carbon $date * - * @return \Carbon\Carbon + * @return Carbon */ protected function nextDateMatch(Bill $bill, Carbon $date): Carbon { diff --git a/app/Transformers/CategoryTransformer.php b/app/Transformers/CategoryTransformer.php index 5f771b7aae..794fc4fc25 100644 --- a/app/Transformers/CategoryTransformer.php +++ b/app/Transformers/CategoryTransformer.php @@ -24,10 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Transformers; -use Carbon\Carbon; use FireflyIII\Models\Category; -use FireflyIII\Models\Transaction; -use FireflyIII\Models\TransactionCurrency; use FireflyIII\Repositories\Category\CategoryRepositoryInterface; use Illuminate\Support\Collection; use Log; diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php index 0da6a0117d..1f9206d5c1 100644 --- a/app/Validation/FireflyValidator.php +++ b/app/Validation/FireflyValidator.php @@ -46,8 +46,6 @@ use Illuminate\Validation\Validator; class FireflyValidator extends Validator { /** - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * * @param $attribute * @param $value * @@ -65,8 +63,6 @@ class FireflyValidator extends Validator } /** - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * * @param $attribute * @param $value * @param $parameters @@ -86,8 +82,6 @@ class FireflyValidator extends Validator } /** - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * * @param $attribute * @param $value * @@ -108,8 +102,6 @@ class FireflyValidator extends Validator } /** - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * * @param $attribute * @param $value * @@ -191,8 +183,6 @@ class FireflyValidator extends Validator * @param $attribute * @param $value * @param $parameters - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * * @return bool */ public function validateLess($attribute, $value, $parameters): bool @@ -207,8 +197,6 @@ class FireflyValidator extends Validator * @param $attribute * @param $value * @param $parameters - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * * @return bool */ public function validateMore($attribute, $value, $parameters): bool @@ -220,8 +208,6 @@ class FireflyValidator extends Validator } /** - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * * @param $attribute * @param $value * @param $parameters @@ -381,8 +367,6 @@ class FireflyValidator extends Validator } /** - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * * @param $attribute * @param $value * @param $parameters @@ -415,8 +399,6 @@ class FireflyValidator extends Validator } /** - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * * @param $attribute * @param $value * @param $parameters @@ -452,7 +434,7 @@ class FireflyValidator extends Validator } /** - * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * * Validate an object and its unicity. Checks for encryption / encrypted values as well. * * parameter 0: the table @@ -496,8 +478,6 @@ class FireflyValidator extends Validator } /** - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * * @param $attribute * @param $value * @param $parameters