From 13b78bdc20ca2809325d889423b153613a488b82 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 28 Apr 2018 06:23:13 +0200 Subject: [PATCH] Code cleanup --- app/Api/V1/Controllers/Controller.php | 11 +- .../V1/Controllers/TransactionController.php | 2 +- app/Api/V1/Requests/TransactionRequest.php | 21 ++- app/Console/Commands/CreateExport.php | 4 +- app/Console/Commands/DecryptAttachment.php | 1 - app/Console/Commands/Import.php | 1 - app/Console/Commands/UpgradeDatabase.php | 10 +- .../Commands/UpgradeFireflyInstructions.php | 4 +- app/Exceptions/Handler.php | 6 +- app/Export/Collector/AttachmentCollector.php | 10 +- app/Export/Collector/UploadCollector.php | 2 +- app/Export/Entry/Entry.php | 2 +- app/Export/ExpandedProcessor.php | 5 +- app/Factory/BudgetFactory.php | 4 +- app/Factory/CategoryFactory.php | 4 +- app/Factory/PiggyBankFactory.php | 4 +- app/Factory/TransactionCurrencyFactory.php | 4 +- .../Chart/Basic/ChartJsGenerator.php | 6 +- .../Report/Account/MonthReportGenerator.php | 1 - .../Report/Standard/MonthReportGenerator.php | 2 - .../Standard/MultiYearReportGenerator.php | 2 - .../Report/Standard/YearReportGenerator.php | 2 - app/Helpers/Attachments/AttachmentHelper.php | 12 +- app/Helpers/Chart/MetaPieChart.php | 2 +- app/Helpers/Collector/JournalCollector.php | 10 +- app/Helpers/Filter/InternalTransferFilter.php | 2 +- app/Helpers/Filter/OpposingAccountFilter.php | 2 +- app/Helpers/Help/Help.php | 4 +- .../Account/ReconcileController.php | 2 + app/Http/Controllers/AccountController.php | 2 +- .../Controllers/Admin/UpdateController.php | 1 - app/Http/Controllers/Admin/UserController.php | 2 +- app/Http/Controllers/AttachmentController.php | 2 +- .../Controllers/Auth/TwoFactorController.php | 2 +- app/Http/Controllers/BillController.php | 18 ++- app/Http/Controllers/BudgetController.php | 8 +- app/Http/Controllers/CategoryController.php | 20 +-- .../Controllers/Chart/AccountController.php | 2 +- .../Chart/BudgetReportController.php | 2 +- .../Chart/CategoryReportController.php | 2 +- .../Chart/ExpenseReportController.php | 2 +- .../Controllers/Chart/TagReportController.php | 2 +- app/Http/Controllers/Controller.php | 4 +- app/Http/Controllers/ExportController.php | 2 +- app/Http/Controllers/HelpController.php | 4 +- app/Http/Controllers/HomeController.php | 2 +- .../Import/ConfigurationController.php | 2 +- .../Controllers/Import/IndexController.php | 2 +- .../Controllers/Import/StatusController.php | 2 +- app/Http/Controllers/Json/BoxController.php | 2 +- .../Controllers/Json/FrontpageController.php | 5 +- app/Http/Controllers/Json/IntroController.php | 14 +- app/Http/Controllers/JsonController.php | 4 +- app/Http/Controllers/PiggyBankController.php | 2 +- .../Controllers/Popup/ReportController.php | 15 +- .../Controllers/PreferencesController.php | 2 +- .../Controllers/Report/AccountController.php | 2 +- .../Controllers/Report/BalanceController.php | 3 +- .../Controllers/Report/BudgetController.php | 6 +- .../Controllers/Report/CategoryController.php | 14 +- .../Controllers/Report/ExpenseController.php | 15 +- .../Report/OperationsController.php | 9 +- app/Http/Controllers/ReportController.php | 17 +-- app/Http/Controllers/RuleController.php | 11 +- app/Http/Controllers/SearchController.php | 3 +- app/Http/Controllers/TagController.php | 4 +- .../Transaction/MassController.php | 4 +- .../Transaction/SingleController.php | 4 +- .../Transaction/SplitController.php | 6 +- .../Controllers/TransactionController.php | 2 +- app/Http/Middleware/Authenticate.php | 3 +- app/Http/Middleware/Sandstorm.php | 10 +- app/Http/Requests/JournalLinkRequest.php | 2 +- .../Requests/ReconciliationStoreRequest.php | 2 +- app/Http/Requests/ReportFormRequest.php | 14 +- app/Import/Configuration/BunqConfigurator.php | 1 - app/Import/Configuration/FileConfigurator.php | 3 +- .../Configuration/SpectreConfigurator.php | 1 - app/Import/Converter/Amount.php | 6 +- app/Import/FileProcessor/CsvProcessor.php | 6 +- app/Import/Logging/CommandHandler.php | 4 +- app/Import/Mapper/AssetAccountIbans.php | 4 +- app/Import/Mapper/AssetAccounts.php | 2 +- app/Import/Mapper/OpposingAccountIbans.php | 4 +- app/Import/Mapper/OpposingAccounts.php | 2 +- app/Import/MapperPreProcess/TagsComma.php | 2 +- app/Import/MapperPreProcess/TagsSpace.php | 2 +- app/Import/Object/ImportAccount.php | 8 +- app/Import/Object/ImportBill.php | 8 +- app/Import/Object/ImportBudget.php | 8 +- app/Import/Object/ImportCategory.php | 8 +- app/Import/Object/ImportCurrency.php | 2 +- app/Import/Object/ImportJournal.php | 8 +- .../Prerequisites/FilePrerequisites.php | 1 - .../Prerequisites/SpectrePrerequisites.php | 2 - app/Import/Routine/BunqRoutine.php | 7 +- app/Import/Routine/SpectreRoutine.php | 4 +- app/Import/Specifics/AbnAmroDescription.php | 8 +- app/Import/Specifics/IngDescription.php | 4 +- app/Import/Specifics/PresidentsChoice.php | 2 +- app/Import/Specifics/RabobankDescription.php | 6 +- app/Import/Storage/ImportSupport.php | 15 +- ...ExecuteRuleGroupOnExistingTransactions.php | 1 - app/Models/Account.php | 20 ++- app/Models/AccountMeta.php | 3 +- app/Models/AccountType.php | 3 +- app/Models/Attachment.php | 11 +- app/Models/AvailableBudget.php | 6 +- app/Models/Bill.php | 3 +- app/Models/Budget.php | 12 +- app/Models/BudgetLimit.php | 3 +- app/Models/Category.php | 9 +- app/Models/ExportJob.php | 2 +- app/Models/ImportJob.php | 14 +- app/Models/PiggyBank.php | 12 +- app/Models/PiggyBankEvent.php | 6 +- app/Models/PiggyBankRepetition.php | 3 +- app/Models/Role.php | 3 +- app/Models/Rule.php | 12 +- app/Models/RuleAction.php | 3 +- app/Models/RuleGroup.php | 6 +- app/Models/RuleTrigger.php | 3 +- app/Models/Tag.php | 6 +- app/Models/Transaction.php | 17 ++- app/Models/TransactionCurrency.php | 3 +- app/Models/TransactionJournal.php | 39 +++-- app/Models/TransactionJournalLink.php | 2 +- app/Models/TransactionJournalMeta.php | 3 +- app/Models/TransactionType.php | 3 +- .../Account/AccountRepository.php | 4 - .../Account/FindAccountsTrait.php | 14 +- .../Attachment/AttachmentRepository.php | 7 +- app/Repositories/Bill/BillRepository.php | 33 ---- app/Repositories/Budget/BudgetRepository.php | 10 +- .../Category/CategoryRepository.php | 6 +- .../ExportJob/ExportJobRepository.php | 5 +- .../ImportJob/ImportJobRepository.php | 6 +- .../Journal/JournalRepository.php | 4 +- .../LinkType/LinkTypeRepository.php | 8 +- .../PiggyBank/PiggyBankRepository.php | 7 +- app/Repositories/Rule/RuleRepository.php | 4 +- .../RuleGroup/RuleGroupRepository.php | 2 +- app/Repositories/Tag/TagRepository.php | 9 +- app/Repositories/User/UserRepository.php | 4 +- app/Rules/BelongsUser.php | 4 +- app/Rules/ValidTransactions.php | 2 +- app/Services/Bunq/Object/Alias.php | 2 - app/Services/Bunq/Object/Amount.php | 1 - app/Services/Bunq/Object/DeviceServer.php | 1 + .../Bunq/Object/LabelMonetaryAccount.php | 1 + app/Services/Bunq/Object/LabelUser.php | 1 + .../Bunq/Object/MonetaryAccountProfile.php | 1 - .../Bunq/Object/MonetaryAccountSetting.php | 1 - app/Services/Bunq/Object/Payment.php | 1 + app/Services/Bunq/Object/UserLight.php | 3 +- app/Services/Bunq/Object/UserPerson.php | 2 +- app/Services/Bunq/Request/BunqRequest.php | 12 +- .../Request/DeleteDeviceSessionRequest.php | 1 - .../Bunq/Request/DeviceServerRequest.php | 2 - .../Bunq/Request/DeviceSessionRequest.php | 1 - .../Bunq/Request/ListDeviceServerRequest.php | 3 +- .../Request/ListMonetaryAccountRequest.php | 1 - .../Bunq/Request/ListPaymentRequest.php | 1 - app/Services/Bunq/Request/ListUserRequest.php | 1 - app/Services/Currency/FixerIOv2.php | 2 +- .../Destroy/AccountDestroyService.php | 2 - .../Destroy/JournalDestroyService.php | 1 - .../Internal/Support/AccountServiceTrait.php | 5 +- .../Internal/Support/BillServiceTrait.php | 2 +- .../Internal/Support/JournalServiceTrait.php | 6 +- .../Support/TransactionServiceTrait.php | 7 +- .../Internal/Update/AccountUpdateService.php | 2 +- .../Internal/Update/JournalUpdateService.php | 4 +- .../Spectre/Request/CreateTokenRequest.php | 1 - .../Spectre/Request/ListAccountsRequest.php | 3 +- .../Spectre/Request/ListCustomersRequest.php | 3 +- .../Request/ListTransactionsRequest.php | 3 +- .../Spectre/Request/NewCustomerRequest.php | 1 - .../Spectre/Request/SpectreRequest.php | 1 - app/Support/Binder/AccountList.php | 2 +- app/Support/Binder/BudgetList.php | 4 +- app/Support/Binder/CategoryList.php | 4 +- app/Support/Binder/JournalList.php | 2 +- app/Support/Binder/TagList.php | 4 +- app/Support/ChartColour.php | 2 +- app/Support/ExpandedForm.php | 143 ++++++++---------- .../Configuration/Bunq/HaveAccounts.php | 2 +- app/Support/Import/Configuration/File/Map.php | 10 +- .../Import/Configuration/File/Roles.php | 6 +- .../Configuration/File/UploadConfig.php | 2 +- .../Import/Information/BunqInformation.php | 7 +- app/Support/Navigation.php | 6 +- app/Support/Search/Modifier.php | 2 +- app/Support/Search/Search.php | 16 +- app/Support/Twig/Extension/Transaction.php | 7 +- .../Twig/Extension/TransactionJournal.php | 4 +- app/Support/Twig/General.php | 6 +- app/Support/Twig/Journal.php | 2 +- app/TransactionRules/Actions/AddTag.php | 12 +- app/TransactionRules/Actions/ClearNotes.php | 3 +- .../Factory/ActionFactory.php | 2 +- .../Factory/TriggerFactory.php | 4 +- app/TransactionRules/Processor.php | 4 +- app/TransactionRules/TransactionMatcher.php | 3 +- .../Triggers/DescriptionEnds.php | 4 +- .../Triggers/DescriptionStarts.php | 2 +- .../Triggers/FromAccountEnds.php | 4 +- .../Triggers/FromAccountStarts.php | 2 +- app/TransactionRules/Triggers/NotesAny.php | 2 +- app/TransactionRules/Triggers/NotesAre.php | 2 +- .../Triggers/NotesContain.php | 2 +- app/TransactionRules/Triggers/NotesEmpty.php | 2 +- app/TransactionRules/Triggers/NotesEnd.php | 4 +- app/TransactionRules/Triggers/NotesStart.php | 2 +- .../Triggers/ToAccountEnds.php | 4 +- .../Triggers/ToAccountStarts.php | 2 +- app/User.php | 52 ++++--- app/Validation/FireflyValidator.php | 15 +- 218 files changed, 621 insertions(+), 681 deletions(-) diff --git a/app/Api/V1/Controllers/Controller.php b/app/Api/V1/Controllers/Controller.php index e2bee3452b..ba49f812aa 100644 --- a/app/Api/V1/Controllers/Controller.php +++ b/app/Api/V1/Controllers/Controller.php @@ -48,18 +48,9 @@ class Controller extends BaseController /** * Controller constructor. * - * @throws FireflyException */ public function __construct() { - // is site a demo site? - $isDemoSite = FireflyConfig::get('is_demo_site', config('firefly.configuration.is_demo_site'))->data; - - // do not expose API on demo site: - if (true === $isDemoSite) { - //throw new FireflyException('The API is not available on the demo site.'); - } - // get global parameters $this->parameters = $this->getParameters(); } @@ -83,7 +74,7 @@ class Controller extends BaseController } } $return .= http_build_query($params); - if (strlen($return) === 1) { + if (\strlen($return) === 1) { return ''; } diff --git a/app/Api/V1/Controllers/TransactionController.php b/app/Api/V1/Controllers/TransactionController.php index 987536ee0b..99ea62de2a 100644 --- a/app/Api/V1/Controllers/TransactionController.php +++ b/app/Api/V1/Controllers/TransactionController.php @@ -111,7 +111,7 @@ class TransactionController extends Controller $collector->setAllAssetAccounts(); // remove internal transfer filter: - if (in_array(TransactionType::TRANSFER, $types)) { + if (\in_array(TransactionType::TRANSFER, $types)) { $collector->removeFilter(InternalTransferFilter::class); } diff --git a/app/Api/V1/Requests/TransactionRequest.php b/app/Api/V1/Requests/TransactionRequest.php index dfbf8d0619..2b7ce5c0f9 100644 --- a/app/Api/V1/Requests/TransactionRequest.php +++ b/app/Api/V1/Requests/TransactionRequest.php @@ -168,7 +168,6 @@ class TransactionRequest extends Request * @param Validator $validator * * @return void - * @throws \FireflyIII\Exceptions\FireflyException */ public function withValidator(Validator $validator): void { @@ -202,7 +201,7 @@ class TransactionRequest extends Request $accountId = (int)$accountId; $accountName = (string)$accountName; // both empty? hard exit. - if ($accountId < 1 && strlen($accountName) === 0) { + if ($accountId < 1 && \strlen($accountName) === 0) { $validator->errors()->add($idField, trans('validation.filled', ['attribute' => $idField])); return null; @@ -245,7 +244,7 @@ class TransactionRequest extends Request $data = $validator->getData(); $transactions = $data['transactions'] ?? []; // need at least one transaction - if (count($transactions) === 0) { + if (\count($transactions) === 0) { $validator->errors()->add('description', trans('validation.at_least_one_transaction')); } } @@ -263,13 +262,13 @@ class TransactionRequest extends Request $journalDescription = (string)($data['description'] ?? ''); $validDescriptions = 0; foreach ($transactions as $index => $transaction) { - if (strlen((string)($transaction['description'] ?? '')) > 0) { + if (\strlen((string)($transaction['description'] ?? '')) > 0) { $validDescriptions++; } } // no valid descriptions and empty journal description? error. - if ($validDescriptions === 0 && strlen($journalDescription) === 0) { + if ($validDescriptions === 0 && \strlen($journalDescription) === 0) { $validator->errors()->add('description', trans('validation.filled', ['attribute' => trans('validation.attributes.description')])); } @@ -288,7 +287,7 @@ class TransactionRequest extends Request foreach ($transactions as $index => $transaction) { $description = (string)($transaction['description'] ?? ''); // filled description is mandatory for split transactions. - if (count($transactions) > 1 && strlen($description) === 0) { + if (\count($transactions) > 1 && \strlen($description) === 0) { $validator->errors()->add( 'transactions.' . $index . '.description', trans('validation.filled', ['attribute' => trans('validation.attributes.transaction_description')]) @@ -355,7 +354,7 @@ class TransactionRequest extends Request $accountId = (int)$accountId; $accountName = (string)$accountName; // both empty? done! - if ($accountId < 1 && strlen($accountName) === 0) { + if ($accountId < 1 && \strlen($accountName) === 0) { return null; } if ($accountId !== 0) { @@ -457,7 +456,7 @@ class TransactionRequest extends Request protected function validateSplitAccounts(Validator $validator) { $data = $validator->getData(); - $count = isset($data['transactions']) ? count($data['transactions']) : 0; + $count = isset($data['transactions']) ? \count($data['transactions']) : 0; if ($count < 2) { return; } @@ -487,17 +486,17 @@ class TransactionRequest extends Request // switch on type: switch ($data['type']) { case 'withdrawal': - if (count($sources) > 1) { + if (\count($sources) > 1) { $validator->errors()->add('transactions.0.source_id', trans('validation.all_accounts_equal')); } break; case 'deposit': - if (count($destinations) > 1) { + if (\count($destinations) > 1) { $validator->errors()->add('transactions.0.destination_id', trans('validation.all_accounts_equal')); } break; case 'transfer': - if (count($sources) > 1 || count($destinations) > 1) { + if (\count($sources) > 1 || \count($destinations) > 1) { $validator->errors()->add('transactions.0.source_id', trans('validation.all_accounts_equal')); $validator->errors()->add('transactions.0.destination_id', trans('validation.all_accounts_equal')); } diff --git a/app/Console/Commands/CreateExport.php b/app/Console/Commands/CreateExport.php index 0406b5e572..658dce8505 100644 --- a/app/Console/Commands/CreateExport.php +++ b/app/Console/Commands/CreateExport.php @@ -89,9 +89,9 @@ class CreateExport extends Command $accountRepository->setUser($user); // first date - $firstJournal = $journalRepository->first(); + $firstJournal = $journalRepository->firstNull(); $first = new Carbon; - if (null !== $firstJournal->id) { + if (null !== $firstJournal) { $first = $firstJournal->date; } diff --git a/app/Console/Commands/DecryptAttachment.php b/app/Console/Commands/DecryptAttachment.php index 5792bad504..baf2414ba5 100644 --- a/app/Console/Commands/DecryptAttachment.php +++ b/app/Console/Commands/DecryptAttachment.php @@ -100,6 +100,5 @@ class DecryptAttachment extends Command } $this->info(sprintf('%d bytes written. Exiting now..', $result)); - return; } } diff --git a/app/Console/Commands/Import.php b/app/Console/Commands/Import.php index 6794a31430..9a12e5988f 100644 --- a/app/Console/Commands/Import.php +++ b/app/Console/Commands/Import.php @@ -93,7 +93,6 @@ class Import extends Command sprintf('The import has finished. %d transactions have been imported out of %d records.', $routine->getJournals()->count(), $routine->getLines()) ); - return; } /** diff --git a/app/Console/Commands/UpgradeDatabase.php b/app/Console/Commands/UpgradeDatabase.php index 9b5459523e..9c3adc2536 100644 --- a/app/Console/Commands/UpgradeDatabase.php +++ b/app/Console/Commands/UpgradeDatabase.php @@ -106,7 +106,7 @@ class UpgradeDatabase extends Command if ($ruleGroup === null) { $array = RuleGroup::get(['order'])->pluck('order')->toArray(); - $order = count($array) > 0 ? max($array) + 1 : 1; + $order = \count($array) > 0 ? max($array) + 1 : 1; $ruleGroup = RuleGroup::create( [ 'user_id' => $user->id, @@ -240,7 +240,6 @@ class UpgradeDatabase extends Command $this->updateJournalidentifiers((int)$journalId); } - return; } /** @@ -294,7 +293,6 @@ class UpgradeDatabase extends Command } ); - return; } /** @@ -352,7 +350,6 @@ class UpgradeDatabase extends Command } ); - return; } /** @@ -413,7 +410,7 @@ class UpgradeDatabase extends Command // move description: $description = (string)$att->description; - if (strlen($description) > 0) { + if (\strlen($description) > 0) { // find or create note: $note = $att->notes()->first(); if (null === $note) { @@ -484,7 +481,6 @@ class UpgradeDatabase extends Command $journal->save(); } - return; } /** @@ -530,7 +526,6 @@ class UpgradeDatabase extends Command ++$identifier; } - return; } /** @@ -663,7 +658,6 @@ class UpgradeDatabase extends Command $opposing->save(); } - return; } } diff --git a/app/Console/Commands/UpgradeFireflyInstructions.php b/app/Console/Commands/UpgradeFireflyInstructions.php index 7c7ff814d3..a79e62f05f 100644 --- a/app/Console/Commands/UpgradeFireflyInstructions.php +++ b/app/Console/Commands/UpgradeFireflyInstructions.php @@ -92,7 +92,7 @@ class UpgradeFireflyInstructions extends Command $text = ''; foreach (array_keys($config) as $compare) { // if string starts with: - $len = strlen($compare); + $len = \strlen($compare); if (substr($version, 0, $len) === $compare) { $text = $config[$compare]; } @@ -139,7 +139,7 @@ class UpgradeFireflyInstructions extends Command $text = ''; foreach (array_keys($config) as $compare) { // if string starts with: - $len = strlen($compare); + $len = \strlen($compare); if (substr($version, 0, $len) === $compare) { $text = $config[$compare]; } diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index dee948baa3..9bcf356980 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -85,7 +85,7 @@ class Handler extends ExceptionHandler return response()->json( [ 'message' => $exception->getMessage(), - 'exception' => get_class($exception), + 'exception' => \get_class($exception), 'line' => $exception->getLine(), 'file' => $exception->getFile(), 'trace' => $exception->getTrace(), @@ -93,7 +93,7 @@ class Handler extends ExceptionHandler ); } - return response()->json(['message' => 'Internal Firefly III Exception. See log files.', 'exception' => get_class($exception)], 500); + return response()->json(['message' => 'Internal Firefly III Exception. See log files.', 'exception' => \get_class($exception)], 500); } if ($exception instanceof FireflyException || $exception instanceof ErrorException) { @@ -131,7 +131,7 @@ class Handler extends ExceptionHandler $userData['email'] = auth()->user()->email; } $data = [ - 'class' => get_class($exception), + 'class' => \get_class($exception), 'errorMessage' => $exception->getMessage(), 'time' => date('r'), 'stackTrace' => $exception->getTraceAsString(), diff --git a/app/Export/Collector/AttachmentCollector.php b/app/Export/Collector/AttachmentCollector.php index 36adbfcb6b..5405855e3b 100644 --- a/app/Export/Collector/AttachmentCollector.php +++ b/app/Export/Collector/AttachmentCollector.php @@ -97,14 +97,16 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface $file = $attachment->fileName(); if ($this->uploadDisk->exists($file)) { try { - $decrypted = Crypt::decrypt($this->uploadDisk->get($file)); - $exportFile = $this->exportFileName($attachment); - $this->exportDisk->put($exportFile, $decrypted); - $this->getEntries()->push($exportFile); + $decrypted = Crypt::decrypt($this->uploadDisk->get($file)); } catch (DecryptException $e) { Log::error('Catchable error: could not decrypt attachment #' . $attachment->id . ' because: ' . $e->getMessage()); + + return false; } } + $exportFile = $this->exportFileName($attachment); + $this->exportDisk->put($exportFile, $decrypted); + $this->getEntries()->push($exportFile); return true; } diff --git a/app/Export/Collector/UploadCollector.php b/app/Export/Collector/UploadCollector.php index 9f4a932fec..fccc32814a 100644 --- a/app/Export/Collector/UploadCollector.php +++ b/app/Export/Collector/UploadCollector.php @@ -103,7 +103,7 @@ class UploadCollector extends BasicCollector implements CollectorInterface Log::error(sprintf('Could not decrypt old import file "%s". Skipped because: %s', $key, $e->getMessage())); } - if (strlen($content) > 0) { + if (\strlen($content) > 0) { // add to export disk. $date = $job->created_at->format('Y-m-d'); $file = sprintf('%s-Old %s import dated %s.%s', $this->job->key, strtoupper($job->file_type), $date, $job->file_type); diff --git a/app/Export/Entry/Entry.php b/app/Export/Entry/Entry.php index d6e4917999..a91b50e45f 100644 --- a/app/Export/Entry/Entry.php +++ b/app/Export/Entry/Entry.php @@ -199,7 +199,7 @@ final class Entry $entry->transaction_id = $transaction->id; $entry->date = $transaction->date->format('Ymd'); $entry->description = $transaction->description; - if (strlen((string)$transaction->transaction_description) > 0) { + if (\strlen((string)$transaction->transaction_description) > 0) { $entry->description = $transaction->transaction_description . '(' . $transaction->description . ')'; } $entry->currency_code = $transaction->transactionCurrency->code; diff --git a/app/Export/ExpandedProcessor.php b/app/Export/ExpandedProcessor.php index 3f8d71ae57..33db5e518b 100644 --- a/app/Export/ExpandedProcessor.php +++ b/app/Export/ExpandedProcessor.php @@ -39,6 +39,7 @@ use Illuminate\Support\Collection; use Log; use Storage; use ZipArchive; +use FireflyIII\Models\TransactionJournal; /** * Class ExpandedProcessor. @@ -310,13 +311,13 @@ class ExpandedProcessor implements ProcessorInterface private function getNotes(array $array): array { $array = array_unique($array); - $notes = Note::where('notes.noteable_type', 'FireflyIII\\Models\\TransactionJournal') + $notes = Note::where('notes.noteable_type', TransactionJournal::class) ->whereIn('notes.noteable_id', $array) ->get(['notes.*']); $return = []; /** @var Note $note */ foreach ($notes as $note) { - if (strlen(trim((string)$note->text)) > 0) { + if (\strlen(trim((string)$note->text)) > 0) { $id = (int)$note->noteable_id; $return[$id] = $note->text; } diff --git a/app/Factory/BudgetFactory.php b/app/Factory/BudgetFactory.php index 0549ca27a4..bd96712658 100644 --- a/app/Factory/BudgetFactory.php +++ b/app/Factory/BudgetFactory.php @@ -47,7 +47,7 @@ class BudgetFactory $budgetId = (int)$budgetId; $budgetName = (string)$budgetName; - if (strlen($budgetName) === 0 && $budgetId === 0) { + if (\strlen($budgetName) === 0 && $budgetId === 0) { return null; } @@ -60,7 +60,7 @@ class BudgetFactory } } - if (strlen($budgetName) > 0) { + if (\strlen($budgetName) > 0) { $budget = $this->findByName($budgetName); if (null !== $budget) { return $budget; diff --git a/app/Factory/CategoryFactory.php b/app/Factory/CategoryFactory.php index 85d42954ab..5bc20ec485 100644 --- a/app/Factory/CategoryFactory.php +++ b/app/Factory/CategoryFactory.php @@ -71,7 +71,7 @@ class CategoryFactory Log::debug(sprintf('Going to find category with ID %d and name "%s"', $categoryId, $categoryName)); - if (strlen($categoryName) === 0 && $categoryId === 0) { + if (\strlen($categoryName) === 0 && $categoryId === 0) { return null; } // first by ID: @@ -83,7 +83,7 @@ class CategoryFactory } } - if (strlen($categoryName) > 0) { + if (\strlen($categoryName) > 0) { $category = $this->findByName($categoryName); if (null !== $category) { return $category; diff --git a/app/Factory/PiggyBankFactory.php b/app/Factory/PiggyBankFactory.php index 795f1044be..1f8ecf617d 100644 --- a/app/Factory/PiggyBankFactory.php +++ b/app/Factory/PiggyBankFactory.php @@ -45,7 +45,7 @@ class PiggyBankFactory { $piggyBankId = (int)$piggyBankId; $piggyBankName = (string)$piggyBankName; - if (strlen($piggyBankName) === 0 && $piggyBankId === 0) { + if (\strlen($piggyBankName) === 0 && $piggyBankId === 0) { return null; } // first find by ID: @@ -58,7 +58,7 @@ class PiggyBankFactory } // then find by name: - if (strlen($piggyBankName) > 0) { + if (\strlen($piggyBankName) > 0) { /** @var PiggyBank $piggyBank */ $piggyBank = $this->findByName($piggyBankName); if (null !== $piggyBank) { diff --git a/app/Factory/TransactionCurrencyFactory.php b/app/Factory/TransactionCurrencyFactory.php index 623f441042..1c95a60e7f 100644 --- a/app/Factory/TransactionCurrencyFactory.php +++ b/app/Factory/TransactionCurrencyFactory.php @@ -68,7 +68,7 @@ class TransactionCurrencyFactory $currencyCode = (string)$currencyCode; $currencyId = (int)$currencyId; - if (strlen($currencyCode) === 0 && (int)$currencyId === 0) { + if (\strlen($currencyCode) === 0 && (int)$currencyId === 0) { return null; } @@ -80,7 +80,7 @@ class TransactionCurrencyFactory } } // then by code: - if (strlen($currencyCode) > 0) { + if (\strlen($currencyCode) > 0) { $currency = TransactionCurrency::whereCode($currencyCode)->first(); if (null !== $currency) { return $currency; diff --git a/app/Generator/Chart/Basic/ChartJsGenerator.php b/app/Generator/Chart/Basic/ChartJsGenerator.php index 4b81a7148d..da6252548f 100644 --- a/app/Generator/Chart/Basic/ChartJsGenerator.php +++ b/app/Generator/Chart/Basic/ChartJsGenerator.php @@ -66,10 +66,10 @@ class ChartJsGenerator implements GeneratorInterface { reset($data); $first = current($data); - $labels = is_array($first['entries']) ? array_keys($first['entries']) : []; + $labels = \is_array($first['entries']) ? array_keys($first['entries']) : []; $chartData = [ - 'count' => count($data), + 'count' => \count($data), 'labels' => $labels, // take ALL labels from the first set. 'datasets' => [], ]; @@ -119,7 +119,7 @@ class ChartJsGenerator implements GeneratorInterface // different sort when values are positive and when they're negative. asort($data); $next = next($data); - if (!is_bool($next) && 1 === bccomp($next, '0')) { + if (!\is_bool($next) && 1 === bccomp($next, '0')) { // next is positive, sort other way around. arsort($data); } diff --git a/app/Generator/Report/Account/MonthReportGenerator.php b/app/Generator/Report/Account/MonthReportGenerator.php index 3897e7b456..d3dc1e659d 100644 --- a/app/Generator/Report/Account/MonthReportGenerator.php +++ b/app/Generator/Report/Account/MonthReportGenerator.php @@ -42,7 +42,6 @@ class MonthReportGenerator implements ReportGeneratorInterface /** * @return string - * */ public function generate(): string { diff --git a/app/Generator/Report/Standard/MonthReportGenerator.php b/app/Generator/Report/Standard/MonthReportGenerator.php index 792eb4bd31..348efb6975 100644 --- a/app/Generator/Report/Standard/MonthReportGenerator.php +++ b/app/Generator/Report/Standard/MonthReportGenerator.php @@ -41,8 +41,6 @@ class MonthReportGenerator implements ReportGeneratorInterface /** * @return string - * - */ public function generate(): string { diff --git a/app/Generator/Report/Standard/MultiYearReportGenerator.php b/app/Generator/Report/Standard/MultiYearReportGenerator.php index 558c395339..d03465386e 100644 --- a/app/Generator/Report/Standard/MultiYearReportGenerator.php +++ b/app/Generator/Report/Standard/MultiYearReportGenerator.php @@ -40,8 +40,6 @@ class MultiYearReportGenerator implements ReportGeneratorInterface /** * @return string - * - */ public function generate(): string { diff --git a/app/Generator/Report/Standard/YearReportGenerator.php b/app/Generator/Report/Standard/YearReportGenerator.php index fc0e06d2f7..900758a1ca 100644 --- a/app/Generator/Report/Standard/YearReportGenerator.php +++ b/app/Generator/Report/Standard/YearReportGenerator.php @@ -40,8 +40,6 @@ class YearReportGenerator implements ReportGeneratorInterface /** * @return string - * - */ public function generate(): string { diff --git a/app/Helpers/Attachments/AttachmentHelper.php b/app/Helpers/Attachments/AttachmentHelper.php index d4e0aa5878..b4da01386b 100644 --- a/app/Helpers/Attachments/AttachmentHelper.php +++ b/app/Helpers/Attachments/AttachmentHelper.php @@ -108,8 +108,8 @@ class AttachmentHelper implements AttachmentHelperInterface */ public function saveAttachmentsForModel(Model $model, ?array $files): bool { - Log::debug(sprintf('Now in saveAttachmentsForModel for model %s', get_class($model))); - if (is_array($files)) { + Log::debug(sprintf('Now in saveAttachmentsForModel for model %s', \get_class($model))); + if (\is_array($files)) { Log::debug('$files is an array.'); /** @var UploadedFile $entry */ foreach ($files as $entry) { @@ -136,7 +136,7 @@ class AttachmentHelper implements AttachmentHelperInterface { $md5 = md5_file($file->getRealPath()); $name = $file->getClientOriginalName(); - $class = get_class($model); + $class = \get_class($model); $count = $model->user->attachments()->where('md5', $md5)->where('attachable_id', $model->id)->where('attachable_type', $class)->count(); if ($count > 0) { @@ -180,8 +180,8 @@ class AttachmentHelper implements AttachmentHelperInterface $fileObject->rewind(); $content = $fileObject->fread($file->getSize()); $encrypted = Crypt::encrypt($content); - Log::debug(sprintf('Full file length is %d and upload size is %d.', strlen($content), $file->getSize())); - Log::debug(sprintf('Encrypted content is %d', strlen($encrypted))); + Log::debug(sprintf('Full file length is %d and upload size is %d.', \strlen($content), $file->getSize())); + Log::debug(sprintf('Encrypted content is %d', \strlen($encrypted))); // store it: $this->uploadDisk->put($attachment->fileName(), $encrypted); @@ -210,7 +210,7 @@ class AttachmentHelper implements AttachmentHelperInterface Log::debug(sprintf('Name is %s, and mime is %s', $name, $mime)); Log::debug('Valid mimes are', $this->allowedMimes); - if (!in_array($mime, $this->allowedMimes)) { + if (!\in_array($mime, $this->allowedMimes)) { $msg = (string)trans('validation.file_invalid_mime', ['name' => $name, 'mime' => $mime]); $this->errors->add('attachments', $msg); Log::error($msg); diff --git a/app/Helpers/Chart/MetaPieChart.php b/app/Helpers/Chart/MetaPieChart.php index de7694ef12..fb60b3db80 100644 --- a/app/Helpers/Chart/MetaPieChart.php +++ b/app/Helpers/Chart/MetaPieChart.php @@ -298,7 +298,7 @@ class MetaPieChart implements MetaPieChartInterface */ protected function groupByFields(Collection $set, array $fields): array { - if (0 === count($fields) && $this->tags->count() > 0) { + if (0 === \count($fields) && $this->tags->count() > 0) { // do a special group on tags: return $this->groupByTag($set); // @codeCoverageIgnore } diff --git a/app/Helpers/Collector/JournalCollector.php b/app/Helpers/Collector/JournalCollector.php index 16f798adef..79e69f923c 100644 --- a/app/Helpers/Collector/JournalCollector.php +++ b/app/Helpers/Collector/JournalCollector.php @@ -136,7 +136,7 @@ class JournalCollector implements JournalCollectorInterface public function addFilter(string $filter): JournalCollectorInterface { $interfaces = class_implements($filter); - if (in_array(FilterInterface::class, $interfaces) && !in_array($filter, $this->filters)) { + if (\in_array(FilterInterface::class, $interfaces) && !\in_array($filter, $this->filters)) { Log::debug(sprintf('Enabled filter %s', $filter)); $this->filters[] = $filter; } @@ -444,7 +444,7 @@ class JournalCollector implements JournalCollectorInterface public function setBudgets(Collection $budgets): JournalCollectorInterface { $budgetIds = $budgets->pluck('id')->toArray(); - if (0 === count($budgetIds)) { + if (0 === \count($budgetIds)) { return $this; } $this->joinBudgetTables(); @@ -468,7 +468,7 @@ class JournalCollector implements JournalCollectorInterface public function setCategories(Collection $categories): JournalCollectorInterface { $categoryIds = $categories->pluck('id')->toArray(); - if (0 === count($categoryIds)) { + if (0 === \count($categoryIds)) { return $this; } $this->joinCategoryTables(); @@ -643,7 +643,7 @@ class JournalCollector implements JournalCollectorInterface */ public function setTypes(array $types): JournalCollectorInterface { - if (count($types) > 0) { + if (\count($types) > 0) { Log::debug('Set query collector types', $types); $this->query->whereIn('transaction_types.type', $types); } @@ -769,7 +769,7 @@ class JournalCollector implements JournalCollectorInterface SplitIndicatorFilter::class => new SplitIndicatorFilter, CountAttachmentsFilter::class => new CountAttachmentsFilter, ]; - Log::debug(sprintf('Will run %d filters on the set.', count($this->filters))); + Log::debug(sprintf('Will run %d filters on the set.', \count($this->filters))); foreach ($this->filters as $enabled) { if (isset($filters[$enabled])) { Log::debug(sprintf('Before filter %s: %d', $enabled, $set->count())); diff --git a/app/Helpers/Filter/InternalTransferFilter.php b/app/Helpers/Filter/InternalTransferFilter.php index e9dcaeb215..c36e5f1353 100644 --- a/app/Helpers/Filter/InternalTransferFilter.php +++ b/app/Helpers/Filter/InternalTransferFilter.php @@ -61,7 +61,7 @@ class InternalTransferFilter implements FilterInterface return $transaction; } // both id's in $parameters? - if (in_array($transaction->account_id, $this->accounts) && in_array($transaction->opposing_account_id, $this->accounts)) { + if (\in_array($transaction->account_id, $this->accounts) && \in_array($transaction->opposing_account_id, $this->accounts)) { Log::debug( sprintf( 'Transaction #%d has #%d and #%d in set, so removed', diff --git a/app/Helpers/Filter/OpposingAccountFilter.php b/app/Helpers/Filter/OpposingAccountFilter.php index 85f6cd0449..7868f67556 100644 --- a/app/Helpers/Filter/OpposingAccountFilter.php +++ b/app/Helpers/Filter/OpposingAccountFilter.php @@ -58,7 +58,7 @@ class OpposingAccountFilter implements FilterInterface function (Transaction $transaction) { $opposing = $transaction->opposing_account_id; // remove internal transfer - if (in_array($opposing, $this->accounts)) { + if (\in_array($opposing, $this->accounts)) { Log::debug(sprintf('Filtered #%d because its opposite is in accounts.', $transaction->id), $this->accounts); return null; diff --git a/app/Helpers/Help/Help.php b/app/Helpers/Help/Help.php index cf7711bf55..7c9358e4bb 100644 --- a/app/Helpers/Help/Help.php +++ b/app/Helpers/Help/Help.php @@ -80,7 +80,7 @@ class Help implements HelpInterface $content = trim($result->body); } - if (strlen($content) > 0) { + if (\strlen($content) > 0) { Log::debug('Content is longer than zero. Expect something.'); $converter = new CommonMarkConverter(); $content = $converter->convertToHtml($content); @@ -127,7 +127,7 @@ class Help implements HelpInterface public function putInCache(string $route, string $language, string $content) { $key = sprintf(self::CACHEKEY, $route, $language); - if (strlen($content) > 0) { + if (\strlen($content) > 0) { Log::debug(sprintf('Will store entry in cache: %s', $key)); Cache::put($key, $content, 10080); // a week. diff --git a/app/Http/Controllers/Account/ReconcileController.php b/app/Http/Controllers/Account/ReconcileController.php index 047de6bc14..d004c440aa 100644 --- a/app/Http/Controllers/Account/ReconcileController.php +++ b/app/Http/Controllers/Account/ReconcileController.php @@ -122,6 +122,7 @@ class ReconcileController extends Controller * @return \Illuminate\Http\JsonResponse * * @throws FireflyException + * @throws \Throwable */ public function overview(Request $request, Account $account, Carbon $start, Carbon $end) { @@ -339,6 +340,7 @@ class ReconcileController extends Controller * @return mixed * * @throws FireflyException + * @throws \Throwable */ public function transactions(Account $account, Carbon $start, Carbon $end) { diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index b46adfdf38..4c15c0406b 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -380,7 +380,7 @@ class AccountController extends Controller // update preferences if necessary: $frontPage = Preferences::get('frontPageAccounts', [])->data; - if (count($frontPage) > 0 && AccountType::ASSET === $account->accountType->type) { + if (AccountType::ASSET === $account->accountType->type && \count($frontPage) > 0) { // @codeCoverageIgnoreStart $frontPage[] = $account->id; Preferences::set('frontPageAccounts', $frontPage); diff --git a/app/Http/Controllers/Admin/UpdateController.php b/app/Http/Controllers/Admin/UpdateController.php index 9aadf140dc..8a6b0b5494 100644 --- a/app/Http/Controllers/Admin/UpdateController.php +++ b/app/Http/Controllers/Admin/UpdateController.php @@ -62,7 +62,6 @@ class UpdateController extends Controller * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View * @throws \Psr\Container\NotFoundExceptionInterface * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Illuminate\Container\EntryNotFoundException */ public function index() { diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index a1df8408c6..02be837ae9 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -174,7 +174,7 @@ class UserController extends Controller $data = $request->getUserData(); // update password - if (strlen($data['password']) > 0) { + if (\strlen($data['password']) > 0) { $repository->changePassword($user, $data['password']); } diff --git a/app/Http/Controllers/AttachmentController.php b/app/Http/Controllers/AttachmentController.php index df25aec1db..775df201fe 100644 --- a/app/Http/Controllers/AttachmentController.php +++ b/app/Http/Controllers/AttachmentController.php @@ -117,7 +117,7 @@ class AttachmentController extends Controller ->header('Expires', '0') ->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0') ->header('Pragma', 'public') - ->header('Content-Length', strlen($content)); + ->header('Content-Length', \strlen($content)); return $response; } diff --git a/app/Http/Controllers/Auth/TwoFactorController.php b/app/Http/Controllers/Auth/TwoFactorController.php index 2ce3ddf14b..1e1d6f6d94 100644 --- a/app/Http/Controllers/Auth/TwoFactorController.php +++ b/app/Http/Controllers/Auth/TwoFactorController.php @@ -59,7 +59,7 @@ class TwoFactorController extends Controller return redirect(route('index')); } - if (0 === strlen((string)$secret)) { + if (0 === \strlen((string)$secret)) { throw new FireflyException('Your two factor authentication secret is empty, which it cannot be at this point. Please check the log files.'); } $request->session()->flash('two-factor-secret', $secret); diff --git a/app/Http/Controllers/BillController.php b/app/Http/Controllers/BillController.php index 395cdd4738..2e0d35969b 100644 --- a/app/Http/Controllers/BillController.php +++ b/app/Http/Controllers/BillController.php @@ -75,7 +75,9 @@ class BillController extends Controller } /** - * @param Request $request + * @param Request $request + * + * @param CurrencyRepositoryInterface $repository * * @return View */ @@ -131,8 +133,9 @@ class BillController extends Controller } /** - * @param Request $request - * @param Bill $bill + * @param Request $request + * @param CurrencyRepositoryInterface $repository + * @param Bill $bill * * @return View */ @@ -293,9 +296,10 @@ class BillController extends Controller } /** - * @param BillFormRequest $request - * @param BillRepositoryInterface $repository + * @param BillFormRequest $request + * @param BillRepositoryInterface $repository * + * @param RuleGroupRepositoryInterface $ruleGroupRepository * @return \Illuminate\Http\RedirectResponse */ public function store(BillFormRequest $request, BillRepositoryInterface $repository, RuleGroupRepositoryInterface $ruleGroupRepository) @@ -315,7 +319,7 @@ class BillController extends Controller $this->attachments->saveAttachmentsForModel($bill, $files); // flash messages - if (count($this->attachments->getMessages()->get('attachments')) > 0) { + if (\count($this->attachments->getMessages()->get('attachments')) > 0) { $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore } @@ -364,7 +368,7 @@ class BillController extends Controller $this->attachments->saveAttachmentsForModel($bill, $files); // flash messages - if (count($this->attachments->getMessages()->get('attachments')) > 0) { + if (\count($this->attachments->getMessages()->get('attachments')) > 0) { $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore } diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php index f14ed31da5..8eef1f0a1e 100644 --- a/app/Http/Controllers/BudgetController.php +++ b/app/Http/Controllers/BudgetController.php @@ -417,13 +417,13 @@ class BudgetController extends Controller // prep for "all" view. if ('all' === $moment) { $subTitle = trans('firefly.all_journals_without_budget'); - $first = $repository->first(); - $start = $first->date ?? new Carbon; + $first = $repository->firstNull(); + $start = null === $first ? new Carbon : $first->date; $end = new Carbon; } // prep for "specific date" view. - if (strlen($moment) > 0 && 'all' !== $moment) { + if ('all' !== $moment && \strlen($moment) > 0) { $start = new Carbon($moment); $end = app('navigation')->endOfPeriod($start, $range); $subTitle = trans( @@ -434,7 +434,7 @@ class BudgetController extends Controller } // prep for current period - if (0 === strlen($moment)) { + if ('' === $moment) { $start = clone session('start', app('navigation')->startOfPeriod(new Carbon, $range)); $end = clone session('end', app('navigation')->endOfPeriod(new Carbon, $range)); $periods = $this->getPeriodOverview(); diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php index 0598240fd3..87af547c89 100644 --- a/app/Http/Controllers/CategoryController.php +++ b/app/Http/Controllers/CategoryController.php @@ -185,13 +185,13 @@ class CategoryController extends Controller // prep for "all" view. if ('all' === $moment) { $subTitle = trans('firefly.all_journals_without_category'); - $first = $this->journalRepos->first(); - $start = $first->date ?? new Carbon; + $first = $this->journalRepos->firstNull(); + $start = null === $first ? new Carbon : $first->date; $end = new Carbon; } // prep for "specific date" view. - if (strlen($moment) > 0 && 'all' !== $moment) { + if ('all' !== $moment && \strlen($moment) > 0) { $start = app('navigation')->startOfPeriod(new Carbon($moment), $range); $end = app('navigation')->endOfPeriod($start, $range); $subTitle = trans( @@ -202,7 +202,7 @@ class CategoryController extends Controller } // prep for current period - if (0 === strlen($moment)) { + if ('' === $moment) { $start = clone session('start', app('navigation')->startOfPeriod(new Carbon, $range)); $end = clone session('end', app('navigation')->endOfPeriod(new Carbon, $range)); $periods = $this->getNoCategoryPeriodOverview($start); @@ -255,7 +255,7 @@ class CategoryController extends Controller } // prep for "specific date" view. - if (strlen($moment) > 0 && 'all' !== $moment) { + if (\strlen($moment) > 0 && 'all' !== $moment) { $start = app('navigation')->startOfPeriod(new Carbon($moment), $range); $end = app('navigation')->endOfPeriod($start, $range); $subTitle = trans( @@ -268,7 +268,7 @@ class CategoryController extends Controller } // prep for current period - if (0 === strlen($moment)) { + if (0 === \strlen($moment)) { /** @var Carbon $start */ $start = clone session('start', app('navigation')->startOfPeriod(new Carbon, $range)); /** @var Carbon $end */ @@ -351,8 +351,8 @@ class CategoryController extends Controller private function getNoCategoryPeriodOverview(Carbon $theDate): Collection { $range = Preferences::get('viewRange', '1M')->data; - $first = $this->journalRepos->first(); - $start = $first->date ?? new Carbon; + $first = $this->journalRepos->firstNull(); + $start = null === $first ? new Carbon : $first->date; $end = $theDate ?? new Carbon; // properties for cache @@ -431,8 +431,8 @@ class CategoryController extends Controller private function getPeriodOverview(Category $category, Carbon $date): Collection { $range = Preferences::get('viewRange', '1M')->data; - $first = $this->journalRepos->first(); - $start = $first->date ?? new Carbon; + $first = $this->journalRepos->firstNull(); + $start = null === $first ? new Carbon : $first->date; $end = $date ?? new Carbon; $accounts = $this->accountRepos->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]); diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php index b365bc23a5..e0e18773b8 100644 --- a/app/Http/Controllers/Chart/AccountController.php +++ b/app/Http/Controllers/Chart/AccountController.php @@ -228,7 +228,7 @@ class AccountController extends Controller Log::debug('Default set is ', $defaultSet); $frontPage = Preferences::get('frontPageAccounts', $defaultSet); Log::debug('Frontpage preference set is ', $frontPage->data); - if (0 === count($frontPage->data)) { + if (0 === \count($frontPage->data)) { $frontPage->data = $defaultSet; Log::debug('frontpage set is empty!'); $frontPage->save(); diff --git a/app/Http/Controllers/Chart/BudgetReportController.php b/app/Http/Controllers/Chart/BudgetReportController.php index e4285a2ef9..6f433c0ad2 100644 --- a/app/Http/Controllers/Chart/BudgetReportController.php +++ b/app/Http/Controllers/Chart/BudgetReportController.php @@ -180,7 +180,7 @@ class BudgetReportController extends Controller $chartData[$budget->id]['entries'][$label] = bcmul($currentExpenses, '-1'); $chartData[$budget->id . '-sum']['entries'][$label] = bcmul($sumOfExpenses[$budget->id], '-1'); - if (count($budgetLimits) > 0) { + if (\count($budgetLimits) > 0) { $budgetLimitId = $budgetLimits->first()->id; $leftOfLimits[$budgetLimitId] = $leftOfLimits[$budgetLimitId] ?? (string)$budgetLimits->sum('amount'); $leftOfLimits[$budgetLimitId] = bcadd($leftOfLimits[$budgetLimitId], $currentExpenses); diff --git a/app/Http/Controllers/Chart/CategoryReportController.php b/app/Http/Controllers/Chart/CategoryReportController.php index a62db6c9c4..116fdce7d2 100644 --- a/app/Http/Controllers/Chart/CategoryReportController.php +++ b/app/Http/Controllers/Chart/CategoryReportController.php @@ -251,7 +251,7 @@ class CategoryReportController extends Controller $newSet[$key] = $chartData[$key]; } } - if (0 === count($newSet)) { + if (0 === \count($newSet)) { $newSet = $chartData; } $data = $this->generator->multiSet($newSet); diff --git a/app/Http/Controllers/Chart/ExpenseReportController.php b/app/Http/Controllers/Chart/ExpenseReportController.php index 031d5f113b..3848afe95f 100644 --- a/app/Http/Controllers/Chart/ExpenseReportController.php +++ b/app/Http/Controllers/Chart/ExpenseReportController.php @@ -173,7 +173,7 @@ class ExpenseReportController extends Controller $newSet[$key] = $chartData[$key]; } } - if (0 === count($newSet)) { + if (0 === \count($newSet)) { $newSet = $chartData; // @codeCoverageIgnore } $data = $this->generator->multiSet($newSet); diff --git a/app/Http/Controllers/Chart/TagReportController.php b/app/Http/Controllers/Chart/TagReportController.php index ceb4b52105..552aa239a1 100644 --- a/app/Http/Controllers/Chart/TagReportController.php +++ b/app/Http/Controllers/Chart/TagReportController.php @@ -245,7 +245,7 @@ class TagReportController extends Controller $newSet[$key] = $chartData[$key]; } } - if (0 === count($newSet)) { + if (0 === \count($newSet)) { $newSet = $chartData; // @codeCoverageIgnore } $data = $this->generator->multiSet($newSet); diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 2e206063ff..d343926732 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -92,7 +92,7 @@ class Controller extends BaseController $shownDemo = true; // either must be array and either must be > 0 - if ((is_array($intro) || is_array($specialIntro)) && (count($intro) > 0 || count($specialIntro) > 0)) { + if ((\is_array($intro) || \is_array($specialIntro)) && (\count($intro) > 0 || \count($specialIntro) > 0)) { $shownDemo = Preferences::get($key, false)->data; Log::debug(sprintf('Check if user has already seen intro with key "%s". Result is %d', $key, $shownDemo)); } @@ -157,7 +157,7 @@ class Controller extends BaseController /** @var Transaction $transaction */ foreach ($transactions as $transaction) { $account = $transaction->account; - if (in_array($account->accountType->type, $valid)) { + if (\in_array($account->accountType->type, $valid)) { return redirect(route('accounts.show', [$account->id])); } } diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php index 3ff7d4f982..2c19715d42 100644 --- a/app/Http/Controllers/ExportController.php +++ b/app/Http/Controllers/ExportController.php @@ -91,7 +91,7 @@ class ExportController extends Controller ->header('Expires', '0') ->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0') ->header('Pragma', 'public') - ->header('Content-Length', strlen($content)); + ->header('Content-Length', \strlen($content)); return $response; } diff --git a/app/Http/Controllers/HelpController.php b/app/Http/Controllers/HelpController.php index eb13a6a623..a4fcf0a520 100644 --- a/app/Http/Controllers/HelpController.php +++ b/app/Http/Controllers/HelpController.php @@ -93,7 +93,7 @@ class HelpController extends Controller $content = $this->help->getFromGithub($route, $language); // content will have 0 length when Github failed. Try en_US when it does: - if (0 === strlen($content)) { + if (0 === \strlen($content)) { $language = 'en_US'; // also check cache first: @@ -108,7 +108,7 @@ class HelpController extends Controller } // help still empty? - if (0 !== strlen($content)) { + if (0 !== \strlen($content)) { $this->help->putInCache($route, $language, $content); return $content; diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 55d0183346..ba32b7e7ba 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -211,7 +211,7 @@ class HomeController extends Controller /** @var Route $route */ foreach ($set as $route) { $name = $route->getName(); - if (null !== $name && in_array('GET', $route->methods()) && strlen($name) > 0) { + if (null !== $name && \in_array('GET', $route->methods()) && \strlen($name) > 0) { $found = false; foreach ($ignore as $string) { diff --git a/app/Http/Controllers/Import/ConfigurationController.php b/app/Http/Controllers/Import/ConfigurationController.php index 8450c26aab..7f6ee65b1c 100644 --- a/app/Http/Controllers/Import/ConfigurationController.php +++ b/app/Http/Controllers/Import/ConfigurationController.php @@ -114,7 +114,7 @@ class ConfigurationController extends Controller // get possible warning from configurator: $warning = $configurator->getWarningMessage(); - if (strlen($warning) > 0) { + if (\strlen($warning) > 0) { $request->session()->flash('warning', $warning); } diff --git a/app/Http/Controllers/Import/IndexController.php b/app/Http/Controllers/Import/IndexController.php index b79bf1ed8e..c340ef8f1e 100644 --- a/app/Http/Controllers/Import/IndexController.php +++ b/app/Http/Controllers/Import/IndexController.php @@ -115,7 +115,7 @@ class IndexController extends Controller ->header('Expires', '0') ->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0') ->header('Pragma', 'public') - ->header('Content-Length', strlen($result)); + ->header('Content-Length', \strlen($result)); return $response; } diff --git a/app/Http/Controllers/Import/StatusController.php b/app/Http/Controllers/Import/StatusController.php index 6c33e3695a..4c95ec77a3 100644 --- a/app/Http/Controllers/Import/StatusController.php +++ b/app/Http/Controllers/Import/StatusController.php @@ -59,7 +59,7 @@ class StatusController extends Controller public function index(ImportJob $job) { $statuses = ['configured', 'running', 'finished', 'error']; - if (!in_array($job->status, $statuses)) { + if (!\in_array($job->status, $statuses)) { return redirect(route('import.configure', [$job->key])); } $subTitle = trans('import.status_sub_title'); diff --git a/app/Http/Controllers/Json/BoxController.php b/app/Http/Controllers/Json/BoxController.php index 132ea0c829..27c857d97b 100644 --- a/app/Http/Controllers/Json/BoxController.php +++ b/app/Http/Controllers/Json/BoxController.php @@ -158,7 +158,7 @@ class BoxController extends Controller 'incomes' => $incomes, 'expenses' => $expenses, 'sums' => $sums, - 'size' => count($sums), + 'size' => \count($sums), ]; $cache->store($response); diff --git a/app/Http/Controllers/Json/FrontpageController.php b/app/Http/Controllers/Json/FrontpageController.php index 0051608c91..422d2b4e75 100644 --- a/app/Http/Controllers/Json/FrontpageController.php +++ b/app/Http/Controllers/Json/FrontpageController.php @@ -35,8 +35,7 @@ class FrontpageController extends Controller * @param PiggyBankRepositoryInterface $repository * * @return \Illuminate\Http\JsonResponse - * - + * @throws \Throwable */ public function piggyBanks(PiggyBankRepositoryInterface $repository) { @@ -61,7 +60,7 @@ class FrontpageController extends Controller } } $html = ''; - if (count($info) > 0) { + if (\count($info) > 0) { $html = view('json.piggy-banks', compact('info'))->render(); } diff --git a/app/Http/Controllers/Json/IntroController.php b/app/Http/Controllers/Json/IntroController.php index 6b1c6c1be1..be974afb74 100644 --- a/app/Http/Controllers/Json/IntroController.php +++ b/app/Http/Controllers/Json/IntroController.php @@ -43,7 +43,7 @@ class IntroController Log::debug(sprintf('getIntroSteps for route "%s" and page "%s"', $route, $specificPage)); $steps = $this->getBasicSteps($route); $specificSteps = $this->getSpecificSteps($route, $specificPage); - if (0 === count($specificSteps)) { + if (0 === \count($specificSteps)) { Log::debug(sprintf('No specific steps for route "%s" and page "%s"', $route, $specificPage)); return response()->json($steps); @@ -51,7 +51,7 @@ class IntroController if ($this->hasOutroStep($route)) { // @codeCoverageIgnoreStart // save last step: - $lastStep = $steps[count($steps) - 1]; + $lastStep = $steps[\count($steps) - 1]; // remove last step: array_pop($steps); // merge arrays and add last step again @@ -136,7 +136,7 @@ class IntroController $routeKey = str_replace('.', '_', $route); $elements = config(sprintf('intro.%s', $routeKey)); $steps = []; - if (is_array($elements) && count($elements) > 0) { + if (\is_array($elements) && \count($elements) > 0) { foreach ($elements as $key => $options) { $currentStep = $options; @@ -147,7 +147,7 @@ class IntroController $steps[] = $currentStep; } } - Log::debug(sprintf('Total basic steps for %s is %d', $routeKey, count($steps))); + Log::debug(sprintf('Total basic steps for %s is %d', $routeKey, \count($steps))); return $steps; } @@ -164,10 +164,10 @@ class IntroController $routeKey = ''; // user is on page with specific instructions: - if (strlen($specificPage) > 0) { + if (\strlen($specificPage) > 0) { $routeKey = str_replace('.', '_', $route); $elements = config(sprintf('intro.%s', $routeKey . '_' . $specificPage)); - if (is_array($elements) && count($elements) > 0) { + if (\is_array($elements) && \count($elements) > 0) { foreach ($elements as $key => $options) { $currentStep = $options; @@ -179,7 +179,7 @@ class IntroController } } } - Log::debug(sprintf('Total specific steps for route "%s" and page "%s" (routeKey is "%s") is %d', $route, $specificPage, $routeKey, count($steps))); + Log::debug(sprintf('Total specific steps for route "%s" and page "%s" (routeKey is "%s") is %d', $route, $specificPage, $routeKey, \count($steps))); return $steps; } diff --git a/app/Http/Controllers/JsonController.php b/app/Http/Controllers/JsonController.php index fddd772a25..2e5988d2c6 100644 --- a/app/Http/Controllers/JsonController.php +++ b/app/Http/Controllers/JsonController.php @@ -33,8 +33,7 @@ class JsonController extends Controller * @param Request $request * * @return \Illuminate\Http\JsonResponse - * - + * @throws \Throwable */ public function action(Request $request) { @@ -53,6 +52,7 @@ class JsonController extends Controller * @param Request $request * * @return \Illuminate\Http\JsonResponse + * @throws \Throwable */ public function trigger(Request $request) { diff --git a/app/Http/Controllers/PiggyBankController.php b/app/Http/Controllers/PiggyBankController.php index 8fe2936832..12a56e79c6 100644 --- a/app/Http/Controllers/PiggyBankController.php +++ b/app/Http/Controllers/PiggyBankController.php @@ -273,7 +273,7 @@ class PiggyBankController extends Controller // set all users piggy banks to zero: $this->piggyRepos->reset(); - if (is_array($data)) { + if (\is_array($data)) { foreach ($data as $order => $id) { $this->piggyRepos->setOrder((int)$id, $order + 1); } diff --git a/app/Http/Controllers/Popup/ReportController.php b/app/Http/Controllers/Popup/ReportController.php index b20a9b15a0..ed57022b60 100644 --- a/app/Http/Controllers/Popup/ReportController.php +++ b/app/Http/Controllers/Popup/ReportController.php @@ -114,11 +114,12 @@ class ReportController extends Controller } /** - * @param $attributes + * @param array $attributes * * @return string * * @throws FireflyException + * @throws \Throwable */ private function balanceAmount(array $attributes): string { @@ -155,8 +156,7 @@ class ReportController extends Controller * @param array $attributes * * @return string - * - + * @throws \Throwable */ private function budgetSpentAmount(array $attributes): string { @@ -173,8 +173,7 @@ class ReportController extends Controller * @param array $attributes * * @return string - * - + * @throws \Throwable */ private function categoryEntry(array $attributes): string { @@ -191,8 +190,7 @@ class ReportController extends Controller * @param array $attributes * * @return string - * - + * @throws \Throwable */ private function expenseEntry(array $attributes): string { @@ -209,8 +207,7 @@ class ReportController extends Controller * @param array $attributes * * @return string - * - + * @throws \Throwable */ private function incomeEntry(array $attributes): string { diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.php index 17e8adc52b..52d3c79ffc 100644 --- a/app/Http/Controllers/PreferencesController.php +++ b/app/Http/Controllers/PreferencesController.php @@ -94,7 +94,7 @@ class PreferencesController extends Controller { // front page accounts $frontPageAccounts = []; - if (is_array($request->get('frontPageAccounts'))) { + if (\is_array($request->get('frontPageAccounts'))) { foreach ($request->get('frontPageAccounts') as $id) { $frontPageAccounts[] = (int)$id; } diff --git a/app/Http/Controllers/Report/AccountController.php b/app/Http/Controllers/Report/AccountController.php index db107b0eba..c7c8ff447f 100644 --- a/app/Http/Controllers/Report/AccountController.php +++ b/app/Http/Controllers/Report/AccountController.php @@ -40,7 +40,7 @@ class AccountController extends Controller * * @return mixed|string * - + * @throws \Throwable */ public function general(Collection $accounts, Carbon $start, Carbon $end) { diff --git a/app/Http/Controllers/Report/BalanceController.php b/app/Http/Controllers/Report/BalanceController.php index c66c7f666e..3b31be87de 100644 --- a/app/Http/Controllers/Report/BalanceController.php +++ b/app/Http/Controllers/Report/BalanceController.php @@ -40,8 +40,7 @@ class BalanceController extends Controller * @param Carbon $end * * @return mixed|string - * - + * @throws \Throwable */ public function general(BalanceReportHelperInterface $helper, Collection $accounts, Carbon $start, Carbon $end) { diff --git a/app/Http/Controllers/Report/BudgetController.php b/app/Http/Controllers/Report/BudgetController.php index 9e6a8cb5e4..7a129f3fa7 100644 --- a/app/Http/Controllers/Report/BudgetController.php +++ b/app/Http/Controllers/Report/BudgetController.php @@ -41,8 +41,7 @@ class BudgetController extends Controller * @param Carbon $end * * @return mixed|string - * - + * @throws \Throwable */ public function general(BudgetReportHelperInterface $helper, Collection $accounts, Carbon $start, Carbon $end) { @@ -70,8 +69,7 @@ class BudgetController extends Controller * @param Carbon $end * * @return mixed|string - * - + * @throws \Throwable */ public function period(Collection $accounts, Carbon $start, Carbon $end) { diff --git a/app/Http/Controllers/Report/CategoryController.php b/app/Http/Controllers/Report/CategoryController.php index f55aa23429..5b182a8e7e 100644 --- a/app/Http/Controllers/Report/CategoryController.php +++ b/app/Http/Controllers/Report/CategoryController.php @@ -40,8 +40,7 @@ class CategoryController extends Controller * @param Carbon $end * * @return mixed|string - * - + * @throws \Throwable */ public function expenses(Collection $accounts, Carbon $start, Carbon $end) { @@ -68,13 +67,13 @@ class CategoryController extends Controller } /** - * @param Carbon $start - * @param Carbon $end * @param Collection $accounts * - * @return string + * @param Carbon $start + * @param Carbon $end * - + * @return string + * @throws \Throwable */ public function income(Collection $accounts, Carbon $start, Carbon $end) { @@ -107,9 +106,8 @@ class CategoryController extends Controller * * @return mixed|string * + * @throws \Throwable * @internal param ReportHelperInterface $helper - * - */ public function operations(Collection $accounts, Carbon $start, Carbon $end) { diff --git a/app/Http/Controllers/Report/ExpenseController.php b/app/Http/Controllers/Report/ExpenseController.php index 2f4df4daef..485b0d6842 100644 --- a/app/Http/Controllers/Report/ExpenseController.php +++ b/app/Http/Controllers/Report/ExpenseController.php @@ -67,8 +67,7 @@ class ExpenseController extends Controller * @param Carbon $end * * @return string - * - + * @throws \Throwable */ public function budget(Collection $accounts, Collection $expense, Carbon $start, Carbon $end) { @@ -115,8 +114,7 @@ class ExpenseController extends Controller * @param Carbon $end * * @return string - * - + * @throws \Throwable */ public function category(Collection $accounts, Collection $expense, Carbon $start, Carbon $end) { @@ -173,8 +171,7 @@ class ExpenseController extends Controller * @param Carbon $end * * @return array|mixed|string - * - + * @throws \Throwable */ public function spent(Collection $accounts, Collection $expense, Carbon $start, Carbon $end) { @@ -218,8 +215,7 @@ class ExpenseController extends Controller * @param Carbon $end * * @return string - * - + * @throws \Throwable */ public function topExpense(Collection $accounts, Collection $expense, Carbon $start, Carbon $end) { @@ -262,8 +258,7 @@ class ExpenseController extends Controller * @param Carbon $end * * @return mixed|string - * - + * @throws \Throwable */ public function topIncome(Collection $accounts, Collection $expense, Carbon $start, Carbon $end) { diff --git a/app/Http/Controllers/Report/OperationsController.php b/app/Http/Controllers/Report/OperationsController.php index d112384006..2164c57749 100644 --- a/app/Http/Controllers/Report/OperationsController.php +++ b/app/Http/Controllers/Report/OperationsController.php @@ -40,8 +40,7 @@ class OperationsController extends Controller * @param Carbon $end * * @return mixed|string - * - + * @throws \Throwable */ public function expenses(AccountTaskerInterface $tasker, Collection $accounts, Carbon $start, Carbon $end) { @@ -69,8 +68,7 @@ class OperationsController extends Controller * @param Carbon $end * * @return string - * - + * @throws \Throwable */ public function income(AccountTaskerInterface $tasker, Collection $accounts, Carbon $start, Carbon $end) { @@ -99,8 +97,7 @@ class OperationsController extends Controller * @param Carbon $end * * @return mixed|string - * - + * @throws \Throwable */ public function operations(AccountTaskerInterface $tasker, Collection $accounts, Carbon $start, Carbon $end) { diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index bfb00130f7..2b4bff068d 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -415,8 +415,7 @@ class ReportController extends Controller /** * @return string - * - + * @throws \Throwable */ private function accountReportOptions(): string { @@ -427,7 +426,7 @@ class ReportController extends Controller $set = new Collection; $names = $revenue->pluck('name')->toArray(); foreach ($expense as $exp) { - if (in_array($exp->name, $names)) { + if (\in_array($exp->name, $names)) { $set->push($exp); } } @@ -437,8 +436,7 @@ class ReportController extends Controller /** * @return string - * - + * @throws \Throwable */ private function budgetReportOptions(): string { @@ -451,8 +449,7 @@ class ReportController extends Controller /** * @return string - * - + * @throws \Throwable */ private function categoryReportOptions(): string { @@ -465,8 +462,7 @@ class ReportController extends Controller /** * @return string - * - + * @throws \Throwable */ private function noReportOptions(): string { @@ -475,8 +471,7 @@ class ReportController extends Controller /** * @return string - * - + * @throws \Throwable */ private function tagReportOptions(): string { diff --git a/app/Http/Controllers/RuleController.php b/app/Http/Controllers/RuleController.php index 03bffefe91..c33c759eb3 100644 --- a/app/Http/Controllers/RuleController.php +++ b/app/Http/Controllers/RuleController.php @@ -310,9 +310,8 @@ class RuleController extends Controller } /** - * @param Request $request - * @param RuleRepositoryInterface $repository - * @param Rule $rule + * @param Request $request + * @param Rule $rule * * @return JsonResponse */ @@ -452,7 +451,7 @@ class RuleController extends Controller { $triggers = $rule->ruleTriggers; - if (0 === count($triggers)) { + if (0 === \count($triggers)) { return response()->json(['html' => '', 'warning' => trans('firefly.warning_no_valid_triggers')]); // @codeCoverageIgnore } @@ -682,7 +681,7 @@ class RuleController extends Controller $newIndex = 0; $actions = []; /** @var array $oldActions */ - $oldActions = is_array($request->old('rule-action')) ? $request->old('rule-action') : []; + $oldActions = \is_array($request->old('rule-action')) ? $request->old('rule-action') : []; foreach ($oldActions as $index => $entry) { $count = ($newIndex + 1); $checked = isset($request->old('rule-action-stop')[$index]) ? true : false; @@ -718,7 +717,7 @@ class RuleController extends Controller $newIndex = 0; $triggers = []; /** @var array $oldTriggers */ - $oldTriggers = is_array($request->old('rule-trigger')) ? $request->old('rule-trigger') : []; + $oldTriggers = \is_array($request->old('rule-trigger')) ? $request->old('rule-trigger') : []; foreach ($oldTriggers as $index => $entry) { $count = ($newIndex + 1); $oldChecked = isset($request->old('rule-trigger-stop')[$index]) ? true : false; diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index 401f9bcc8f..4baf91f083 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -73,8 +73,7 @@ class SearchController extends Controller * @param SearchInterface $searcher * * @return \Illuminate\Http\JsonResponse - * - + * @throws \Throwable */ public function search(Request $request, SearchInterface $searcher) { diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index 43a8b57470..294d364014 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -213,7 +213,7 @@ class TagController extends Controller } // prep for "specific date" view. - if (strlen($moment) > 0 && 'all' !== $moment) { + if (\strlen($moment) > 0 && 'all' !== $moment) { $start = new Carbon($moment); $end = app('navigation')->endOfPeriod($start, $range); $subTitle = trans( @@ -226,7 +226,7 @@ class TagController extends Controller } // prep for current period - if (0 === strlen($moment)) { + if (0 === \strlen($moment)) { /** @var Carbon $start */ $start = clone session('start', app('navigation')->startOfPeriod(new Carbon, $range)); /** @var Carbon $end */ diff --git a/app/Http/Controllers/Transaction/MassController.php b/app/Http/Controllers/Transaction/MassController.php index ede2e9b6ba..e404300f61 100644 --- a/app/Http/Controllers/Transaction/MassController.php +++ b/app/Http/Controllers/Transaction/MassController.php @@ -120,7 +120,7 @@ class MassController extends Controller /** * @param Collection $journals * - * @return View + * @return IlluminateView */ public function edit(Collection $journals): IlluminateView { @@ -173,7 +173,7 @@ class MassController extends Controller { $journalIds = $request->get('journals'); $count = 0; - if (is_array($journalIds)) { + if (\is_array($journalIds)) { foreach ($journalIds as $journalId) { $journal = $repository->find((int)$journalId); if (null !== $journal) { diff --git a/app/Http/Controllers/Transaction/SingleController.php b/app/Http/Controllers/Transaction/SingleController.php index 4973dfedce..0f65bf03ff 100644 --- a/app/Http/Controllers/Transaction/SingleController.php +++ b/app/Http/Controllers/Transaction/SingleController.php @@ -408,10 +408,10 @@ class SingleController extends Controller $this->attachments->saveAttachmentsForModel($journal, $files); // @codeCoverageIgnoreStart - if (count($this->attachments->getErrors()->get('attachments')) > 0) { + if (\count($this->attachments->getErrors()->get('attachments')) > 0) { session()->flash('error', $this->attachments->getErrors()->get('attachments')); } - if (count($this->attachments->getMessages()->get('attachments')) > 0) { + if (\count($this->attachments->getMessages()->get('attachments')) > 0) { session()->flash('info', $this->attachments->getMessages()->get('attachments')); } // @codeCoverageIgnoreEnd diff --git a/app/Http/Controllers/Transaction/SplitController.php b/app/Http/Controllers/Transaction/SplitController.php index e3e1fe1116..2dfc57325c 100644 --- a/app/Http/Controllers/Transaction/SplitController.php +++ b/app/Http/Controllers/Transaction/SplitController.php @@ -157,7 +157,7 @@ class SplitController extends Controller // flash messages // @codeCoverageIgnoreStart - if (count($this->attachments->getMessages()->get('attachments')) > 0) { + if (\count($this->attachments->getMessages()->get('attachments')) > 0) { session()->flash('info', $this->attachments->getMessages()->get('attachments')); } // @codeCoverageIgnoreEnd @@ -253,7 +253,7 @@ class SplitController extends Controller $res = $transformer->transform($transaction); } - if (count($res) > 0) { + if (\count($res) > 0) { $res['amount'] = app('steam')->positive((string)$res['amount']); $res['foreign_amount'] = app('steam')->positive((string)$res['foreign_amount']); $transactions[] = $res; @@ -271,7 +271,7 @@ class SplitController extends Controller */ private function updateWithPrevious($array, $old): array { - if (0 === count($old) || !isset($old['transactions'])) { + if (0 === \count($old) || !isset($old['transactions'])) { return $array; } $old = $old['transactions']; diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php index f010d38b26..e445d58f4f 100644 --- a/app/Http/Controllers/TransactionController.php +++ b/app/Http/Controllers/TransactionController.php @@ -175,7 +175,7 @@ class TransactionController extends Controller { $ids = $request->get('items'); $date = new Carbon($request->get('date')); - if (count($ids) > 0) { + if (\count($ids) > 0) { $order = 0; $ids = array_unique($ids); foreach ($ids as $id) { diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index 04cd89f0fb..394f04d01a 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -62,7 +62,8 @@ class Authenticate * * @return mixed * - * @throws \Illuminate\Auth\AuthenticationException + * @throws AuthenticationException + * @throws FireflyException */ public function handle($request, Closure $next, ...$guards) { diff --git a/app/Http/Middleware/Sandstorm.php b/app/Http/Middleware/Sandstorm.php index 30ad044198..b097d48ad5 100644 --- a/app/Http/Middleware/Sandstorm.php +++ b/app/Http/Middleware/Sandstorm.php @@ -71,7 +71,7 @@ class Sandstorm // access the same data so we have no choice but to simply login // the new user to the same account and just forget about Bob and Alice // and any other differences there may be between these users. - if (1 === $count && strlen($userId) > 0) { + if (1 === $count && \strlen($userId) > 0) { // login as first user user. $user = $repository->first(); Auth::guard($guard)->login($user); @@ -80,7 +80,7 @@ class Sandstorm return $next($request); } - if (1 === $count && 0 === strlen($userId)) { + if (1 === $count && 0 === \strlen($userId)) { // login but indicate anonymous $user = User::first(); Auth::guard($guard)->login($user); @@ -89,7 +89,7 @@ class Sandstorm return $next($request); } - if (0 === $count && strlen($userId) > 0) { + if (0 === $count && \strlen($userId) > 0) { // create new user. $email = $userId . '@firefly'; /** @var User $user */ @@ -111,7 +111,7 @@ class Sandstorm return $next($request); } - if (0 === $count && 0 === strlen($userId)) { + if (0 === $count && 0 === \strlen($userId)) { throw new FireflyException('The first visit to a new Firefly III administration cannot be by a guest user.'); } @@ -121,7 +121,7 @@ class Sandstorm } // if in Sandstorm, user logged in, still must check if user is anon. $userId = (string)$request->header('X-Sandstorm-User-Id'); - if (strlen($userId) === 0) { + if (\strlen($userId) === 0) { View::share('SANDSTORM_ANON', true); return $next($request); diff --git a/app/Http/Requests/JournalLinkRequest.php b/app/Http/Requests/JournalLinkRequest.php index 3e12a28686..ace48c5032 100644 --- a/app/Http/Requests/JournalLinkRequest.php +++ b/app/Http/Requests/JournalLinkRequest.php @@ -48,7 +48,7 @@ class JournalLinkRequest extends Request $parts = explode('_', $linkType); $return['link_type_id'] = (int)$parts[0]; $return['transaction_journal_id'] = $this->integer('link_journal_id'); - $return['notes'] = strlen($this->string('notes')) > 0 ? $this->string('notes') : ''; + $return['notes'] = \strlen($this->string('notes')) > 0 ? $this->string('notes') : ''; $return['direction'] = $parts[1]; if (0 === $return['transaction_journal_id'] && ctype_digit($this->string('link_other'))) { $return['transaction_journal_id'] = $this->integer('link_other'); diff --git a/app/Http/Requests/ReconciliationStoreRequest.php b/app/Http/Requests/ReconciliationStoreRequest.php index 98fdc46973..7866ca793b 100644 --- a/app/Http/Requests/ReconciliationStoreRequest.php +++ b/app/Http/Requests/ReconciliationStoreRequest.php @@ -46,7 +46,7 @@ class ReconciliationStoreRequest extends Request public function getAll(): array { $transactions = $this->get('transactions'); - if (!is_array($transactions)) { + if (!\is_array($transactions)) { $transactions = []; // @codeCoverageIgnore } $data = [ diff --git a/app/Http/Requests/ReportFormRequest.php b/app/Http/Requests/ReportFormRequest.php index ce59a59330..edd58743ea 100644 --- a/app/Http/Requests/ReportFormRequest.php +++ b/app/Http/Requests/ReportFormRequest.php @@ -56,7 +56,7 @@ class ReportFormRequest extends Request $repository = app(AccountRepositoryInterface::class); $set = $this->get('accounts'); $collection = new Collection; - if (is_array($set)) { + if (\is_array($set)) { foreach ($set as $accountId) { $account = $repository->findNull((int)$accountId); if (null !== $account) { @@ -77,7 +77,7 @@ class ReportFormRequest extends Request $repository = app(BudgetRepositoryInterface::class); $set = $this->get('budget'); $collection = new Collection; - if (is_array($set)) { + if (\is_array($set)) { foreach ($set as $budgetId) { $budget = $repository->findNull((int)$budgetId); if (null !== $budget) { @@ -98,7 +98,7 @@ class ReportFormRequest extends Request $repository = app(CategoryRepositoryInterface::class); $set = $this->get('category'); $collection = new Collection; - if (is_array($set)) { + if (\is_array($set)) { foreach ($set as $categoryId) { $category = $repository->findNull((int)$categoryId); if (null !== $category) { @@ -120,7 +120,7 @@ class ReportFormRequest extends Request $date = new Carbon; $range = $this->get('daterange'); $parts = explode(' - ', (string)$range); - if (2 === count($parts)) { + if (2 === \count($parts)) { try { $date = new Carbon($parts[1]); // @codeCoverageIgnoreStart @@ -145,7 +145,7 @@ class ReportFormRequest extends Request $repository = app(AccountRepositoryInterface::class); $set = $this->get('exp_rev'); $collection = new Collection; - if (is_array($set)) { + if (\is_array($set)) { foreach ($set as $accountId) { $account = $repository->findNull((int)$accountId); if (null !== $account) { @@ -167,7 +167,7 @@ class ReportFormRequest extends Request $date = new Carbon; $range = $this->get('daterange'); $parts = explode(' - ', (string)$range); - if (2 === count($parts)) { + if (2 === \count($parts)) { try { $date = new Carbon($parts[0]); // @codeCoverageIgnoreStart @@ -190,7 +190,7 @@ class ReportFormRequest extends Request $repository = app(TagRepositoryInterface::class); $set = $this->get('tag'); $collection = new Collection; - if (is_array($set)) { + if (\is_array($set)) { foreach ($set as $tagTag) { $tag = $repository->findByTag($tagTag); if (null !== $tag->id) { diff --git a/app/Import/Configuration/BunqConfigurator.php b/app/Import/Configuration/BunqConfigurator.php index 6dad1ea2ad..910c494d71 100644 --- a/app/Import/Configuration/BunqConfigurator.php +++ b/app/Import/Configuration/BunqConfigurator.php @@ -198,7 +198,6 @@ class BunqConfigurator implements ConfiguratorInterface $job = $this->repository->setExtendedStatus($job, $extendedStatus); $this->job = $job; - return; } /** diff --git a/app/Import/Configuration/FileConfigurator.php b/app/Import/Configuration/FileConfigurator.php index 2151e0091c..4d98232d2a 100644 --- a/app/Import/Configuration/FileConfigurator.php +++ b/app/Import/Configuration/FileConfigurator.php @@ -237,7 +237,7 @@ class FileConfigurator implements ConfiguratorInterface break; } - if (false === $class || 0 === strlen($class)) { + if (false === $class || 0 === \strlen($class)) { throw new FireflyException(sprintf('Cannot handle job stage "%s" in getConfigurationClass().', $stage)); } if (!class_exists($class)) { @@ -271,6 +271,5 @@ class FileConfigurator implements ConfiguratorInterface { $this->repository->setExtendedStatus($this->job, $extended); - return; } } diff --git a/app/Import/Configuration/SpectreConfigurator.php b/app/Import/Configuration/SpectreConfigurator.php index a0b5a41915..3f65633d3a 100644 --- a/app/Import/Configuration/SpectreConfigurator.php +++ b/app/Import/Configuration/SpectreConfigurator.php @@ -219,7 +219,6 @@ class SpectreConfigurator implements ConfiguratorInterface $job = $this->repository->setExtendedStatus($job, $extendedStatus); $this->job = $job; - return; } /** diff --git a/app/Import/Converter/Amount.php b/app/Import/Converter/Amount.php index 3a9103780b..21b3769c0c 100644 --- a/app/Import/Converter/Amount.php +++ b/app/Import/Converter/Amount.php @@ -49,7 +49,7 @@ class Amount implements ConverterInterface $original = $value; $value = (string)$value; $value = $this->stripAmount($value); - $len = strlen($value); + $len = \strlen($value); $decimalPosition = $len - 3; $altPosition = $len - 2; $decimal = null; @@ -99,7 +99,7 @@ class Amount implements ConverterInterface Log::debug(sprintf('No decimal character found. Converted amount from "%s" to "%s".', $original, $value)); } - return strval(number_format(round(floatval($value), 12), 12, '.', '')); + return (string)number_format(round(floatval($value), 12), 12, '.', ''); } /** @@ -110,7 +110,7 @@ class Amount implements ConverterInterface private function stripAmount(string $value): string { $str = preg_replace('/[^\-\(\)\.\,0-9 ]/', '', $value); - $len = strlen($str); + $len = \strlen($str); if ('(' === $str[0] && ')' === $str[$len - 1]) { $str = '-' . substr($str, 1, $len - 2); } diff --git a/app/Import/FileProcessor/CsvProcessor.php b/app/Import/FileProcessor/CsvProcessor.php index 140783adc1..affd463daa 100644 --- a/app/Import/FileProcessor/CsvProcessor.php +++ b/app/Import/FileProcessor/CsvProcessor.php @@ -176,7 +176,7 @@ class CsvProcessor implements FileProcessorInterface $mapped = $config['column-mapping-config'][$index][$value] ?? null; // throw error when not a valid converter. - if (!in_array($role, $this->validConverters)) { + if (!\in_array($role, $this->validConverters)) { throw new FireflyException(sprintf('"%s" is not a valid role.', $role)); } @@ -313,7 +313,7 @@ class CsvProcessor implements FileProcessorInterface */ foreach ($row as $rowIndex => $value) { $value = trim((string)$value); - if (strlen($value) > 0) { + if (\strlen($value) > 0) { $annotated = $this->annotateValue($rowIndex, $value); Log::debug('Annotated value', $annotated); $journal->setValue($annotated); @@ -358,7 +358,7 @@ class CsvProcessor implements FileProcessorInterface $config = $this->getConfig(); $names = array_keys($config['specifics'] ?? []); foreach ($names as $name) { - if (!in_array($name, $this->validSpecifics)) { + if (!\in_array($name, $this->validSpecifics)) { throw new FireflyException(sprintf('"%s" is not a valid class name', $name)); } diff --git a/app/Import/Logging/CommandHandler.php b/app/Import/Logging/CommandHandler.php index f52fe8a71b..c1dfc85773 100644 --- a/app/Import/Logging/CommandHandler.php +++ b/app/Import/Logging/CommandHandler.php @@ -64,8 +64,8 @@ class CommandHandler extends AbstractProcessingHandler { $level = strtoupper($level); $reference = sprintf('\Monolog\Logger::%s', $level); - if (defined($reference)) { - $this->setLevel(constant($reference)); + if (\defined($reference)) { + $this->setLevel(\constant($reference)); } } } diff --git a/app/Import/Mapper/AssetAccountIbans.php b/app/Import/Mapper/AssetAccountIbans.php index c9ffcdbe01..9460771bd6 100644 --- a/app/Import/Mapper/AssetAccountIbans.php +++ b/app/Import/Mapper/AssetAccountIbans.php @@ -46,10 +46,10 @@ class AssetAccountIbans implements MapperInterface foreach ($set as $account) { $iban = $account->iban ?? ''; $accountId = (int)$account->id; - if (strlen($iban) > 0) { + if (\strlen($iban) > 0) { $topList[$accountId] = $account->iban . ' (' . $account->name . ')'; } - if (0 === strlen($iban)) { + if (0 === \strlen($iban)) { $list[$accountId] = $account->name; } } diff --git a/app/Import/Mapper/AssetAccounts.php b/app/Import/Mapper/AssetAccounts.php index 23536b13c5..23d8b23322 100644 --- a/app/Import/Mapper/AssetAccounts.php +++ b/app/Import/Mapper/AssetAccounts.php @@ -46,7 +46,7 @@ class AssetAccounts implements MapperInterface $accountId = (int)$account->id; $name = $account->name; $iban = $account->iban ?? ''; - if (strlen($iban) > 0) { + if (\strlen($iban) > 0) { $name .= ' (' . $iban . ')'; } $list[$accountId] = $name; diff --git a/app/Import/Mapper/OpposingAccountIbans.php b/app/Import/Mapper/OpposingAccountIbans.php index 8ae1f146e3..a567648563 100644 --- a/app/Import/Mapper/OpposingAccountIbans.php +++ b/app/Import/Mapper/OpposingAccountIbans.php @@ -52,10 +52,10 @@ class OpposingAccountIbans implements MapperInterface foreach ($set as $account) { $iban = $account->iban ?? ''; $accountId = (int)$account->id; - if (strlen($iban) > 0) { + if (\strlen($iban) > 0) { $topList[$accountId] = $account->iban . ' (' . $account->name . ')'; } - if (0 === strlen($iban)) { + if (0 === \strlen($iban)) { $list[$accountId] = $account->name; } } diff --git a/app/Import/Mapper/OpposingAccounts.php b/app/Import/Mapper/OpposingAccounts.php index 63875ad338..b5ee6089b5 100644 --- a/app/Import/Mapper/OpposingAccounts.php +++ b/app/Import/Mapper/OpposingAccounts.php @@ -52,7 +52,7 @@ class OpposingAccounts implements MapperInterface $accountId = (int)$account->id; $name = $account->name; $iban = $account->iban ?? ''; - if (strlen($iban) > 0) { + if (\strlen($iban) > 0) { $name .= ' (' . $iban . ')'; } $list[$accountId] = $name; diff --git a/app/Import/MapperPreProcess/TagsComma.php b/app/Import/MapperPreProcess/TagsComma.php index 0866cfc1d5..294026c090 100644 --- a/app/Import/MapperPreProcess/TagsComma.php +++ b/app/Import/MapperPreProcess/TagsComma.php @@ -36,7 +36,7 @@ class TagsComma implements PreProcessorInterface { $set = explode(',', $value); $set = array_map('trim', $set); - $set = array_filter($set, 'strlen'); + $set = array_filter($set, '\strlen'); return array_values($set); } diff --git a/app/Import/MapperPreProcess/TagsSpace.php b/app/Import/MapperPreProcess/TagsSpace.php index e87627b5be..63e949e5d7 100644 --- a/app/Import/MapperPreProcess/TagsSpace.php +++ b/app/Import/MapperPreProcess/TagsSpace.php @@ -36,7 +36,7 @@ class TagsSpace implements PreProcessorInterface { $set = explode(' ', $value); $set = array_map('trim', $set); - $set = array_filter($set, 'strlen'); + $set = array_filter($set, '\strlen'); return array_values($set); } diff --git a/app/Import/Object/ImportAccount.php b/app/Import/Object/ImportAccount.php index 5babe8e471..fe2ffc8767 100644 --- a/app/Import/Object/ImportAccount.php +++ b/app/Import/Object/ImportAccount.php @@ -195,7 +195,7 @@ class ImportAccount */ private function findByIBAN(AccountType $type): ?Account { - if (3 === count($this->accountIban)) { + if (3 === \count($this->accountIban)) { $accounts = $this->repository->getAccountsByType([$type->type]); $iban = $this->accountIban['value']; Log::debug(sprintf('Finding account of type %d and IBAN %s', $type->id, $iban)); @@ -233,7 +233,7 @@ class ImportAccount */ private function findById(AccountType $type): ?Account { - if (3 === count($this->accountId)) { + if (3 === \count($this->accountId)) { Log::debug(sprintf('Finding account of type %d and ID %d', $type->id, $this->accountId['value'])); /** @var Account $account */ $account = $this->user->accounts() @@ -263,7 +263,7 @@ class ImportAccount private function findByName(AccountType $type): ?Account { // Three: find by name (and type): - if (3 === count($this->accountName)) { + if (3 === \count($this->accountName)) { $accounts = $this->repository->getAccountsByType([$type->type]); $name = $this->accountName['value']; Log::debug(sprintf('Finding account of type %d and name %s', $type->id, $name)); @@ -351,7 +351,7 @@ class ImportAccount private function getMappedObject(array $array): ?Account { Log::debug('In getMappedObject() for Account'); - if (0 === count($array)) { + if (0 === \count($array)) { Log::debug('Array is empty, nothing will come of this.'); return null; diff --git a/app/Import/Object/ImportBill.php b/app/Import/Object/ImportBill.php index a364e9e679..aacc6e33b5 100644 --- a/app/Import/Object/ImportBill.php +++ b/app/Import/Object/ImportBill.php @@ -105,7 +105,7 @@ class ImportBill */ private function findById(): ?Bill { - if (3 === count($this->id)) { + if (3 === \count($this->id)) { Log::debug(sprintf('Finding bill with ID #%d', $this->id['value'])); /** @var Bill $bill */ $bill = $this->repository->find((int)$this->id['value']); @@ -125,7 +125,7 @@ class ImportBill */ private function findByName(): ?Bill { - if (3 === count($this->name)) { + if (3 === \count($this->name)) { $bills = $this->repository->getBills(); $name = $this->name['value']; Log::debug(sprintf('Finding bill with name %s', $name)); @@ -201,7 +201,7 @@ class ImportBill private function getMappedObject(array $array): ?Bill { Log::debug('In getMappedObject() for Bill'); - if (0 === count($array)) { + if (0 === \count($array)) { Log::debug('Array is empty, nothing will come of this.'); return null; @@ -250,7 +250,7 @@ class ImportBill } $name = $this->name['value'] ?? ''; - if (0 === strlen($name)) { + if (0 === \strlen($name)) { return true; } diff --git a/app/Import/Object/ImportBudget.php b/app/Import/Object/ImportBudget.php index 2a34c18906..53e92a8f80 100644 --- a/app/Import/Object/ImportBudget.php +++ b/app/Import/Object/ImportBudget.php @@ -94,7 +94,7 @@ class ImportBudget */ private function findById(): ?Budget { - if (3 === count($this->id)) { + if (3 === \count($this->id)) { Log::debug(sprintf('Finding budget with ID #%d', $this->id['value'])); /** @var Budget $budget */ $budget = $this->repository->findNull((int)$this->id['value']); @@ -114,7 +114,7 @@ class ImportBudget */ private function findByName(): ?Budget { - if (3 === count($this->name)) { + if (3 === \count($this->name)) { $budgets = $this->repository->getBudgets(); $name = $this->name['value']; Log::debug(sprintf('Finding budget with name %s', $name)); @@ -190,7 +190,7 @@ class ImportBudget private function getMappedObject(array $array): ?Budget { Log::debug('In getMappedObject() for Budget'); - if (0 === count($array)) { + if (0 === \count($array)) { Log::debug('Array is empty, nothing will come of this.'); return null; @@ -239,7 +239,7 @@ class ImportBudget } $name = $this->name['value'] ?? ''; - if (0 === strlen($name)) { + if (0 === \strlen($name)) { return true; } diff --git a/app/Import/Object/ImportCategory.php b/app/Import/Object/ImportCategory.php index dde6cfa24e..9427d74871 100644 --- a/app/Import/Object/ImportCategory.php +++ b/app/Import/Object/ImportCategory.php @@ -96,7 +96,7 @@ class ImportCategory */ private function findById(): ?Category { - if (3 === count($this->id)) { + if (3 === \count($this->id)) { Log::debug(sprintf('Finding category with ID #%d', $this->id['value'])); /** @var Category $category */ $category = $this->repository->findNull((int)$this->id['value']); @@ -118,7 +118,7 @@ class ImportCategory */ private function findByName(): ?Category { - if (3 === count($this->name)) { + if (3 === \count($this->name)) { $categories = $this->repository->getCategories(); $name = $this->name['value']; Log::debug(sprintf('Finding category with name %s', $name)); @@ -195,7 +195,7 @@ class ImportCategory private function getMappedObject(array $array): ?Category { Log::debug('In getMappedObject() for Category'); - if (0 === count($array)) { + if (0 === \count($array)) { Log::debug('Array is empty, nothing will come of this.'); return null; @@ -244,7 +244,7 @@ class ImportCategory } $name = $this->name['value'] ?? ''; - if (0 === strlen($name)) { + if (0 === \strlen($name)) { return true; } diff --git a/app/Import/Object/ImportCurrency.php b/app/Import/Object/ImportCurrency.php index 47b7a0fa95..2d63bf9955 100644 --- a/app/Import/Object/ImportCurrency.php +++ b/app/Import/Object/ImportCurrency.php @@ -201,7 +201,7 @@ class ImportCurrency private function getMappedObject(array $array): ?TransactionCurrency { Log::debug('In getMappedObject()'); - if (0 === count($array)) { + if (0 === \count($array)) { Log::debug('Array is empty, nothing will come of this.'); return null; diff --git a/app/Import/Object/ImportJournal.php b/app/Import/Object/ImportJournal.php index fa5d7ad66f..9fe1d82349 100644 --- a/app/Import/Object/ImportJournal.php +++ b/app/Import/Object/ImportJournal.php @@ -224,7 +224,7 @@ class ImportJournal */ public function getMetaString(string $field): ?string { - if (isset($this->metaFields[$field]) && strlen($this->metaFields[$field]) > 0) { + if (isset($this->metaFields[$field]) && \strlen($this->metaFields[$field]) > 0) { return (string)$this->metaFields[$field]; } @@ -278,7 +278,7 @@ class ImportJournal case 'sepa-ep': case 'sepa-ci': $value = trim((string)$array['value']); - if (strlen($value) > 0) { + if (\strlen($value) > 0) { $this->metaFields[$array['role']] = $value; } break; @@ -411,11 +411,11 @@ class ImportJournal $info = $this->selectAmountInput(); - if (0 === count($info)) { + if (0 === \count($info)) { throw new FireflyException('No amount information for this row.'); } $class = $info['class'] ?? ''; - if (0 === strlen($class)) { + if (0 === \strlen($class)) { throw new FireflyException('No amount information (conversion class) for this row.'); } diff --git a/app/Import/Prerequisites/FilePrerequisites.php b/app/Import/Prerequisites/FilePrerequisites.php index 72ed8fab76..e2177af913 100644 --- a/app/Import/Prerequisites/FilePrerequisites.php +++ b/app/Import/Prerequisites/FilePrerequisites.php @@ -84,7 +84,6 @@ class FilePrerequisites implements PrerequisitesInterface { $this->user = $user; - return; } /** diff --git a/app/Import/Prerequisites/SpectrePrerequisites.php b/app/Import/Prerequisites/SpectrePrerequisites.php index 93319c7fdd..a780c3ddd1 100644 --- a/app/Import/Prerequisites/SpectrePrerequisites.php +++ b/app/Import/Prerequisites/SpectrePrerequisites.php @@ -96,7 +96,6 @@ class SpectrePrerequisites implements PrerequisitesInterface { $this->user = $user; - return; } /** @@ -144,7 +143,6 @@ class SpectrePrerequisites implements PrerequisitesInterface Preferences::setForUser($this->user, 'spectre_public_key', $pubKey['key']); Log::debug('Created key pair'); - return; } /** diff --git a/app/Import/Routine/BunqRoutine.php b/app/Import/Routine/BunqRoutine.php index 9ae6e42871..98156f9d7e 100644 --- a/app/Import/Routine/BunqRoutine.php +++ b/app/Import/Routine/BunqRoutine.php @@ -314,8 +314,6 @@ class BunqRoutine implements RoutineInterface * @param string $expectedType * * @return Account - * @throws \FireflyIII\Exceptions\FireflyException - * @throws FireflyException */ private function convertToAccount(LabelMonetaryAccount $party, string $expectedType): Account { @@ -541,7 +539,6 @@ class BunqRoutine implements RoutineInterface * * @return string * - * @throws FireflyException */ private function getRemoteIp(): ?string { @@ -602,7 +599,7 @@ class BunqRoutine implements RoutineInterface $journals = new Collection; $config = $this->getConfig(); foreach ($payments as $accountId => $data) { - Log::debug(sprintf('Now running for bunq account #%d with %d payment(s).', $accountId, count($data['payments']))); + Log::debug(sprintf('Now running for bunq account #%d with %d payment(s).', $accountId, \count($data['payments']))); /** @var Payment $payment */ foreach ($data['payments'] as $index => $payment) { Log::debug(sprintf('Now at payment #%d with ID #%d', $index, $payment->getId())); @@ -808,7 +805,7 @@ class BunqRoutine implements RoutineInterface Log::debug(sprintf('Will try to get transactions for company #%d', $user->getId())); } - $this->addTotalSteps(count($config['accounts']) * 2); + $this->addTotalSteps(\count($config['accounts']) * 2); foreach ($config['accounts'] as $accountData) { $this->addStep(); diff --git a/app/Import/Routine/SpectreRoutine.php b/app/Import/Routine/SpectreRoutine.php index 55aee3e111..3147f7788f 100644 --- a/app/Import/Routine/SpectreRoutine.php +++ b/app/Import/Routine/SpectreRoutine.php @@ -505,7 +505,7 @@ class SpectreRoutine implements RoutineInterface Log::debug('Looping journals...'); $journalIds = $storage->journals->pluck('id')->toArray(); $tagId = $tag->id; - $this->addTotalSteps(count($journalIds)); + $this->addTotalSteps(\count($journalIds)); foreach ($journalIds as $journalId) { Log::debug(sprintf('Linking journal #%d to tag #%d...', $journalId, $tagId)); @@ -551,7 +551,7 @@ class SpectreRoutine implements RoutineInterface 'import_id' => $importId, 'transactions' => $transactions, ]; - $count += count($transactions); + $count += \count($transactions); } Log::debug(sprintf('Total number of transactions: %d', $count)); $this->addStep(); diff --git a/app/Import/Specifics/AbnAmroDescription.php b/app/Import/Specifics/AbnAmroDescription.php index 26658ad045..47ab96db0a 100644 --- a/app/Import/Specifics/AbnAmroDescription.php +++ b/app/Import/Specifics/AbnAmroDescription.php @@ -136,7 +136,7 @@ class AbnAmroDescription implements SpecificInterface // SEPA plain descriptions contain several key-value pairs, split by a colon preg_match_all('/([A-Za-z]+(?=:\s)):\s([A-Za-z 0-9._#-]+(?=\s|$))/', $this->row[7], $matches, PREG_SET_ORDER); - if (is_array($matches)) { + if (\is_array($matches)) { foreach ($matches as $match) { $key = $match[1]; $value = trim($match[2]); @@ -163,7 +163,7 @@ class AbnAmroDescription implements SpecificInterface // Set a new description for the current transaction. If none was given // set the description to type, name and reference $this->row[7] = $newDescription; - if (0 === strlen($newDescription)) { + if (0 === \strlen($newDescription)) { $this->row[7] = sprintf('%s - %s (%s)', $type, $name, $reference); } @@ -189,7 +189,7 @@ class AbnAmroDescription implements SpecificInterface // Search for properties specified in the TRTP format. If no description // is provided, use the type, name and reference as new description - if (is_array($matches)) { + if (\is_array($matches)) { foreach ($matches as $match) { $key = $match[1]; $value = trim($match[2]); @@ -218,7 +218,7 @@ class AbnAmroDescription implements SpecificInterface // Set a new description for the current transaction. If none was given // set the description to type, name and reference $this->row[7] = $newDescription; - if (0 === strlen($newDescription)) { + if (0 === \strlen($newDescription)) { $this->row[7] = sprintf('%s - %s (%s)', $type, $name, $reference); } } diff --git a/app/Import/Specifics/IngDescription.php b/app/Import/Specifics/IngDescription.php index 6839fa76ba..4277a31df2 100644 --- a/app/Import/Specifics/IngDescription.php +++ b/app/Import/Specifics/IngDescription.php @@ -61,7 +61,7 @@ class IngDescription implements SpecificInterface public function run(array $row): array { $this->row = array_values($row); - if (count($this->row) >= 8) { // check if the array is correct + if (\count($this->row) >= 8) { // check if the array is correct switch ($this->row[4]) { // Get value for the mutation type case 'GT': // InternetBankieren case 'OV': // Overschrijving @@ -127,7 +127,7 @@ class IngDescription implements SpecificInterface private function copyDescriptionToOpposite(): void { $search = ['Naar Oranje Spaarrekening ', 'Afschrijvingen']; - if (0 === strlen($this->row[3])) { + if (0 === \strlen($this->row[3])) { $this->row[3] = trim(str_ireplace($search, '', $this->row[8])); } } diff --git a/app/Import/Specifics/PresidentsChoice.php b/app/Import/Specifics/PresidentsChoice.php index 96fec74867..6db235e8e8 100644 --- a/app/Import/Specifics/PresidentsChoice.php +++ b/app/Import/Specifics/PresidentsChoice.php @@ -53,7 +53,7 @@ class PresidentsChoice implements SpecificInterface $row = array_values($row); // first, if column 2 is empty and 3 is not, do nothing. // if column 3 is empty and column 2 is not, move amount to column 3, *-1 - if (isset($row[3]) && 0 === strlen($row[3])) { + if (isset($row[3]) && 0 === \strlen($row[3])) { $row[3] = bcmul($row[2], '-1'); } if (isset($row[1])) { diff --git a/app/Import/Specifics/RabobankDescription.php b/app/Import/Specifics/RabobankDescription.php index b29127260a..b940239f2f 100644 --- a/app/Import/Specifics/RabobankDescription.php +++ b/app/Import/Specifics/RabobankDescription.php @@ -53,12 +53,12 @@ class RabobankDescription implements SpecificInterface public function run(array $row): array { $row = array_values($row); - Log::debug(sprintf('Now in RabobankSpecific::run(). Row has %d columns', count($row))); + Log::debug(sprintf('Now in RabobankSpecific::run(). Row has %d columns', \count($row))); $oppositeAccount = isset($row[5]) ? trim($row[5]) : ''; $oppositeName = isset($row[6]) ? trim($row[6]) : ''; $alternateName = isset($row[10]) ? trim($row[10]) : ''; - if (strlen($oppositeAccount) < 1 && strlen($oppositeName) < 1) { + if (\strlen($oppositeAccount) < 1 && \strlen($oppositeName) < 1) { Log::debug( sprintf( 'Rabobank specific: Opposite account and opposite name are' . @@ -69,7 +69,7 @@ class RabobankDescription implements SpecificInterface $row[6] = $alternateName; $row[10] = ''; } - if (!(strlen($oppositeAccount) < 1 && strlen($oppositeName) < 1)) { + if (!(\strlen($oppositeAccount) < 1 && \strlen($oppositeName) < 1)) { Log::debug('Rabobank specific: either opposite account or name are filled.'); } diff --git a/app/Import/Storage/ImportSupport.php b/app/Import/Storage/ImportSupport.php index f7544b516e..1affa15731 100644 --- a/app/Import/Storage/ImportSupport.php +++ b/app/Import/Storage/ImportSupport.php @@ -41,23 +41,18 @@ use Log; /** * Trait ImportSupport. + * + * @property int $defaultCurrencyId + * @property ImportJob $job + * @property JournalRepositoryInterface $journalRepository; + * @property Collection $rules */ trait ImportSupport { - /** @var int */ - protected $defaultCurrencyId = 1; - /** @var ImportJob */ - protected $job; - /** @var JournalRepositoryInterface */ - protected $journalRepository; - /** @var Collection */ - protected $rules; - /** * @param TransactionJournal $journal * * @return bool - * @throws \FireflyIII\Exceptions\FireflyException */ protected function applyRules(TransactionJournal $journal): bool { diff --git a/app/Jobs/ExecuteRuleGroupOnExistingTransactions.php b/app/Jobs/ExecuteRuleGroupOnExistingTransactions.php index 5a4495e84b..670deb6550 100644 --- a/app/Jobs/ExecuteRuleGroupOnExistingTransactions.php +++ b/app/Jobs/ExecuteRuleGroupOnExistingTransactions.php @@ -170,7 +170,6 @@ class ExecuteRuleGroupOnExistingTransactions extends Job implements ShouldQueue * Collects a list of rule processors, one for each rule within the rule group. * * @return array - * @throws \FireflyIII\Exceptions\FireflyException */ protected function collectProcessors() { diff --git a/app/Models/Account.php b/app/Models/Account.php index d799551c0e..3e823b5a9a 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -32,6 +32,12 @@ use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Query\JoinClause; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use Log; +use FireflyIII\Models\AccountType; +use FireflyIII\Models\AccountMeta; +use FireflyIII\User; +use FireflyIII\Models\Transaction; +use FireflyIII\Models\PiggyBank; /** * Class Account. @@ -126,7 +132,7 @@ class Account extends Model */ public function accountMeta(): HasMany { - return $this->hasMany('FireflyIII\Models\AccountMeta'); + return $this->hasMany(AccountMeta::class); } /** @@ -135,7 +141,7 @@ class Account extends Model */ public function accountType(): BelongsTo { - return $this->belongsTo('FireflyIII\Models\AccountType'); + return $this->belongsTo(AccountType::class); } /** @@ -162,12 +168,14 @@ class Account extends Model */ public function getIbanAttribute($value): string { - if (null === $value || 0 === strlen((string)$value)) { + if (null === $value || '' === (string)$value) { return ''; } try { $result = Crypt::decrypt($value); } catch (DecryptException $e) { + Log::error($e->getMessage()); + Log::error($e->getTraceAsString()); throw new FireflyException('Cannot decrypt value "' . $value . '" for account #' . $this->id); } if (null === $result) { @@ -246,7 +254,7 @@ class Account extends Model */ public function piggyBanks(): HasMany { - return $this->hasMany('FireflyIII\Models\PiggyBank'); + return $this->hasMany(PiggyBank::class); } /** @@ -330,7 +338,7 @@ class Account extends Model */ public function transactions(): HasMany { - return $this->hasMany('FireflyIII\Models\Transaction'); + return $this->hasMany(Transaction::class); } /** @@ -339,6 +347,6 @@ class Account extends Model */ public function user(): BelongsTo { - return $this->belongsTo('FireflyIII\User'); + return $this->belongsTo(User::class); } } diff --git a/app/Models/AccountMeta.php b/app/Models/AccountMeta.php index c98e4780da..aa5bb522fd 100644 --- a/app/Models/AccountMeta.php +++ b/app/Models/AccountMeta.php @@ -24,6 +24,7 @@ namespace FireflyIII\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use FireflyIII\Models\Account; /** * Class AccountMeta. @@ -53,7 +54,7 @@ class AccountMeta extends Model */ public function account(): BelongsTo { - return $this->belongsTo('FireflyIII\Models\Account'); + return $this->belongsTo(Account::class); } /** diff --git a/app/Models/AccountType.php b/app/Models/AccountType.php index 09402789c7..5602821e59 100644 --- a/app/Models/AccountType.php +++ b/app/Models/AccountType.php @@ -24,6 +24,7 @@ namespace FireflyIII\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; +use FireflyIII\Models\Account; /** * Class AccountType. @@ -89,6 +90,6 @@ class AccountType extends Model */ public function accounts(): HasMany { - return $this->hasMany('FireflyIII\Models\Account'); + return $this->hasMany(Account::class); } } diff --git a/app/Models/Attachment.php b/app/Models/Attachment.php index 3e6c3e81be..2c1a1e61b6 100644 --- a/app/Models/Attachment.php +++ b/app/Models/Attachment.php @@ -28,6 +28,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\MorphTo; use Illuminate\Database\Eloquent\SoftDeletes; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use FireflyIII\User; /** * Class Attachment. @@ -101,7 +102,7 @@ class Attachment extends Model */ public function getDescriptionAttribute($value) { - if (null === $value || 0 === strlen($value)) { + if (null === $value || 0 === \strlen($value)) { return null; } @@ -117,7 +118,7 @@ class Attachment extends Model */ public function getFilenameAttribute($value) { - if (null === $value || 0 === strlen($value)) { + if (null === $value || 0 === \strlen($value)) { return null; } @@ -133,7 +134,7 @@ class Attachment extends Model */ public function getMimeAttribute($value) { - if (null === $value || 0 === strlen($value)) { + if (null === $value || 0 === \strlen($value)) { return null; } @@ -149,7 +150,7 @@ class Attachment extends Model */ public function getTitleAttribute($value) { - if (null === $value || 0 === strlen($value)) { + if (null === $value || 0 === \strlen($value)) { return null; } @@ -219,6 +220,6 @@ class Attachment extends Model */ public function user(): BelongsTo { - return $this->belongsTo('FireflyIII\User'); + return $this->belongsTo(User::class); } } diff --git a/app/Models/AvailableBudget.php b/app/Models/AvailableBudget.php index b936a1a580..1e74d00af1 100644 --- a/app/Models/AvailableBudget.php +++ b/app/Models/AvailableBudget.php @@ -25,6 +25,8 @@ namespace FireflyIII\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\SoftDeletes; +use FireflyIII\User; +use FireflyIII\Models\TransactionCurrency; /** * Class AvailableBudget. @@ -54,7 +56,7 @@ class AvailableBudget extends Model */ public function transactionCurrency() { - return $this->belongsTo('FireflyIII\Models\TransactionCurrency'); + return $this->belongsTo(TransactionCurrency::class); } /** @@ -63,6 +65,6 @@ class AvailableBudget extends Model */ public function user(): BelongsTo { - return $this->belongsTo('FireflyIII\User'); + return $this->belongsTo(User::class); } } diff --git a/app/Models/Bill.php b/app/Models/Bill.php index 73e5d93b49..e42126e39d 100644 --- a/app/Models/Bill.php +++ b/app/Models/Bill.php @@ -29,6 +29,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\SoftDeletes; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use FireflyIII\Models\Attachment; /** * Class Bill. @@ -88,7 +89,7 @@ class Bill extends Model */ public function attachments() { - return $this->morphMany('FireflyIII\Models\Attachment', 'attachable'); + return $this->morphMany(Attachment::class, 'attachable'); } /** diff --git a/app/Models/Budget.php b/app/Models/Budget.php index 2ef3a9ded5..6fc3e3d6f4 100644 --- a/app/Models/Budget.php +++ b/app/Models/Budget.php @@ -27,6 +27,10 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\SoftDeletes; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use FireflyIII\User; +use FireflyIII\Models\Transaction; +use FireflyIII\Models\TransactionJournal; +use FireflyIII\Models\BudgetLimit; /** * Class Budget. @@ -105,7 +109,7 @@ class Budget extends Model */ public function budgetlimits() { - return $this->hasMany('FireflyIII\Models\BudgetLimit'); + return $this->hasMany(BudgetLimit::class); } /** @@ -145,7 +149,7 @@ class Budget extends Model */ public function transactionJournals() { - return $this->belongsToMany('FireflyIII\Models\TransactionJournal', 'budget_transaction_journal', 'budget_id'); + return $this->belongsToMany(TransactionJournal::class, 'budget_transaction_journal', 'budget_id'); } /** @@ -154,7 +158,7 @@ class Budget extends Model */ public function transactions() { - return $this->belongsToMany('FireflyIII\Models\Transaction', 'budget_transaction', 'budget_id'); + return $this->belongsToMany(Transaction::class, 'budget_transaction', 'budget_id'); } /** @@ -163,6 +167,6 @@ class Budget extends Model */ public function user(): BelongsTo { - return $this->belongsTo('FireflyIII\User'); + return $this->belongsTo(User::class); } } diff --git a/app/Models/BudgetLimit.php b/app/Models/BudgetLimit.php index 4a1070f876..615c2d90ee 100644 --- a/app/Models/BudgetLimit.php +++ b/app/Models/BudgetLimit.php @@ -24,6 +24,7 @@ namespace FireflyIII\Models; use Illuminate\Database\Eloquent\Model; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use FireflyIII\Models\Budget; /** * Class BudgetLimit. @@ -71,7 +72,7 @@ class BudgetLimit extends Model */ public function budget() { - return $this->belongsTo('FireflyIII\Models\Budget'); + return $this->belongsTo(Budget::class); } /** diff --git a/app/Models/Category.php b/app/Models/Category.php index 85a68a5cdd..2e2f0aaf26 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -27,6 +27,9 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\SoftDeletes; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use FireflyIII\User; +use FireflyIII\Models\Transaction; +use FireflyIII\Models\TransactionJournal; /** * Class Category. @@ -135,7 +138,7 @@ class Category extends Model */ public function transactionJournals() { - return $this->belongsToMany('FireflyIII\Models\TransactionJournal', 'category_transaction_journal', 'category_id'); + return $this->belongsToMany(TransactionJournal::class, 'category_transaction_journal', 'category_id'); } /** @@ -144,7 +147,7 @@ class Category extends Model */ public function transactions() { - return $this->belongsToMany('FireflyIII\Models\Transaction', 'category_transaction', 'category_id'); + return $this->belongsToMany(Transaction::class, 'category_transaction', 'category_id'); } /** @@ -153,6 +156,6 @@ class Category extends Model */ public function user(): BelongsTo { - return $this->belongsTo('FireflyIII\User'); + return $this->belongsTo(User::class); } } diff --git a/app/Models/ExportJob.php b/app/Models/ExportJob.php index 03ec4c5816..5e671cc1f0 100644 --- a/app/Models/ExportJob.php +++ b/app/Models/ExportJob.php @@ -77,6 +77,6 @@ class ExportJob extends Model */ public function user() { - return $this->belongsTo('FireflyIII\User'); + return $this->belongsTo(User::class); } } diff --git a/app/Models/ImportJob.php b/app/Models/ImportJob.php index 84364547e1..a984176a9b 100644 --- a/app/Models/ImportJob.php +++ b/app/Models/ImportJob.php @@ -75,7 +75,7 @@ class ImportJob extends Model $importJob = auth()->user()->importJobs()->where('key', $key)->first(); if (null !== $importJob) { // must have valid status: - if (!in_array($importJob->status, $importJob->validStatus)) { + if (!\in_array($importJob->status, $importJob->validStatus)) { throw new FireflyException(sprintf('ImportJob with key "%s" has invalid status "%s"', $importJob->key, $importJob->status)); } @@ -104,7 +104,7 @@ class ImportJob extends Model */ public function change(string $status): void { - if (in_array($status, $this->validStatus)) { + if (\in_array($status, $this->validStatus)) { Log::debug(sprintf('Job status set (in model) to "%s"', $status)); $this->status = $status; $this->save(); @@ -125,7 +125,7 @@ class ImportJob extends Model if (null === $value) { return []; } - if (0 === strlen($value)) { + if (0 === \strlen($value)) { return []; } @@ -139,7 +139,7 @@ class ImportJob extends Model */ public function getExtendedStatusAttribute($value) { - if (0 === strlen((string)$value)) { + if (0 === \strlen((string)$value)) { return []; } @@ -171,7 +171,7 @@ class ImportJob extends Model */ public function setStatusAttribute(string $value) { - if (in_array($value, $this->validStatus)) { + if (\in_array($value, $this->validStatus)) { $this->attributes['status'] = $value; } } @@ -189,7 +189,7 @@ class ImportJob extends Model $encryptedContent = $disk->get($fileName); $content = Crypt::decrypt($encryptedContent); $content = trim($content); - Log::debug(sprintf('Content size is %d bytes.', strlen($content))); + Log::debug(sprintf('Content size is %d bytes.', \strlen($content))); return $content; } @@ -200,6 +200,6 @@ class ImportJob extends Model */ public function user() { - return $this->belongsTo('FireflyIII\User'); + return $this->belongsTo(User::class); } } diff --git a/app/Models/PiggyBank.php b/app/Models/PiggyBank.php index ce24a63b30..eefd0d0706 100644 --- a/app/Models/PiggyBank.php +++ b/app/Models/PiggyBank.php @@ -29,6 +29,10 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\SoftDeletes; use Steam; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use FireflyIII\Models\PiggyBankRepetition; +use FireflyIII\Models\PiggyBankEvent; +use FireflyIII\Models\Note; +use FireflyIII\Models\Account; /** * Class PiggyBank. @@ -86,7 +90,7 @@ class PiggyBank extends Model */ public function account(): BelongsTo { - return $this->belongsTo('FireflyIII\Models\Account'); + return $this->belongsTo(Account::class); } /** @@ -179,7 +183,7 @@ class PiggyBank extends Model */ public function notes() { - return $this->morphMany('FireflyIII\Models\Note', 'noteable'); + return $this->morphMany(Note::class, 'noteable'); } /** @@ -188,7 +192,7 @@ class PiggyBank extends Model */ public function piggyBankEvents() { - return $this->hasMany('FireflyIII\Models\PiggyBankEvent'); + return $this->hasMany(PiggyBankEvent::class); } /** @@ -197,7 +201,7 @@ class PiggyBank extends Model */ public function piggyBankRepetitions() { - return $this->hasMany('FireflyIII\Models\PiggyBankRepetition'); + return $this->hasMany(PiggyBankRepetition::class); } /** diff --git a/app/Models/PiggyBankEvent.php b/app/Models/PiggyBankEvent.php index 3dec5e720c..9463fcc39c 100644 --- a/app/Models/PiggyBankEvent.php +++ b/app/Models/PiggyBankEvent.php @@ -23,6 +23,8 @@ declare(strict_types=1); namespace FireflyIII\Models; use Illuminate\Database\Eloquent\Model; +use FireflyIII\Models\TransactionJournal; +use FireflyIII\Models\PiggyBank; /** * Class PiggyBankEvent. @@ -59,7 +61,7 @@ class PiggyBankEvent extends Model */ public function piggyBank() { - return $this->belongsTo('FireflyIII\Models\PiggyBank'); + return $this->belongsTo(PiggyBank::class); } /** @@ -78,6 +80,6 @@ class PiggyBankEvent extends Model */ public function transactionJournal() { - return $this->belongsTo('FireflyIII\Models\TransactionJournal'); + return $this->belongsTo(TransactionJournal::class); } } diff --git a/app/Models/PiggyBankRepetition.php b/app/Models/PiggyBankRepetition.php index 4b3d98a3b6..c1644456f4 100644 --- a/app/Models/PiggyBankRepetition.php +++ b/app/Models/PiggyBankRepetition.php @@ -25,6 +25,7 @@ namespace FireflyIII\Models; use Carbon\Carbon; use Illuminate\Database\Eloquent\Builder as EloquentBuilder; use Illuminate\Database\Eloquent\Model; +use FireflyIII\Models\PiggyBank; /** * Class PiggyBankRepetition. @@ -55,7 +56,7 @@ class PiggyBankRepetition extends Model */ public function piggyBank() { - return $this->belongsTo('FireflyIII\Models\PiggyBank'); + return $this->belongsTo(PiggyBank::class); } /** diff --git a/app/Models/Role.php b/app/Models/Role.php index 339ed95f41..02fcfb5a5d 100644 --- a/app/Models/Role.php +++ b/app/Models/Role.php @@ -24,6 +24,7 @@ namespace FireflyIII\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsToMany; +use FireflyIII\User; /** * Class Role. @@ -52,6 +53,6 @@ class Role extends Model */ public function users(): BelongsToMany { - return $this->belongsToMany('FireflyIII\User'); + return $this->belongsToMany(User::class); } } diff --git a/app/Models/Rule.php b/app/Models/Rule.php index f9178b06b5..ed2d1161bb 100644 --- a/app/Models/Rule.php +++ b/app/Models/Rule.php @@ -25,6 +25,10 @@ namespace FireflyIII\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use FireflyIII\User; +use FireflyIII\Models\RuleTrigger; +use FireflyIII\Models\RuleGroup; +use FireflyIII\Models\RuleAction; /** * Class Rule. @@ -75,7 +79,7 @@ class Rule extends Model */ public function ruleActions() { - return $this->hasMany('FireflyIII\Models\RuleAction'); + return $this->hasMany(RuleAction::class); } /** @@ -84,7 +88,7 @@ class Rule extends Model */ public function ruleGroup() { - return $this->belongsTo('FireflyIII\Models\RuleGroup'); + return $this->belongsTo(RuleGroup::class); } /** @@ -93,7 +97,7 @@ class Rule extends Model */ public function ruleTriggers() { - return $this->hasMany('FireflyIII\Models\RuleTrigger'); + return $this->hasMany(RuleTrigger::class); } /** @@ -110,6 +114,6 @@ class Rule extends Model */ public function user() { - return $this->belongsTo('FireflyIII\User'); + return $this->belongsTo(User::class); } } diff --git a/app/Models/RuleAction.php b/app/Models/RuleAction.php index 6586610f67..d498ee11f6 100644 --- a/app/Models/RuleAction.php +++ b/app/Models/RuleAction.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Models; use Illuminate\Database\Eloquent\Model; +use FireflyIII\Models\Rule; /** * Class RuleAction. @@ -52,6 +53,6 @@ class RuleAction extends Model */ public function rule() { - return $this->belongsTo('FireflyIII\Models\Rule'); + return $this->belongsTo(Rule::class); } } diff --git a/app/Models/RuleGroup.php b/app/Models/RuleGroup.php index d9355a24a6..f16c6079ae 100644 --- a/app/Models/RuleGroup.php +++ b/app/Models/RuleGroup.php @@ -25,6 +25,8 @@ namespace FireflyIII\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use FireflyIII\User; +use FireflyIII\Models\Rule; /** * Class RuleGroup. @@ -75,7 +77,7 @@ class RuleGroup extends Model */ public function rules() { - return $this->hasMany('FireflyIII\Models\Rule'); + return $this->hasMany(Rule::class); } /** @@ -84,6 +86,6 @@ class RuleGroup extends Model */ public function user() { - return $this->belongsTo('FireflyIII\User'); + return $this->belongsTo(User::class); } } diff --git a/app/Models/RuleTrigger.php b/app/Models/RuleTrigger.php index e52fd4340c..3b68656a91 100644 --- a/app/Models/RuleTrigger.php +++ b/app/Models/RuleTrigger.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Models; use Illuminate\Database\Eloquent\Model; +use FireflyIII\Models\Rule; /** * Class RuleTrigger. @@ -52,6 +53,6 @@ class RuleTrigger extends Model */ public function rule() { - return $this->belongsTo('FireflyIII\Models\Rule'); + return $this->belongsTo(Rule::class); } } diff --git a/app/Models/Tag.php b/app/Models/Tag.php index 8c4b93d36e..11a9d8fadd 100644 --- a/app/Models/Tag.php +++ b/app/Models/Tag.php @@ -26,6 +26,8 @@ use Crypt; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use FireflyIII\User; +use FireflyIII\Models\TransactionJournal; /** * Class Tag. @@ -166,7 +168,7 @@ class Tag extends Model */ public function transactionJournals() { - return $this->belongsToMany('FireflyIII\Models\TransactionJournal'); + return $this->belongsToMany(TransactionJournal::class); } /** @@ -175,6 +177,6 @@ class Tag extends Model */ public function user() { - return $this->belongsTo('FireflyIII\User'); + return $this->belongsTo(User::class); } } diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index 77ba6c8b1d..14ed95095b 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -27,6 +27,11 @@ use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use FireflyIII\Models\TransactionJournal; +use FireflyIII\Models\TransactionCurrency; +use FireflyIII\Models\Category; +use FireflyIII\Models\Budget; +use FireflyIII\Models\Account; /** * Class Transaction. @@ -149,7 +154,7 @@ class Transaction extends Model */ public function account() { - return $this->belongsTo('FireflyIII\Models\Account'); + return $this->belongsTo(Account::class); } /** @@ -158,7 +163,7 @@ class Transaction extends Model */ public function budgets() { - return $this->belongsToMany('FireflyIII\Models\Budget'); + return $this->belongsToMany(Budget::class); } /** @@ -167,7 +172,7 @@ class Transaction extends Model */ public function categories() { - return $this->belongsToMany('FireflyIII\Models\Category'); + return $this->belongsToMany(Category::class); } /** @@ -176,7 +181,7 @@ class Transaction extends Model */ public function foreignCurrency() { - return $this->belongsTo('FireflyIII\Models\TransactionCurrency', 'foreign_currency_id'); + return $this->belongsTo(TransactionCurrency::class, 'foreign_currency_id'); } /** @@ -253,7 +258,7 @@ class Transaction extends Model */ public function transactionCurrency() { - return $this->belongsTo('FireflyIII\Models\TransactionCurrency'); + return $this->belongsTo(TransactionCurrency::class); } /** @@ -262,6 +267,6 @@ class Transaction extends Model */ public function transactionJournal() { - return $this->belongsTo('FireflyIII\Models\TransactionJournal'); + return $this->belongsTo(TransactionJournal::class); } } diff --git a/app/Models/TransactionCurrency.php b/app/Models/TransactionCurrency.php index afbddc2012..ef74e55f19 100644 --- a/app/Models/TransactionCurrency.php +++ b/app/Models/TransactionCurrency.php @@ -25,6 +25,7 @@ namespace FireflyIII\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use FireflyIII\Models\TransactionJournal; /** * Class TransactionCurrency. @@ -77,6 +78,6 @@ class TransactionCurrency extends Model */ public function transactionJournals() { - return $this->hasMany('FireflyIII\Models\TransactionJournal'); + return $this->hasMany(TransactionJournal::class); } } diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php index acfbb2ef75..6432d371b4 100644 --- a/app/Models/TransactionJournal.php +++ b/app/Models/TransactionJournal.php @@ -35,6 +35,17 @@ use Illuminate\Database\Eloquent\SoftDeletes; use Log; use Preferences; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use FireflyIII\Models\Transaction; +use FireflyIII\Models\TransactionType; +use FireflyIII\Models\TransactionJournalMeta; +use FireflyIII\Models\TransactionCurrency; +use FireflyIII\Models\Tag; +use FireflyIII\Models\PiggyBankEvent; +use FireflyIII\Models\Note; +use FireflyIII\Models\Category; +use FireflyIII\Models\Budget; +use FireflyIII\Models\Bill; +use FireflyIII\Models\Attachment; /** * Class TransactionJournal. @@ -99,7 +110,7 @@ class TransactionJournal extends Model */ public function attachments() { - return $this->morphMany('FireflyIII\Models\Attachment', 'attachable'); + return $this->morphMany(Attachment::class, 'attachable'); } /** @@ -108,7 +119,7 @@ class TransactionJournal extends Model */ public function bill() { - return $this->belongsTo('FireflyIII\Models\Bill'); + return $this->belongsTo(Bill::class); } /** @@ -117,7 +128,7 @@ class TransactionJournal extends Model */ public function budgets(): BelongsToMany { - return $this->belongsToMany('FireflyIII\Models\Budget'); + return $this->belongsToMany(Budget::class); } /** @@ -126,7 +137,7 @@ class TransactionJournal extends Model */ public function categories(): BelongsToMany { - return $this->belongsToMany('FireflyIII\Models\Category'); + return $this->belongsToMany(Category::class); } /** @@ -279,7 +290,7 @@ class TransactionJournal extends Model */ public function notes() { - return $this->morphMany('FireflyIII\Models\Note', 'noteable'); + return $this->morphMany(Note::class, 'noteable'); } /** @@ -288,7 +299,7 @@ class TransactionJournal extends Model */ public function piggyBankEvents(): HasMany { - return $this->hasMany('FireflyIII\Models\PiggyBankEvent'); + return $this->hasMany(PiggyBankEvent::class); } /** @@ -328,7 +339,7 @@ class TransactionJournal extends Model if (!self::isJoined($query, 'transaction_types')) { $query->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id'); } - if (count($types) > 0) { + if (\count($types) > 0) { $query->whereIn('transaction_types.type', $types); } } @@ -362,7 +373,7 @@ class TransactionJournal extends Model return new TransactionJournalMeta(); } - if (is_string($value) && 0 === strlen($value)) { + if (\is_string($value) && 0 === \strlen($value)) { $this->deleteMeta($name); return new TransactionJournalMeta(); @@ -401,7 +412,7 @@ class TransactionJournal extends Model */ public function tags() { - return $this->belongsToMany('FireflyIII\Models\Tag'); + return $this->belongsToMany(Tag::class); } /** @@ -410,7 +421,7 @@ class TransactionJournal extends Model */ public function transactionCurrency() { - return $this->belongsTo('FireflyIII\Models\TransactionCurrency'); + return $this->belongsTo(TransactionCurrency::class); } /** @@ -419,7 +430,7 @@ class TransactionJournal extends Model */ public function transactionJournalMeta(): HasMany { - return $this->hasMany('FireflyIII\Models\TransactionJournalMeta'); + return $this->hasMany(TransactionJournalMeta::class); } /** @@ -428,7 +439,7 @@ class TransactionJournal extends Model */ public function transactionType() { - return $this->belongsTo('FireflyIII\Models\TransactionType'); + return $this->belongsTo(TransactionType::class); } /** @@ -437,7 +448,7 @@ class TransactionJournal extends Model */ public function transactions(): HasMany { - return $this->hasMany('FireflyIII\Models\Transaction'); + return $this->hasMany(Transaction::class); } /** @@ -446,6 +457,6 @@ class TransactionJournal extends Model */ public function user() { - return $this->belongsTo('FireflyIII\User'); + return $this->belongsTo(User::class); } } diff --git a/app/Models/TransactionJournalLink.php b/app/Models/TransactionJournalLink.php index 6b9d1afd46..af47153390 100644 --- a/app/Models/TransactionJournalLink.php +++ b/app/Models/TransactionJournalLink.php @@ -113,7 +113,7 @@ class TransactionJournalLink extends Model */ public function setCommentAttribute($value): void { - if (null !== $value && strlen($value) > 0) { + if (null !== $value && \strlen($value) > 0) { $this->attributes['comment'] = Crypt::encrypt($value); return; diff --git a/app/Models/TransactionJournalMeta.php b/app/Models/TransactionJournalMeta.php index 3e87d48d0b..5016de36e2 100644 --- a/app/Models/TransactionJournalMeta.php +++ b/app/Models/TransactionJournalMeta.php @@ -25,6 +25,7 @@ namespace FireflyIII\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\SoftDeletes; +use FireflyIII\Models\TransactionJournal; /** * Class TransactionJournalMeta. @@ -78,6 +79,6 @@ class TransactionJournalMeta extends Model */ public function transactionJournal(): BelongsTo { - return $this->belongsTo('FireflyIII\Models\TransactionJournal'); + return $this->belongsTo(TransactionJournal::class); } } diff --git a/app/Models/TransactionType.php b/app/Models/TransactionType.php index fa1abdf690..dbbb775f7e 100644 --- a/app/Models/TransactionType.php +++ b/app/Models/TransactionType.php @@ -25,6 +25,7 @@ namespace FireflyIII\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use FireflyIII\Models\TransactionJournal; /** * Class TransactionType. @@ -127,6 +128,6 @@ class TransactionType extends Model */ public function transactionJournals() { - return $this->hasMany('FireflyIII\Models\TransactionJournal'); + return $this->hasMany(TransactionJournal::class); } } diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index 6b8551bc91..6c424d6c81 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -262,8 +262,6 @@ class AccountRepository implements AccountRepositoryInterface * @param array $data * * @return Account - * @throws \FireflyIII\Exceptions\FireflyException - * @throws \FireflyIII\Exceptions\FireflyException */ public function store(array $data): Account { @@ -279,8 +277,6 @@ class AccountRepository implements AccountRepositoryInterface * @param array $data * * @return Account - * @throws \FireflyIII\Exceptions\FireflyException - * @throws \FireflyIII\Exceptions\FireflyException */ public function update(Account $account, array $data): Account { diff --git a/app/Repositories/Account/FindAccountsTrait.php b/app/Repositories/Account/FindAccountsTrait.php index cf36898a51..d520af06fe 100644 --- a/app/Repositories/Account/FindAccountsTrait.php +++ b/app/Repositories/Account/FindAccountsTrait.php @@ -70,7 +70,7 @@ trait FindAccountsTrait ->where('account_meta.name', 'accountNumber') ->where('account_meta.data', json_encode($number)); - if (count($types) > 0) { + if (\count($types) > 0) { $query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id'); $query->whereIn('account_types.type', $types); } @@ -95,7 +95,7 @@ trait FindAccountsTrait { $query = $this->user->accounts()->where('iban', '!=', '')->whereNotNull('iban'); - if (count($types) > 0) { + if (\count($types) > 0) { $query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id'); $query->whereIn('account_types.type', $types); } @@ -121,7 +121,7 @@ trait FindAccountsTrait { $query = $this->user->accounts()->where('iban', '!=', '')->whereNotNull('iban'); - if (count($types) > 0) { + if (\count($types) > 0) { $query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id'); $query->whereIn('account_types.type', $types); } @@ -147,7 +147,7 @@ trait FindAccountsTrait { $query = $this->user->accounts(); - if (count($types) > 0) { + if (\count($types) > 0) { $query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id'); $query->whereIn('account_types.type', $types); } @@ -177,7 +177,7 @@ trait FindAccountsTrait /** @var Collection $result */ $query = $this->user->accounts(); - if (count($accountIds) > 0) { + if (\count($accountIds) > 0) { $query->whereIn('accounts.id', $accountIds); } @@ -200,7 +200,7 @@ trait FindAccountsTrait { /** @var Collection $result */ $query = $this->user->accounts(); - if (count($types) > 0) { + if (\count($types) > 0) { $query->accountTypeIn($types); } @@ -227,7 +227,7 @@ trait FindAccountsTrait $query->where('name', 'accountRole'); }] ); - if (count($types) > 0) { + if (\count($types) > 0) { $query->accountTypeIn($types); } $query->where('active', 1); diff --git a/app/Repositories/Attachment/AttachmentRepository.php b/app/Repositories/Attachment/AttachmentRepository.php index 5e4c913822..23cf6e9fad 100644 --- a/app/Repositories/Attachment/AttachmentRepository.php +++ b/app/Repositories/Attachment/AttachmentRepository.php @@ -44,8 +44,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface * @param Attachment $attachment * * @return bool - * - + * @throws \Exception */ public function destroy(Attachment $attachment): bool { @@ -146,7 +145,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface if ($disk->exists($file)) { $content = Crypt::decrypt($disk->get($file)); } - if (is_bool($content)) { + if (\is_bool($content)) { Log::error(sprintf('Attachment #%d may be corrupted: the content could not be decrypted.', $attachment->id)); return ''; @@ -203,7 +202,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface */ public function updateNote(Attachment $attachment, string $note): bool { - if (0 === strlen($note)) { + if (0 === \strlen($note)) { $dbNote = $attachment->notes()->first(); if (null !== $dbNote) { $dbNote->delete(); diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php index f7acc46d9f..a78481ddfb 100644 --- a/app/Repositories/Bill/BillRepository.php +++ b/app/Repositories/Bill/BillRepository.php @@ -555,37 +555,4 @@ class BillRepository implements BillRepositoryInterface return $service->update($bill, $data); } - /** - * @param float $amount - * @param float $min - * @param float $max - * - * @return bool - */ - protected function doAmountMatch($amount, $min, $max): bool - { - return $amount >= $min && $amount <= $max; - } - - /** - * @param array $matches - * @param $description - * - * @return bool - */ - protected function doWordMatch(array $matches, $description): bool - { - $wordMatch = false; - $count = 0; - foreach ($matches as $word) { - if (!(false === strpos($description, strtolower($word)))) { - ++$count; - } - } - if ($count >= count($matches)) { - $wordMatch = true; - } - - return $wordMatch; - } } diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php index 687f5afaef..903c2b0f27 100644 --- a/app/Repositories/Budget/BudgetRepository.php +++ b/app/Repositories/Budget/BudgetRepository.php @@ -156,8 +156,7 @@ class BudgetRepository implements BudgetRepositoryInterface * @param Budget $budget * * @return bool - * - + * @throws \Exception */ public function destroy(Budget $budget): bool { @@ -569,7 +568,7 @@ class BudgetRepository implements BudgetRepositoryInterface $set = $collector->getJournals(); - return strval($set->sum('transaction_amount')); + return (string)$set->sum('transaction_amount'); } /** @@ -604,7 +603,7 @@ class BudgetRepository implements BudgetRepositoryInterface } ); - return strval($set->sum('transaction_amount')); + return (string)$set->sum('transaction_amount'); } /** @@ -648,8 +647,7 @@ class BudgetRepository implements BudgetRepositoryInterface * @param string $amount * * @return BudgetLimit - * - + * @throws \Exception */ 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 94646bc84e..82964375f8 100644 --- a/app/Repositories/Category/CategoryRepository.php +++ b/app/Repositories/Category/CategoryRepository.php @@ -75,7 +75,7 @@ class CategoryRepository implements CategoryRepositoryInterface $collector->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->setAccounts($accounts)->setCategories($categories); $set = $collector->getJournals(); - return strval($set->sum('transaction_amount')); + return (string)$set->sum('transaction_amount'); } /** @@ -400,7 +400,7 @@ class CategoryRepository implements CategoryRepositoryInterface $set = $collector->getJournals(); - return strval($set->sum('transaction_amount')); + return (string)$set->sum('transaction_amount'); } /** @@ -435,7 +435,7 @@ class CategoryRepository implements CategoryRepositoryInterface } ); - return strval($set->sum('transaction_amount')); + return (string)$set->sum('transaction_amount'); } /** diff --git a/app/Repositories/ExportJob/ExportJobRepository.php b/app/Repositories/ExportJob/ExportJobRepository.php index 20a01c9cf4..f124b8291d 100644 --- a/app/Repositories/ExportJob/ExportJobRepository.php +++ b/app/Repositories/ExportJob/ExportJobRepository.php @@ -53,8 +53,7 @@ class ExportJobRepository implements ExportJobRepositoryInterface /** * @return bool - * - + * @throws \Exception */ public function cleanup(): bool { @@ -67,7 +66,7 @@ class ExportJobRepository implements ExportJobRepositoryInterface /** @var ExportJob $entry */ foreach ($set as $entry) { $key = $entry->key; - $len = strlen($key); + $len = \strlen($key); $files = scandir(storage_path('export'), SCANDIR_SORT_NONE); /** @var string $file */ foreach ($files as $file) { diff --git a/app/Repositories/ImportJob/ImportJobRepository.php b/app/Repositories/ImportJob/ImportJobRepository.php index 821a511b54..353c33e9bb 100644 --- a/app/Repositories/ImportJob/ImportJobRepository.php +++ b/app/Repositories/ImportJob/ImportJobRepository.php @@ -171,7 +171,7 @@ class ImportJobRepository implements ImportJobRepositoryInterface public function getConfiguration(ImportJob $job): array { $config = $job->configuration; - if (is_array($config)) { + if (\is_array($config)) { return $config; } @@ -188,7 +188,7 @@ class ImportJobRepository implements ImportJobRepositoryInterface public function getExtendedStatus(ImportJob $job): array { $status = $job->extended_status; - if (is_array($status)) { + if (\is_array($status)) { return $status; } @@ -226,7 +226,7 @@ class ImportJobRepository implements ImportJobRepositoryInterface $configRaw = $configFileObject->fread($configFileObject->getSize()); $configuration = json_decode($configRaw, true); Log::debug(sprintf('Raw configuration is %s', $configRaw)); - if (null !== $configuration && is_array($configuration)) { + if (null !== $configuration && \is_array($configuration)) { Log::debug('Found configuration', $configuration); $this->setConfiguration($job, $configuration); } diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php index 002f6ea03e..43081d4058 100644 --- a/app/Repositories/Journal/JournalRepository.php +++ b/app/Repositories/Journal/JournalRepository.php @@ -467,7 +467,7 @@ class JournalRepository implements JournalRepositoryInterface $value = $entry->data; // return when array: - if (is_array($value)) { + if (\is_array($value)) { $return = implode(',', $value); $cache->store($return); @@ -661,7 +661,6 @@ class JournalRepository implements JournalRepositoryInterface ] ); - return; } /** @@ -683,7 +682,6 @@ class JournalRepository implements JournalRepositoryInterface ] ); - return; } /** diff --git a/app/Repositories/LinkType/LinkTypeRepository.php b/app/Repositories/LinkType/LinkTypeRepository.php index 6303e97baf..a4eb99cff6 100644 --- a/app/Repositories/LinkType/LinkTypeRepository.php +++ b/app/Repositories/LinkType/LinkTypeRepository.php @@ -54,8 +54,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface * @param LinkType $moveTo * * @return bool - * - + * @throws \Exception */ public function destroy(LinkType $linkType, LinkType $moveTo): bool { @@ -71,8 +70,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface * @param TransactionJournalLink $link * * @return bool - * - + * @throws \Exception */ public function destroyLink(TransactionJournalLink $link): bool { @@ -199,7 +197,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface $link->save(); // make note in noteable: - if (strlen($information['notes']) > 0) { + if (\strlen($information['notes']) > 0) { $dbNote = $link->notes()->first(); if (null === $dbNote) { $dbNote = new Note(); diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php index 005dcd7023..2612cf245c 100644 --- a/app/Repositories/PiggyBank/PiggyBankRepository.php +++ b/app/Repositories/PiggyBank/PiggyBankRepository.php @@ -143,8 +143,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface * @param PiggyBank $piggyBank * * @return bool - * - + * @throws \Exception */ public function destroy(PiggyBank $piggyBank): bool { @@ -238,7 +237,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface Log::debug(sprintf('Will add/remove %f to piggy bank #%d ("%s")', $amount, $piggyBank->id, $piggyBank->name)); // if piggy account matches source account, the amount is positive - if (in_array($piggyBank->account_id, $sources)) { + if (\in_array($piggyBank->account_id, $sources)) { $amount = bcmul($amount, '-1'); Log::debug(sprintf('Account #%d is the source, so will remove amount from piggy bank.', $piggyBank->account_id)); } @@ -456,7 +455,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface */ private function updateNote(PiggyBank $piggyBank, string $note): bool { - if (0 === strlen($note)) { + if (0 === \strlen($note)) { $dbNote = $piggyBank->notes()->first(); if (null !== $dbNote) { $dbNote->delete(); diff --git a/app/Repositories/Rule/RuleRepository.php b/app/Repositories/Rule/RuleRepository.php index 50154ae2bc..f6cd24e1c0 100644 --- a/app/Repositories/Rule/RuleRepository.php +++ b/app/Repositories/Rule/RuleRepository.php @@ -49,7 +49,7 @@ class RuleRepository implements RuleRepositoryInterface * @param Rule $rule * * @return bool - * + * @throws \Exception */ public function destroy(Rule $rule): bool { @@ -261,7 +261,7 @@ class RuleRepository implements RuleRepositoryInterface $rule->strict = $data['strict'] ?? false; $rule->stop_processing = 1 === (int)$data['stop_processing']; $rule->title = $data['title']; - $rule->description = strlen($data['description']) > 0 ? $data['description'] : null; + $rule->description = \strlen($data['description']) > 0 ? $data['description'] : null; $rule->save(); diff --git a/app/Repositories/RuleGroup/RuleGroupRepository.php b/app/Repositories/RuleGroup/RuleGroupRepository.php index a693894aab..a63c5d8d93 100644 --- a/app/Repositories/RuleGroup/RuleGroupRepository.php +++ b/app/Repositories/RuleGroup/RuleGroupRepository.php @@ -49,7 +49,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface * @param RuleGroup|null $moveTo * * @return bool - * + * @throws \Exception */ public function destroy(RuleGroup $ruleGroup, ?RuleGroup $moveTo): bool { diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.php index 0bca55405a..e893ec152e 100644 --- a/app/Repositories/Tag/TagRepository.php +++ b/app/Repositories/Tag/TagRepository.php @@ -75,8 +75,7 @@ class TagRepository implements TagRepositoryInterface * @param Tag $tag * * @return bool - * - + * @throws \Exception */ public function destroy(Tag $tag): bool { @@ -100,7 +99,7 @@ class TagRepository implements TagRepositoryInterface $collector->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->setAllAssetAccounts()->setTag($tag); $set = $collector->getJournals(); - return strval($set->sum('transaction_amount')); + return (string)$set->sum('transaction_amount'); } /** @@ -223,7 +222,7 @@ class TagRepository implements TagRepositoryInterface $collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setAllAssetAccounts()->setTag($tag); $set = $collector->getJournals(); - return strval($set->sum('transaction_amount')); + return (string)$set->sum('transaction_amount'); } /** @@ -354,7 +353,7 @@ class TagRepository implements TagRepositoryInterface /** @var Tag $tag */ foreach ($result as $tag) { $tagsWithAmounts[$tag->id] = (string)$tag->amount_sum; - $amount = strlen($tagsWithAmounts[$tag->id]) ? $tagsWithAmounts[$tag->id] : '0'; + $amount = \strlen($tagsWithAmounts[$tag->id]) ? $tagsWithAmounts[$tag->id] : '0'; if (null === $min) { $min = $amount; } diff --git a/app/Repositories/User/UserRepository.php b/app/Repositories/User/UserRepository.php index a18e4617ae..8b26d88ef5 100644 --- a/app/Repositories/User/UserRepository.php +++ b/app/Repositories/User/UserRepository.php @@ -144,8 +144,7 @@ class UserRepository implements UserRepositoryInterface * @param User $user * * @return bool - * - + * @throws \Exception */ public function destroy(User $user): bool { @@ -294,7 +293,6 @@ class UserRepository implements UserRepositoryInterface $user->blocked_code = ''; $user->save(); - return; } /** diff --git a/app/Rules/BelongsUser.php b/app/Rules/BelongsUser.php index facf3c0b98..91acc6cc54 100644 --- a/app/Rules/BelongsUser.php +++ b/app/Rules/BelongsUser.php @@ -159,10 +159,10 @@ class BelongsUser implements Rule private function parseAttribute(string $attribute): string { $parts = explode('.', $attribute); - if (count($parts) === 1) { + if (\count($parts) === 1) { return $attribute; } - if (count($parts) === 3) { + if (\count($parts) === 3) { return $parts[2]; } diff --git a/app/Rules/ValidTransactions.php b/app/Rules/ValidTransactions.php index 471e328d89..d60f4cc679 100644 --- a/app/Rules/ValidTransactions.php +++ b/app/Rules/ValidTransactions.php @@ -64,7 +64,7 @@ class ValidTransactions implements Rule public function passes($attribute, $value) { Log::debug('In ValidTransactions::passes'); - if (!is_array($value)) { + if (!\is_array($value)) { return true; } $userId = auth()->user()->id; diff --git a/app/Services/Bunq/Object/Alias.php b/app/Services/Bunq/Object/Alias.php index bb3f971a5a..0c29f74136 100644 --- a/app/Services/Bunq/Object/Alias.php +++ b/app/Services/Bunq/Object/Alias.php @@ -44,8 +44,6 @@ class Alias extends BunqObject $this->type = $data['type']; $this->name = $data['name']; $this->value = $data['value']; - - return; } /** diff --git a/app/Services/Bunq/Object/Amount.php b/app/Services/Bunq/Object/Amount.php index 64da7a7416..ec93a1d88b 100644 --- a/app/Services/Bunq/Object/Amount.php +++ b/app/Services/Bunq/Object/Amount.php @@ -42,7 +42,6 @@ class Amount extends BunqObject $this->currency = $data['currency']; $this->value = $data['value']; - return; } /** diff --git a/app/Services/Bunq/Object/DeviceServer.php b/app/Services/Bunq/Object/DeviceServer.php index 486c2e74de..2fd34992ee 100644 --- a/app/Services/Bunq/Object/DeviceServer.php +++ b/app/Services/Bunq/Object/DeviceServer.php @@ -81,6 +81,7 @@ class DeviceServer extends BunqObject /** * @return array + * @throws FireflyException */ public function toArray(): array { diff --git a/app/Services/Bunq/Object/LabelMonetaryAccount.php b/app/Services/Bunq/Object/LabelMonetaryAccount.php index 7bc61a4442..f9d89a456d 100644 --- a/app/Services/Bunq/Object/LabelMonetaryAccount.php +++ b/app/Services/Bunq/Object/LabelMonetaryAccount.php @@ -73,6 +73,7 @@ class LabelMonetaryAccount extends BunqObject /** * @return array + * @throws FireflyException */ public function toArray(): array { diff --git a/app/Services/Bunq/Object/LabelUser.php b/app/Services/Bunq/Object/LabelUser.php index a2b1f8cb39..d0a465a984 100644 --- a/app/Services/Bunq/Object/LabelUser.php +++ b/app/Services/Bunq/Object/LabelUser.php @@ -80,6 +80,7 @@ class LabelUser extends BunqObject /** * @return array + * @throws FireflyException */ public function toArray(): array { diff --git a/app/Services/Bunq/Object/MonetaryAccountProfile.php b/app/Services/Bunq/Object/MonetaryAccountProfile.php index 93d3dd5c2f..d81672ddd5 100644 --- a/app/Services/Bunq/Object/MonetaryAccountProfile.php +++ b/app/Services/Bunq/Object/MonetaryAccountProfile.php @@ -52,7 +52,6 @@ class MonetaryAccountProfile extends BunqObject $this->profileActionRequired = $data['profile_action_required']; $this->profileAmountRequired = new Amount($data['profile_amount_required']); - return; } /** diff --git a/app/Services/Bunq/Object/MonetaryAccountSetting.php b/app/Services/Bunq/Object/MonetaryAccountSetting.php index 449113b80c..0356b1aa83 100644 --- a/app/Services/Bunq/Object/MonetaryAccountSetting.php +++ b/app/Services/Bunq/Object/MonetaryAccountSetting.php @@ -45,7 +45,6 @@ class MonetaryAccountSetting extends BunqObject $this->defaultAvatarStatus = $data['default_avatar_status']; $this->restrictionChat = $data['restriction_chat']; - return; } /** diff --git a/app/Services/Bunq/Object/Payment.php b/app/Services/Bunq/Object/Payment.php index 98b91bcdb8..d9fb3072cd 100644 --- a/app/Services/Bunq/Object/Payment.php +++ b/app/Services/Bunq/Object/Payment.php @@ -135,6 +135,7 @@ class Payment extends BunqObject /** * @return array + * @throws FireflyException */ public function toArray(): array { diff --git a/app/Services/Bunq/Object/UserLight.php b/app/Services/Bunq/Object/UserLight.php index 0de5bee797..2ffed83609 100644 --- a/app/Services/Bunq/Object/UserLight.php +++ b/app/Services/Bunq/Object/UserLight.php @@ -60,7 +60,7 @@ class UserLight extends BunqObject */ public function __construct(array $data) { - if (0 === count($data)) { + if (0 === \count($data)) { return; } $this->id = (int)$data['id']; @@ -78,6 +78,7 @@ class UserLight extends BunqObject /** * @return array + * @throws FireflyException */ public function toArray(): array { diff --git a/app/Services/Bunq/Object/UserPerson.php b/app/Services/Bunq/Object/UserPerson.php index bcec433ebb..10a2737e20 100644 --- a/app/Services/Bunq/Object/UserPerson.php +++ b/app/Services/Bunq/Object/UserPerson.php @@ -120,7 +120,7 @@ class UserPerson extends BunqObject */ public function __construct(array $data) { - if (0 === count($data)) { + if (0 === \count($data)) { $this->created = new Carbon; $this->updated = new Carbon; $this->dateOfBirth = new Carbon; diff --git a/app/Services/Bunq/Request/BunqRequest.php b/app/Services/Bunq/Request/BunqRequest.php index a9ba838fba..f8a66a6347 100644 --- a/app/Services/Bunq/Request/BunqRequest.php +++ b/app/Services/Bunq/Request/BunqRequest.php @@ -119,7 +119,7 @@ abstract class BunqRequest */ protected function generateSignature(string $method, string $uri, array $headers, string $data): string { - if (0 === strlen($this->privateKey)) { + if (0 === \strlen($this->privateKey)) { throw new FireflyException('No private key present.'); } if ('get' === strtolower($method) || 'delete' === strtolower($method)) { @@ -133,7 +133,7 @@ abstract class BunqRequest $headersToSign = ['Cache-Control', 'User-Agent']; ksort($headers); foreach ($headers as $name => $value) { - if (in_array($name, $headersToSign) || 'X-Bunq-' === substr($name, 0, 7)) { + if (\in_array($name, $headersToSign) || 'X-Bunq-' === substr($name, 0, 7)) { $toSign .= sprintf("%s: %s\n", $name, $value); } } @@ -217,7 +217,7 @@ abstract class BunqRequest */ protected function sendSignedBunqDelete(string $uri, array $headers): array { - if (0 === strlen($this->server)) { + if (0 === \strlen($this->server)) { throw new FireflyException('No bunq server defined'); } @@ -263,7 +263,7 @@ abstract class BunqRequest */ protected function sendSignedBunqGet(string $uri, array $data, array $headers): array { - if (0 === strlen($this->server)) { + if (0 === \strlen($this->server)) { throw new FireflyException('No bunq server defined'); } @@ -508,12 +508,12 @@ abstract class BunqRequest $dataToVerify .= "\n" . $body; $result = openssl_verify($dataToVerify, base64_decode($signature), $this->serverPublicKey->getPublicKey(), OPENSSL_ALGO_SHA256); - if (is_int($result) && $result < 1) { + if (\is_int($result) && $result < 1) { Log::error(sprintf('Result of verification is %d, return false.', $result)); return false; } - if (!is_int($result)) { + if (!\is_int($result)) { Log::error(sprintf('Result of verification is a boolean (%d), return false.', $result)); return false; diff --git a/app/Services/Bunq/Request/DeleteDeviceSessionRequest.php b/app/Services/Bunq/Request/DeleteDeviceSessionRequest.php index 31567043cb..758d0531e9 100644 --- a/app/Services/Bunq/Request/DeleteDeviceSessionRequest.php +++ b/app/Services/Bunq/Request/DeleteDeviceSessionRequest.php @@ -43,7 +43,6 @@ class DeleteDeviceSessionRequest extends BunqRequest $headers['X-Bunq-Client-Authentication'] = $this->sessionToken->getToken(); $this->sendSignedBunqDelete($uri, $headers); - return; } /** diff --git a/app/Services/Bunq/Request/DeviceServerRequest.php b/app/Services/Bunq/Request/DeviceServerRequest.php index 236d0b3b94..5bb6f4e33f 100644 --- a/app/Services/Bunq/Request/DeviceServerRequest.php +++ b/app/Services/Bunq/Request/DeviceServerRequest.php @@ -55,8 +55,6 @@ class DeviceServerRequest extends BunqRequest $deviceServerId = new DeviceServerId; $deviceServerId->setId((int)$response['Response'][0]['Id']['id']); $this->deviceServerId = $deviceServerId; - - return; } /** diff --git a/app/Services/Bunq/Request/DeviceSessionRequest.php b/app/Services/Bunq/Request/DeviceSessionRequest.php index 5e559485d3..a8c34fe224 100644 --- a/app/Services/Bunq/Request/DeviceSessionRequest.php +++ b/app/Services/Bunq/Request/DeviceSessionRequest.php @@ -61,7 +61,6 @@ class DeviceSessionRequest extends BunqRequest $this->userPerson = $this->extractUserPerson($response); $this->userCompany = $this->extractUserCompany($response); - return; } /** diff --git a/app/Services/Bunq/Request/ListDeviceServerRequest.php b/app/Services/Bunq/Request/ListDeviceServerRequest.php index 1c7664379b..a143150ddf 100644 --- a/app/Services/Bunq/Request/ListDeviceServerRequest.php +++ b/app/Services/Bunq/Request/ListDeviceServerRequest.php @@ -58,7 +58,7 @@ class ListDeviceServerRequest extends BunqRequest Log::debug('Returned from sending device-server list request!'); // create device server objects: $raw = $this->getArrayFromResponse('DeviceServer', $response); - Log::debug(sprintf('Count %d entries in response array.', count($raw))); + Log::debug(sprintf('Count %d entries in response array.', \count($raw))); Log::debug('Full response', $response); /** @var array $entry */ foreach ($raw as $entry) { @@ -67,7 +67,6 @@ class ListDeviceServerRequest extends BunqRequest $this->devices->push($server); } - return; } /** diff --git a/app/Services/Bunq/Request/ListMonetaryAccountRequest.php b/app/Services/Bunq/Request/ListMonetaryAccountRequest.php index d51df9d792..6860a8a076 100644 --- a/app/Services/Bunq/Request/ListMonetaryAccountRequest.php +++ b/app/Services/Bunq/Request/ListMonetaryAccountRequest.php @@ -57,7 +57,6 @@ class ListMonetaryAccountRequest extends BunqRequest $this->monetaryAccounts->push($account); } - return; } /** diff --git a/app/Services/Bunq/Request/ListPaymentRequest.php b/app/Services/Bunq/Request/ListPaymentRequest.php index 5394ff928c..9b3eb4ac6f 100644 --- a/app/Services/Bunq/Request/ListPaymentRequest.php +++ b/app/Services/Bunq/Request/ListPaymentRequest.php @@ -70,7 +70,6 @@ class ListPaymentRequest extends BunqRequest } } - return; } /** diff --git a/app/Services/Bunq/Request/ListUserRequest.php b/app/Services/Bunq/Request/ListUserRequest.php index 9c5549df92..32b3cdf32c 100644 --- a/app/Services/Bunq/Request/ListUserRequest.php +++ b/app/Services/Bunq/Request/ListUserRequest.php @@ -59,7 +59,6 @@ class ListUserRequest extends BunqRequest $this->userCompany = new UserCompany($company); $this->userPerson = new UserPerson($person); - return; } /** diff --git a/app/Services/Currency/FixerIOv2.php b/app/Services/Currency/FixerIOv2.php index e037206fb4..67d4a77c82 100644 --- a/app/Services/Currency/FixerIOv2.php +++ b/app/Services/Currency/FixerIOv2.php @@ -60,7 +60,7 @@ class FixerIOv2 implements ExchangeRateInterface $apiKey = env('FIXER_API_KEY', ''); // if no API key, return unsaved exchange rate. - if (strlen($apiKey) === 0) { + if (\strlen($apiKey) === 0) { return $exchangeRate; } diff --git a/app/Services/Internal/Destroy/AccountDestroyService.php b/app/Services/Internal/Destroy/AccountDestroyService.php index 8006315735..d04c319515 100644 --- a/app/Services/Internal/Destroy/AccountDestroyService.php +++ b/app/Services/Internal/Destroy/AccountDestroyService.php @@ -65,8 +65,6 @@ class AccountDestroyService } catch (Exception $e) { // @codeCoverageIgnore Log::error(sprintf('Could not delete account: %s', $e->getMessage())); // @codeCoverageIgnore } - - return; } } diff --git a/app/Services/Internal/Destroy/JournalDestroyService.php b/app/Services/Internal/Destroy/JournalDestroyService.php index a85c988514..1adadb9e27 100644 --- a/app/Services/Internal/Destroy/JournalDestroyService.php +++ b/app/Services/Internal/Destroy/JournalDestroyService.php @@ -59,7 +59,6 @@ class JournalDestroyService Log::error(sprintf('Could not delete bill: %s', $e->getMessage())); // @codeCoverageIgnore } - return; } } diff --git a/app/Services/Internal/Support/AccountServiceTrait.php b/app/Services/Internal/Support/AccountServiceTrait.php index e555407fde..7fd65fb224 100644 --- a/app/Services/Internal/Support/AccountServiceTrait.php +++ b/app/Services/Internal/Support/AccountServiceTrait.php @@ -127,6 +127,7 @@ trait AccountServiceTrait * @param array $data * * @return TransactionJournal|null + * @throws \FireflyIII\Exceptions\FireflyException */ public function storeIBJournal(Account $account, array $data): ?TransactionJournal { @@ -330,7 +331,7 @@ trait AccountServiceTrait $entry = $account->accountMeta()->where('name', $field)->first(); // must not be an empty string: - if (isset($data[$field]) && strlen((string)$data[$field]) > 0) { + if (isset($data[$field]) && \strlen((string)$data[$field]) > 0) { // if $data has field and $entry is null, create new one: if (null === $entry) { @@ -357,7 +358,7 @@ trait AccountServiceTrait */ public function updateNote(Account $account, string $note): bool { - if (0 === strlen($note)) { + if (0 === \strlen($note)) { $dbNote = $account->notes()->first(); if (null !== $dbNote) { $dbNote->delete(); diff --git a/app/Services/Internal/Support/BillServiceTrait.php b/app/Services/Internal/Support/BillServiceTrait.php index d4ab545309..2f60a8cf39 100644 --- a/app/Services/Internal/Support/BillServiceTrait.php +++ b/app/Services/Internal/Support/BillServiceTrait.php @@ -68,7 +68,7 @@ trait BillServiceTrait */ public function updateNote(Bill $bill, string $note): bool { - if (0 === strlen($note)) { + if (0 === \strlen($note)) { $dbNote = $bill->notes()->first(); if (null !== $dbNote) { $dbNote->delete(); // @codeCoverageIgnore diff --git a/app/Services/Internal/Support/JournalServiceTrait.php b/app/Services/Internal/Support/JournalServiceTrait.php index f87e8dcf68..99e5376852 100644 --- a/app/Services/Internal/Support/JournalServiceTrait.php +++ b/app/Services/Internal/Support/JournalServiceTrait.php @@ -47,7 +47,7 @@ trait JournalServiceTrait $factory = app(TagFactory::class); $factory->setUser($journal->user); $set = []; - if (!is_array($data['tags'])) { + if (!\is_array($data['tags'])) { return; // @codeCoverageIgnore } foreach ($data['tags'] as $string) { @@ -81,7 +81,6 @@ trait JournalServiceTrait $journal->bill_id = null; $journal->save(); - return; } /** @@ -111,7 +110,7 @@ trait JournalServiceTrait protected function storeNote(TransactionJournal $journal, ?string $notes): void { $notes = (string)$notes; - if (strlen($notes) > 0) { + if (\strlen($notes) > 0) { $note = $journal->notes()->first(); if (null === $note) { $note = new Note; @@ -127,7 +126,6 @@ trait JournalServiceTrait $note->delete(); } - return; } } diff --git a/app/Services/Internal/Support/TransactionServiceTrait.php b/app/Services/Internal/Support/TransactionServiceTrait.php index 7346c5cd98..59cb9e6a49 100644 --- a/app/Services/Internal/Support/TransactionServiceTrait.php +++ b/app/Services/Internal/Support/TransactionServiceTrait.php @@ -128,7 +128,7 @@ trait TransactionServiceTrait // must be able to find it based on ID. Validator should catch invalid ID's. return $repository->findNull($accountId); } - if (strlen($accountName) > 0) { + if (\strlen($accountName) > 0) { /** @var AccountFactory $factory */ $factory = app(AccountFactory::class); $factory->setUser($this->user); @@ -144,7 +144,7 @@ trait TransactionServiceTrait // must be able to find it based on ID. Validator should catch invalid ID's. return $repository->findNull($accountId); } - if (strlen($accountName) > 0) { + if (\strlen($accountName) > 0) { // alternatively, return by name. /** @var AccountFactory $factory */ $factory = app(AccountFactory::class); @@ -222,7 +222,6 @@ trait TransactionServiceTrait } $transaction->budgets()->sync([$budget->id]); - return; } @@ -239,7 +238,6 @@ trait TransactionServiceTrait } $transaction->categories()->sync([$category->id]); - return; } @@ -269,7 +267,6 @@ trait TransactionServiceTrait $transaction->foreign_currency_id = $currency->id; $transaction->save(); - return; } diff --git a/app/Services/Internal/Update/AccountUpdateService.php b/app/Services/Internal/Update/AccountUpdateService.php index b66110e0d3..41eb9af480 100644 --- a/app/Services/Internal/Update/AccountUpdateService.php +++ b/app/Services/Internal/Update/AccountUpdateService.php @@ -70,7 +70,7 @@ class AccountUpdateService } // update note: - if (isset($data['notes']) && null !== $data['notes']) { + if (isset($data['notes'])) { $this->updateNote($account, (string)$data['notes']); } diff --git a/app/Services/Internal/Update/JournalUpdateService.php b/app/Services/Internal/Update/JournalUpdateService.php index 23ef433190..3964818fd5 100644 --- a/app/Services/Internal/Update/JournalUpdateService.php +++ b/app/Services/Internal/Update/JournalUpdateService.php @@ -62,7 +62,7 @@ class JournalUpdateService $factory = app(TransactionFactory::class); $factory->setUser($journal->user); - Log::debug(sprintf('Found %d rows in array (should result in %d transactions', count($data['transactions']), count($data['transactions']) * 2)); + Log::debug(sprintf('Found %d rows in array (should result in %d transactions', \count($data['transactions']), \count($data['transactions']) * 2)); /** * @var int $identifier @@ -97,7 +97,7 @@ class JournalUpdateService $journal->transactions()->where('identifier', $transaction->identifier)->delete(); } } - Log::debug(sprintf('New count is %d, transactions array held %d items', $journal->transactions()->count(), count($data['transactions']))); + Log::debug(sprintf('New count is %d, transactions array held %d items', $journal->transactions()->count(), \count($data['transactions']))); // connect bill: $this->connectBill($journal, $data); diff --git a/app/Services/Spectre/Request/CreateTokenRequest.php b/app/Services/Spectre/Request/CreateTokenRequest.php index 60ab35cd39..1705759daa 100644 --- a/app/Services/Spectre/Request/CreateTokenRequest.php +++ b/app/Services/Spectre/Request/CreateTokenRequest.php @@ -44,7 +44,6 @@ class CreateTokenRequest extends SpectreRequest /** * * @throws \FireflyIII\Exceptions\FireflyException - * @throws \FireflyIII\Services\Spectre\Exception\SpectreException */ public function call(): void { diff --git a/app/Services/Spectre/Request/ListAccountsRequest.php b/app/Services/Spectre/Request/ListAccountsRequest.php index 93191f9ed7..a1e87f72eb 100644 --- a/app/Services/Spectre/Request/ListAccountsRequest.php +++ b/app/Services/Spectre/Request/ListAccountsRequest.php @@ -40,7 +40,6 @@ class ListAccountsRequest extends SpectreRequest private $login; /** - * @throws SpectreException * @throws FireflyException */ public function call(): void @@ -54,7 +53,7 @@ class ListAccountsRequest extends SpectreRequest $response = $this->sendSignedSpectreGet($uri, []); // count entries: - Log::debug(sprintf('Found %d entries in data-array', count($response['data']))); + Log::debug(sprintf('Found %d entries in data-array', \count($response['data']))); // extract next ID $hasNextPage = false; diff --git a/app/Services/Spectre/Request/ListCustomersRequest.php b/app/Services/Spectre/Request/ListCustomersRequest.php index 809518a963..def720dc9a 100644 --- a/app/Services/Spectre/Request/ListCustomersRequest.php +++ b/app/Services/Spectre/Request/ListCustomersRequest.php @@ -38,7 +38,6 @@ class ListCustomersRequest extends SpectreRequest /** * * @throws \FireflyIII\Exceptions\FireflyException - * @throws \FireflyIII\Services\Spectre\Exception\SpectreException */ public function call(): void { @@ -51,7 +50,7 @@ class ListCustomersRequest extends SpectreRequest $response = $this->sendSignedSpectreGet($uri, []); // count entries: - Log::debug(sprintf('Found %d entries in data-array', count($response['data']))); + Log::debug(sprintf('Found %d entries in data-array', \count($response['data']))); // extract next ID $hasNextPage = false; diff --git a/app/Services/Spectre/Request/ListTransactionsRequest.php b/app/Services/Spectre/Request/ListTransactionsRequest.php index 59f62f4d11..dfa8c566ff 100644 --- a/app/Services/Spectre/Request/ListTransactionsRequest.php +++ b/app/Services/Spectre/Request/ListTransactionsRequest.php @@ -41,7 +41,6 @@ class ListTransactionsRequest extends SpectreRequest /** * @throws FireflyException - * @throws SpectreException */ public function call(): void { @@ -54,7 +53,7 @@ class ListTransactionsRequest extends SpectreRequest $response = $this->sendSignedSpectreGet($uri, []); // count entries: - Log::debug(sprintf('Found %d entries in data-array', count($response['data']))); + Log::debug(sprintf('Found %d entries in data-array', \count($response['data']))); // extract next ID $hasNextPage = false; diff --git a/app/Services/Spectre/Request/NewCustomerRequest.php b/app/Services/Spectre/Request/NewCustomerRequest.php index 0049487123..eea0b17c05 100644 --- a/app/Services/Spectre/Request/NewCustomerRequest.php +++ b/app/Services/Spectre/Request/NewCustomerRequest.php @@ -34,7 +34,6 @@ class NewCustomerRequest extends SpectreRequest /** * @throws \FireflyIII\Exceptions\FireflyException - * @throws \FireflyIII\Services\Spectre\Exception\SpectreException */ public function call(): void { diff --git a/app/Services/Spectre/Request/SpectreRequest.php b/app/Services/Spectre/Request/SpectreRequest.php index 8698ea12f8..2094fb8e3f 100644 --- a/app/Services/Spectre/Request/SpectreRequest.php +++ b/app/Services/Spectre/Request/SpectreRequest.php @@ -54,7 +54,6 @@ abstract class SpectreRequest * * @throws \Psr\Container\NotFoundExceptionInterface * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Illuminate\Container\EntryNotFoundException */ public function __construct(User $user) { diff --git a/app/Support/Binder/AccountList.php b/app/Support/Binder/AccountList.php index 085a7a43de..24b249db28 100644 --- a/app/Support/Binder/AccountList.php +++ b/app/Support/Binder/AccountList.php @@ -50,7 +50,7 @@ class AccountList implements BinderInterface $list[] = (int)$entry; } $list = array_unique($list); - if (count($list) === 0) { + if (\count($list) === 0) { Log::error('Account list is empty.'); throw new NotFoundHttpException; // @codeCoverageIgnore } diff --git a/app/Support/Binder/BudgetList.php b/app/Support/Binder/BudgetList.php index 2db96e1c51..374640b127 100644 --- a/app/Support/Binder/BudgetList.php +++ b/app/Support/Binder/BudgetList.php @@ -48,7 +48,7 @@ class BudgetList implements BinderInterface $list[] = (int)$entry; } $list = array_unique($list); - if (count($list) === 0) { + if (\count($list) === 0) { throw new NotFoundHttpException; // @codeCoverageIgnore } @@ -59,7 +59,7 @@ class BudgetList implements BinderInterface ->get(); // add empty budget if applicable. - if (in_array(0, $list)) { + if (\in_array(0, $list)) { $collection->push(new Budget); } diff --git a/app/Support/Binder/CategoryList.php b/app/Support/Binder/CategoryList.php index c8aa6c2cae..90bb36dfff 100644 --- a/app/Support/Binder/CategoryList.php +++ b/app/Support/Binder/CategoryList.php @@ -48,7 +48,7 @@ class CategoryList implements BinderInterface $list[] = (int)$entry; } $list = array_unique($list); - if (count($list) === 0) { + if (\count($list) === 0) { throw new NotFoundHttpException; // @codeCoverageIgnore } @@ -58,7 +58,7 @@ class CategoryList implements BinderInterface ->get(); // add empty category if applicable. - if (in_array(0, $list)) { + if (\in_array(0, $list)) { $collection->push(new Category); } diff --git a/app/Support/Binder/JournalList.php b/app/Support/Binder/JournalList.php index b58133bc3f..e86774d871 100644 --- a/app/Support/Binder/JournalList.php +++ b/app/Support/Binder/JournalList.php @@ -47,7 +47,7 @@ class JournalList implements BinderInterface $list[] = (int)$entry; } $list = array_unique($list); - if (count($list) === 0) { + if (\count($list) === 0) { throw new NotFoundHttpException; // @codeCoverageIgnore } diff --git a/app/Support/Binder/TagList.php b/app/Support/Binder/TagList.php index 0db60e1041..1b9eb74aa6 100644 --- a/app/Support/Binder/TagList.php +++ b/app/Support/Binder/TagList.php @@ -50,7 +50,7 @@ class TagList implements BinderInterface $list[] = strtolower(trim($entry)); } $list = array_unique($list); - if (count($list) === 0) { + if (\count($list) === 0) { Log::error('Tag list is empty.'); throw new NotFoundHttpException; // @codeCoverageIgnore } @@ -61,7 +61,7 @@ class TagList implements BinderInterface $collection = $allTags->filter( function (Tag $tag) use ($list) { - return in_array(strtolower($tag->tag), $list); + return \in_array(strtolower($tag->tag), $list); } ); diff --git a/app/Support/ChartColour.php b/app/Support/ChartColour.php index 5f0ab48904..f64ea93eb5 100644 --- a/app/Support/ChartColour.php +++ b/app/Support/ChartColour.php @@ -58,7 +58,7 @@ class ChartColour */ public static function getColour(int $index): string { - $index %= count(self::$colours); + $index %= \count(self::$colours); $row = self::$colours[$index]; return sprintf('rgba(%d, %d, %d, 0.7)', $row[0], $row[1], $row[2]); diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.php index 5dabfcdee2..cbfc8c48ac 100644 --- a/app/Support/ExpandedForm.php +++ b/app/Support/ExpandedForm.php @@ -59,7 +59,6 @@ class ExpandedForm * @param array $options * * @return string - * @throws \FireflyIII\Exceptions\FireflyException * @throws \Throwable */ public function amountNoCurrency(string $name, $value = null, array $options = []): string @@ -129,7 +128,7 @@ class ExpandedForm $currencyId = (int)$account->getMeta('currency_id'); $currency = $currencyRepos->findNull($currencyId); $role = $account->getMeta('accountRole'); - if (0 === strlen($role)) { + if (0 === \strlen($role)) { $role = 'no_account_type'; // @codeCoverageIgnore } if (null === $currency) { @@ -159,14 +158,13 @@ class ExpandedForm } /** - * @param $name - * @param int $value - * @param null $checked - * @param array $options + * @param string $name + * @param int $value + * @param null $checked + * @param array $options * * @return string - * - + * @throws \Throwable */ public function checkbox(string $name, $value = 1, $checked = null, $options = []): string { @@ -225,13 +223,12 @@ class ExpandedForm } /** - * @param $name - * @param null $value - * @param array $options + * @param string $name + * @param null $value + * @param array $options * * @return string - * - + * @throws \Throwable */ public function date(string $name, $value = null, array $options = []): string { @@ -246,12 +243,11 @@ class ExpandedForm } /** - * @param $name - * @param array $options + * @param string $name + * @param array $options * * @return string - * - + * @throws \Throwable */ public function file(string $name, array $options = []): string { @@ -264,13 +260,12 @@ class ExpandedForm } /** - * @param $name - * @param null $value - * @param array $options + * @param string $name + * @param null $value + * @param array $options * * @return string - * - + * @throws \Throwable */ public function integer(string $name, $value = null, array $options = []): string { @@ -285,13 +280,12 @@ class ExpandedForm } /** - * @param $name - * @param null $value - * @param array $options + * @param string $name + * @param null $value + * @param array $options * * @return string - * - + * @throws \Throwable */ public function location(string $name, $value = null, array $options = []): string { @@ -358,14 +352,13 @@ class ExpandedForm } /** - * @param $name - * @param array $list - * @param null $selected - * @param array $options + * @param string $name + * @param array $list + * @param null $selected + * @param array $options * * @return string - * - + * @throws \Throwable */ public function multiCheckbox(string $name, array $list = [], $selected = null, array $options = []): string { @@ -381,14 +374,13 @@ class ExpandedForm } /** - * @param $name - * @param array $list - * @param null $selected - * @param array $options + * @param string $name + * @param array $list + * @param null $selected + * @param array $options * * @return string - * - + * @throws \Throwable */ public function multiRadio(string $name, array $list = [], $selected = null, array $options = []): string { @@ -409,8 +401,8 @@ class ExpandedForm * @param array $options * * @return string - * - + * @throws \FireflyIII\Exceptions\FireflyException + * @throws \Throwable */ public function nonSelectableAmount(string $name, $value = null, array $options = []): string { @@ -438,8 +430,8 @@ class ExpandedForm * @param array $options * * @return string - * - + * @throws \FireflyIII\Exceptions\FireflyException + * @throws \Throwable */ public function nonSelectableBalance(string $name, $value = null, array $options = []): string { @@ -468,8 +460,7 @@ class ExpandedForm * @param array $options * * @return string - * - + * @throws \Throwable */ public function number(string $name, $value = null, array $options = []): string { @@ -486,12 +477,11 @@ class ExpandedForm } /** - * @param $type - * @param $name + * @param string $type + * @param string $name * * @return string - * - + * @throws \Throwable */ public function optionsList(string $type, string $name): string { @@ -510,12 +500,11 @@ class ExpandedForm } /** - * @param $name - * @param array $options + * @param string $name + * @param array $options * * @return string - * - + * @throws \Throwable */ public function password(string $name, array $options = []): string { @@ -528,14 +517,13 @@ class ExpandedForm } /** - * @param $name - * @param array $list - * @param null $selected - * @param array $options + * @param string $name + * @param array $list + * @param null $selected + * @param array $options * * @return string - * - + * @throws \Throwable */ public function select(string $name, array $list = [], $selected = null, array $options = []): string { @@ -550,13 +538,12 @@ class ExpandedForm } /** - * @param $name - * @param null $value - * @param array $options + * @param string $name + * @param null $value + * @param array $options * * @return string - * - + * @throws \Throwable */ public function staticText(string $name, $value, array $options = []): string { @@ -569,13 +556,12 @@ class ExpandedForm } /** - * @param $name - * @param null $value - * @param array $options + * @param string $name + * @param null $value + * @param array $options * * @return string - * - + * @throws \Throwable */ public function tags(string $name, $value = null, array $options = []): string { @@ -590,13 +576,12 @@ class ExpandedForm } /** - * @param $name - * @param null $value - * @param array $options + * @param string $name + * @param null $value + * @param array $options * * @return string - * - + * @throws \Throwable */ public function text(string $name, $value = null, array $options = []): string { @@ -610,13 +595,12 @@ class ExpandedForm } /** - * @param $name - * @param null $value - * @param array $options + * @param string $name + * @param null $value + * @param array $options * * @return string - * - + * @throws \Throwable */ public function textarea(string $name, $value = null, array $options = []): string { @@ -718,6 +702,7 @@ class ExpandedForm * @return string * * @throws \FireflyIII\Exceptions\FireflyException + * @throws \Throwable */ private function currencyField(string $name, string $view, $value = null, array $options = []): string { diff --git a/app/Support/Import/Configuration/Bunq/HaveAccounts.php b/app/Support/Import/Configuration/Bunq/HaveAccounts.php index 7a0db86d2a..3291c843e8 100644 --- a/app/Support/Import/Configuration/Bunq/HaveAccounts.php +++ b/app/Support/Import/Configuration/Bunq/HaveAccounts.php @@ -61,7 +61,7 @@ class HaveAccounts implements ConfigurationInterface $currency = $currencyRepository->findNull($currencyId); $dbAccounts[$id] = [ 'account' => $dbAccount, - 'currency' => null === $currency ? $defaultCurrency : $currency, + 'currency' => $currency ?? $defaultCurrency, ]; } diff --git a/app/Support/Import/Configuration/File/Map.php b/app/Support/Import/Configuration/File/Map.php index 2cf3ef4b39..3072d88e9f 100644 --- a/app/Support/Import/Configuration/File/Map.php +++ b/app/Support/Import/Configuration/File/Map.php @@ -82,10 +82,10 @@ class Map implements ConfigurationInterface continue; } $value = trim($row[$index]); - if (strlen($value) > 0) { + if (\strlen($value) > 0) { // we can do some preprocessing here, // which is exclusively to fix the tags: - if (null !== $this->data[$index]['preProcessMap'] && strlen($this->data[$index]['preProcessMap']) > 0) { + if (null !== $this->data[$index]['preProcessMap'] && \strlen($this->data[$index]['preProcessMap']) > 0) { /** @var PreProcessorInterface $preProcessor */ $preProcessor = app($this->data[$index]['preProcessMap']); $result = $preProcessor->run($value); @@ -107,7 +107,7 @@ class Map implements ConfigurationInterface $this->data[$index]['values'] = array_unique($this->data[$index]['values']); asort($this->data[$index]['values']); // if the count of this array is zero, there is nothing to map. - if (count($this->data[$index]['values']) === 0) { + if (\count($this->data[$index]['values']) === 0) { unset($this->data[$index]); } } @@ -263,7 +263,7 @@ class Map implements ConfigurationInterface $specifics = $config['specifics'] ?? []; $names = array_keys($specifics); foreach ($names as $name) { - if (!in_array($name, $this->validSpecifics)) { + if (!\in_array($name, $this->validSpecifics)) { throw new FireflyException(sprintf('"%s" is not a valid class name', $name)); } $class = config('csv.import_specifics.' . $name); @@ -309,7 +309,7 @@ class Map implements ConfigurationInterface { // is valid column? $validColumns = array_keys(config('csv.import_roles')); - if (!in_array($column, $validColumns)) { + if (!\in_array($column, $validColumns)) { throw new FireflyException(sprintf('"%s" is not a valid column.', $column)); } diff --git a/app/Support/Import/Configuration/File/Roles.php b/app/Support/Import/Configuration/File/Roles.php index a619906114..9b5b786a6c 100644 --- a/app/Support/Import/Configuration/File/Roles.php +++ b/app/Support/Import/Configuration/File/Roles.php @@ -89,7 +89,7 @@ class Roles implements ConfigurationInterface foreach ($records as $row) { $row = array_values($row); $row = $this->processSpecifics($row); - $count = count($row); + $count = \count($row); $this->data['total'] = $count > $this->data['total'] ? $count : $this->data['total']; $this->processRow($row); } @@ -246,7 +246,7 @@ class Roles implements ConfigurationInterface if ('_ignore' !== $role) { ++$assigned; } - if (in_array($role, ['amount', 'amount_credit', 'amount_debit'])) { + if (\in_array($role, ['amount', 'amount_credit', 'amount_debit'])) { $hasAmount = true; } if ($role === 'foreign-currency-code') { @@ -313,7 +313,7 @@ class Roles implements ConfigurationInterface { foreach ($row as $index => $value) { $value = trim($value); - if (strlen($value) > 0) { + if (\strlen($value) > 0) { $this->data['examples'][$index][] = $value; } } diff --git a/app/Support/Import/Configuration/File/UploadConfig.php b/app/Support/Import/Configuration/File/UploadConfig.php index 750e7603d8..3a699c76d4 100644 --- a/app/Support/Import/Configuration/File/UploadConfig.php +++ b/app/Support/Import/Configuration/File/UploadConfig.php @@ -173,7 +173,7 @@ class UploadConfig implements ConfigurationInterface private function storeSpecifics(array $data, array $config): array { // loop specifics. - if (isset($data['specifics']) && is_array($data['specifics'])) { + if (isset($data['specifics']) && \is_array($data['specifics'])) { $names = array_keys($data['specifics']); foreach ($names as $name) { // verify their content. diff --git a/app/Support/Import/Information/BunqInformation.php b/app/Support/Import/Information/BunqInformation.php index 76356bbef3..9b180baca9 100644 --- a/app/Support/Import/Information/BunqInformation.php +++ b/app/Support/Import/Information/BunqInformation.php @@ -131,7 +131,6 @@ class BunqInformation implements InformationInterface $request->setSessionToken($sessionToken); $request->call(); - return; } /** @@ -139,8 +138,7 @@ class BunqInformation implements InformationInterface * @param int $userId * * @return Collection - * - + * @throws FireflyException */ private function getMonetaryAccounts(SessionToken $sessionToken, int $userId): Collection { @@ -191,8 +189,7 @@ class BunqInformation implements InformationInterface /** * @return SessionToken - * - + * @throws FireflyException */ private function startSession(): SessionToken { diff --git a/app/Support/Navigation.php b/app/Support/Navigation.php index 9c1fe63c02..cbb4645d76 100644 --- a/app/Support/Navigation.php +++ b/app/Support/Navigation.php @@ -73,7 +73,7 @@ class Navigation // if period is 1M and diff in month is 2 and new DOM = 1, sub a day: $months = ['1M', 'month', 'monthly']; $difference = $date->month - $theDate->month; - if (in_array($repeatFreq, $months) && 2 === $difference && 1 === $date->day) { + if (\in_array($repeatFreq, $months) && 2 === $difference && 1 === $date->day) { $date->subDay(); } @@ -197,14 +197,14 @@ class Navigation if (isset($modifierMap[$repeatFreq])) { $currentEnd->$function($modifierMap[$repeatFreq]); - if (in_array($repeatFreq, $subDay)) { + if (\in_array($repeatFreq, $subDay)) { $currentEnd->subDay(); } return $currentEnd; } $currentEnd->$function(); - if (in_array($repeatFreq, $subDay)) { + if (\in_array($repeatFreq, $subDay)) { $currentEnd->subDay(); } diff --git a/app/Support/Search/Modifier.php b/app/Support/Search/Modifier.php index 6ac782f818..97ab9cf805 100644 --- a/app/Support/Search/Modifier.php +++ b/app/Support/Search/Modifier.php @@ -150,7 +150,7 @@ class Modifier */ public static function stringCompare(string $haystack, string $needle): bool { - $res = !(false === strpos(strtolower($haystack), strtolower($needle))); + $res = !(false === stripos($haystack, $needle)); Log::debug(sprintf('"%s" is in "%s"? %s', $needle, $haystack, var_export($res, true))); return $res; diff --git a/app/Support/Search/Search.php b/app/Support/Search/Search.php index 2b21f7bfb9..d8e6b72c0c 100644 --- a/app/Support/Search/Search.php +++ b/app/Support/Search/Search.php @@ -63,8 +63,8 @@ class Search implements SearchInterface public function getWordsAsString(): string { $string = implode(' ', $this->words); - if (0 === strlen($string)) { - return is_string($this->originalQuery) ? $this->originalQuery : ''; + if (0 === \strlen($string)) { + return \is_string($this->originalQuery) ? $this->originalQuery : ''; } return $string; @@ -94,7 +94,7 @@ class Search implements SearchInterface $filteredQuery = str_replace($match, '', $filteredQuery); } $filteredQuery = trim(str_replace(['"', "'"], '', $filteredQuery)); - if (strlen($filteredQuery) > 0) { + if (\strlen($filteredQuery) > 0) { $this->words = array_map('trim', explode(' ', $filteredQuery)); } } @@ -147,7 +147,7 @@ class Search implements SearchInterface // Update counters ++$page; - $processed += count($set); + $processed += \count($set); Log::debug(sprintf('Page is now %d, processed is %d', $page, $processed)); @@ -245,10 +245,10 @@ class Search implements SearchInterface private function extractModifier(string $string) { $parts = explode(':', $string); - if (2 === count($parts) && strlen(trim((string)$parts[0])) > 0 && strlen(trim((string)$parts[1]))) { + if (2 === \count($parts) && \strlen(trim((string)$parts[0])) > 0 && \strlen(trim((string)$parts[1]))) { $type = trim((string)$parts[0]); $value = trim((string)$parts[1]); - if (in_array($type, $this->validModifiers)) { + if (\in_array($type, $this->validModifiers)) { // filter for valid type $this->modifiers->push(['type' => $type, 'value' => $value]); } @@ -266,7 +266,7 @@ class Search implements SearchInterface Log::debug(sprintf('Now at transaction #%d', $transaction->id)); // first "modifier" is always the text of the search: // check descr of journal: - if (count($this->words) > 0 + if (\count($this->words) > 0 && !$this->strposArray(strtolower((string)$transaction->description), $this->words) && !$this->strposArray(strtolower((string)$transaction->transaction_description), $this->words) ) { @@ -294,7 +294,7 @@ class Search implements SearchInterface */ private function strposArray(string $haystack, array $needle) { - if (0 === strlen($haystack)) { + if (0 === \strlen($haystack)) { return false; } foreach ($needle as $what) { diff --git a/app/Support/Twig/Extension/Transaction.php b/app/Support/Twig/Extension/Transaction.php index 622d08d6ed..759880ff88 100644 --- a/app/Support/Twig/Extension/Transaction.php +++ b/app/Support/Twig/Extension/Transaction.php @@ -30,6 +30,7 @@ use FireflyIII\Models\TransactionType; use Lang; use Log; use Twig_Extension; +use FireflyIII\Models\TransactionJournal; /** * Class Transaction. @@ -205,7 +206,7 @@ class Transaction extends Twig_Extension public function description(TransactionModel $transaction): string { $description = $transaction->description; - if (strlen((string)$transaction->transaction_description) > 0) { + if (\strlen((string)$transaction->transaction_description) > 0) { $description = $transaction->transaction_description . ' (' . $transaction->description . ')'; } @@ -278,7 +279,7 @@ class Transaction extends Twig_Extension public function hasAttachments(TransactionModel $transaction): string { $res = ''; - if (is_int($transaction->attachmentCount) && $transaction->attachmentCount > 0) { + if (\is_int($transaction->attachmentCount) && $transaction->attachmentCount > 0) { $res = sprintf( '', Lang::choice( 'firefly.nr_of_attachments', @@ -289,7 +290,7 @@ class Transaction extends Twig_Extension if ($transaction->attachmentCount === null) { $journalId = (int)$transaction->journal_id; $count = Attachment::whereNull('deleted_at') - ->where('attachable_type', 'FireflyIII\Models\TransactionJournal') + ->where('attachable_type', TransactionJournal::class) ->where('attachable_id', $journalId) ->count(); if ($count > 0) { diff --git a/app/Support/Twig/Extension/TransactionJournal.php b/app/Support/Twig/Extension/TransactionJournal.php index cc06e02726..c9b56a3d8b 100644 --- a/app/Support/Twig/Extension/TransactionJournal.php +++ b/app/Support/Twig/Extension/TransactionJournal.php @@ -83,7 +83,7 @@ class TransactionJournal extends Twig_Extension if (null === $result) { return false; } - if (strlen((string)$result) === 0) { + if (\strlen((string)$result) === 0) { return false; } @@ -136,6 +136,6 @@ class TransactionJournal extends Twig_Extension $array[] = app('amount')->formatAnything($total['currency'], $total['amount']); } - return join(' / ', $array); + return implode(' / ', $array); } } diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php index ca06db2ada..66548bd11b 100644 --- a/app/Support/Twig/General.php +++ b/app/Support/Twig/General.php @@ -78,7 +78,7 @@ class General extends Twig_Extension return new Twig_SimpleFunction( 'activeRoutePartial', function (): string { - $args = func_get_args(); + $args = \func_get_args(); $route = $args[0]; // name of the route. $name = Route::getCurrentRoute()->getName() ?? ''; if (!(false === strpos($name, $route))) { @@ -101,7 +101,7 @@ class General extends Twig_Extension return new Twig_SimpleFunction( 'activeRoutePartialWhat', function ($context): string { - $args = func_get_args(); + $args = \func_get_args(); $route = $args[1]; // name of the route. $what = $args[2]; // name of the route. $activeWhat = $context['what'] ?? false; @@ -127,7 +127,7 @@ class General extends Twig_Extension return new Twig_SimpleFunction( 'activeRouteStrict', function (): string { - $args = func_get_args(); + $args = \func_get_args(); $route = $args[0]; // name of the route. if (Route::getCurrentRoute()->getName() === $route) { diff --git a/app/Support/Twig/Journal.php b/app/Support/Twig/Journal.php index ec15461939..c68a7bedfe 100644 --- a/app/Support/Twig/Journal.php +++ b/app/Support/Twig/Journal.php @@ -192,7 +192,7 @@ class Journal extends Twig_Extension foreach ($journal->categories as $category) { $categories[] = sprintf('%1$s', e($category->name), route('categories.show', $category->id)); } - if (0 === count($categories)) { + if (0 === \count($categories)) { $set = Category::distinct()->leftJoin('category_transaction', 'categories.id', '=', 'category_transaction.category_id') ->leftJoin('transactions', 'category_transaction.transaction_id', '=', 'transactions.id') ->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') diff --git a/app/TransactionRules/Actions/AddTag.php b/app/TransactionRules/Actions/AddTag.php index 09a1dd6c54..4da72dcf74 100644 --- a/app/TransactionRules/Actions/AddTag.php +++ b/app/TransactionRules/Actions/AddTag.php @@ -22,8 +22,8 @@ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; +use FireflyIII\Factory\TagFactory; use FireflyIII\Models\RuleAction; -use FireflyIII\Models\Tag; use FireflyIII\Models\TransactionJournal; use Log; @@ -55,8 +55,16 @@ class AddTag implements ActionInterface public function act(TransactionJournal $journal): bool { // journal has this tag maybe? - $tag = Tag::firstOrCreateEncrypted(['tag' => $this->action->action_value, 'user_id' => $journal->user->id]); + /** @var TagFactory $factory */ + $factory = app(TagFactory::class); + $factory->setUser($journal->user); + $tag = $factory->findOrCreate($this->action->action_value); + if (null === $tag) { + // could not find, could not create tag. + Log::error(sprintf('RuleAction AddTag. Could not find or create tag "%s"', $this->action->action_value)); + return false; + } $count = $journal->tags()->where('tag_id', $tag->id)->count(); if (0 === $count) { $journal->tags()->save($tag); diff --git a/app/TransactionRules/Actions/ClearNotes.php b/app/TransactionRules/Actions/ClearNotes.php index a6bd490588..ff823ffbeb 100644 --- a/app/TransactionRules/Actions/ClearNotes.php +++ b/app/TransactionRules/Actions/ClearNotes.php @@ -51,8 +51,7 @@ class ClearNotes implements ActionInterface * @param TransactionJournal $journal * * @return bool - * - + * @throws \Exception */ public function act(TransactionJournal $journal): bool { diff --git a/app/TransactionRules/Factory/ActionFactory.php b/app/TransactionRules/Factory/ActionFactory.php index f9864c0e5d..7d3cf1001e 100644 --- a/app/TransactionRules/Factory/ActionFactory.php +++ b/app/TransactionRules/Factory/ActionFactory.php @@ -92,7 +92,7 @@ class ActionFactory */ protected static function getActionTypes(): array { - if (0 === count(self::$actionTypes)) { + if (0 === \count(self::$actionTypes)) { self::$actionTypes = Domain::getRuleActions(); } diff --git a/app/TransactionRules/Factory/TriggerFactory.php b/app/TransactionRules/Factory/TriggerFactory.php index 9616939987..e117de55bc 100644 --- a/app/TransactionRules/Factory/TriggerFactory.php +++ b/app/TransactionRules/Factory/TriggerFactory.php @@ -62,7 +62,7 @@ class TriggerFactory $obj->stopProcessing = $trigger->stop_processing; Log::debug(sprintf('self::getTriggerClass("%s") = "%s"', $triggerType, $class)); - Log::debug(sprintf('%s::makeFromTriggerValue(%s) = object of class "%s"', $class, $trigger->trigger_value, get_class($obj))); + Log::debug(sprintf('%s::makeFromTriggerValue(%s) = object of class "%s"', $class, $trigger->trigger_value, \get_class($obj))); return $obj; } @@ -101,7 +101,7 @@ class TriggerFactory */ protected static function getTriggerTypes(): array { - if (0 === count(self::$triggerTypes)) { + if (0 === \count(self::$triggerTypes)) { self::$triggerTypes = Domain::getRuleTriggers(); } diff --git a/app/TransactionRules/Processor.php b/app/TransactionRules/Processor.php index 41d5cfed1a..dd5f630198 100644 --- a/app/TransactionRules/Processor.php +++ b/app/TransactionRules/Processor.php @@ -247,7 +247,7 @@ final class Processor 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)); + 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.'); @@ -273,7 +273,7 @@ final class Processor /** @var AbstractTrigger $trigger */ foreach ($this->triggers as $trigger) { ++$foundTriggers; - Log::debug(sprintf('Now checking trigger %s with value %s', get_class($trigger), $trigger->getTriggerValue())); + Log::debug(sprintf('Now checking trigger %s with value %s', \get_class($trigger), $trigger->getTriggerValue())); /** @var AbstractTrigger $trigger */ if ($trigger->triggered($this->journal)) { Log::debug('Is a match!'); diff --git a/app/TransactionRules/TransactionMatcher.php b/app/TransactionRules/TransactionMatcher.php index 8a204fd3b0..b417311aae 100644 --- a/app/TransactionRules/TransactionMatcher.php +++ b/app/TransactionRules/TransactionMatcher.php @@ -217,7 +217,6 @@ class TransactionMatcher * @param Processor $processor * * @return Collection - * @throws \FireflyIII\Exceptions\FireflyException */ private function runProcessor(Processor $processor): Collection { @@ -276,7 +275,7 @@ class TransactionMatcher // Update counters ++$page; - $processed += count($set); + $processed += \count($set); Log::debug(sprintf('Page is now %d, processed is %d', $page, $processed)); diff --git a/app/TransactionRules/Triggers/DescriptionEnds.php b/app/TransactionRules/Triggers/DescriptionEnds.php index e4bbf5b71d..f55f9c095a 100644 --- a/app/TransactionRules/Triggers/DescriptionEnds.php +++ b/app/TransactionRules/Triggers/DescriptionEnds.php @@ -72,9 +72,9 @@ final class DescriptionEnds extends AbstractTrigger implements TriggerInterface public function triggered(TransactionJournal $journal): bool { $description = strtolower($journal->description ?? ''); - $descriptionLength = strlen($description); + $descriptionLength = \strlen($description); $search = strtolower($this->triggerValue); - $searchLength = strlen($search); + $searchLength = \strlen($search); // if the string to search for is longer than the description, // return false. diff --git a/app/TransactionRules/Triggers/DescriptionStarts.php b/app/TransactionRules/Triggers/DescriptionStarts.php index d795004605..f8decc9ef0 100644 --- a/app/TransactionRules/Triggers/DescriptionStarts.php +++ b/app/TransactionRules/Triggers/DescriptionStarts.php @@ -74,7 +74,7 @@ final class DescriptionStarts extends AbstractTrigger implements TriggerInterfac $description = strtolower($journal->description ?? ''); $search = strtolower($this->triggerValue); - $part = substr($description, 0, strlen($search)); + $part = substr($description, 0, \strlen($search)); if ($part === $search) { Log::debug(sprintf('RuleTrigger DescriptionStarts for journal #%d: "%s" starts with "%s", return true.', $journal->id, $description, $search)); diff --git a/app/TransactionRules/Triggers/FromAccountEnds.php b/app/TransactionRules/Triggers/FromAccountEnds.php index 16f1393a23..8b30c32c3d 100644 --- a/app/TransactionRules/Triggers/FromAccountEnds.php +++ b/app/TransactionRules/Triggers/FromAccountEnds.php @@ -78,9 +78,9 @@ final class FromAccountEnds extends AbstractTrigger implements TriggerInterface $name .= strtolower($account->name); } - $nameLength = strlen($name); + $nameLength = \strlen($name); $search = strtolower($this->triggerValue); - $searchLength = strlen($search); + $searchLength = \strlen($search); // if the string to search for is longer than the account name, // it will never be in the account name. diff --git a/app/TransactionRules/Triggers/FromAccountStarts.php b/app/TransactionRules/Triggers/FromAccountStarts.php index cc12f8fcfb..23987e3210 100644 --- a/app/TransactionRules/Triggers/FromAccountStarts.php +++ b/app/TransactionRules/Triggers/FromAccountStarts.php @@ -79,7 +79,7 @@ final class FromAccountStarts extends AbstractTrigger implements TriggerInterfac } $search = strtolower($this->triggerValue); - $part = substr($name, 0, strlen($search)); + $part = substr($name, 0, \strlen($search)); if ($part === $search) { Log::debug(sprintf('RuleTrigger FromAccountStarts for journal #%d: "%s" starts with "%s", return true.', $journal->id, $name, $search)); diff --git a/app/TransactionRules/Triggers/NotesAny.php b/app/TransactionRules/Triggers/NotesAny.php index cee387e0dd..6be0eab197 100644 --- a/app/TransactionRules/Triggers/NotesAny.php +++ b/app/TransactionRules/Triggers/NotesAny.php @@ -68,7 +68,7 @@ final class NotesAny extends AbstractTrigger implements TriggerInterface $text = $note->text; } - if (strlen($text) > 0) { + if (\strlen($text) > 0) { Log::debug(sprintf('RuleTrigger NotesEmpty for journal #%d: strlen > 0, return true.', $journal->id)); return true; diff --git a/app/TransactionRules/Triggers/NotesAre.php b/app/TransactionRules/Triggers/NotesAre.php index a191edf5ff..00275edecd 100644 --- a/app/TransactionRules/Triggers/NotesAre.php +++ b/app/TransactionRules/Triggers/NotesAre.php @@ -75,7 +75,7 @@ final class NotesAre extends AbstractTrigger implements TriggerInterface } $search = strtolower($this->triggerValue); - if ($text === $search && strlen($text) > 0) { + if ($text === $search && \strlen($text) > 0) { Log::debug(sprintf('RuleTrigger NotesAre for journal #%d: "%s" is "%s", return true.', $journal->id, $text, $search)); return true; diff --git a/app/TransactionRules/Triggers/NotesContain.php b/app/TransactionRules/Triggers/NotesContain.php index 68aa90ec86..23c74cc74d 100644 --- a/app/TransactionRules/Triggers/NotesContain.php +++ b/app/TransactionRules/Triggers/NotesContain.php @@ -74,7 +74,7 @@ final class NotesContain extends AbstractTrigger implements TriggerInterface { $search = strtolower(trim($this->triggerValue)); - if (0 === strlen($search)) { + if (0 === \strlen($search)) { Log::debug(sprintf('RuleTrigger NotesContain for journal #%d: "%s" is empty, return false.', $journal->id, $search)); return false; diff --git a/app/TransactionRules/Triggers/NotesEmpty.php b/app/TransactionRules/Triggers/NotesEmpty.php index f552709b98..dc548d40e5 100644 --- a/app/TransactionRules/Triggers/NotesEmpty.php +++ b/app/TransactionRules/Triggers/NotesEmpty.php @@ -68,7 +68,7 @@ final class NotesEmpty extends AbstractTrigger implements TriggerInterface $text = $note->text; } - if (0 === strlen($text)) { + if (0 === \strlen($text)) { Log::debug(sprintf('RuleTrigger NotesEmpty for journal #%d: strlen is 0, return true.', $journal->id)); return true; diff --git a/app/TransactionRules/Triggers/NotesEnd.php b/app/TransactionRules/Triggers/NotesEnd.php index 4929b29ad2..aa3f264c13 100644 --- a/app/TransactionRules/Triggers/NotesEnd.php +++ b/app/TransactionRules/Triggers/NotesEnd.php @@ -78,9 +78,9 @@ final class NotesEnd extends AbstractTrigger implements TriggerInterface if (null !== $note) { $text = strtolower($note->text); } - $notesLength = strlen($text); + $notesLength = \strlen($text); $search = strtolower($this->triggerValue); - $searchLength = strlen($search); + $searchLength = \strlen($search); // if the string to search for is longer than the description, // return false diff --git a/app/TransactionRules/Triggers/NotesStart.php b/app/TransactionRules/Triggers/NotesStart.php index 3631143312..0346f6136a 100644 --- a/app/TransactionRules/Triggers/NotesStart.php +++ b/app/TransactionRules/Triggers/NotesStart.php @@ -80,7 +80,7 @@ final class NotesStart extends AbstractTrigger implements TriggerInterface } $search = strtolower($this->triggerValue); - $part = substr($text, 0, strlen($search)); + $part = substr($text, 0, \strlen($search)); if ($part === $search) { Log::debug(sprintf('RuleTrigger NotesStart for journal #%d: "%s" starts with "%s", return true.', $journal->id, $text, $search)); diff --git a/app/TransactionRules/Triggers/ToAccountEnds.php b/app/TransactionRules/Triggers/ToAccountEnds.php index d7ecefdbea..d23cbee4e7 100644 --- a/app/TransactionRules/Triggers/ToAccountEnds.php +++ b/app/TransactionRules/Triggers/ToAccountEnds.php @@ -78,9 +78,9 @@ final class ToAccountEnds extends AbstractTrigger implements TriggerInterface $toAccountName .= strtolower($account->name); } - $toAccountNameLength = strlen($toAccountName); + $toAccountNameLength = \strlen($toAccountName); $search = strtolower($this->triggerValue); - $searchLength = strlen($search); + $searchLength = \strlen($search); // if the string to search for is longer than the account name, // return false diff --git a/app/TransactionRules/Triggers/ToAccountStarts.php b/app/TransactionRules/Triggers/ToAccountStarts.php index 6867a95fa3..ab21f63b66 100644 --- a/app/TransactionRules/Triggers/ToAccountStarts.php +++ b/app/TransactionRules/Triggers/ToAccountStarts.php @@ -79,7 +79,7 @@ final class ToAccountStarts extends AbstractTrigger implements TriggerInterface } $search = strtolower($this->triggerValue); - $part = substr($toAccountName, 0, strlen($search)); + $part = substr($toAccountName, 0, \strlen($search)); if ($part === $search) { Log::debug(sprintf('RuleTrigger ToAccountStarts for journal #%d: "%s" starts with "%s", return true.', $journal->id, $toAccountName, $search)); diff --git a/app/User.php b/app/User.php index 641bbc70dc..27b9f1bea7 100644 --- a/app/User.php +++ b/app/User.php @@ -34,6 +34,22 @@ use Laravel\Passport\HasApiTokens; use Log; use Request; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use FireflyIII\Models\TransactionJournal; +use FireflyIII\Models\Transaction; +use FireflyIII\Models\Tag; +use FireflyIII\Models\Rule; +use FireflyIII\Models\RuleGroup; +use FireflyIII\Models\Role; +use FireflyIII\Models\Preference; +use FireflyIII\Models\Account; +use FireflyIII\Models\PiggyBank; +use FireflyIII\Models\ImportJob; +use FireflyIII\Models\ExportJob; +use FireflyIII\Models\Category; +use FireflyIII\Models\Budget; +use FireflyIII\Models\Bill; +use FireflyIII\Models\AvailableBudget; +use FireflyIII\Models\Attachment; /** * Class User. @@ -98,7 +114,7 @@ class User extends Authenticatable */ public function accounts(): HasMany { - return $this->hasMany('FireflyIII\Models\Account'); + return $this->hasMany(Account::class); } /** @@ -110,11 +126,11 @@ class User extends Authenticatable */ public function attachRole($role) { - if (is_object($role)) { + if (\is_object($role)) { $role = $role->getKey(); } - if (is_array($role)) { + if (\is_array($role)) { $role = $role['id']; } try { @@ -133,7 +149,7 @@ class User extends Authenticatable */ public function attachments(): HasMany { - return $this->hasMany('FireflyIII\Models\Attachment'); + return $this->hasMany(Attachment::class); } /** @@ -144,7 +160,7 @@ class User extends Authenticatable */ public function availableBudgets(): HasMany { - return $this->hasMany('FireflyIII\Models\AvailableBudget'); + return $this->hasMany(AvailableBudget::class); } /** @@ -155,7 +171,7 @@ class User extends Authenticatable */ public function bills(): HasMany { - return $this->hasMany('FireflyIII\Models\Bill'); + return $this->hasMany(Bill::class); } /** @@ -166,7 +182,7 @@ class User extends Authenticatable */ public function budgets(): HasMany { - return $this->hasMany('FireflyIII\Models\Budget'); + return $this->hasMany(Budget::class); } /** @@ -177,7 +193,7 @@ class User extends Authenticatable */ public function categories(): HasMany { - return $this->hasMany('FireflyIII\Models\Category'); + return $this->hasMany(Category::class); } /** @@ -199,7 +215,7 @@ class User extends Authenticatable */ public function exportJobs(): HasMany { - return $this->hasMany('FireflyIII\Models\ExportJob'); + return $this->hasMany(ExportJob::class); } /** @@ -245,7 +261,7 @@ class User extends Authenticatable */ public function importJobs(): HasMany { - return $this->hasMany('FireflyIII\Models\ImportJob'); + return $this->hasMany(ImportJob::class); } /** @@ -256,7 +272,7 @@ class User extends Authenticatable */ public function piggyBanks(): HasManyThrough { - return $this->hasManyThrough('FireflyIII\Models\PiggyBank', 'FireflyIII\Models\Account'); + return $this->hasManyThrough(PiggyBank::class, Account::class); } /** @@ -267,7 +283,7 @@ class User extends Authenticatable */ public function preferences(): HasMany { - return $this->hasMany('FireflyIII\Models\Preference'); + return $this->hasMany(Preference::class); } /** @@ -278,7 +294,7 @@ class User extends Authenticatable */ public function roles(): BelongsToMany { - return $this->belongsToMany('FireflyIII\Models\Role'); + return $this->belongsToMany(Role::class); } /** @@ -289,7 +305,7 @@ class User extends Authenticatable */ public function ruleGroups(): HasMany { - return $this->hasMany('FireflyIII\Models\RuleGroup'); + return $this->hasMany(RuleGroup::class); } /** @@ -300,7 +316,7 @@ class User extends Authenticatable */ public function rules(): HasMany { - return $this->hasMany('FireflyIII\Models\Rule'); + return $this->hasMany(Rule::class); } /** @@ -324,7 +340,7 @@ class User extends Authenticatable */ public function tags(): HasMany { - return $this->hasMany('FireflyIII\Models\Tag'); + return $this->hasMany(Tag::class); } /** @@ -335,7 +351,7 @@ class User extends Authenticatable */ public function transactionJournals(): HasMany { - return $this->hasMany('FireflyIII\Models\TransactionJournal'); + return $this->hasMany(TransactionJournal::class); } /** @@ -346,6 +362,6 @@ class User extends Authenticatable */ public function transactions(): HasManyThrough { - return $this->hasManyThrough('FireflyIII\Models\Transaction', 'FireflyIII\Models\TransactionJournal'); + return $this->hasManyThrough(Transaction::class, TransactionJournal::class); } } diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php index 79b7ced902..c27cb6d6a4 100644 --- a/app/Validation/FireflyValidator.php +++ b/app/Validation/FireflyValidator.php @@ -55,7 +55,7 @@ class FireflyValidator extends Validator */ public function validate2faCode($attribute, $value): bool { - if (!is_string($value) || null === $value || 6 != strlen($value)) { + if (!\is_string($value) || null === $value || 6 != \strlen($value)) { return false; } @@ -117,7 +117,7 @@ class FireflyValidator extends Validator */ public function validateIban($attribute, $value): bool { - if (!is_string($value) || null === $value || strlen($value) < 6) { + if (!\is_string($value) || null === $value || \strlen($value) < 6) { return false; } // strip spaces @@ -197,9 +197,10 @@ class FireflyValidator extends Validator */ public function validateMore($attribute, $value, $parameters): bool { - $compare = (string)$parameters[0] ?? '0'; + /** @var mixed $compare */ + $compare = $parameters[0] ?? '0'; - return bccomp((string)$value, $compare) > 0; + return bccomp((string)$value, (string)$compare) > 0; } /** @@ -232,11 +233,11 @@ class FireflyValidator extends Validator { // get the index from a string like "rule-action-value.2". $parts = explode('.', $attribute); - $index = $parts[count($parts) - 1]; + $index = $parts[\count($parts) - 1]; // loop all rule-actions. // check if rule-action-value matches the thing. - if (is_array($this->data['rule-action'])) { + if (\is_array($this->data['rule-action'])) { $name = $this->data['rule-action'][$index] ?? 'invalid'; $value = $this->data['rule-action-value'][$index] ?? false; switch ($name) { @@ -278,7 +279,7 @@ class FireflyValidator extends Validator { // get the index from a string like "rule-trigger-value.2". $parts = explode('.', $attribute); - $index = $parts[count($parts) - 1]; + $index = $parts[\count($parts) - 1]; // loop all rule-triggers. // check if rule-value matches the thing.