From 3a3eb4e84f0e746518f041771fdb902984d23039 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 9 Sep 2017 06:41:45 +0200 Subject: [PATCH] Various code cleanup. --- app/Console/Commands/UpgradeDatabase.php | 9 -- app/Console/Commands/VerifyDatabase.php | 1 + app/Export/Entry/Entry.php | 8 +- app/Helpers/Collector/JournalCollector.php | 1 - app/Helpers/Report/BalanceReportHelper.php | 8 +- app/Http/Controllers/Admin/LinkController.php | 8 +- app/Http/Controllers/ExportController.php | 1 - .../Controllers/Import/BankController.php | 8 +- .../Json/AutoCompleteController.php | 2 + app/Http/Controllers/RuleController.php | 8 +- .../Transaction/LinkController.php | 10 +- .../Transaction/SingleController.php | 8 +- .../Transaction/SplitController.php | 6 +- .../Controllers/TransactionController.php | 8 +- app/Http/Requests/ExportFormRequest.php | 16 ++-- app/Http/Requests/Request.php | 94 +++++++++---------- app/Mail/RegisteredUser.php | 1 - app/Mail/RequestedNewPassword.php | 1 - app/Models/PiggyBank.php | 1 + app/Models/TransactionJournal.php | 15 +-- .../LinkType/LinkTypeRepositoryInterface.php | 28 +++--- app/Repositories/Tag/TagRepository.php | 63 +++++++------ .../Tag/TagRepositoryInterface.php | 10 +- app/Rules/Processor.php | 2 +- .../Bunq/Object/NotificationFilter.php | 2 - app/Services/Bunq/Object/UserPerson.php | 5 - .../Request/DeleteDeviceSessionRequest.php | 2 +- .../Bunq/Request/ListDeviceServerRequest.php | 17 ++-- .../Request/ListMonetaryAccountRequest.php | 16 ++-- .../Import/Information/BunqInformation.php | 1 - .../Information/InformationInterface.php | 15 ++- .../Prerequisites/PrerequisitesInterface.php | 14 +-- app/Support/Search/Search.php | 2 +- app/Support/Twig/AmountFormat.php | 15 +-- app/Support/Twig/Translation.php | 20 ++-- .../Controllers/JsonControllerTest.php | 2 - .../Feature/Controllers/TagControllerTest.php | 1 - .../Controllers/TransactionControllerTest.php | 1 - 38 files changed, 212 insertions(+), 218 deletions(-) diff --git a/app/Console/Commands/UpgradeDatabase.php b/app/Console/Commands/UpgradeDatabase.php index bcc8e2e43f..7294a247e3 100644 --- a/app/Console/Commands/UpgradeDatabase.php +++ b/app/Console/Commands/UpgradeDatabase.php @@ -269,15 +269,6 @@ class UpgradeDatabase extends Command $this->updateJournalCurrency($transaction); } ); - - - // /** @var Collection $transactions */ - // $transactions = $transfer->transactions()->where('amount', '>', 0)->get(); - // $transactions->each( - // function (Transaction $transaction) { - // $this->updateTransactionCurrency($transaction); - // } - // ); } ); } diff --git a/app/Console/Commands/VerifyDatabase.php b/app/Console/Commands/VerifyDatabase.php index 4dd0848501..4f1ab1938f 100644 --- a/app/Console/Commands/VerifyDatabase.php +++ b/app/Console/Commands/VerifyDatabase.php @@ -292,6 +292,7 @@ class VerifyDatabase extends Command /** * Report on things with no linked journals. + * * @param string $name */ private function reportObject(string $name) diff --git a/app/Export/Entry/Entry.php b/app/Export/Entry/Entry.php index bc8c52dd33..8aff206d47 100644 --- a/app/Export/Entry/Entry.php +++ b/app/Export/Entry/Entry.php @@ -138,9 +138,11 @@ final class Entry $entry->foreign_currency_code = is_null($transaction->foreign_currency_id) ? null : $transaction->foreignCurrency->code; $entry->foreign_amount = is_null($transaction->foreign_currency_id) ? null - : strval(round( - $transaction->transaction_foreign_amount, $transaction->foreignCurrency->decimal_places - )); + : strval( + round( + $transaction->transaction_foreign_amount, $transaction->foreignCurrency->decimal_places + ) + ); $entry->transaction_type = $transaction->transaction_type_type; $entry->asset_account_id = $transaction->account_id; diff --git a/app/Helpers/Collector/JournalCollector.php b/app/Helpers/Collector/JournalCollector.php index 4d7f2c3bce..939831be30 100644 --- a/app/Helpers/Collector/JournalCollector.php +++ b/app/Helpers/Collector/JournalCollector.php @@ -15,7 +15,6 @@ namespace FireflyIII\Helpers\Collector; use Carbon\Carbon; -use Crypt; use DB; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Helpers\Filter\FilterInterface; diff --git a/app/Helpers/Report/BalanceReportHelper.php b/app/Helpers/Report/BalanceReportHelper.php index 63bb4114da..fdd7563ef5 100644 --- a/app/Helpers/Report/BalanceReportHelper.php +++ b/app/Helpers/Report/BalanceReportHelper.php @@ -14,16 +14,12 @@ declare(strict_types=1); namespace FireflyIII\Helpers\Report; use Carbon\Carbon; -use DB; use FireflyIII\Helpers\Collection\Balance; use FireflyIII\Helpers\Collection\BalanceEntry; use FireflyIII\Helpers\Collection\BalanceHeader; use FireflyIII\Helpers\Collection\BalanceLine; use FireflyIII\Models\BudgetLimit; -use FireflyIII\Models\Tag; -use FireflyIII\Models\TransactionType; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; -use Illuminate\Database\Query\JoinClause; use Illuminate\Support\Collection; use Log; @@ -74,7 +70,7 @@ class BalanceReportHelper implements BalanceReportHelperInterface $line = $this->createBalanceLine($budgetLimit, $accounts); $balance->addBalanceLine($line); } - $noBudgetLine = $this->createNoBudgetLine($accounts, $start, $end); + $noBudgetLine = $this->createNoBudgetLine($accounts, $start, $end); $balance->addBalanceLine($noBudgetLine); $balance->setBalanceHeader($header); @@ -89,7 +85,6 @@ class BalanceReportHelper implements BalanceReportHelperInterface } - /** * @param BudgetLimit $budgetLimit * @param Collection $accounts @@ -142,7 +137,6 @@ class BalanceReportHelper implements BalanceReportHelperInterface } - /** * @param Balance $balance * @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly 5. diff --git a/app/Http/Controllers/Admin/LinkController.php b/app/Http/Controllers/Admin/LinkController.php index 569dd63121..93efc19d03 100644 --- a/app/Http/Controllers/Admin/LinkController.php +++ b/app/Http/Controllers/Admin/LinkController.php @@ -62,7 +62,9 @@ class LinkController extends Controller } /** - * @param LinkType $linkType + * @param Request $request + * @param LinkTypeRepositoryInterface $repository + * @param LinkType $linkType * * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View */ @@ -136,6 +138,8 @@ class LinkController extends Controller } /** + * @param LinkTypeRepositoryInterface $repository + * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function index(LinkTypeRepositoryInterface $repository) @@ -153,6 +157,8 @@ class LinkController extends Controller } /** + * @param LinkType $linkType + * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function show(LinkType $linkType) diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php index 0afaba639f..5cdd3bed06 100644 --- a/app/Http/Controllers/ExportController.php +++ b/app/Http/Controllers/ExportController.php @@ -17,7 +17,6 @@ namespace FireflyIII\Http\Controllers; use Carbon\Carbon; use ExpandedForm; use FireflyIII\Exceptions\FireflyException; -use FireflyIII\Export\ExpandedProcessor; use FireflyIII\Export\ProcessorInterface; use FireflyIII\Http\Requests\ExportFormRequest; use FireflyIII\Models\AccountType; diff --git a/app/Http/Controllers/Import/BankController.php b/app/Http/Controllers/Import/BankController.php index 6e46db2f78..661da55a77 100644 --- a/app/Http/Controllers/Import/BankController.php +++ b/app/Http/Controllers/Import/BankController.php @@ -26,6 +26,10 @@ class BankController extends Controller * This method must ask the user all parameters necessary to start importing data. This may not be enough * to finish the import itself (ie. mapping) but it should be enough to begin: accounts to import from, * accounts to import into, data ranges, etc. + * + * @param string $bank + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View */ public function form(string $bank) { @@ -77,15 +81,11 @@ class BankController extends Controller $remoteAccounts = array_keys($remoteAccounts); $class = config(sprintf('firefly.import_pre.%s', $bank)); - - var_dump($remoteAccounts);exit; - // get import file // get import config - } /** diff --git a/app/Http/Controllers/Json/AutoCompleteController.php b/app/Http/Controllers/Json/AutoCompleteController.php index 2a270da41a..8f654d9f82 100644 --- a/app/Http/Controllers/Json/AutoCompleteController.php +++ b/app/Http/Controllers/Json/AutoCompleteController.php @@ -94,6 +94,8 @@ class AutoCompleteController extends Controller /** * @param JournalCollectorInterface $collector * + * @param TransactionJournal $except + * * @return \Illuminate\Http\JsonResponse|mixed */ public function journalsWithId(JournalCollectorInterface $collector, TransactionJournal $except) diff --git a/app/Http/Controllers/RuleController.php b/app/Http/Controllers/RuleController.php index 4f90ca2bbc..46de443874 100644 --- a/app/Http/Controllers/RuleController.php +++ b/app/Http/Controllers/RuleController.php @@ -194,8 +194,12 @@ class RuleController extends Controller Session::flash('gaEventCategory', 'rules'); Session::flash('gaEventAction', 'edit-rule'); - return view('rules.rule.edit', compact('rule', 'subTitle', - 'primaryTrigger', 'oldTriggers', 'oldActions', 'triggerCount', 'actionCount','ruleGroups')); + return view( + 'rules.rule.edit', compact( + 'rule', 'subTitle', + 'primaryTrigger', 'oldTriggers', 'oldActions', 'triggerCount', 'actionCount', 'ruleGroups' + ) + ); } /** diff --git a/app/Http/Controllers/Transaction/LinkController.php b/app/Http/Controllers/Transaction/LinkController.php index 4022e5fedc..98aaf10651 100644 --- a/app/Http/Controllers/Transaction/LinkController.php +++ b/app/Http/Controllers/Transaction/LinkController.php @@ -101,7 +101,7 @@ class LinkController extends Controller if ($alreadyLinked) { Session::flash('error', trans('firefly.journals_error_linked')); - return redirect(route('transactions.show', $journal->id)); + return redirect(route('transactions.show', [$journal->id])); } Log::debug(sprintf('Journal is %d, opposing is %d', $journal->id, $other->id)); @@ -123,9 +123,15 @@ class LinkController extends Controller $journalLink->save(); Session::flash('success', trans('firefly.journals_linked')); - return redirect(route('transactions.show', $journal->id)); + return redirect(route('transactions.show', [$journal->id])); } + /** + * @param LinkTypeRepositoryInterface $repository + * @param TransactionJournalLink $link + * + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + */ public function switch(LinkTypeRepositoryInterface $repository, TransactionJournalLink $link) { diff --git a/app/Http/Controllers/Transaction/SingleController.php b/app/Http/Controllers/Transaction/SingleController.php index ddace0e615..4c40a76125 100644 --- a/app/Http/Controllers/Transaction/SingleController.php +++ b/app/Http/Controllers/Transaction/SingleController.php @@ -413,9 +413,9 @@ class SingleController extends Controller /** * @return array */ - private function groupedActiveAccountList(): array + private function groupedAccountList(): array { - $accounts = $this->accounts->getActiveAccountsByType([AccountType::DEFAULT, AccountType::ASSET]); + $accounts = $this->accounts->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]); $return = []; /** @var Account $account */ foreach ($accounts as $account) { @@ -433,9 +433,9 @@ class SingleController extends Controller /** * @return array */ - private function groupedAccountList(): array + private function groupedActiveAccountList(): array { - $accounts = $this->accounts->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]); + $accounts = $this->accounts->getActiveAccountsByType([AccountType::DEFAULT, AccountType::ASSET]); $return = []; /** @var Account $account */ foreach ($accounts as $account) { diff --git a/app/Http/Controllers/Transaction/SplitController.php b/app/Http/Controllers/Transaction/SplitController.php index a3ea3b0efc..8f3783a476 100644 --- a/app/Http/Controllers/Transaction/SplitController.php +++ b/app/Http/Controllers/Transaction/SplitController.php @@ -211,8 +211,8 @@ class SplitController extends Controller } /** - * @param SplitJournalFormRequest $request - * @param TransactionJournal $journal + * @param SplitJournalFormRequest|Request $request + * @param TransactionJournal $journal * * @return array */ @@ -295,7 +295,7 @@ class SplitController extends Controller } /** - * @param Request $request + * @param SplitJournalFormRequest|Request $request * * @return array */ diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php index 7e042fbe7e..59465552e1 100644 --- a/app/Http/Controllers/TransactionController.php +++ b/app/Http/Controllers/TransactionController.php @@ -151,8 +151,10 @@ class TransactionController extends Controller } /** - * @param TransactionJournal $journal - * @param JournalTaskerInterface $tasker + * @param TransactionJournal $journal + * @param JournalTaskerInterface $tasker + * + * @param LinkTypeRepositoryInterface $linkTypeRepository * * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View */ @@ -198,7 +200,7 @@ class TransactionController extends Controller $cache->addProperty('transaction-list-entries'); if ($cache->has()) { - // return $cache->get(); // @codeCoverageIgnore + return $cache->get(); // @codeCoverageIgnore } Log::debug(sprintf('Going to get period expenses and incomes between %s and %s.', $start->format('Y-m-d'), $end->format('Y-m-d'))); diff --git a/app/Http/Requests/ExportFormRequest.php b/app/Http/Requests/ExportFormRequest.php index fac7f1ee2c..7b02ec5520 100644 --- a/app/Http/Requests/ExportFormRequest.php +++ b/app/Http/Requests/ExportFormRequest.php @@ -43,14 +43,14 @@ class ExportFormRequest extends Request $formats = join(',', array_keys(config('firefly.export_formats'))); return [ -// 'export_start_range' => 'required|date|after:' . $first, -// 'export_end_range' => 'required|date|before:' . $today, -// 'accounts' => 'required', -// 'job' => 'required|belongsToUser:export_jobs,key', -// 'accounts.*' => 'required|exists:accounts,id|belongsToUser:accounts', -// 'include_attachments' => 'in:0,1', -// 'include_config' => 'in:0,1', -// 'exportFormat' => 'in:' . $formats, + 'export_start_range' => 'required|date|after:' . $first, + 'export_end_range' => 'required|date|before:' . $today, + 'accounts' => 'required', + 'job' => 'required|belongsToUser:export_jobs,key', + 'accounts.*' => 'required|exists:accounts,id|belongsToUser:accounts', + 'include_attachments' => 'in:0,1', + 'include_config' => 'in:0,1', + 'exportFormat' => 'in:' . $formats, ]; } } diff --git a/app/Http/Requests/Request.php b/app/Http/Requests/Request.php index 30906089c5..04fa99de73 100644 --- a/app/Http/Requests/Request.php +++ b/app/Http/Requests/Request.php @@ -33,53 +33,6 @@ class Request extends FormRequest return intval($this->input($field)) === 1; } - /** - * @param string $field - * - * @return Carbon|null - */ - protected function date(string $field) - { - return $this->get($field) ? new Carbon($this->get($field)) : null; - } - - /** - * @param string $field - * - * @return float - */ - protected function float(string $field): float - { - return round($this->input($field), 12); - } - - /** - * @param string $field - * @param string $type - * - * @return array - */ - protected function getArray(string $field, string $type): array - { - $original = $this->get($field); - $return = []; - foreach ($original as $index => $value) { - $return[$index] = $this->$type($value); - } - - return $return; - } - - /** - * @param string $field - * - * @return int - */ - protected function integer(string $field): int - { - return intval($this->get($field)); - } - /** * @param string $field * @@ -140,4 +93,51 @@ class Request extends FormRequest return trim($string); } + + /** + * @param string $field + * + * @return Carbon|null + */ + protected function date(string $field) + { + return $this->get($field) ? new Carbon($this->get($field)) : null; + } + + /** + * @param string $field + * + * @return float + */ + protected function float(string $field): float + { + return round($this->input($field), 12); + } + + /** + * @param string $field + * @param string $type + * + * @return array + */ + protected function getArray(string $field, string $type): array + { + $original = $this->get($field); + $return = []; + foreach ($original as $index => $value) { + $return[$index] = $this->$type($value); + } + + return $return; + } + + /** + * @param string $field + * + * @return int + */ + protected function integer(string $field): int + { + return intval($this->get($field)); + } } diff --git a/app/Mail/RegisteredUser.php b/app/Mail/RegisteredUser.php index 3f820ed719..bb1468035a 100644 --- a/app/Mail/RegisteredUser.php +++ b/app/Mail/RegisteredUser.php @@ -12,7 +12,6 @@ declare(strict_types=1); - /** * RegisteredUser.php * Copyright (c) 2017 thegrumpydictator@gmail.com diff --git a/app/Mail/RequestedNewPassword.php b/app/Mail/RequestedNewPassword.php index 58b0a42f05..e638c04de2 100644 --- a/app/Mail/RequestedNewPassword.php +++ b/app/Mail/RequestedNewPassword.php @@ -12,7 +12,6 @@ declare(strict_types=1); - /** * RequestedNewPassword.php * Copyright (c) 2017 thegrumpydictator@gmail.com diff --git a/app/Models/PiggyBank.php b/app/Models/PiggyBank.php index 2c8d67539c..19bf7de6b2 100644 --- a/app/Models/PiggyBank.php +++ b/app/Models/PiggyBank.php @@ -84,6 +84,7 @@ class PiggyBank extends Model return $this->currentRep; } // repeating piggy banks are no longer supported. + /** @var PiggyBankRepetition $rep */ $rep = $this->piggyBankRepetitions()->first(['piggy_bank_repetitions.*']); if (is_null($rep)) { return new PiggyBankRepetition(); diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php index d0f1e4ab8e..275ae35af2 100644 --- a/app/Models/TransactionJournal.php +++ b/app/Models/TransactionJournal.php @@ -140,6 +140,14 @@ class TransactionJournal extends Model return true; } + /** + * @return HasMany + */ + public function destinationJournalLinks(): HasMany + { + return $this->hasMany(TransactionJournalLink::class, 'destination_id'); + } + /** * * @param $value @@ -379,13 +387,6 @@ class TransactionJournal extends Model { return $this->hasMany(TransactionJournalLink::class, 'source_id'); } - /** - * @return HasMany - */ - public function destinationJournalLinks(): HasMany - { - return $this->hasMany(TransactionJournalLink::class, 'destination_id'); - } /** * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany diff --git a/app/Repositories/LinkType/LinkTypeRepositoryInterface.php b/app/Repositories/LinkType/LinkTypeRepositoryInterface.php index 32042514e6..a67fe34805 100644 --- a/app/Repositories/LinkType/LinkTypeRepositoryInterface.php +++ b/app/Repositories/LinkType/LinkTypeRepositoryInterface.php @@ -39,6 +39,13 @@ interface LinkTypeRepositoryInterface */ public function destroy(LinkType $linkType, LinkType $moveTo): bool; + /** + * @param TransactionJournalLink $link + * + * @return bool + */ + public function destroyLink(TransactionJournalLink $link): bool; + /** * @param int $id * @@ -46,20 +53,6 @@ interface LinkTypeRepositoryInterface */ public function find(int $id): LinkType; - /** - * @param TransactionJournalLink $link - * - * @return bool - */ - public function destroyLink(TransactionJournalLink $link):bool; - - /** - * @param TransactionJournalLink $link - * - * @return bool - */ - public function switchLink(TransactionJournalLink $link): bool; - /** * Check if link exists between journals. * @@ -91,6 +84,13 @@ interface LinkTypeRepositoryInterface */ public function store(array $data): LinkType; + /** + * @param TransactionJournalLink $link + * + * @return bool + */ + public function switchLink(TransactionJournalLink $link): bool; + /** * @param LinkType $linkType * @param array $data diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.php index 3f3218da19..bc0b780065 100644 --- a/app/Repositories/Tag/TagRepository.php +++ b/app/Repositories/Tag/TagRepository.php @@ -186,6 +186,34 @@ class TagRepository implements TagRepositoryInterface return new Carbon; } + /** + * Same as sum of tag but substracts income instead of adding it as well. + * + * @param Tag $tag + * @param Carbon|null $start + * @param Carbon|null $end + * + * @return string + */ + public function resultOfTag(Tag $tag, ?Carbon $start, ?Carbon $end): string + { + /** @var JournalCollectorInterface $collector */ + $collector = app(JournalCollectorInterface::class); + + if (!is_null($start) && !is_null($end)) { + $collector->setRange($start, $end); + } + + $collector->setAllAssetAccounts()->setTag($tag); + $journals = $collector->getJournals(); + $sum = '0'; + foreach ($journals as $journal) { + $sum = bcadd($sum, strval($journal->transaction_amount)); + } + + return strval($sum); + } + /** * @param User $user */ @@ -262,34 +290,6 @@ class TagRepository implements TagRepositoryInterface return strval($sum); } - /** - * Same as sum of tag but substracts income instead of adding it as well. - * - * @param Tag $tag - * @param Carbon|null $start - * @param Carbon|null $end - * - * @return string - */ - public function resultOfTag(Tag $tag, ?Carbon $start, ?Carbon $end): string - { - /** @var JournalCollectorInterface $collector */ - $collector = app(JournalCollectorInterface::class); - - if (!is_null($start) && !is_null($end)) { - $collector->setRange($start, $end); - } - - $collector->setAllAssetAccounts()->setTag($tag); - $journals = $collector->getJournals(); - $sum = '0'; - foreach ($journals as $journal) { - $sum = bcadd($sum, strval($journal->transaction_amount)); - } - - return strval($sum); - } - /** * Generates a tag cloud. * @@ -380,13 +380,14 @@ class TagRepository implements TagRepositoryInterface Log::debug(sprintf('AmountDiff is %f', $amountDiff)); // no difference? Every tag same range: - if($amountDiff === 0.0) { + if ($amountDiff === 0.0) { Log::debug(sprintf('AmountDiff is zero, return %d', $range[0])); + return $range[0]; } - $diff = $range[1] - $range[0]; - $step = 1; + $diff = $range[1] - $range[0]; + $step = 1; if ($diff != 0) { $step = $amountDiff / $diff; } diff --git a/app/Repositories/Tag/TagRepositoryInterface.php b/app/Repositories/Tag/TagRepositoryInterface.php index 85e54f58c7..688c71dd90 100644 --- a/app/Repositories/Tag/TagRepositoryInterface.php +++ b/app/Repositories/Tag/TagRepositoryInterface.php @@ -103,11 +103,6 @@ interface TagRepositoryInterface */ public function lastUseDate(Tag $tag): Carbon; - /** - * @param User $user - */ - public function setUser(User $user); - /** * @param Tag $tag * @param Carbon|null $start @@ -117,6 +112,11 @@ interface TagRepositoryInterface */ public function resultOfTag(Tag $tag, ?Carbon $start, ?Carbon $end): string; + /** + * @param User $user + */ + public function setUser(User $user); + /** * @param Tag $tag * @param Carbon $start diff --git a/app/Rules/Processor.php b/app/Rules/Processor.php index 4ad14ea467..5916da22e5 100644 --- a/app/Rules/Processor.php +++ b/app/Rules/Processor.php @@ -119,7 +119,7 @@ final class Processor $self = new self; foreach ($triggers as $entry) { $entry['value'] = is_null($entry['value']) ? '' : $entry['value']; - $trigger = TriggerFactory::makeTriggerFromStrings($entry['type'], $entry['value'], $entry['stopProcessing']); + $trigger = TriggerFactory::makeTriggerFromStrings($entry['type'], $entry['value'], $entry['stopProcessing']); $self->triggers->push($trigger); } diff --git a/app/Services/Bunq/Object/NotificationFilter.php b/app/Services/Bunq/Object/NotificationFilter.php index c6c89d1ada..16e24410c9 100644 --- a/app/Services/Bunq/Object/NotificationFilter.php +++ b/app/Services/Bunq/Object/NotificationFilter.php @@ -26,8 +26,6 @@ class NotificationFilter extends BunqObject */ public function __construct(array $data) { - var_dump($data); - exit; } } diff --git a/app/Services/Bunq/Object/UserPerson.php b/app/Services/Bunq/Object/UserPerson.php index 0fea94bd44..7a3c865e6b 100644 --- a/app/Services/Bunq/Object/UserPerson.php +++ b/app/Services/Bunq/Object/UserPerson.php @@ -127,11 +127,6 @@ class UserPerson extends BunqObject // document front, back attachment // customer, customer_limit // billing contracts - - // echo '
';
-        //        print_r($data);
-        //        var_dump($this);
-        //        echo '
'; } /** diff --git a/app/Services/Bunq/Request/DeleteDeviceSessionRequest.php b/app/Services/Bunq/Request/DeleteDeviceSessionRequest.php index cccb466c9b..cd70b833c9 100644 --- a/app/Services/Bunq/Request/DeleteDeviceSessionRequest.php +++ b/app/Services/Bunq/Request/DeleteDeviceSessionRequest.php @@ -12,7 +12,6 @@ declare(strict_types=1); namespace FireflyIII\Services\Bunq\Request; -use FireflyIII\Services\Bunq\Token\InstallationToken; use FireflyIII\Services\Bunq\Token\SessionToken; use Log; @@ -36,6 +35,7 @@ class DeleteDeviceSessionRequest extends BunqRequest $headers = $this->getDefaultHeaders(); $headers['X-Bunq-Client-Authentication'] = $this->sessionToken->getToken(); $this->sendSignedBunqDelete($uri, $headers); + return; } diff --git a/app/Services/Bunq/Request/ListDeviceServerRequest.php b/app/Services/Bunq/Request/ListDeviceServerRequest.php index fe0f33dec2..bfc7b7109f 100644 --- a/app/Services/Bunq/Request/ListDeviceServerRequest.php +++ b/app/Services/Bunq/Request/ListDeviceServerRequest.php @@ -34,15 +34,6 @@ class ListDeviceServerRequest extends BunqRequest $this->devices = new Collection; } - /** - * @return Collection - */ - public function getDevices(): Collection - { - return $this->devices; - } - - /** * */ @@ -64,6 +55,14 @@ class ListDeviceServerRequest extends BunqRequest return; } + /** + * @return Collection + */ + public function getDevices(): Collection + { + return $this->devices; + } + /** * @param InstallationToken $installationToken */ diff --git a/app/Services/Bunq/Request/ListMonetaryAccountRequest.php b/app/Services/Bunq/Request/ListMonetaryAccountRequest.php index b2762de940..6378edff8c 100644 --- a/app/Services/Bunq/Request/ListMonetaryAccountRequest.php +++ b/app/Services/Bunq/Request/ListMonetaryAccountRequest.php @@ -30,14 +30,6 @@ class ListMonetaryAccountRequest extends BunqRequest /** @var int */ private $userId = 0; - /** - * @return Collection - */ - public function getMonetaryAccounts(): Collection - { - return $this->monetaryAccounts; - } - /** * */ @@ -60,6 +52,14 @@ class ListMonetaryAccountRequest extends BunqRequest return; } + /** + * @return Collection + */ + public function getMonetaryAccounts(): Collection + { + return $this->monetaryAccounts; + } + /** * @param SessionToken $sessionToken */ diff --git a/app/Support/Import/Information/BunqInformation.php b/app/Support/Import/Information/BunqInformation.php index 8f59243286..dc1428e103 100644 --- a/app/Support/Import/Information/BunqInformation.php +++ b/app/Support/Import/Information/BunqInformation.php @@ -13,7 +13,6 @@ declare(strict_types=1); namespace FireflyIII\Support\Import\Information; use FireflyIII\Exceptions\FireflyException; -use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use FireflyIII\Services\Bunq\Object\Alias; use FireflyIII\Services\Bunq\Object\MonetaryAccountBank; use FireflyIII\Services\Bunq\Request\DeleteDeviceSessionRequest; diff --git a/app/Support/Import/Information/InformationInterface.php b/app/Support/Import/Information/InformationInterface.php index 9cf5106082..980703e26a 100644 --- a/app/Support/Import/Information/InformationInterface.php +++ b/app/Support/Import/Information/InformationInterface.php @@ -13,7 +13,6 @@ declare(strict_types=1); namespace FireflyIII\Support\Import\Information; use FireflyIII\User; -use Illuminate\Support\Collection; /** * Interface InformationInterface @@ -23,13 +22,6 @@ use Illuminate\Support\Collection; interface InformationInterface { - /** - * Set the user for this Prerequisites-routine. Class is expected to implement and save this. - * - * @param User $user - */ - public function setUser(User $user): void; - /** * Returns a collection of accounts. Preferrably, these follow a uniform Firefly III format so they can be managed over banks. * @@ -46,4 +38,11 @@ interface InformationInterface * @return array */ public function getAccounts(): array; + + /** + * Set the user for this Prerequisites-routine. Class is expected to implement and save this. + * + * @param User $user + */ + public function setUser(User $user): void; } diff --git a/app/Support/Import/Prerequisites/PrerequisitesInterface.php b/app/Support/Import/Prerequisites/PrerequisitesInterface.php index 393a3d82a5..03c62fc910 100644 --- a/app/Support/Import/Prerequisites/PrerequisitesInterface.php +++ b/app/Support/Import/Prerequisites/PrerequisitesInterface.php @@ -32,13 +32,6 @@ interface PrerequisitesInterface */ public function getViewParameters(): array; - /** - * @param Request $request - * - * @return MessageBag - */ - public function storePrerequisites(Request $request): MessageBag; - /** * Returns if this import method has any special prerequisites such as config * variables or other things. @@ -53,4 +46,11 @@ interface PrerequisitesInterface * @param User $user */ public function setUser(User $user): void; + + /** + * @param Request $request + * + * @return MessageBag + */ + public function storePrerequisites(Request $request): MessageBag; } diff --git a/app/Support/Search/Search.php b/app/Support/Search/Search.php index 95f292def8..55dea965d2 100644 --- a/app/Support/Search/Search.php +++ b/app/Support/Search/Search.php @@ -112,7 +112,7 @@ class Search implements SearchInterface $collector->withOpposingAccount()->withCategoryInformation()->withBudgetInformation(); } $collector->removeFilter(InternalTransferFilter::class); - $set = $collector->getPaginatedJournals()->getCollection(); + $set = $collector->getPaginatedJournals()->getCollection(); Log::debug(sprintf('Found %d journals to check. ', $set->count())); diff --git a/app/Support/Twig/AmountFormat.php b/app/Support/Twig/AmountFormat.php index 5033388258..3f9cd2ebcf 100644 --- a/app/Support/Twig/AmountFormat.php +++ b/app/Support/Twig/AmountFormat.php @@ -114,14 +114,11 @@ class AmountFormat extends Twig_Extension * * @return Twig_SimpleFunction */ - protected function formatAmountBySymbol(): Twig_SimpleFunction + protected function formatAmountByCurrency(): Twig_SimpleFunction { return new Twig_SimpleFunction( - 'formatAmountBySymbol', function (string $amount, string $symbol, int $decimalPlaces = 2, bool $coloured = true): string { + 'formatAmountByCurrency', function (TransactionCurrency $currency, string $amount, bool $coloured = true): string { - $currency = new TransactionCurrency; - $currency->symbol = $symbol; - $currency->decimal_places = $decimalPlaces; return app('amount')->formatAnything($currency, $amount, $coloured); @@ -134,10 +131,14 @@ class AmountFormat extends Twig_Extension * * @return Twig_SimpleFunction */ - protected function formatAmountByCurrency(): Twig_SimpleFunction + protected function formatAmountBySymbol(): Twig_SimpleFunction { return new Twig_SimpleFunction( - 'formatAmountByCurrency', function (TransactionCurrency $currency, string $amount, bool $coloured = true): string { + 'formatAmountBySymbol', function (string $amount, string $symbol, int $decimalPlaces = 2, bool $coloured = true): string { + + $currency = new TransactionCurrency; + $currency->symbol = $symbol; + $currency->decimal_places = $decimalPlaces; return app('amount')->formatAnything($currency, $amount, $coloured); diff --git a/app/Support/Twig/Translation.php b/app/Support/Twig/Translation.php index ef64b3aca7..40ce29ebdb 100644 --- a/app/Support/Twig/Translation.php +++ b/app/Support/Twig/Translation.php @@ -57,6 +57,14 @@ class Translation extends Twig_Extension } + /** + * {@inheritDoc} + */ + public function getName(): string + { + return 'FireflyIII\Support\Twig\Translation'; + } + /** * @return Twig_SimpleFunction */ @@ -64,9 +72,9 @@ class Translation extends Twig_Extension { return new Twig_SimpleFunction( 'journalLinkTranslation', function (int $linkTypeId, string $direction, string $original) { - $key = sprintf('firefly.%d_%s', $linkTypeId, $direction); + $key = sprintf('firefly.%d_%s', $linkTypeId, $direction); $translation = trans($key); - if($key === $translation) { + if ($key === $translation) { return $original; } @@ -76,12 +84,4 @@ class Translation extends Twig_Extension }, ['is_safe' => ['html']] ); } - - /** - * {@inheritDoc} - */ - public function getName(): string - { - return 'FireflyIII\Support\Twig\Translation'; - } } diff --git a/tests/Feature/Controllers/JsonControllerTest.php b/tests/Feature/Controllers/JsonControllerTest.php index 72567af9a8..a4a7c3cf94 100644 --- a/tests/Feature/Controllers/JsonControllerTest.php +++ b/tests/Feature/Controllers/JsonControllerTest.php @@ -13,14 +13,12 @@ namespace Tests\Feature\Controllers; use Amount; use FireflyIII\Helpers\Collector\JournalCollectorInterface; -use FireflyIII\Models\AccountType; use FireflyIII\Models\Budget; use FireflyIII\Models\Category; use FireflyIII\Models\Tag; use FireflyIII\Models\Transaction; use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionType; -use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Bill\BillRepositoryInterface; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; use FireflyIII\Repositories\Category\CategoryRepositoryInterface; diff --git a/tests/Feature/Controllers/TagControllerTest.php b/tests/Feature/Controllers/TagControllerTest.php index 4846cd6136..ef7cd4286b 100644 --- a/tests/Feature/Controllers/TagControllerTest.php +++ b/tests/Feature/Controllers/TagControllerTest.php @@ -18,7 +18,6 @@ use FireflyIII\Models\TransactionJournal; use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\Tag\TagRepositoryInterface; use Illuminate\Pagination\LengthAwarePaginator; -use Illuminate\Support\Collection; use Tests\TestCase; diff --git a/tests/Feature/Controllers/TransactionControllerTest.php b/tests/Feature/Controllers/TransactionControllerTest.php index 3465d7c59e..711ea5bf50 100644 --- a/tests/Feature/Controllers/TransactionControllerTest.php +++ b/tests/Feature/Controllers/TransactionControllerTest.php @@ -19,7 +19,6 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\Journal\JournalTaskerInterface; use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Support\Collection; -use Steam; use Tests\TestCase; /**