diff --git a/app/Console/Commands/EncryptFile.php b/app/Console/Commands/EncryptFile.php index 174cc3917e..734da2de91 100644 --- a/app/Console/Commands/EncryptFile.php +++ b/app/Console/Commands/EncryptFile.php @@ -46,8 +46,6 @@ class EncryptFile extends Command /** * Execute the console command. - * - * @return mixed */ public function handle() { @@ -64,6 +62,5 @@ class EncryptFile extends Command $path = storage_path('upload') . '/' . $newName; file_put_contents($path, $content); $this->line(sprintf('Encrypted "%s" and put it in "%s"', $file, $path)); - } } diff --git a/app/Console/Commands/UpgradeFireflyInstructions.php b/app/Console/Commands/UpgradeFireflyInstructions.php index 7881f87646..561858ba9e 100644 --- a/app/Console/Commands/UpgradeFireflyInstructions.php +++ b/app/Console/Commands/UpgradeFireflyInstructions.php @@ -44,8 +44,6 @@ class UpgradeFireflyInstructions extends Command /** * Execute the console command. - * - * @return mixed */ public function handle() { diff --git a/app/Console/Commands/VerifyDatabase.php b/app/Console/Commands/VerifyDatabase.php index 4cd64ec5af..5fed76218f 100644 --- a/app/Console/Commands/VerifyDatabase.php +++ b/app/Console/Commands/VerifyDatabase.php @@ -55,8 +55,6 @@ class VerifyDatabase extends Command /** * Execute the console command. - * - * @return mixed */ public function handle() { diff --git a/app/Handlers/Events/ConnectJournalToPiggyBank.php b/app/Handlers/Events/ConnectJournalToPiggyBank.php index 7aed8a222d..b0c9daa9a2 100644 --- a/app/Handlers/Events/ConnectJournalToPiggyBank.php +++ b/app/Handlers/Events/ConnectJournalToPiggyBank.php @@ -39,7 +39,7 @@ class ConnectJournalToPiggyBank $piggyBankId = $event->piggyBankId; /** @var PiggyBank $piggyBank */ - $piggyBank = Auth::user()->piggybanks()->where('piggy_banks.id', $piggyBankId)->first(['piggy_banks.*']); + $piggyBank = Auth::user()->piggyBanks()->where('piggy_banks.id', $piggyBankId)->first(['piggy_banks.*']); if (is_null($piggyBank)) { return true; diff --git a/app/Helpers/Attachments/AttachmentHelper.php b/app/Helpers/Attachments/AttachmentHelper.php index 41bbe24922..b1045e4d78 100644 --- a/app/Helpers/Attachments/AttachmentHelper.php +++ b/app/Helpers/Attachments/AttachmentHelper.php @@ -250,6 +250,8 @@ class AttachmentHelper implements AttachmentHelperInterface /** * @param array $files * + * @param Model $model + * * @return bool */ private function processFiles(array $files, Model $model): bool diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php deleted file mode 100644 index fab6760b05..0000000000 --- a/app/Helpers/Csv/Importer.php +++ /dev/null @@ -1,385 +0,0 @@ -errors; - } - - /** - * Used by CsvController - * - * @return int - */ - public function getImported(): int - { - return $this->imported; - } - - /** - * @return Collection - */ - public function getJournals(): Collection - { - return $this->journals; - } - - /** - * Used by CsvController - * - * @return int - */ - public function getRows(): int - { - return $this->rows; - } - - /** - * @return array - */ - public function getSpecifix(): array - { - return is_array($this->specifix) ? $this->specifix : []; - } - - /** - * @throws FireflyException - */ - public function run() - { - set_time_limit(0); - - $this->journals = new Collection; - $this->map = $this->data->getMap(); - $this->roles = $this->data->getRoles(); - $this->mapped = $this->data->getMapped(); - $this->specifix = $this->data->getSpecifix(); - - foreach ($this->data->getReader() as $index => $row) { - if ($this->parseRow($index)) { - $this->rows++; - $result = $this->importRow($row); - if (!($result instanceof TransactionJournal)) { - Log::error('Caught error at row #' . $index . ': ' . $result); - $this->errors[$index] = $result; - } else { - $this->imported++; - $this->journals->push($result); - event(new TransactionJournalStored($result, 0)); - } - } - } - } - - /** - * @param Data $data - */ - public function setData(Data $data) - { - $this->data = $data; - } - - /** - * @return TransactionJournal|string - */ - protected function createTransactionJournal() - { - $date = $this->importData['date']; - if (is_null($this->importData['date'])) { - $date = $this->importData['date-rent']; - } - - - $transactionType = $this->getTransactionType(); // defaults to deposit - $errors = new MessageBag; - - $journal = TransactionJournal::create( - [ - 'user_id' => Auth::user()->id, - 'transaction_type_id' => $transactionType->id, - 'transaction_currency_id' => $this->importData['currency']->id, - 'description' => $this->importData['description'], - 'completed' => 0, - 'date' => $date, - 'bill_id' => $this->importData['bill-id'], - ] - ); - if ($journal->getErrors()->count() == 0) { - // first transaction - $accountId = $this->importData['asset-account-object']->id; // create first transaction: - $amount = $this->importData['amount']; - $transaction = Transaction::create(['transaction_journal_id' => $journal->id, 'account_id' => $accountId, 'amount' => $amount]); - $errors = $transaction->getErrors(); - - // second transaction - $accountId = $this->importData['opposing-account-object']->id; // create second transaction: - $amount = bcmul($this->importData['amount'], '-1'); - $transaction = Transaction::create(['transaction_journal_id' => $journal->id, 'account_id' => $accountId, 'amount' => $amount]); - $errors = $transaction->getErrors()->merge($errors); - } - if ($errors->count() == 0) { - $journal->completed = 1; - $journal->save(); - } else { - $text = join(',', $errors->all()); - - return $text; - } - $this->saveBudget($journal); - $this->saveCategory($journal); - $this->saveTags($journal); - - // some debug info: - $journalId = $journal->id; - $type = $journal->transaction_type_type ?? $journal->transactionType->type; - /** @var Account $asset */ - $asset = $this->importData['asset-account-object']; - /** @var Account $opposing */ - $opposing = $this->importData['opposing-account-object']; - - Log::info('Created journal #' . $journalId . ' of type ' . $type . '!'); - Log::info('Asset account #' . $asset->id . ' lost/gained: ' . $this->importData['amount']); - Log::info($opposing->accountType->type . ' #' . $opposing->id . ' lost/gained: ' . bcmul($this->importData['amount'], '-1')); - - return $journal; - } - - /** - * @return TransactionType - */ - protected function getTransactionType() - { - $transactionType = TransactionType::where('type', TransactionType::DEPOSIT)->first(); - if ($this->importData['amount'] < 0) { - $transactionType = TransactionType::where('type', TransactionType::WITHDRAWAL)->first(); - } - - if (in_array($this->importData['opposing-account-object']->accountType->type, ['Asset account', 'Default account'])) { - $transactionType = TransactionType::where('type', TransactionType::TRANSFER)->first(); - } - - return $transactionType; - } - - /** - * @param array $row - * - * @throws FireflyException - * @return string|bool - */ - protected function importRow(array $row) - { - - $data = $this->getFiller(); // These fields are necessary to create a new transaction journal. Some are optional - foreach ($row as $index => $value) { - $role = $this->roles[$index] ?? '_ignore'; - $class = config('csv.roles.' . $role . '.converter'); - $field = config('csv.roles.' . $role . '.field'); - - - // here would be the place where preprocessors would fire. - - /** @var ConverterInterface $converter */ - $converter = app('FireflyIII\Helpers\Csv\Converter\\' . $class); - $converter->setData($data); // the complete array so far. - $converter->setField($field); - $converter->setIndex($index); - $converter->setMapped($this->mapped); - $converter->setValue($value); - $data[$field] = $converter->convert(); - } - // move to class vars. - $this->importData = $data; - $this->importRow = $row; - unset($data, $row); - // post processing and validating. - $this->postProcess(); - $result = $this->validateData(); - - if (!($result === true)) { - return $result; // return error. - } - $journal = $this->createTransactionJournal(); - - return $journal; - } - - /** - * @param int $index - * - * @return bool - */ - protected function parseRow(int $index) - { - return (($this->data->hasHeaders() && $index >= 1) || !$this->data->hasHeaders()); - } - - /** - * Row denotes the original data. - * - * @return void - */ - protected function postProcess() - { - // do bank specific fixes (must be enabled but now all of them. - - foreach ($this->getSpecifix() as $className) { - /** @var SpecifixInterface $specifix */ - $specifix = app('FireflyIII\Helpers\Csv\Specifix\\' . $className); - if ($specifix->getProcessorType() == SpecifixInterface::POST_PROCESSOR) { - $specifix->setData($this->importData); - $specifix->setRow($this->importRow); - $this->importData = $specifix->fix(); - } - } - - - $set = config('csv.post_processors'); - foreach ($set as $className) { - /** @var PostProcessorInterface $postProcessor */ - $postProcessor = app('FireflyIII\Helpers\Csv\PostProcessing\\' . $className); - $array = $this->importData ?? []; - $postProcessor->setData($array); - $this->importData = $postProcessor->process(); - } - - } - - /** - * @param TransactionJournal $journal - */ - protected function saveBudget(TransactionJournal $journal) - { - // add budget: - if (!is_null($this->importData['budget'])) { - $journal->budgets()->save($this->importData['budget']); - } - } - - /** - * @param TransactionJournal $journal - */ - protected function saveCategory(TransactionJournal $journal) - { - // add category: - if (!is_null($this->importData['category'])) { - $journal->categories()->save($this->importData['category']); - } - } - - /** - * @param TransactionJournal $journal - */ - protected function saveTags(TransactionJournal $journal) - { - if (!is_null($this->importData['tags'])) { - foreach ($this->importData['tags'] as $tag) { - $journal->tags()->save($tag); - } - } - } - - /** - * - * @return bool|string - */ - protected function validateData() - { - $date = $this->importData['date'] ?? null; - $rentDate = $this->importData['date-rent'] ?? null; - if (is_null($date) && is_null($rentDate)) { - return 'No date value for this row.'; - } - if (is_null($this->importData['opposing-account-object'])) { - return 'Opposing account is null'; - } - - if (!($this->importData['asset-account-object'] instanceof Account)) { - return 'No asset account to import into.'; - } - - return true; - } - - /** - * @return array - */ - private function getFiller() - { - $filler = []; - foreach (config('csv.roles') as $role) { - if (isset($role['field'])) { - $fieldName = $role['field']; - $filler[$fieldName] = null; - } - } - // some extra's: - $filler['bill-id'] = null; - $filler['opposing-account-object'] = null; - $filler['asset-account-object'] = null; - $filler['amount-modifier'] = '1'; - - return $filler; - - } - -} diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.php index 6fe2734ff5..67de6c1e97 100644 --- a/app/Helpers/Report/ReportHelper.php +++ b/app/Helpers/Report/ReportHelper.php @@ -82,8 +82,8 @@ class ReportHelper implements ReportHelperInterface $billLine = new BillLine; $billLine->setBill($bill); $billLine->setActive(intval($bill->active) === 1); - $billLine->setMin($bill->amount_min); - $billLine->setMax($bill->amount_max); + $billLine->setMin(strval($bill->amount_min)); + $billLine->setMax(strval($bill->amount_max)); $billLine->setHit(false); // is hit in period? diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index f5381b4512..355868dd6e 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -50,7 +50,7 @@ class AccountController extends Controller /** * @param string $what * - * @return \Illuminate\View\View + * @return View */ public function create(string $what = 'asset') { @@ -116,7 +116,7 @@ class AccountController extends Controller * @param ARI $repository * @param Account $account * - * @return \Illuminate\View\View + * @return View */ public function edit(ARI $repository, Account $account) { @@ -172,7 +172,9 @@ class AccountController extends Controller $subTitleIcon = config('firefly.subIconsByIdentifier.' . $what); $types = config('firefly.accountTypesByIdentifier.' . $what); $accounts = $crud->getAccountsByType($types); + /** @var Carbon $start */ $start = clone session('start', Carbon::now()->startOfMonth()); + /** @var Carbon $end */ $end = clone session('end', Carbon::now()->endOfMonth()); $start->subDay(); @@ -196,7 +198,7 @@ class AccountController extends Controller * @param ARI $repository * @param Account $account * - * @return \Illuminate\View\View + * @return View */ public function show(ARI $repository, Account $account) { @@ -204,7 +206,9 @@ class AccountController extends Controller $subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type); $subTitle = $account->name; $range = Preferences::get('viewRange', '1M')->data; + /** @var Carbon $start */ $start = session('start', Navigation::startOfPeriod(new Carbon, $range)); + /** @var Carbon $end */ $end = session('end', Navigation::endOfPeriod(new Carbon, $range)); $page = intval(Input::get('page')); $pageSize = Preferences::get('transactionPageSize', 50)->data; @@ -287,7 +291,7 @@ class AccountController extends Controller * @param AccountFormRequest $request * @param AccountCrudInterface $crud * - * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function store(AccountFormRequest $request, AccountCrudInterface $crud) { @@ -335,7 +339,7 @@ class AccountController extends Controller * @param AccountCrudInterface $crud * @param Account $account * - * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function update(AccountFormRequest $request, AccountCrudInterface $crud, Account $account) { diff --git a/app/Http/Controllers/AttachmentController.php b/app/Http/Controllers/AttachmentController.php index 73826b72ec..2f62c3ba27 100644 --- a/app/Http/Controllers/AttachmentController.php +++ b/app/Http/Controllers/AttachmentController.php @@ -47,7 +47,7 @@ class AttachmentController extends Controller /** * @param Attachment $attachment * - * @return \Illuminate\View\View + * @return View */ public function delete(Attachment $attachment) { @@ -116,7 +116,7 @@ class AttachmentController extends Controller /** * @param Attachment $attachment * - * @return \Illuminate\View\View + * @return View */ public function edit(Attachment $attachment) { diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index e66c2561e9..5d306246b6 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -223,7 +223,7 @@ class AuthController extends Controller * @param \Illuminate\Http\Request $request * @param string $message * - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse */ protected function sendFailedLoginResponse(Request $request, string $message) { diff --git a/app/Http/Controllers/Auth/ConfirmationController.php b/app/Http/Controllers/Auth/ConfirmationController.php index ea45b5efb8..2a07f9563b 100644 --- a/app/Http/Controllers/Auth/ConfirmationController.php +++ b/app/Http/Controllers/Auth/ConfirmationController.php @@ -68,6 +68,8 @@ class ConfirmationController extends Controller /** * @param Request $request + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function resendConfirmation(Request $request) { diff --git a/app/Http/Controllers/Auth/PasswordController.php b/app/Http/Controllers/Auth/PasswordController.php index 6c72dd16c4..5eb4f8e4dc 100644 --- a/app/Http/Controllers/Auth/PasswordController.php +++ b/app/Http/Controllers/Auth/PasswordController.php @@ -55,7 +55,7 @@ class PasswordController extends Controller * * @param \Illuminate\Http\Request $request * - * @return \Illuminate\Http\Response + * @return \Symfony\Component\HttpFoundation\Response */ public function sendResetLinkEmail(Request $request) { diff --git a/app/Http/Controllers/BillController.php b/app/Http/Controllers/BillController.php index 47ca757b4d..71c22a00b8 100644 --- a/app/Http/Controllers/BillController.php +++ b/app/Http/Controllers/BillController.php @@ -41,7 +41,7 @@ class BillController extends Controller } /** - * @return \Illuminate\View\View + * @return View */ public function create() { @@ -66,7 +66,7 @@ class BillController extends Controller /** * @param Bill $bill * - * @return \Illuminate\View\View + * @return View */ public function delete(Bill $bill) { @@ -99,7 +99,7 @@ class BillController extends Controller /** * @param Bill $bill * - * @return \Illuminate\View\View + * @return View */ public function edit(Bill $bill) { @@ -123,11 +123,13 @@ class BillController extends Controller /** * @param BillRepositoryInterface $repository * - * @return \Illuminate\View\View + * @return View */ public function index(BillRepositoryInterface $repository) { + /** @var Carbon $start */ $start = session('start'); + /** @var Carbon $end */ $end = session('end'); $bills = $repository->getBills(); @@ -187,7 +189,7 @@ class BillController extends Controller * @param BillRepositoryInterface $repository * @param Bill $bill * - * @return \Illuminate\View\View + * @return View */ public function show(BillRepositoryInterface $repository, Bill $bill) { @@ -195,7 +197,7 @@ class BillController extends Controller $date = session('start'); $year = $date->year; $page = intval(Input::get('page')) == 0 ? 1 : intval(Input::get('page')); - $pageSize = Preferences::get('transactionPageSize', 50)->data; + $pageSize = intval(Preferences::get('transactionPageSize', 50)->data); $journals = $repository->getJournals($bill, $page, $pageSize); $yearAverage = $repository->getYearAverage($bill, $date); $overallAverage = $repository->getOverallAverage($bill); diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php index e6f517c9a8..5451b8050c 100644 --- a/app/Http/Controllers/BudgetController.php +++ b/app/Http/Controllers/BudgetController.php @@ -82,7 +82,7 @@ class BudgetController extends Controller } /** - * @return \Illuminate\View\View + * @return View */ public function create() { @@ -101,7 +101,7 @@ class BudgetController extends Controller /** * @param Budget $budget * - * @return \Illuminate\View\View + * @return View */ public function delete(Budget $budget) { @@ -138,7 +138,7 @@ class BudgetController extends Controller /** * @param Budget $budget * - * @return \Illuminate\View\View + * @return View */ public function edit(Budget $budget) { @@ -237,7 +237,7 @@ class BudgetController extends Controller /** * @param BudgetRepositoryInterface $repository * - * @return \Illuminate\View\View + * @return View */ public function noBudget(BudgetRepositoryInterface $repository) { @@ -411,7 +411,7 @@ class BudgetController extends Controller } /** - * @return \Illuminate\View\View + * @return View */ public function updateIncome() { diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php index b826da6030..77ddfde730 100644 --- a/app/Http/Controllers/CategoryController.php +++ b/app/Http/Controllers/CategoryController.php @@ -47,7 +47,7 @@ class CategoryController extends Controller } /** - * @return \Illuminate\View\View + * @return View */ public function create() { @@ -66,7 +66,7 @@ class CategoryController extends Controller /** * @param Category $category * - * @return \Illuminate\View\View + * @return View */ public function delete(Category $category) { @@ -101,7 +101,7 @@ class CategoryController extends Controller /** * @param Category $category * - * @return \Illuminate\View\View + * @return View */ public function edit(Category $category) { @@ -122,7 +122,7 @@ class CategoryController extends Controller /** * @param CRI $repository * - * @return \Illuminate\View\View + * @return View */ public function index(CRI $repository) { @@ -140,7 +140,7 @@ class CategoryController extends Controller /** * @param CRI $repository * - * @return \Illuminate\View\View + * @return View */ public function noCategory(CRI $repository) { @@ -166,9 +166,10 @@ class CategoryController extends Controller */ public function show(CRI $repository, AccountCrudInterface $crud, Category $category) { - /** @var Carbon $carbon */ $range = Preferences::get('viewRange', '1M')->data; + /** @var Carbon $start */ $start = session('start', Navigation::startOfPeriod(new Carbon, $range)); + /** @var Carbon $end */ $end = session('end', Navigation::endOfPeriod(new Carbon, $range)); $hideCategory = true; // used in list. $page = intval(Input::get('page')); @@ -232,7 +233,7 @@ class CategoryController extends Controller * * @param $date * - * @return \Illuminate\View\View + * @return View */ public function showWithDate(CRI $repository, Category $category, string $date) { diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php index b6a80a0b7f..477306085d 100644 --- a/app/Http/Controllers/Chart/BudgetController.php +++ b/app/Http/Controllers/Chart/BudgetController.php @@ -214,8 +214,9 @@ class BudgetController extends Controller $repetitions = $repetitions->filter( function (LimitRepetition $repetition) use ($budgetIds) { if (in_array(strval($repetition->budget_id), $budgetIds)) { - return $repetition; + return true; } + return false; } ); /** @var LimitRepetition $repetition */ @@ -289,8 +290,9 @@ class BudgetController extends Controller $reps = $repetitions->filter( function (LimitRepetition $repetition) use ($budget, $currentStart) { if ($repetition->budget_id === $budget->id && $repetition->startdate == $currentStart) { - return $repetition; + return true; } + return false; } ); $budgeted = $reps->sum('amount'); @@ -325,8 +327,9 @@ class BudgetController extends Controller return $repetitions->filter( function (LimitRepetition $repetition) use ($budget, $start, $end) { if ($repetition->startdate < $end && $repetition->enddate > $start && $repetition->budget_id === $budget->id) { - return $repetition; + return true; } + return false; } ); } diff --git a/app/Http/Controllers/CurrencyController.php b/app/Http/Controllers/CurrencyController.php index 0681d3633f..a5da5fdcba 100644 --- a/app/Http/Controllers/CurrencyController.php +++ b/app/Http/Controllers/CurrencyController.php @@ -43,7 +43,7 @@ class CurrencyController extends Controller } /** - * @return \Illuminate\View\View + * @return View */ public function create() { @@ -131,7 +131,7 @@ class CurrencyController extends Controller /** * @param TransactionCurrency $currency * - * @return \Illuminate\View\View + * @return View */ public function edit(TransactionCurrency $currency) { @@ -154,7 +154,7 @@ class CurrencyController extends Controller /** * @param CurrencyRepositoryInterface $repository * - * @return \Illuminate\View\View + * @return View */ public function index(CurrencyRepositoryInterface $repository) { @@ -175,7 +175,7 @@ class CurrencyController extends Controller * @param CurrencyFormRequest $request * @param CurrencyRepositoryInterface $repository * - * @return $this|\Illuminate\Http\RedirectResponse + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function store(CurrencyFormRequest $request, CurrencyRepositoryInterface $repository) { diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php index 815c54b41c..8d5808685a 100644 --- a/app/Http/Controllers/ExportController.php +++ b/app/Http/Controllers/ExportController.php @@ -92,7 +92,7 @@ class ExportController extends Controller * @param AccountCrudInterface $crud * @param EJRI $jobs * - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + * @return View */ public function index(AccountCrudInterface $crud, EJRI $jobs) { diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index c70d974824..0a28ce307b 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -97,7 +97,7 @@ class HomeController extends Controller /** @var Tag $tag */ foreach ($tags as $tag) { - foreach ($tag->transactionjournals()->get() as $journal) { + foreach ($tag->transactionJournals()->get() as $journal) { $count = $journal->tags()->count(); $journal->tag_count = $count; $journal->save(); diff --git a/app/Http/Controllers/ImportController.php b/app/Http/Controllers/ImportController.php index 9ccd87cea1..7ff18fc8e5 100644 --- a/app/Http/Controllers/ImportController.php +++ b/app/Http/Controllers/ImportController.php @@ -263,7 +263,7 @@ class ImportController extends Controller * * @param ImportJob $job * - * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * @return View * @throws FireflyException */ public function settings(ImportJob $job) diff --git a/app/Http/Controllers/NewUserController.php b/app/Http/Controllers/NewUserController.php index 81c2e05dda..cefdbe21a1 100644 --- a/app/Http/Controllers/NewUserController.php +++ b/app/Http/Controllers/NewUserController.php @@ -38,7 +38,7 @@ class NewUserController extends Controller /** * @param ARI $repository * - * @@return \Illuminate\Http\RedirectResponse|\Illuminate\View\View + * @@return View */ public function index(ARI $repository) { diff --git a/app/Http/Controllers/PiggyBankController.php b/app/Http/Controllers/PiggyBankController.php index c5557953c9..c3ddece955 100644 --- a/app/Http/Controllers/PiggyBankController.php +++ b/app/Http/Controllers/PiggyBankController.php @@ -54,7 +54,7 @@ class PiggyBankController extends Controller * @param ARI $repository * @param PiggyBank $piggyBank * - * @return $this + * @return View */ public function add(ARI $repository, PiggyBank $piggyBank) { @@ -74,7 +74,7 @@ class PiggyBankController extends Controller * @param ARI $repository * @param PiggyBank $piggyBank * - * @return $this + * @return View */ public function addMobile(ARI $repository, PiggyBank $piggyBank) { @@ -113,7 +113,7 @@ class PiggyBankController extends Controller /** * @param PiggyBank $piggyBank * - * @return $this + * @return View */ public function delete(PiggyBank $piggyBank) { @@ -254,6 +254,7 @@ class PiggyBankController extends Controller public function postAdd(PiggyBankRepositoryInterface $repository, ARI $accounts, PiggyBank $piggyBank) { $amount = strval(round(Input::get('amount'), 2)); + /** @var Carbon $date */ $date = session('end', Carbon::now()->endOfMonth()); $leftOnAccount = $accounts->leftOnAccount($piggyBank->account, $date); $savedSoFar = strval($piggyBank->currentRelevantRep()->currentamount); @@ -320,7 +321,7 @@ class PiggyBankController extends Controller * @param PiggyBank $piggyBank * * - * @return \Illuminate\View\View + * @return View */ public function remove(PiggyBank $piggyBank) { @@ -332,7 +333,7 @@ class PiggyBankController extends Controller * * @param PiggyBank $piggyBank * - * @return $this + * @return View */ public function removeMobile(PiggyBank $piggyBank) { @@ -358,7 +359,7 @@ class PiggyBankController extends Controller * @param PiggyBankFormRequest $request * @param PiggyBankRepositoryInterface $repository * - * @return $this|\Illuminate\Http\RedirectResponse + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function store(PiggyBankFormRequest $request, PiggyBankRepositoryInterface $repository) { diff --git a/app/Http/Controllers/Popup/ReportController.php b/app/Http/Controllers/Popup/ReportController.php index d24b9be3ba..a54b0cc1a9 100644 --- a/app/Http/Controllers/Popup/ReportController.php +++ b/app/Http/Controllers/Popup/ReportController.php @@ -110,8 +110,9 @@ class ReportController extends Controller function (TransactionJournal $journal) { $tags = $journal->tags()->where('tagMode', 'balancingAct')->count(); if ($tags === 0) { - return $journal; + return true; } + return false; } ); break; @@ -191,8 +192,9 @@ class ReportController extends Controller $journals = $journals->filter( function (TransactionJournal $journal) use ($account) { if ($journal->destination_account_id === $account->id) { - return $journal; + return true; } + return false; } ); @@ -225,8 +227,9 @@ class ReportController extends Controller $journal->source_account_id === $account->id && in_array($journal->destination_account_id, $destinations) ) { - return $journal; + return true; } + return false; } ); diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.php index 595a7aac34..8db5d91e08 100644 --- a/app/Http/Controllers/PreferencesController.php +++ b/app/Http/Controllers/PreferencesController.php @@ -46,6 +46,7 @@ class PreferencesController extends Controller public function code(Google2FA $google2fa) { $domain = $this->getDomain(); + /** @noinspection PhpMethodParametersCountMismatchInspection */ $secret = $google2fa->generateSecretKey(16, Auth::user()->id); Session::flash('two-factor-secret', $secret); $image = $google2fa->getQRCodeInline('Firefly III at ' . $domain, null, $secret, 150); diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 1febd0a0ab..5a58392aba 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -19,6 +19,7 @@ use FireflyIII\User; use Hash; use Preferences; use Session; +use View; /** * Class ProfileController @@ -36,7 +37,7 @@ class ProfileController extends Controller } /** - * @return \Illuminate\View\View + * @return View */ public function changePassword() { @@ -46,7 +47,7 @@ class ProfileController extends Controller } /** - * @return \Illuminate\View\View + * @return View */ public function deleteAccount() { @@ -56,7 +57,7 @@ class ProfileController extends Controller } /** - * @return \Illuminate\View\View + * @return View * */ public function index() diff --git a/app/Http/Controllers/RuleController.php b/app/Http/Controllers/RuleController.php index 0b908806cd..23c5bf7fac 100644 --- a/app/Http/Controllers/RuleController.php +++ b/app/Http/Controllers/RuleController.php @@ -233,7 +233,7 @@ class RuleController extends Controller * @param RuleRepositoryInterface $repository * @param RuleGroup $ruleGroup * - * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function store(RuleFormRequest $request, RuleRepositoryInterface $repository, RuleGroup $ruleGroup) { @@ -281,7 +281,7 @@ class RuleController extends Controller * * @param TestRuleFormRequest $request * - * @return \Illuminate\View\View + * @return \Illuminate\Http\JsonResponse */ public function testTriggers(TestRuleFormRequest $request) { @@ -336,7 +336,7 @@ class RuleController extends Controller * @param RuleFormRequest $request * @param Rule $rule * - * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function update(RuleRepositoryInterface $repository, RuleFormRequest $request, Rule $rule) { diff --git a/app/Http/Controllers/RuleGroupController.php b/app/Http/Controllers/RuleGroupController.php index 6c014adaef..9dc3f38d66 100644 --- a/app/Http/Controllers/RuleGroupController.php +++ b/app/Http/Controllers/RuleGroupController.php @@ -200,7 +200,7 @@ class RuleGroupController extends Controller * @param RuleGroupFormRequest $request * @param RuleGroupRepositoryInterface $repository * - * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function store(RuleGroupFormRequest $request, RuleGroupRepositoryInterface $repository) { @@ -245,7 +245,7 @@ class RuleGroupController extends Controller * @param RuleGroupRepositoryInterface $repository * @param RuleGroup $ruleGroup * - * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function update(RuleGroupFormRequest $request, RuleGroupRepositoryInterface $repository, RuleGroup $ruleGroup) { diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index cf1a0ca710..c135cb5e0c 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -61,7 +61,7 @@ class TagController extends Controller } /** - * @return \Illuminate\View\View + * @return View */ public function create() { @@ -88,7 +88,7 @@ class TagController extends Controller /** * @param Tag $tag * - * @return \Illuminate\View\View + * @return View */ public function delete(Tag $tag) { @@ -123,7 +123,7 @@ class TagController extends Controller /** * @param Tag $tag * - * @return \Illuminate\View\View + * @return View */ public function edit(Tag $tag) { @@ -220,14 +220,14 @@ class TagController extends Controller /** * @param Tag $tag * - * @return \Illuminate\View\View + * @return View */ public function show(Tag $tag) { $subTitle = $tag->tag; $subTitleIcon = 'fa-tag'; /** @var Collection $journals */ - $journals = $tag->transactionjournals()->sortCorrectly()->expanded()->get(TransactionJournal::queryFields()); + $journals = $tag->transactionJournals()->sortCorrectly()->expanded()->get(TransactionJournal::queryFields()); $sum = $journals->sum( function (TransactionJournal $journal) { diff --git a/app/Http/Controllers/Transaction/SplitController.php b/app/Http/Controllers/Transaction/SplitController.php index 43e3d2e821..94236356c1 100644 --- a/app/Http/Controllers/Transaction/SplitController.php +++ b/app/Http/Controllers/Transaction/SplitController.php @@ -160,7 +160,7 @@ class SplitController extends Controller * @param JournalInterface $repository * @param AttachmentHelperInterface $att * - * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function update(TransactionJournal $journal, SplitJournalFormRequest $request, JournalInterface $repository, AttachmentHelperInterface $att) { diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php index 1149949efb..f5eb24b3ea 100644 --- a/app/Http/Controllers/TransactionController.php +++ b/app/Http/Controllers/TransactionController.php @@ -49,7 +49,7 @@ class TransactionController extends Controller /** * @param string $what * - * @return \Illuminate\View\View + * @return View */ public function create(string $what = TransactionType::DEPOSIT) { @@ -88,7 +88,7 @@ class TransactionController extends Controller * * @param TransactionJournal $journal * - * @return \Illuminate\View\View + * @return View */ public function delete(TransactionJournal $journal) { @@ -336,7 +336,7 @@ class TransactionController extends Controller * @param AttachmentHelperInterface $att * @param TransactionJournal $journal * - * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function update(JournalFormRequest $request, JournalRepositoryInterface $repository, AttachmentHelperInterface $att, TransactionJournal $journal) { diff --git a/app/Import/Converter/BillName.php b/app/Import/Converter/BillName.php index 9d1095ce12..04b48ea156 100644 --- a/app/Import/Converter/BillName.php +++ b/app/Import/Converter/BillName.php @@ -27,6 +27,7 @@ class BillName extends BasicConverter implements ConverterInterface /** * @param $value * + * @return Bill * @throws FireflyException */ public function convert($value) diff --git a/app/Import/ImportStorage.php b/app/Import/ImportStorage.php index 340d8a630f..8585b3ac9d 100644 --- a/app/Import/ImportStorage.php +++ b/app/Import/ImportStorage.php @@ -313,7 +313,7 @@ class ImportStorage $meta = new TransactionJournalMeta; $meta->name = 'originalImportHash'; $meta->data = $entry->hash; - $meta->transactionjournal()->associate($journal); + $meta->transactionJournal()->associate($journal); $meta->save(); return $journal; diff --git a/app/Import/Role/Map.php b/app/Import/Role/Map.php deleted file mode 100644 index 594578e97f..0000000000 --- a/app/Import/Role/Map.php +++ /dev/null @@ -1,18 +0,0 @@ -hasMany('FireflyIII\Models\TransactionJournal'); } diff --git a/app/Models/Budget.php b/app/Models/Budget.php index 98f22bab7e..a5be969f4f 100644 --- a/app/Models/Budget.php +++ b/app/Models/Budget.php @@ -146,7 +146,7 @@ class Budget extends Model /** * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ - public function transactionjournals() + public function transactionJournals() { return $this->belongsToMany('FireflyIII\Models\TransactionJournal', 'budget_transaction_journal', 'budget_id'); } diff --git a/app/Models/Category.php b/app/Models/Category.php index d88d627ecb..1568847992 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -126,7 +126,7 @@ class Category extends Model /** * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ - public function transactionjournals() + public function transactionJournals() { return $this->belongsToMany('FireflyIII\Models\TransactionJournal', 'category_transaction_journal', 'category_id'); } diff --git a/app/Models/LimitRepetition.php b/app/Models/LimitRepetition.php index fb0a77ac40..ae578cea03 100644 --- a/app/Models/LimitRepetition.php +++ b/app/Models/LimitRepetition.php @@ -56,7 +56,7 @@ class LimitRepetition extends Model { if (Auth::check()) { $object = LimitRepetition::where('limit_repetitions.id', $value) - ->leftjoin('budget_limits', 'budget_limits.id', '=', 'limit_repetitions.budget_limit_id') + ->leftJoin('budget_limits', 'budget_limits.id', '=', 'limit_repetitions.budget_limit_id') ->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id') ->where('budgets.user_id', Auth::user()->id) ->first(['limit_repetitions.*']); diff --git a/app/Models/PiggyBankRepetition.php b/app/Models/PiggyBankRepetition.php index 75e57de22d..cbe16a866f 100644 --- a/app/Models/PiggyBankRepetition.php +++ b/app/Models/PiggyBankRepetition.php @@ -57,7 +57,7 @@ class PiggyBankRepetition extends Model * @param Carbon $start * @param Carbon $target * - * @return $this + * @return EloquentBuilder */ public function scopeOnDates(EloquentBuilder $query, Carbon $start, Carbon $target) { diff --git a/app/Models/RuleGroup.php b/app/Models/RuleGroup.php index d10b736600..08a8835206 100644 --- a/app/Models/RuleGroup.php +++ b/app/Models/RuleGroup.php @@ -51,7 +51,7 @@ class RuleGroup extends Model /** * @param RuleGroup $value * - * @return Rule + * @return RuleGroup */ public static function routeBinder(RuleGroup $value) { diff --git a/app/Models/Tag.php b/app/Models/Tag.php index 2c5ddab13c..0b21b5627e 100644 --- a/app/Models/Tag.php +++ b/app/Models/Tag.php @@ -155,7 +155,7 @@ class Tag extends TagSupport */ public function save(array $options = []) { - foreach ($this->transactionjournals()->get() as $journal) { + foreach ($this->transactionJournals()->get() as $journal) { $count = $journal->tags()->count(); $journal->tag_count = $count; $journal->save(); @@ -185,7 +185,7 @@ class Tag extends TagSupport /** * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ - public function transactionjournals() + public function transactionJournals() { return $this->belongsToMany('FireflyIII\Models\TransactionJournal'); } diff --git a/app/Models/TransactionGroup.php b/app/Models/TransactionGroup.php index 0f17f99caa..59859cf3c2 100644 --- a/app/Models/TransactionGroup.php +++ b/app/Models/TransactionGroup.php @@ -42,7 +42,7 @@ class TransactionGroup extends Model /** * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ - public function transactionjournals() + public function transactionJournals() { return $this->belongsToMany('FireflyIII\Models\TransactionJournal'); } diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index eda705f8b2..83229984c2 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -37,8 +37,6 @@ class AccountRepository implements AccountRepositoryInterface /** @var User */ private $user; - /** @var array */ - private $validFields = ['accountRole', 'ccMonthlyPaymentDate', 'ccType', 'accountNumber']; /** * AttachmentRepository constructor. @@ -76,7 +74,7 @@ class AccountRepository implements AccountRepositoryInterface */ public function earnedFromInPeriod(Collection $accounts, Carbon $start, Carbon $end): string { - $query = $this->user->transactionjournals()->expanded()->sortCorrectly() + $query = $this->user->transactionJournals()->expanded()->sortCorrectly() ->transactionTypes([TransactionType::DEPOSIT]); if ($end >= $start) { @@ -113,7 +111,7 @@ class AccountRepository implements AccountRepositoryInterface */ public function earnedInPeriod(Collection $accounts, Carbon $start, Carbon $end): string { - $query = $this->user->transactionjournals()->expanded()->sortCorrectly() + $query = $this->user->transactionJournals()->expanded()->sortCorrectly() ->transactionTypes([TransactionType::DEPOSIT, TransactionType::TRANSFER]); if ($end >= $start) { @@ -178,15 +176,16 @@ class AccountRepository implements AccountRepositoryInterface $journals = $journals->filter( function (TransactionJournal $journal) use ($accountIds) { if ($journal->transaction_type_type == TransactionType::WITHDRAWAL) { - return $journal; + return true; } /* * The source of a transfer must be one of the $accounts in order to * be included. Otherwise, it would not be an expense. */ if (in_array($journal->source_account_id, $accountIds)) { - return $journal; + return true; } + return false; } ); @@ -362,15 +361,16 @@ class AccountRepository implements AccountRepositoryInterface $journals = $journals->filter( function (TransactionJournal $journal) use ($accountIds) { if ($journal->transaction_type_type == TransactionType::DEPOSIT) { - return $journal; + return true; } /* * The destination of a transfer must be one of the $accounts in order to * be included. Otherwise, it would not be income. */ if (in_array($journal->destination_account_id, $accountIds)) { - return $journal; + return true; } + return false; } ); @@ -388,7 +388,7 @@ class AccountRepository implements AccountRepositoryInterface public function journalsInPeriod(Collection $accounts, array $types, Carbon $start, Carbon $end): Collection { // first collect actual transaction journals (fairly easy) - $query = $this->user->transactionjournals()->expanded()->sortCorrectly(); + $query = $this->user->transactionJournals()->expanded()->sortCorrectly(); if ($end >= $start) { $query->before($end)->after($start); @@ -436,7 +436,7 @@ class AccountRepository implements AccountRepositoryInterface $balance = Steam::balanceIgnoreVirtual($account, $date); /** @var PiggyBank $p */ - foreach ($account->piggybanks()->get() as $p) { + foreach ($account->piggyBanks()->get() as $p) { $currentAmount = $p->currentRelevantRep()->currentamount ?? '0'; $balance = bcsub($balance, $currentAmount); @@ -527,7 +527,7 @@ class AccountRepository implements AccountRepositoryInterface public function spentAtInPeriod(Collection $accounts, Carbon $start, Carbon $end): string { /** @var HasMany $query */ - $query = $this->user->transactionjournals()->expanded()->sortCorrectly() + $query = $this->user->transactionJournals()->expanded()->sortCorrectly() ->transactionTypes([TransactionType::WITHDRAWAL]); if ($end >= $start) { $query->before($end)->after($start); @@ -563,7 +563,7 @@ class AccountRepository implements AccountRepositoryInterface public function spentInPeriod(Collection $accounts, Carbon $start, Carbon $end): string { /** @var HasMany $query */ - $query = $this->user->transactionjournals()->expanded()->sortCorrectly() + $query = $this->user->transactionJournals()->expanded()->sortCorrectly() ->transactionTypes([TransactionType::WITHDRAWAL, TransactionType::TRANSFER]); if ($end >= $start) { $query->before($end)->after($start); diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php index 51e0d4301a..df002f2680 100644 --- a/app/Repositories/Bill/BillRepository.php +++ b/app/Repositories/Bill/BillRepository.php @@ -125,7 +125,7 @@ class BillRepository implements BillRepositoryInterface { $ids = $bills->pluck('id')->toArray(); - $set = $this->user->transactionjournals() + $set = $this->user->transactionJournals() ->leftJoin( 'transactions', function (JoinClause $join) { $join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('transactions.amount', '<', 0); @@ -221,7 +221,7 @@ class BillRepository implements BillRepositoryInterface $ranges = $this->getRanges($bill, $start, $end); foreach ($ranges as $range) { - $paid = $bill->transactionjournals() + $paid = $bill->transactionJournals() ->before($range['end']) ->after($range['start']) ->leftJoin( @@ -256,7 +256,7 @@ class BillRepository implements BillRepositoryInterface $ranges = $this->getRanges($bill, $start, $end); $paidBill = '0'; foreach ($ranges as $range) { - $paid = $bill->transactionjournals() + $paid = $bill->transactionJournals() ->before($range['end']) ->after($range['start']) ->leftJoin( @@ -290,7 +290,7 @@ class BillRepository implements BillRepositoryInterface public function getJournals(Bill $bill, int $page, int $pageSize = 50): LengthAwarePaginator { $offset = ($page - 1) * $pageSize; - $query = $bill->transactionjournals() + $query = $bill->transactionJournals() ->expanded() ->sortCorrectly(); $count = $query->count(); @@ -311,7 +311,7 @@ class BillRepository implements BillRepositoryInterface */ public function getJournalsInRange(Bill $bill, Carbon $start, Carbon $end): Collection { - return $bill->transactionjournals()->before($end)->after($start)->get(); + return $bill->transactionJournals()->before($end)->after($start)->get(); } /** @@ -321,7 +321,7 @@ class BillRepository implements BillRepositoryInterface */ public function getOverallAverage($bill): string { - $journals = $bill->transactionjournals()->get(); + $journals = $bill->transactionJournals()->get(); $sum = '0'; $count = strval($journals->count()); /** @var TransactionJournal $journal */ @@ -351,7 +351,7 @@ class BillRepository implements BillRepositoryInterface $journals = new Collection; if (count($ids) > 0) { - $journals = $this->user->transactionjournals()->transactionTypes([TransactionType::WITHDRAWAL])->whereIn('transaction_journals.id', $ids)->get( + $journals = $this->user->transactionJournals()->transactionTypes([TransactionType::WITHDRAWAL])->whereIn('transaction_journals.id', $ids)->get( ['transaction_journals.*'] ); } @@ -409,7 +409,7 @@ class BillRepository implements BillRepositoryInterface */ public function getYearAverage(Bill $bill, Carbon $date): string { - $journals = $bill->transactionjournals() + $journals = $bill->transactionJournals() ->where('date', '>=', $date->year . '-01-01') ->where('date', '<=', $date->year . '-12-31') ->get(); @@ -434,7 +434,7 @@ class BillRepository implements BillRepositoryInterface */ public function lastFoundMatch(Bill $bill): Carbon { - $last = $bill->transactionjournals()->orderBy('date', 'DESC')->first(); + $last = $bill->transactionJournals()->orderBy('date', 'DESC')->first(); if ($last) { return $last->date; } @@ -476,7 +476,7 @@ class BillRepository implements BillRepositoryInterface if (($counter % $skip) == 0) { // do something. $end = Navigation::endOfPeriod(clone $start, $bill->repeat_freq); - $journalCount = $bill->transactionjournals()->before($end)->after($start)->count(); + $journalCount = $bill->transactionJournals()->before($end)->after($start)->count(); if ($journalCount == 0) { $finalDate = new Carbon($start->format('Y-m-d')); break; diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php index 88bb56912a..a0fcf85387 100644 --- a/app/Repositories/Budget/BudgetRepository.php +++ b/app/Repositories/Budget/BudgetRepository.php @@ -116,7 +116,7 @@ class BudgetRepository implements BudgetRepositoryInterface public function firstUseDate(Budget $budget): Carbon { $oldest = Carbon::create()->startOfYear(); - $journal = $budget->transactionjournals()->orderBy('date', 'ASC')->first(); + $journal = $budget->transactionJournals()->orderBy('date', 'ASC')->first(); if (!is_null($journal)) { $oldest = $journal->date < $oldest ? $journal->date : $oldest; } @@ -225,7 +225,7 @@ class BudgetRepository implements BudgetRepositoryInterface } // first get all journals for all budget(s): - $journalQuery = $this->user->transactionjournals() + $journalQuery = $this->user->transactionJournals() ->expanded() ->sortCorrectly() ->before($end) @@ -246,7 +246,7 @@ class BudgetRepository implements BudgetRepositoryInterface $journals = $journalQuery->get(TransactionJournal::queryFields()); // then get transactions themselves. - $transactionQuery = $this->user->transactionjournals() + $transactionQuery = $this->user->transactionJournals() ->expanded() ->before($end) ->sortCorrectly() @@ -290,7 +290,7 @@ class BudgetRepository implements BudgetRepositoryInterface /** @var Collection $set */ $query = $this->user - ->transactionjournals() + ->transactionJournals() ->expanded() ->sortCorrectly() ->transactionTypes([TransactionType::WITHDRAWAL]) @@ -322,9 +322,10 @@ class BudgetRepository implements BudgetRepositoryInterface function (TransactionJournal $journal) { foreach ($journal->transactions as $t) { if ($t->budgets->count() === 0) { - return $journal; + return true; } } + return false; } ); @@ -343,7 +344,7 @@ class BudgetRepository implements BudgetRepositoryInterface { // first collect actual transaction journals (fairly easy) $query = $this->user - ->transactionjournals() + ->transactionJournals() ->leftJoin( 'transactions as source', function (JoinClause $join) { $join->on('source.transaction_journal_id', '=', 'transaction_journals.id')->where('source.amount', '<', 0); @@ -415,7 +416,7 @@ class BudgetRepository implements BudgetRepositoryInterface public function spentInPeriodWithoutBudget(Collection $accounts, Carbon $start, Carbon $end): string { $types = [TransactionType::WITHDRAWAL]; - $query = $this->user->transactionjournals() + $query = $this->user->transactionJournals() ->distinct() ->transactionTypes($types) ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id') diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.php index e0a662b355..b43fdbd7d7 100644 --- a/app/Repositories/Category/CategoryRepository.php +++ b/app/Repositories/Category/CategoryRepository.php @@ -131,7 +131,7 @@ class CategoryRepository implements CategoryRepositoryInterface $first = null; /** @var TransactionJournal $first */ - $firstJournalQuery = $category->transactionjournals()->orderBy('date', 'ASC'); + $firstJournalQuery = $category->transactionJournals()->orderBy('date', 'ASC'); if ($accounts->count() > 0) { // filter journals: @@ -198,13 +198,13 @@ class CategoryRepository implements CategoryRepositoryInterface { $complete = new Collection; // first collect actual transaction journals (fairly easy) - $query = $this->user->transactionjournals()->expanded()->sortCorrectly(); + $query = $this->user->transactionJournals()->expanded()->sortCorrectly(); $query->leftJoin('category_transaction_journal', 'category_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id'); $query->where('category_transaction_journal.category_id', $category->id); $first = $query->get(TransactionJournal::queryFields()); // then collection transactions (harder) - $query = $this->user->transactionjournals()->distinct() + $query = $this->user->transactionJournals()->distinct() ->leftJoin('transactions', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') ->leftJoin('category_transaction', 'category_transaction.transaction_id', '=', 'transactions.id') ->where('category_transaction.category_id', $category->id); @@ -245,7 +245,7 @@ class CategoryRepository implements CategoryRepositoryInterface { $complete = new Collection; // first collect actual transaction journals (fairly easy) - $query = $this->user->transactionjournals()->expanded()->sortCorrectly(); + $query = $this->user->transactionJournals()->expanded()->sortCorrectly(); if ($end >= $start) { $query->before($end)->after($start); @@ -270,7 +270,7 @@ class CategoryRepository implements CategoryRepositoryInterface // then collection transactions (harder) - $query = $this->user->transactionjournals()->distinct() + $query = $this->user->transactionJournals()->distinct() ->leftJoin('transactions', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') ->leftJoin('category_transaction', 'category_transaction.transaction_id', '=', 'transactions.id'); @@ -308,7 +308,7 @@ class CategoryRepository implements CategoryRepositoryInterface { /** @var Collection $set */ $query = $this->user - ->transactionjournals(); + ->transactionJournals(); if (count($types) > 0) { $query->transactionTypes($types); } @@ -348,7 +348,7 @@ class CategoryRepository implements CategoryRepositoryInterface // this second set REALLY doesn't have any categories. $secondSet = $secondQuery->get(['transactions.transaction_journal_id']); $allIds = $secondSet->pluck('transaction_journal_id')->toArray(); - $return = $this->user->transactionjournals()->sortCorrectly()->expanded()->whereIn('transaction_journals.id', $allIds)->get( + $return = $this->user->transactionJournals()->sortCorrectly()->expanded()->whereIn('transaction_journals.id', $allIds)->get( TransactionJournal::queryFields() ); @@ -368,7 +368,7 @@ class CategoryRepository implements CategoryRepositoryInterface $last = null; /** @var TransactionJournal $first */ - $lastJournalQuery = $category->transactionjournals()->orderBy('date', 'DESC'); + $lastJournalQuery = $category->transactionJournals()->orderBy('date', 'DESC'); if ($accounts->count() > 0) { // filter journals: @@ -483,7 +483,7 @@ class CategoryRepository implements CategoryRepositoryInterface { // first collect actual transaction journals (fairly easy) $query = $this->user - ->transactionjournals() + ->transactionJournals() ->transactionTypes($types) ->leftJoin( 'transactions as source', function (JoinClause $join) { @@ -548,7 +548,7 @@ class CategoryRepository implements CategoryRepositoryInterface */ private function sumInPeriodWithoutCategory(Collection $accounts, array $types, Carbon $start, Carbon $end): string { - $query = $this->user->transactionjournals() + $query = $this->user->transactionJournals() ->distinct() ->transactionTypes($types) ->leftJoin('category_transaction_journal', 'category_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id') diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php index 0ea29d5deb..3631c5da4b 100644 --- a/app/Repositories/Journal/JournalRepository.php +++ b/app/Repositories/Journal/JournalRepository.php @@ -108,7 +108,7 @@ class JournalRepository implements JournalRepositoryInterface */ public function find(int $journalId) : TransactionJournal { - $journal = $this->user->transactionjournals()->where('id', $journalId)->first(); + $journal = $this->user->transactionJournals()->where('id', $journalId)->first(); if (is_null($journal)) { return new TransactionJournal; } @@ -123,7 +123,7 @@ class JournalRepository implements JournalRepositoryInterface */ public function first(): TransactionJournal { - $entry = $this->user->transactionjournals()->orderBy('date', 'ASC')->first(['transaction_journals.*']); + $entry = $this->user->transactionJournals()->orderBy('date', 'ASC')->first(['transaction_journals.*']); if (is_null($entry)) { diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.php index a794d3f6f7..605f5b6924 100644 --- a/app/Repositories/Tag/TagRepository.php +++ b/app/Repositories/Tag/TagRepository.php @@ -189,8 +189,8 @@ class TagRepository implements TagRepositoryInterface /** @var TransactionType $deposit */ $deposit = TransactionType::whereType(TransactionType::DEPOSIT)->first(); - $withdrawals = $tag->transactionjournals()->where('transaction_type_id', $withdrawal->id)->count(); - $deposits = $tag->transactionjournals()->where('transaction_type_id', $deposit->id)->count(); + $withdrawals = $tag->transactionJournals()->where('transaction_type_id', $withdrawal->id)->count(); + $deposits = $tag->transactionJournals()->where('transaction_type_id', $deposit->id)->count(); if ($journal->transaction_type_id == $transfer->id) { // advance payments cannot accept transfers: return false; @@ -229,10 +229,10 @@ class TagRepository implements TagRepositoryInterface { /** @var TransactionType $withdrawal */ $withdrawal = TransactionType::whereType(TransactionType::WITHDRAWAL)->first(); - $withdrawals = $tag->transactionjournals()->where('transaction_type_id', $withdrawal->id)->count(); + $withdrawals = $tag->transactionJournals()->where('transaction_type_id', $withdrawal->id)->count(); /** @var TransactionType $transfer */ $transfer = TransactionType::whereType(TransactionType::TRANSFER)->first(); - $transfers = $tag->transactionjournals()->where('transaction_type_id', $transfer->id)->count(); + $transfers = $tag->transactionJournals()->where('transaction_type_id', $transfer->id)->count(); // only if this is the only withdrawal. diff --git a/app/Rules/TransactionMatcher.php b/app/Rules/TransactionMatcher.php index 7cbef9a970..599a0932ba 100644 --- a/app/Rules/TransactionMatcher.php +++ b/app/Rules/TransactionMatcher.php @@ -85,6 +85,7 @@ class TransactionMatcher ); // merge: + /** @var Collection $result */ $result = $result->merge($filtered); // Update counters diff --git a/app/Support/Amount.php b/app/Support/Amount.php index d9b5882a22..0b3620d1e5 100644 --- a/app/Support/Amount.php +++ b/app/Support/Amount.php @@ -114,7 +114,7 @@ class Amount { $currency = $transaction->transactionJournal->transactionCurrency; - return $this->formatAnything($currency, $transaction->amount, $coloured); + return $this->formatAnything($currency, strval($transaction->amount), $coloured); } /** diff --git a/app/Support/Migration/TestData.php b/app/Support/Migration/TestData.php index cb38a63fc7..a71e4f0710 100644 --- a/app/Support/Migration/TestData.php +++ b/app/Support/Migration/TestData.php @@ -98,8 +98,7 @@ class TestData */ private function createAttachments() { - $insert = []; - $disk = Storage::disk('upload'); + $disk = Storage::disk('upload'); foreach ($this->data['attachments'] as $attachment) { $data = Crypt::encrypt($attachment['content']); $attachmentId = DB::table('attachments')->insertGetId( diff --git a/app/Support/Preferences.php b/app/Support/Preferences.php index 96d935bc85..46a93ad058 100644 --- a/app/Support/Preferences.php +++ b/app/Support/Preferences.php @@ -57,10 +57,11 @@ class Preferences } /** + * @param User $user * @param string $name * @param string $default * - * @return null|\FireflyIII\Models\Preference + * @return Preference|null */ public function getForUser(User $user, $name, $default = null) { diff --git a/app/Support/Search/Search.php b/app/Support/Search/Search.php index cc163b99a9..2379dfd2bc 100644 --- a/app/Support/Search/Search.php +++ b/app/Support/Search/Search.php @@ -111,7 +111,7 @@ class Search implements SearchInterface public function searchTransactions(array $words): Collection { // decrypted transaction journals: - $decrypted = Auth::user()->transactionjournals()->expanded()->where('transaction_journals.encrypted', 0)->where( + $decrypted = Auth::user()->transactionJournals()->expanded()->where('transaction_journals.encrypted', 0)->where( function (EloquentBuilder $q) use ($words) { foreach ($words as $word) { $q->orWhere('transaction_journals.description', 'LIKE', '%' . e($word) . '%'); @@ -120,7 +120,7 @@ class Search implements SearchInterface )->get(TransactionJournal::queryFields()); // encrypted - $all = Auth::user()->transactionjournals()->expanded()->where('transaction_journals.encrypted', 1)->get(TransactionJournal::queryFields()); + $all = Auth::user()->transactionJournals()->expanded()->where('transaction_journals.encrypted', 1)->get(TransactionJournal::queryFields()); $set = $all->filter( function (TransactionJournal $journal) use ($words) { foreach ($words as $word) { diff --git a/app/Support/Twig/Budget.php b/app/Support/Twig/Budget.php index 496b5ae2cc..673ed156d7 100644 --- a/app/Support/Twig/Budget.php +++ b/app/Support/Twig/Budget.php @@ -39,7 +39,7 @@ class Budget extends Twig_Extension return $cache->get(); } $sum - = Auth::user()->transactionjournals() + = Auth::user()->transactionJournals() ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id') ->leftJoin('budget_limits', 'budget_limits.budget_id', '=', 'budget_transaction_journal.budget_id') ->leftJoin('limit_repetitions', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id') diff --git a/app/User.php b/app/User.php index b200536c65..f451f6c787 100644 --- a/app/User.php +++ b/app/User.php @@ -143,7 +143,7 @@ class User extends Authenticatable /** * @return HasMany */ - public function exportjobs(): HasMany + public function exportJobs(): HasMany { return $this->hasMany('FireflyIII\Models\ExportJob'); } @@ -172,7 +172,7 @@ class User extends Authenticatable /** * @return HasMany */ - public function importjobs(): HasMany + public function importJobs(): HasMany { return $this->hasMany('FireflyIII\Models\ImportJob'); } @@ -228,7 +228,7 @@ class User extends Authenticatable /** * @return HasMany */ - public function transactionjournals(): HasMany + public function transactionJournals(): HasMany { return $this->hasMany('FireflyIII\Models\TransactionJournal'); } diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php index 636aea80ba..34bb493891 100644 --- a/app/Validation/FireflyValidator.php +++ b/app/Validation/FireflyValidator.php @@ -54,10 +54,11 @@ class FireflyValidator extends Validator /** * @param $attribute * @param $value - * @param $parameters - * * * @return bool + * @internal param $parameters + * + * */ public function validate2faCode($attribute, $value): bool { diff --git a/tests/TestCase.php b/tests/TestCase.php index 1adf1eecb2..1a459cb68f 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,10 +2,6 @@ declare(strict_types = 1); -use Carbon\Carbon; -use FireflyIII\Models\Preference; -use FireflyIII\User; - /** * Class TestCase */