diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php index 4305b02a8b..6223216e17 100644 --- a/app/Http/Controllers/BudgetController.php +++ b/app/Http/Controllers/BudgetController.php @@ -166,7 +166,7 @@ class BudgetController extends Controller foreach ($budgets as $budget) { $budget->spent = $repository->balanceInPeriod($budget, $start, $end, $accounts); $budget->currentRep = $repository->getCurrentRepetition($budget, $start, $end); - if ($budget->currentRep) { + if (!is_null($budget->currentRep->id)) { $budgeted = bcadd($budgeted, $budget->currentRep->amount); } $spent = bcadd($spent, $budget->spent); diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index e37a21abbc..9e9a73a7c9 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -174,7 +174,7 @@ class AccountRepository implements AccountRepositoryInterface * * @return Collection */ - public function getExpensesByDestination(Account $account, Collection $accounts, Carbon $start, Carbon $end) + public function getExpensesByDestination(Account $account, Collection $accounts, Carbon $start, Carbon $end): Collection { $ids = $accounts->pluck('id')->toArray(); $journals = $this->user->transactionjournals() @@ -259,7 +259,7 @@ class AccountRepository implements AccountRepositoryInterface * * @return LengthAwarePaginator */ - public function getJournals(Account $account, $page): LengthAwarePaginator + public function getJournals(Account $account, int $page): LengthAwarePaginator { $offset = ($page - 1) * 50; $query = $this->user @@ -449,7 +449,7 @@ class AccountRepository implements AccountRepositoryInterface * * @return AccountMeta */ - public function storeMeta($account, $name, $value): AccountMeta + public function storeMeta(Account $account, string $name, $value): AccountMeta { return AccountMeta::create(['name' => $name, 'data' => $value, 'account_id' => $account->id,]); } @@ -688,7 +688,7 @@ class AccountRepository implements AccountRepositoryInterface * * @return Collection */ - public function getIncomeByDestination(Account $account, Collection $accounts, Carbon $start, Carbon $end) + public function getIncomeByDestination(Account $account, Collection $accounts, Carbon $start, Carbon $end): Collection { $ids = $accounts->pluck('id')->toArray(); $journals = $this->user->transactionjournals() diff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.php index 0e7fba5fd0..13cf3e3ace 100644 --- a/app/Repositories/Account/AccountRepositoryInterface.php +++ b/app/Repositories/Account/AccountRepositoryInterface.php @@ -82,7 +82,7 @@ interface AccountRepositoryInterface * * @return Collection */ - public function getExpensesByDestination(Account $account, Collection $accounts, Carbon $start, Carbon $end); + public function getExpensesByDestination(Account $account, Collection $accounts, Carbon $start, Carbon $end): Collection; /** * @param TransactionJournal $journal @@ -119,7 +119,7 @@ interface AccountRepositoryInterface * * @return Collection */ - public function getIncomeByDestination(Account $account, Collection $accounts, Carbon $start, Carbon $end); + public function getIncomeByDestination(Account $account, Collection $accounts, Carbon $start, Carbon $end): Collection; /** * @param Account $account @@ -127,7 +127,7 @@ interface AccountRepositoryInterface * * @return LengthAwarePaginator */ - public function getJournals(Account $account, $page): LengthAwarePaginator; + public function getJournals(Account $account, int $page): LengthAwarePaginator; /** * Get the accounts of a user that have piggy banks connected to them. @@ -172,7 +172,7 @@ interface AccountRepositoryInterface * * @return AccountMeta */ - public function storeMeta($account, $name, $value): AccountMeta; + public function storeMeta(Account $account, string $name, $value): AccountMeta; /** * @return string diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php index dd7cffd278..fee7ec4421 100644 --- a/app/Repositories/Budget/BudgetRepository.php +++ b/app/Repositories/Budget/BudgetRepository.php @@ -48,27 +48,28 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn * * @return string */ - public function balanceInPeriod(Budget $budget, Carbon $start, Carbon $end, Collection $accounts) + public function balanceInPeriod(Budget $budget, Carbon $start, Carbon $end, Collection $accounts): string { return $this->commonBalanceInPeriod($budget, $start, $end, $accounts); } /** - * @return void + * @return bool */ - public function cleanupBudgets() + public function cleanupBudgets(): bool { // delete limits with amount 0: BudgetLimit::where('amount', 0)->delete(); + return true; } /** * @param Budget $budget * - * @return boolean + * @return bool */ - public function destroy(Budget $budget) + public function destroy(Budget $budget): bool { $budget->delete(); @@ -114,7 +115,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn * * @return Carbon */ - public function firstActivity(Budget $budget) + public function firstActivity(Budget $budget): Carbon { $first = $budget->transactionjournals()->orderBy('date', 'ASC')->first(); if ($first) { @@ -127,7 +128,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn /** * @return Collection */ - public function getActiveBudgets() + public function getActiveBudgets(): Collection { /** @var Collection $set */ $set = $this->user->budgets()->where('active', 1)->get(); @@ -147,7 +148,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn * * @return Collection */ - public function getAllBudgetLimitRepetitions(Carbon $start, Carbon $end) + public function getAllBudgetLimitRepetitions(Carbon $start, Carbon $end): Collection { /** @var Collection $repetitions */ return LimitRepetition:: @@ -167,7 +168,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn * * @return Collection */ - public function getAllWithoutBudget(Account $account, Collection $accounts, Carbon $start, Carbon $end) + public function getAllWithoutBudget(Account $account, Collection $accounts, Carbon $start, Carbon $end): Collection { $ids = $accounts->pluck('id')->toArray(); @@ -192,7 +193,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn * * @return Collection */ - public function getBudgetedPerYear(Collection $budgets, Carbon $start, Carbon $end) + public function getBudgetedPerYear(Collection $budgets, Carbon $start, Carbon $end): Collection { $budgetIds = $budgets->pluck('id')->toArray(); @@ -218,7 +219,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn /** * @return Collection */ - public function getBudgets() + public function getBudgets(): Collection { /** @var Collection $set */ $set = $this->user->budgets()->get(); @@ -242,7 +243,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn * * @return array */ - public function getBudgetsAndExpensesPerMonth(Collection $accounts, Carbon $start, Carbon $end) + public function getBudgetsAndExpensesPerMonth(Collection $accounts, Carbon $start, Carbon $end): array { $ids = $accounts->pluck('id')->toArray(); @@ -303,7 +304,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn * * @return array */ - public function getBudgetsAndExpensesPerYear(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end) + public function getBudgetsAndExpensesPerYear(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): array { $ids = $accounts->pluck('id')->toArray(); $budgetIds = $budgets->pluck('id')->toArray(); @@ -362,7 +363,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn * * @return Collection */ - public function getBudgetsAndLimitsInRange(Carbon $start, Carbon $end) + public function getBudgetsAndLimitsInRange(Carbon $start, Carbon $end): Collection { /** @var Collection $set */ $set = $this->user @@ -402,14 +403,17 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn * @param Carbon $start * @param Carbon $end * - * @return LimitRepetition|null + * @return LimitRepetition */ - public function getCurrentRepetition(Budget $budget, Carbon $start, Carbon $end) + public function getCurrentRepetition(Budget $budget, Carbon $start, Carbon $end): LimitRepetition { $data = $budget->limitrepetitions() ->where('limit_repetitions.startdate', $start->format('Y-m-d 00:00:00')) ->where('limit_repetitions.enddate', $end->format('Y-m-d 00:00:00')) ->first(['limit_repetitions.*']); + if(is_null($data)) { + return new LimitRepetition; + } return $data; } @@ -448,7 +452,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn * * @return Collection */ - public function getExpensesPerDay(Budget $budget, Carbon $start, Carbon $end) + public function getExpensesPerDay(Budget $budget, Carbon $start, Carbon $end): Collection { $set = $this->user->budgets() ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.budget_id', '=', 'budgets.id') @@ -471,7 +475,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn * * @return Carbon */ - public function getFirstBudgetLimitDate(Budget $budget) + public function getFirstBudgetLimitDate(Budget $budget): Carbon { $limit = $budget->budgetlimits()->orderBy('startdate', 'ASC')->first(); if ($limit) { @@ -484,7 +488,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn /** * @return Collection */ - public function getInactiveBudgets() + public function getInactiveBudgets(): Collection { /** @var Collection $set */ $set = $this->user->budgets()->where('active', 0)->get(); @@ -507,7 +511,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn * * @return LengthAwarePaginator */ - public function getJournals(Budget $budget, LimitRepetition $repetition = null, int $take = 50) + public function getJournals(Budget $budget, LimitRepetition $repetition = null, int $take = 50): LengthAwarePaginator { $offset = intval(Input::get('page')) > 0 ? intval(Input::get('page')) * $take : 0; $setQuery = $budget->transactionjournals()->expanded() @@ -539,7 +543,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn * * @return Collection */ - public function getWithoutBudget(Carbon $start, Carbon $end) + public function getWithoutBudget(Carbon $start, Carbon $end): Collection { return $this->user ->transactionjournals() @@ -559,7 +563,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn * * @return Collection */ - public function getWithoutBudgetForAccounts(Collection $accounts, Carbon $start, Carbon $end) + public function getWithoutBudgetForAccounts(Collection $accounts, Carbon $start, Carbon $end): Collection { $ids = $accounts->pluck('id')->toArray(); @@ -633,7 +637,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn * * @return array */ - public function spentAllPerDayForAccounts(Collection $accounts, Carbon $start, Carbon $end) + public function spentAllPerDayForAccounts(Collection $accounts, Carbon $start, Carbon $end): array { $ids = $accounts->pluck('id')->toArray(); /** @var Collection $query */ @@ -674,7 +678,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn * * @return Collection */ - public function spentPerBudgetPerAccount(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end) + public function spentPerBudgetPerAccount(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): Collection { $accountIds = $accounts->pluck('id')->toArray(); $budgetIds = $budgets->pluck('id')->toArray(); @@ -752,7 +756,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn * * @return Budget */ - public function store(array $data) + public function store(array $data): Budget { $newBudget = new Budget( [ @@ -771,7 +775,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn * * @return Budget */ - public function update(Budget $budget, array $data) + public function update(Budget $budget, array $data): Budget { // update the account: $budget->name = $data['name']; @@ -788,7 +792,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn * * @return BudgetLimit */ - public function updateLimitAmount(Budget $budget, Carbon $date, int $amount) + public function updateLimitAmount(Budget $budget, Carbon $date, int $amount): BudgetLimit { // there should be a budget limit for this startdate: /** @var BudgetLimit $limit */ diff --git a/app/Repositories/Budget/BudgetRepositoryInterface.php b/app/Repositories/Budget/BudgetRepositoryInterface.php index 3c33aa0d0f..4d6e55cd52 100644 --- a/app/Repositories/Budget/BudgetRepositoryInterface.php +++ b/app/Repositories/Budget/BudgetRepositoryInterface.php @@ -6,6 +6,7 @@ namespace FireflyIII\Repositories\Budget; use Carbon\Carbon; use FireflyIII\Models\Account; use FireflyIII\Models\Budget; +use FireflyIII\Models\BudgetLimit; use FireflyIII\Models\LimitRepetition; use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Support\Collection; @@ -32,16 +33,16 @@ interface BudgetRepositoryInterface public function balanceInPeriod(Budget $budget, Carbon $start, Carbon $end, Collection $accounts); /** - * @return void + * @return bool */ - public function cleanupBudgets(); + public function cleanupBudgets(): bool; /** * @param Budget $budget * - * @return boolean + * @return bool */ - public function destroy(Budget $budget); + public function destroy(Budget $budget): bool; /** * @param Budget $budget @@ -67,12 +68,12 @@ interface BudgetRepositoryInterface * * @return Carbon */ - public function firstActivity(Budget $budget); + public function firstActivity(Budget $budget): Carbon; /** * @return Collection */ - public function getActiveBudgets(); + public function getActiveBudgets(): Collection; /** * @param Carbon $start @@ -80,17 +81,17 @@ interface BudgetRepositoryInterface * * @return Collection */ - public function getAllBudgetLimitRepetitions(Carbon $start, Carbon $end); + public function getAllBudgetLimitRepetitions(Carbon $start, Carbon $end): Collection; /** - * @param Account $account + * @param Account $account * @param Collection $accounts - * @param Carbon $start - * @param Carbon $end + * @param Carbon $start + * @param Carbon $end * * @return Collection */ - public function getAllWithoutBudget(Account $account, Collection $accounts, Carbon $start, Carbon $end); + public function getAllWithoutBudget(Account $account, Collection $accounts, Carbon $start, Carbon $end): Collection; /** * Get the budgeted amounts for each budgets in each year. @@ -101,12 +102,12 @@ interface BudgetRepositoryInterface * * @return Collection */ - public function getBudgetedPerYear(Collection $budgets, Carbon $start, Carbon $end); + public function getBudgetedPerYear(Collection $budgets, Carbon $start, Carbon $end): Collection; /** * @return Collection */ - public function getBudgets(); + public function getBudgets(): Collection; /** * Returns an array with every budget in it and the expenses for each budget @@ -118,7 +119,7 @@ interface BudgetRepositoryInterface * * @return array */ - public function getBudgetsAndExpensesPerMonth(Collection $accounts, Carbon $start, Carbon $end); + public function getBudgetsAndExpensesPerMonth(Collection $accounts, Carbon $start, Carbon $end): array; /** * Returns an array with every budget in it and the expenses for each budget @@ -131,7 +132,7 @@ interface BudgetRepositoryInterface * * @return array */ - public function getBudgetsAndExpensesPerYear(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end); + public function getBudgetsAndExpensesPerYear(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): array; /** * Returns a list of budgets, budget limits and limit repetitions @@ -142,16 +143,16 @@ interface BudgetRepositoryInterface * * @return Collection */ - public function getBudgetsAndLimitsInRange(Carbon $start, Carbon $end); + public function getBudgetsAndLimitsInRange(Carbon $start, Carbon $end): Collection; /** * @param Budget $budget * @param Carbon $start * @param Carbon $end * - * @return LimitRepetition|null + * @return LimitRepetition */ - public function getCurrentRepetition(Budget $budget, Carbon $start, Carbon $end); + public function getCurrentRepetition(Budget $budget, Carbon $start, Carbon $end): LimitRepetition; /** * Returns all expenses for the given budget and the given accounts, in the given period. @@ -175,19 +176,19 @@ interface BudgetRepositoryInterface * * @return Collection */ - public function getExpensesPerDay(Budget $budget, Carbon $start, Carbon $end); + public function getExpensesPerDay(Budget $budget, Carbon $start, Carbon $end):Collection; /** * @param Budget $budget * * @return Carbon */ - public function getFirstBudgetLimitDate(Budget $budget); + public function getFirstBudgetLimitDate(Budget $budget):Carbon; /** * @return Collection */ - public function getInactiveBudgets(); + public function getInactiveBudgets(): Collection; /** * Returns all the transaction journals for a limit, possibly limited by a limit repetition. @@ -198,7 +199,7 @@ interface BudgetRepositoryInterface * * @return LengthAwarePaginator */ - public function getJournals(Budget $budget, LimitRepetition $repetition = null, int $take = 50); + public function getJournals(Budget $budget, LimitRepetition $repetition = null, int $take = 50): LengthAwarePaginator; /** * @param Carbon $start @@ -206,7 +207,7 @@ interface BudgetRepositoryInterface * * @return Collection */ - public function getWithoutBudget(Carbon $start, Carbon $end); + public function getWithoutBudget(Carbon $start, Carbon $end): Collection; /** * @param Collection $accounts @@ -215,7 +216,7 @@ interface BudgetRepositoryInterface * * @return Collection */ - public function getWithoutBudgetForAccounts(Collection $accounts, Carbon $start, Carbon $end); + public function getWithoutBudgetForAccounts(Collection $accounts, Carbon $start, Carbon $end): Collection; /** * @param Collection $accounts @@ -244,7 +245,7 @@ interface BudgetRepositoryInterface * * @return array */ - public function spentAllPerDayForAccounts(Collection $accounts, Carbon $start, Carbon $end); + public function spentAllPerDayForAccounts(Collection $accounts, Carbon $start, Carbon $end): array; /** * Returns a list of expenses (in the field "spent", grouped per budget per account. @@ -256,7 +257,7 @@ interface BudgetRepositoryInterface * * @return Collection */ - public function spentPerBudgetPerAccount(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end); + public function spentPerBudgetPerAccount(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): Collection; /** * Returns an array with the following key:value pairs: @@ -279,7 +280,7 @@ interface BudgetRepositoryInterface * * @return Budget */ - public function store(array $data); + public function store(array $data): Budget; /** * @param Budget $budget @@ -287,15 +288,15 @@ interface BudgetRepositoryInterface * * @return Budget */ - public function update(Budget $budget, array $data); + public function update(Budget $budget, array $data) : Budget; /** * @param Budget $budget * @param Carbon $date * @param int $amount * - * @return mixed + * @return BudgetLimit */ - public function updateLimitAmount(Budget $budget, Carbon $date, int $amount); + public function updateLimitAmount(Budget $budget, Carbon $date, int $amount) : BudgetLimit; } diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.php index fa9ecc98bf..af4544c458 100644 --- a/app/Repositories/Category/CategoryRepository.php +++ b/app/Repositories/Category/CategoryRepository.php @@ -7,7 +7,6 @@ use Carbon\Carbon; use DB; use FireflyIII\Models\Category; use FireflyIII\Models\TransactionType; -use FireflyIII\Sql\Query; use FireflyIII\User; use Illuminate\Database\Query\JoinClause; use Illuminate\Support\Collection; @@ -19,6 +18,10 @@ use Illuminate\Support\Collection; */ class CategoryRepository implements CategoryRepositoryInterface { + const SPENT = 1; + const EARNED = 2; + + /** @var User */ private $user; @@ -43,7 +46,7 @@ class CategoryRepository implements CategoryRepositoryInterface * * @return Collection */ - public function earnedForAccountsPerMonth(Collection $accounts, Carbon $start, Carbon $end) + public function earnedForAccountsPerMonth(Collection $accounts, Carbon $start, Carbon $end): Collection { $collection = $this->user->categories() @@ -87,7 +90,7 @@ class CategoryRepository implements CategoryRepositoryInterface * * @return Collection */ - public function listCategories() + public function listCategories(): Collection { /** @var Collection $set */ $set = $this->user->categories()->orderBy('name', 'ASC')->get(); @@ -114,7 +117,7 @@ class CategoryRepository implements CategoryRepositoryInterface * * @return Collection */ - public function listMultiYear(Collection $categories, Collection $accounts, Carbon $start, Carbon $end) + public function listMultiYear(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): Collection { $set = $this->user->categories() @@ -152,7 +155,7 @@ class CategoryRepository implements CategoryRepositoryInterface * * @return Collection */ - public function listNoCategory(Carbon $start, Carbon $end) + public function listNoCategory(Carbon $start, Carbon $end): Collection { return $this->user ->transactionjournals() @@ -177,7 +180,7 @@ class CategoryRepository implements CategoryRepositoryInterface * * @return Collection */ - public function spentForAccountsPerMonth(Collection $accounts, Carbon $start, Carbon $end) + public function spentForAccountsPerMonth(Collection $accounts, Carbon $start, Carbon $end): Collection { $accountIds = $accounts->pluck('id')->toArray(); $query = $this->user->categories() @@ -228,9 +231,9 @@ class CategoryRepository implements CategoryRepositoryInterface * * @return string */ - public function sumEarnedNoCategory(Collection $accounts, Carbon $start, Carbon $end) + public function sumEarnedNoCategory(Collection $accounts, Carbon $start, Carbon $end): string { - return $this->sumNoCategory($accounts, $start, $end, Query::EARNED); + return $this->sumNoCategory($accounts, $start, $end, self::EARNED); } /** @@ -243,9 +246,9 @@ class CategoryRepository implements CategoryRepositoryInterface * * @return string */ - public function sumSpentNoCategory(Collection $accounts, Carbon $start, Carbon $end) + public function sumSpentNoCategory(Collection $accounts, Carbon $start, Carbon $end): string { - return $this->sumNoCategory($accounts, $start, $end, Query::SPENT); + return $this->sumNoCategory($accounts, $start, $end, self::SPENT); } /** @@ -259,10 +262,10 @@ class CategoryRepository implements CategoryRepositoryInterface * * @return string */ - protected function sumNoCategory(Collection $accounts, Carbon $start, Carbon $end, $group = Query::EARNED) + protected function sumNoCategory(Collection $accounts, Carbon $start, Carbon $end, $group = self::EARNED) { $accountIds = $accounts->pluck('id')->toArray(); - if ($group == Query::EARNED) { + if ($group == self::EARNED) { $types = [TransactionType::DEPOSIT]; } else { $types = [TransactionType::WITHDRAWAL]; diff --git a/app/Repositories/Category/CategoryRepositoryInterface.php b/app/Repositories/Category/CategoryRepositoryInterface.php index ec89ccec5e..cbfd632b81 100644 --- a/app/Repositories/Category/CategoryRepositoryInterface.php +++ b/app/Repositories/Category/CategoryRepositoryInterface.php @@ -26,14 +26,14 @@ interface CategoryRepositoryInterface * * @return Collection */ - public function earnedForAccountsPerMonth(Collection $accounts, Carbon $start, Carbon $end); + public function earnedForAccountsPerMonth(Collection $accounts, Carbon $start, Carbon $end): Collection; /** * Returns a list of all the categories belonging to a user. * * @return Collection */ - public function listCategories(); + public function listCategories(): Collection; /** * This method returns a very special collection for each category: @@ -49,7 +49,7 @@ interface CategoryRepositoryInterface * * @return Collection */ - public function listMultiYear(Collection $categories, Collection $accounts, Carbon $start, Carbon $end); + public function listMultiYear(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): Collection; /** * Returns a list of transaction journals in the range (all types, all accounts) that have no category @@ -60,7 +60,7 @@ interface CategoryRepositoryInterface * * @return Collection */ - public function listNoCategory(Carbon $start, Carbon $end); + public function listNoCategory(Carbon $start, Carbon $end): Collection; /** * Returns a collection of Categories appended with the amount of money that has been spent @@ -73,7 +73,7 @@ interface CategoryRepositoryInterface * * @return Collection */ - public function spentForAccountsPerMonth(Collection $accounts, Carbon $start, Carbon $end); + public function spentForAccountsPerMonth(Collection $accounts, Carbon $start, Carbon $end): Collection; /** * Returns the total amount of money related to transactions without any category connected to @@ -85,7 +85,7 @@ interface CategoryRepositoryInterface * * @return string */ - public function sumEarnedNoCategory(Collection $accounts, Carbon $start, Carbon $end); + public function sumEarnedNoCategory(Collection $accounts, Carbon $start, Carbon $end): string; /** * Returns the total amount of money related to transactions without any category connected to @@ -97,6 +97,6 @@ interface CategoryRepositoryInterface * * @return string */ - public function sumSpentNoCategory(Collection $accounts, Carbon $start, Carbon $end); + public function sumSpentNoCategory(Collection $accounts, Carbon $start, Carbon $end): string; } diff --git a/app/Repositories/Category/SingleCategoryRepository.php b/app/Repositories/Category/SingleCategoryRepository.php index 1562ed4846..ea7dd6fc29 100644 --- a/app/Repositories/Category/SingleCategoryRepository.php +++ b/app/Repositories/Category/SingleCategoryRepository.php @@ -37,7 +37,7 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate * * @return int */ - public function countJournals(Category $category) + public function countJournals(Category $category): int { return $category->transactionjournals()->count(); @@ -51,7 +51,7 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate * * @return int */ - public function countJournalsInRange(Category $category, Carbon $start, Carbon $end) + public function countJournalsInRange(Category $category, Carbon $start, Carbon $end): int { return $category->transactionjournals()->before($end)->after($start)->count(); } @@ -59,9 +59,9 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate /** * @param Category $category * - * @return boolean + * @return bool */ - public function destroy(Category $category) + public function destroy(Category $category): bool { $category->delete(); @@ -82,7 +82,7 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate * * @return array */ - public function earnedPerDay(Category $category, Carbon $start, Carbon $end) + public function earnedPerDay(Category $category, Carbon $start, Carbon $end): array { /** @var Collection $query */ $query = $category->transactionjournals() @@ -123,7 +123,7 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate * * @return Carbon */ - public function getFirstActivityDate(Category $category) + public function getFirstActivityDate(Category $category): Carbon { /** @var TransactionJournal $first */ $first = $category->transactionjournals()->orderBy('date', 'ASC')->first(); @@ -141,7 +141,7 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate * * @return Collection */ - public function getJournals(Category $category, $page) + public function getJournals(Category $category, $page): Collection { $offset = $page > 0 ? $page * 50 : 0; @@ -162,7 +162,7 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate * * @return Collection */ - public function getJournalsForAccountsInRange(Category $category, Collection $accounts, Carbon $start, Carbon $end) + public function getJournalsForAccountsInRange(Category $category, Collection $accounts, Carbon $start, Carbon $end): Collection { $ids = $accounts->pluck('id')->toArray(); @@ -181,9 +181,9 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate * @param Carbon $start * @param Carbon $end * - * @return mixed + * @return Collection */ - public function getJournalsInRange(Category $category, $page, Carbon $start, Carbon $end) + public function getJournalsInRange(Category $category, $page, Carbon $start, Carbon $end): Collection { $offset = $page > 0 ? $page * 50 : 0; @@ -201,7 +201,7 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate * * @return Carbon|null */ - public function getLatestActivity(Category $category) + public function getLatestActivity(Category $category): Carbon { $latest = $category->transactionjournals() ->orderBy('transaction_journals.date', 'DESC') @@ -212,7 +212,7 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate return $latest->date; } - return null; + return new Carbon('1900-01-01'); } /** @@ -229,7 +229,7 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate * * @return array */ - public function spentPerDay(Category $category, Carbon $start, Carbon $end) + public function spentPerDay(Category $category, Carbon $start, Carbon $end): array { /** @var Collection $query */ $query = $category->transactionjournals() @@ -253,7 +253,7 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate * * @return Category */ - public function store(array $data) + public function store(array $data): Category { $newCategory = Category::firstOrCreateEncrypted( [ @@ -272,7 +272,7 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate * * @return Category */ - public function update(Category $category, array $data) + public function update(Category $category, array $data): Category { // update the account: $category->name = $data['name']; diff --git a/app/Repositories/Category/SingleCategoryRepositoryInterface.php b/app/Repositories/Category/SingleCategoryRepositoryInterface.php index 88104b957b..29649457be 100644 --- a/app/Repositories/Category/SingleCategoryRepositoryInterface.php +++ b/app/Repositories/Category/SingleCategoryRepositoryInterface.php @@ -20,7 +20,7 @@ interface SingleCategoryRepositoryInterface * * @return int */ - public function countJournals(Category $category); + public function countJournals(Category $category): int; /** * @param Category $category @@ -30,14 +30,14 @@ interface SingleCategoryRepositoryInterface * * @return int */ - public function countJournalsInRange(Category $category, Carbon $start, Carbon $end); + public function countJournalsInRange(Category $category, Carbon $start, Carbon $end): int; /** * @param Category $category * - * @return boolean + * @return bool */ - public function destroy(Category $category); + public function destroy(Category $category): bool; /** * Returns an array with the following key:value pairs: @@ -53,7 +53,7 @@ interface SingleCategoryRepositoryInterface * * @return array */ - public function earnedPerDay(Category $category, Carbon $start, Carbon $end); + public function earnedPerDay(Category $category, Carbon $start, Carbon $end): array; /** * Find a category @@ -69,7 +69,7 @@ interface SingleCategoryRepositoryInterface * * @return Carbon */ - public function getFirstActivityDate(Category $category); + public function getFirstActivityDate(Category $category): Carbon; /** * @param Category $category @@ -77,7 +77,7 @@ interface SingleCategoryRepositoryInterface * * @return Collection */ - public function getJournals(Category $category, $page); + public function getJournals(Category $category, $page): Collection; /** * @param Category $category @@ -88,7 +88,7 @@ interface SingleCategoryRepositoryInterface * * @return Collection */ - public function getJournalsForAccountsInRange(Category $category, Collection $accounts, Carbon $start, Carbon $end); + public function getJournalsForAccountsInRange(Category $category, Collection $accounts, Carbon $start, Carbon $end): Collection; /** * @param Category $category @@ -99,14 +99,14 @@ interface SingleCategoryRepositoryInterface * * @return Collection */ - public function getJournalsInRange(Category $category, $page, Carbon $start, Carbon $end); + public function getJournalsInRange(Category $category, $page, Carbon $start, Carbon $end): Collection; /** * @param Category $category * - * @return Carbon|null + * @return Carbon */ - public function getLatestActivity(Category $category); + public function getLatestActivity(Category $category): Carbon; /** * Returns an array with the following key:value pairs: @@ -122,7 +122,7 @@ interface SingleCategoryRepositoryInterface * * @return array */ - public function spentPerDay(Category $category, Carbon $start, Carbon $end); + public function spentPerDay(Category $category, Carbon $start, Carbon $end): array; /** @@ -130,7 +130,7 @@ interface SingleCategoryRepositoryInterface * * @return Category */ - public function store(array $data); + public function store(array $data): Category; /** * @param Category $category @@ -138,5 +138,5 @@ interface SingleCategoryRepositoryInterface * * @return Category */ - public function update(Category $category, array $data); + public function update(Category $category, array $data): Category; } diff --git a/app/Repositories/Currency/CurrencyRepository.php b/app/Repositories/Currency/CurrencyRepository.php index 02328f291a..f9d60c9740 100644 --- a/app/Repositories/Currency/CurrencyRepository.php +++ b/app/Repositories/Currency/CurrencyRepository.php @@ -21,7 +21,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface * * @return int */ - public function countJournals(TransactionCurrency $currency) + public function countJournals(TransactionCurrency $currency): int { return $currency->transactionJournals()->count(); } @@ -98,7 +98,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface /** * @return Collection */ - public function get() + public function get(): Collection { return TransactionCurrency::get(); } @@ -108,7 +108,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface * * @return TransactionCurrency */ - public function getCurrencyByPreference(Preference $preference) + public function getCurrencyByPreference(Preference $preference): TransactionCurrency { $preferred = TransactionCurrency::whereCode($preference->data)->first(); if (is_null($preferred)) { @@ -123,7 +123,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface * * @return TransactionCurrency */ - public function store(array $data) + public function store(array $data): TransactionCurrency { $currency = TransactionCurrency::create( [ @@ -142,7 +142,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface * * @return TransactionCurrency */ - public function update(TransactionCurrency $currency, array $data) + public function update(TransactionCurrency $currency, array $data): TransactionCurrency { $currency->code = $data['code']; $currency->symbol = $data['symbol']; diff --git a/app/Repositories/Currency/CurrencyRepositoryInterface.php b/app/Repositories/Currency/CurrencyRepositoryInterface.php index 3b82882dd3..2aba1b93bc 100644 --- a/app/Repositories/Currency/CurrencyRepositoryInterface.php +++ b/app/Repositories/Currency/CurrencyRepositoryInterface.php @@ -20,7 +20,7 @@ interface CurrencyRepositoryInterface * * @return int */ - public function countJournals(TransactionCurrency $currency); + public function countJournals(TransactionCurrency $currency): int; /** * Find by ID @@ -61,21 +61,21 @@ interface CurrencyRepositoryInterface /** * @return Collection */ - public function get(); + public function get(): Collection; /** * @param Preference $preference * * @return TransactionCurrency */ - public function getCurrencyByPreference(Preference $preference); + public function getCurrencyByPreference(Preference $preference): TransactionCurrency; /** * @param array $data * * @return TransactionCurrency */ - public function store(array $data); + public function store(array $data): TransactionCurrency; /** * @param TransactionCurrency $currency @@ -83,6 +83,6 @@ interface CurrencyRepositoryInterface * * @return TransactionCurrency */ - public function update(TransactionCurrency $currency, array $data); + public function update(TransactionCurrency $currency, array $data): TransactionCurrency; } diff --git a/app/Repositories/ExportJob/ExportJobRepository.php b/app/Repositories/ExportJob/ExportJobRepository.php index 6d477feb5d..c913972cea 100644 --- a/app/Repositories/ExportJob/ExportJobRepository.php +++ b/app/Repositories/ExportJob/ExportJobRepository.php @@ -38,7 +38,7 @@ class ExportJobRepository implements ExportJobRepositoryInterface /** * @return bool */ - public function cleanup() + public function cleanup(): bool { $dayAgo = Carbon::create()->subDay(); $set = ExportJob::where('created_at', '<', $dayAgo->format('Y-m-d H:i:s')) @@ -66,7 +66,7 @@ class ExportJobRepository implements ExportJobRepositoryInterface /** * @return ExportJob */ - public function create() + public function create(): ExportJob { $exportJob = new ExportJob; $exportJob->user()->associate($this->user); @@ -81,11 +81,14 @@ class ExportJobRepository implements ExportJobRepositoryInterface } /** + * + * FIXME this may return null + * * @param string $key * * @return ExportJob|null */ - public function findByKey(string $key) + public function findByKey(string $key): ExportJob { return $this->user->exportJobs()->where('key', $key)->first(); } diff --git a/app/Repositories/ExportJob/ExportJobRepositoryInterface.php b/app/Repositories/ExportJob/ExportJobRepositoryInterface.php index 9c1dd4c434..43572ed1c2 100644 --- a/app/Repositories/ExportJob/ExportJobRepositoryInterface.php +++ b/app/Repositories/ExportJob/ExportJobRepositoryInterface.php @@ -22,18 +22,18 @@ interface ExportJobRepositoryInterface /** * @return bool */ - public function cleanup(); + public function cleanup(): bool; /** * @return ExportJob */ - public function create(); + public function create(): ExportJob; /** * @param string $key * * @return ExportJob|null */ - public function findByKey(string $key); + public function findByKey(string $key): ExportJob; } diff --git a/app/Repositories/Journal/JournalCollector.php b/app/Repositories/Journal/JournalCollector.php index c971f9091a..804b48c087 100644 --- a/app/Repositories/Journal/JournalCollector.php +++ b/app/Repositories/Journal/JournalCollector.php @@ -49,7 +49,7 @@ class JournalCollector /** * @return Collection */ - public function collect() + public function collect(): Collection { // get all the journals: $ids = $this->accounts->pluck('id')->toArray(); diff --git a/app/Rules/Actions/ActionInterface.php b/app/Rules/Actions/ActionInterface.php index 8b90cb39df..42f95b37db 100644 --- a/app/Rules/Actions/ActionInterface.php +++ b/app/Rules/Actions/ActionInterface.php @@ -32,5 +32,5 @@ interface ActionInterface * * @return bool */ - public function act(TransactionJournal $journal); + public function act(TransactionJournal $journal): bool; } diff --git a/app/Rules/Actions/AddTag.php b/app/Rules/Actions/AddTag.php index 80a5750119..87d2b8e743 100644 --- a/app/Rules/Actions/AddTag.php +++ b/app/Rules/Actions/AddTag.php @@ -42,7 +42,7 @@ class AddTag implements ActionInterface * * @return bool */ - public function act(TransactionJournal $journal) + public function act(TransactionJournal $journal): bool { // journal has this tag maybe? $tag = Tag::firstOrCreateEncrypted(['tag' => $this->action->action_value, 'user_id' => Auth::user()->id]); diff --git a/app/Rules/Actions/AppendDescription.php b/app/Rules/Actions/AppendDescription.php index d858959025..281b1a0857 100644 --- a/app/Rules/Actions/AppendDescription.php +++ b/app/Rules/Actions/AppendDescription.php @@ -39,7 +39,7 @@ class AppendDescription implements ActionInterface * * @return bool */ - public function act(TransactionJournal $journal) + public function act(TransactionJournal $journal): bool { $journal->description = $journal->description . $this->action->action_value; $journal->save(); diff --git a/app/Rules/Actions/ClearBudget.php b/app/Rules/Actions/ClearBudget.php index 441157f07e..0cea12a61e 100644 --- a/app/Rules/Actions/ClearBudget.php +++ b/app/Rules/Actions/ClearBudget.php @@ -40,7 +40,7 @@ class ClearBudget implements ActionInterface * * @return bool */ - public function act(TransactionJournal $journal) + public function act(TransactionJournal $journal): bool { $journal->budgets()->detach(); diff --git a/app/Rules/Actions/ClearCategory.php b/app/Rules/Actions/ClearCategory.php index 16e435b505..3a1c5d1d7f 100644 --- a/app/Rules/Actions/ClearCategory.php +++ b/app/Rules/Actions/ClearCategory.php @@ -40,7 +40,7 @@ class ClearCategory implements ActionInterface * * @return bool */ - public function act(TransactionJournal $journal) + public function act(TransactionJournal $journal): bool { $journal->categories()->detach(); diff --git a/app/Rules/Actions/PrependDescription.php b/app/Rules/Actions/PrependDescription.php index a0eeca1549..52b4b4f2f0 100644 --- a/app/Rules/Actions/PrependDescription.php +++ b/app/Rules/Actions/PrependDescription.php @@ -39,7 +39,7 @@ class PrependDescription implements ActionInterface * * @return bool */ - public function act(TransactionJournal $journal) + public function act(TransactionJournal $journal): bool { $journal->description = $this->action->action_value . $journal->description; $journal->save(); diff --git a/app/Rules/Actions/RemoveAllTags.php b/app/Rules/Actions/RemoveAllTags.php index e3217011d9..3bcd36f8af 100644 --- a/app/Rules/Actions/RemoveAllTags.php +++ b/app/Rules/Actions/RemoveAllTags.php @@ -39,7 +39,7 @@ class RemoveAllTags implements ActionInterface * * @return bool */ - public function act(TransactionJournal $journal) + public function act(TransactionJournal $journal): bool { $journal->tags()->detach(); diff --git a/app/Rules/Actions/RemoveTag.php b/app/Rules/Actions/RemoveTag.php index a090e57009..a6b5c87327 100644 --- a/app/Rules/Actions/RemoveTag.php +++ b/app/Rules/Actions/RemoveTag.php @@ -42,7 +42,7 @@ class RemoveTag implements ActionInterface * * @return bool */ - public function act(TransactionJournal $journal) + public function act(TransactionJournal $journal): bool { // if tag does not exist, no need to continue: $name = $this->action->action_value; diff --git a/app/Rules/Actions/SetBudget.php b/app/Rules/Actions/SetBudget.php index 54847f836b..9ea73e2a39 100644 --- a/app/Rules/Actions/SetBudget.php +++ b/app/Rules/Actions/SetBudget.php @@ -43,7 +43,7 @@ class SetBudget implements ActionInterface * * @return bool */ - public function act(TransactionJournal $journal) + public function act(TransactionJournal $journal): bool { /** @var BudgetRepositoryInterface $repository */ $repository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); diff --git a/app/Rules/Actions/SetCategory.php b/app/Rules/Actions/SetCategory.php index 24107459a5..86ccef422d 100644 --- a/app/Rules/Actions/SetCategory.php +++ b/app/Rules/Actions/SetCategory.php @@ -43,7 +43,7 @@ class SetCategory implements ActionInterface * * @return bool */ - public function act(TransactionJournal $journal) + public function act(TransactionJournal $journal): bool { $name = $this->action->action_value; $category = Category::firstOrCreateEncrypted(['name' => $name, 'user_id' => Auth::user()->id]); diff --git a/app/Rules/Actions/SetDescription.php b/app/Rules/Actions/SetDescription.php index a3c822ddb1..47dabc12d6 100644 --- a/app/Rules/Actions/SetDescription.php +++ b/app/Rules/Actions/SetDescription.php @@ -39,7 +39,7 @@ class SetDescription implements ActionInterface * * @return bool */ - public function act(TransactionJournal $journal) + public function act(TransactionJournal $journal): bool { $journal->description = $this->action->action_value; $journal->save(); diff --git a/app/Rules/Processor.php b/app/Rules/Processor.php index eb3d5da5e3..1bbcc988f5 100644 --- a/app/Rules/Processor.php +++ b/app/Rules/Processor.php @@ -117,7 +117,7 @@ final class Processor * * @return \FireflyIII\Models\Rule */ - public function getRule() + public function getRule(): Rule { return $this->rule; } @@ -131,7 +131,7 @@ final class Processor * * @return bool */ - public function handleTransactionJournal(TransactionJournal $journal) + public function handleTransactionJournal(TransactionJournal $journal): bool { $this->journal = $journal; // get all triggers: diff --git a/app/Rules/TransactionMatcher.php b/app/Rules/TransactionMatcher.php index 3c970430dc..80be3c7366 100644 --- a/app/Rules/TransactionMatcher.php +++ b/app/Rules/TransactionMatcher.php @@ -115,7 +115,7 @@ class TransactionMatcher * * @return TransactionMatcher */ - public function setLimit($limit): TransactionMatcher + public function setLimit(int $limit): TransactionMatcher { $this->limit = $limit; @@ -135,7 +135,7 @@ class TransactionMatcher * * @return TransactionMatcher */ - public function setRange($range): TransactionMatcher + public function setRange(int $range): TransactionMatcher { $this->range = $range; @@ -156,7 +156,7 @@ class TransactionMatcher * * @return TransactionMatcher */ - public function setTriggers($triggers): TransactionMatcher + public function setTriggers(array $triggers): TransactionMatcher { $this->triggers = $triggers; diff --git a/app/Rules/Triggers/AmountExactly.php b/app/Rules/Triggers/AmountExactly.php index 0f2adce2a0..7a6ca714dd 100644 --- a/app/Rules/Triggers/AmountExactly.php +++ b/app/Rules/Triggers/AmountExactly.php @@ -51,7 +51,7 @@ final class AmountExactly extends AbstractTrigger implements TriggerInterface * * @return bool */ - public function triggered(TransactionJournal $journal) + public function triggered(TransactionJournal $journal): bool { $amount = $journal->destination_amount ?? TransactionJournal::amountPositive($journal); $compare = $this->triggerValue; diff --git a/app/Rules/Triggers/AmountLess.php b/app/Rules/Triggers/AmountLess.php index fa96f756dd..e6d8cc9c27 100644 --- a/app/Rules/Triggers/AmountLess.php +++ b/app/Rules/Triggers/AmountLess.php @@ -51,7 +51,7 @@ final class AmountLess extends AbstractTrigger implements TriggerInterface * * @return bool */ - public function triggered(TransactionJournal $journal) + public function triggered(TransactionJournal $journal): bool { $amount = $journal->destination_amount ?? TransactionJournal::amountPositive($journal); $compare = $this->triggerValue; diff --git a/app/Rules/Triggers/AmountMore.php b/app/Rules/Triggers/AmountMore.php index 8c95bf4568..ce8b2c7573 100644 --- a/app/Rules/Triggers/AmountMore.php +++ b/app/Rules/Triggers/AmountMore.php @@ -51,7 +51,7 @@ final class AmountMore extends AbstractTrigger implements TriggerInterface * * @return bool */ - public function triggered(TransactionJournal $journal) + public function triggered(TransactionJournal $journal): bool { $amount = $journal->destination_amount ?? TransactionJournal::amountPositive($journal); $compare = $this->triggerValue; diff --git a/app/Rules/Triggers/DescriptionContains.php b/app/Rules/Triggers/DescriptionContains.php index 284ffa311e..6f75479ce4 100644 --- a/app/Rules/Triggers/DescriptionContains.php +++ b/app/Rules/Triggers/DescriptionContains.php @@ -51,7 +51,7 @@ final class DescriptionContains extends AbstractTrigger implements TriggerInterf * * @return bool */ - public function triggered(TransactionJournal $journal) + public function triggered(TransactionJournal $journal): bool { $search = strtolower($this->triggerValue); $source = strtolower($journal->description); diff --git a/app/Rules/Triggers/DescriptionEnds.php b/app/Rules/Triggers/DescriptionEnds.php index 8bec9cc1fe..751645ff85 100644 --- a/app/Rules/Triggers/DescriptionEnds.php +++ b/app/Rules/Triggers/DescriptionEnds.php @@ -50,7 +50,7 @@ final class DescriptionEnds extends AbstractTrigger implements TriggerInterface * * @return bool */ - public function triggered(TransactionJournal $journal) + public function triggered(TransactionJournal $journal): bool { $description = strtolower($journal->description); $descriptionLength = strlen($description); diff --git a/app/Rules/Triggers/DescriptionIs.php b/app/Rules/Triggers/DescriptionIs.php index 5dcec9b3d1..81bfb8ad7c 100644 --- a/app/Rules/Triggers/DescriptionIs.php +++ b/app/Rules/Triggers/DescriptionIs.php @@ -50,7 +50,7 @@ final class DescriptionIs extends AbstractTrigger implements TriggerInterface * * @return bool */ - public function triggered(TransactionJournal $journal) + public function triggered(TransactionJournal $journal): bool { $description = strtolower($journal->description); $search = strtolower($this->triggerValue); diff --git a/app/Rules/Triggers/DescriptionStarts.php b/app/Rules/Triggers/DescriptionStarts.php index 5763f30d59..295333c95b 100644 --- a/app/Rules/Triggers/DescriptionStarts.php +++ b/app/Rules/Triggers/DescriptionStarts.php @@ -50,7 +50,7 @@ final class DescriptionStarts extends AbstractTrigger implements TriggerInterfac * * @return bool */ - public function triggered(TransactionJournal $journal) + public function triggered(TransactionJournal $journal): bool { $description = strtolower($journal->description); $search = strtolower($this->triggerValue); diff --git a/app/Rules/Triggers/FromAccountContains.php b/app/Rules/Triggers/FromAccountContains.php index 6510a1fb71..58799b60d4 100644 --- a/app/Rules/Triggers/FromAccountContains.php +++ b/app/Rules/Triggers/FromAccountContains.php @@ -50,7 +50,7 @@ final class FromAccountContains extends AbstractTrigger implements TriggerInterf * * @return bool */ - public function triggered(TransactionJournal $journal) + public function triggered(TransactionJournal $journal): bool { $fromAccountName = strtolower($journal->source_account_name ?? TransactionJournal::sourceAccount($journal)->name); $search = strtolower($this->triggerValue); diff --git a/app/Rules/Triggers/FromAccountEnds.php b/app/Rules/Triggers/FromAccountEnds.php index eaee5223fa..96e83fadcf 100644 --- a/app/Rules/Triggers/FromAccountEnds.php +++ b/app/Rules/Triggers/FromAccountEnds.php @@ -50,7 +50,7 @@ final class FromAccountEnds extends AbstractTrigger implements TriggerInterface * * @return bool */ - public function triggered(TransactionJournal $journal) + public function triggered(TransactionJournal $journal): bool { $name = strtolower($journal->source_account_name ?? TransactionJournal::sourceAccount($journal)->name); $nameLength = strlen($name); diff --git a/app/Rules/Triggers/FromAccountIs.php b/app/Rules/Triggers/FromAccountIs.php index 1344847929..061044cf7d 100644 --- a/app/Rules/Triggers/FromAccountIs.php +++ b/app/Rules/Triggers/FromAccountIs.php @@ -50,7 +50,7 @@ final class FromAccountIs extends AbstractTrigger implements TriggerInterface * * @return bool */ - public function triggered(TransactionJournal $journal) + public function triggered(TransactionJournal $journal): bool { $name = strtolower($journal->source_account_name ?? TransactionJournal::sourceAccount($journal)->name); $search = strtolower($this->triggerValue); diff --git a/app/Rules/Triggers/FromAccountStarts.php b/app/Rules/Triggers/FromAccountStarts.php index 32027e4587..62eaafac67 100644 --- a/app/Rules/Triggers/FromAccountStarts.php +++ b/app/Rules/Triggers/FromAccountStarts.php @@ -50,7 +50,7 @@ final class FromAccountStarts extends AbstractTrigger implements TriggerInterfac * * @return bool */ - public function triggered(TransactionJournal $journal) + public function triggered(TransactionJournal $journal): bool { $name = strtolower($journal->source_account_name ?? TransactionJournal::sourceAccount($journal)->name); $search = strtolower($this->triggerValue); diff --git a/app/Rules/Triggers/ToAccountContains.php b/app/Rules/Triggers/ToAccountContains.php index e898743ab0..f6d7c31c68 100644 --- a/app/Rules/Triggers/ToAccountContains.php +++ b/app/Rules/Triggers/ToAccountContains.php @@ -50,7 +50,7 @@ final class ToAccountContains extends AbstractTrigger implements TriggerInterfac * * @return bool */ - public function triggered(TransactionJournal $journal) + public function triggered(TransactionJournal $journal): bool { $toAccountName = strtolower($journal->destination_account_name ?? TransactionJournal::destinationAccount($journal)->name); $search = strtolower($this->triggerValue); diff --git a/app/Rules/Triggers/ToAccountEnds.php b/app/Rules/Triggers/ToAccountEnds.php index a6acfafc90..f01d8d8ba5 100644 --- a/app/Rules/Triggers/ToAccountEnds.php +++ b/app/Rules/Triggers/ToAccountEnds.php @@ -50,7 +50,7 @@ final class ToAccountEnds extends AbstractTrigger implements TriggerInterface * * @return bool */ - public function triggered(TransactionJournal $journal) + public function triggered(TransactionJournal $journal): bool { $toAccountName = strtolower($journal->destination_account_name ?? TransactionJournal::destinationAccount($journal)->name); $toAccountNameLength = strlen($toAccountName); diff --git a/app/Rules/Triggers/ToAccountIs.php b/app/Rules/Triggers/ToAccountIs.php index 03506aa9bc..6d1ea0181e 100644 --- a/app/Rules/Triggers/ToAccountIs.php +++ b/app/Rules/Triggers/ToAccountIs.php @@ -50,7 +50,7 @@ final class ToAccountIs extends AbstractTrigger implements TriggerInterface * * @return bool */ - public function triggered(TransactionJournal $journal) + public function triggered(TransactionJournal $journal): bool { $toAccountName = strtolower($journal->destination_account_name ?? TransactionJournal::destinationAccount($journal)->name); $search = strtolower($this->triggerValue); diff --git a/app/Rules/Triggers/ToAccountStarts.php b/app/Rules/Triggers/ToAccountStarts.php index 2e3c5655ce..8f00f80d0c 100644 --- a/app/Rules/Triggers/ToAccountStarts.php +++ b/app/Rules/Triggers/ToAccountStarts.php @@ -50,7 +50,7 @@ final class ToAccountStarts extends AbstractTrigger implements TriggerInterface * * @return bool */ - public function triggered(TransactionJournal $journal) + public function triggered(TransactionJournal $journal): bool { $toAccountName = strtolower($journal->destination_account_name ?? TransactionJournal::destinationAccount($journal)->name); $search = strtolower($this->triggerValue); diff --git a/app/Rules/Triggers/TransactionType.php b/app/Rules/Triggers/TransactionType.php index b6a0669add..a57d1aa1cc 100644 --- a/app/Rules/Triggers/TransactionType.php +++ b/app/Rules/Triggers/TransactionType.php @@ -50,7 +50,7 @@ final class TransactionType extends AbstractTrigger implements TriggerInterface * * @return bool */ - public function triggered(TransactionJournal $journal) + public function triggered(TransactionJournal $journal): bool { $type = !is_null($journal->transaction_type_type) ? $journal->transaction_type_type : strtolower($journal->transactionType->type); $search = strtolower($this->triggerValue); diff --git a/app/Rules/Triggers/TriggerInterface.php b/app/Rules/Triggers/TriggerInterface.php index 5b7dd50cbf..2cd5bd2c2c 100644 --- a/app/Rules/Triggers/TriggerInterface.php +++ b/app/Rules/Triggers/TriggerInterface.php @@ -43,5 +43,5 @@ interface TriggerInterface * * @return bool */ - public function triggered(TransactionJournal $journal); + public function triggered(TransactionJournal $journal): bool; } diff --git a/app/Rules/Triggers/UserAction.php b/app/Rules/Triggers/UserAction.php index 7aa76ef43c..32f9698a91 100644 --- a/app/Rules/Triggers/UserAction.php +++ b/app/Rules/Triggers/UserAction.php @@ -48,7 +48,7 @@ final class UserAction extends AbstractTrigger implements TriggerInterface * * @return bool */ - public function triggered(TransactionJournal $journal) + public function triggered(TransactionJournal $journal): bool { return true; } diff --git a/app/Sql/Query.php b/app/Sql/Query.php deleted file mode 100644 index ccc9a6244f..0000000000 --- a/app/Sql/Query.php +++ /dev/null @@ -1,18 +0,0 @@ -get(); } @@ -120,7 +120,7 @@ class Amount /** * @return string */ - public function getCurrencyCode() + public function getCurrencyCode(): string { $cache = new CacheProperties; @@ -146,7 +146,7 @@ class Amount /** * @return string */ - public function getCurrencySymbol() + public function getCurrencySymbol(): string { $cache = new CacheProperties; $cache->addProperty('getCurrencySymbol'); @@ -165,7 +165,7 @@ class Amount /** * @return TransactionCurrency */ - public function getDefaultCurrency() + public function getDefaultCurrency(): TransactionCurrency { $cache = new CacheProperties; $cache->addProperty('getDefaultCurrency'); diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.php index 65dcb3dd86..64668d5c03 100644 --- a/app/Support/ExpandedForm.php +++ b/app/Support/ExpandedForm.php @@ -246,7 +246,7 @@ class ExpandedForm * * @return string */ - public function optionsList($type, $name): string + public function optionsList(string $type, string $name): string { $previousValue = null; diff --git a/app/Support/Navigation.php b/app/Support/Navigation.php index 51cb6091bc..0d3777e93e 100644 --- a/app/Support/Navigation.php +++ b/app/Support/Navigation.php @@ -23,7 +23,7 @@ class Navigation * @return \Carbon\Carbon * @throws FireflyException */ - public function addPeriod(Carbon $theDate, string $repeatFreq, int $skip) + public function addPeriod(Carbon $theDate, string $repeatFreq, int $skip): Carbon { $date = clone $theDate; $add = ($skip + 1); @@ -62,7 +62,7 @@ class Navigation * @return \Carbon\Carbon * @throws FireflyException */ - public function endOfPeriod(Carbon $theCurrentEnd, string $repeatFreq) + public function endOfPeriod(Carbon $theCurrentEnd, string $repeatFreq): Carbon { $currentEnd = clone $theCurrentEnd; @@ -121,7 +121,7 @@ class Navigation * * @return \Carbon\Carbon */ - public function endOfX(Carbon $theCurrentEnd, string $repeatFreq, Carbon $maxDate = null) + public function endOfX(Carbon $theCurrentEnd, string $repeatFreq, Carbon $maxDate = null): Carbon { $functionMap = [ '1D' => 'endOfDay', @@ -162,7 +162,7 @@ class Navigation * @return string * @throws FireflyException */ - public function periodShow(Carbon $date, string $repeatFrequency) + public function periodShow(Carbon $date, string $repeatFrequency): string { $formatMap = [ '1D' => trans('config.specific_day'), @@ -197,7 +197,7 @@ class Navigation * @return \Carbon\Carbon * @throws FireflyException */ - public function startOfPeriod(Carbon $theDate, string $repeatFreq) + public function startOfPeriod(Carbon $theDate, string $repeatFreq): Carbon { $date = clone $theDate; @@ -248,7 +248,7 @@ class Navigation * @return \Carbon\Carbon * @throws FireflyException */ - public function subtractPeriod(Carbon $theDate, string $repeatFreq, int $subtract = 1) + public function subtractPeriod(Carbon $theDate, string $repeatFreq, int $subtract = 1): Carbon { $date = clone $theDate; // 1D 1W 1M 3M 6M 1Y @@ -308,7 +308,7 @@ class Navigation * @return \Carbon\Carbon * @throws FireflyException */ - public function updateEndDate(string $range, Carbon $start) + public function updateEndDate(string $range, Carbon $start): Carbon { $functionMap = [ '1D' => 'endOfDay', @@ -344,7 +344,7 @@ class Navigation * @return \Carbon\Carbon * @throws FireflyException */ - public function updateStartDate(string $range, Carbon $start) + public function updateStartDate(string $range, Carbon $start): Carbon { $functionMap = [ '1D' => 'startOfDay', diff --git a/app/Support/Preferences.php b/app/Support/Preferences.php index a5652749f2..8b900f6fb9 100644 --- a/app/Support/Preferences.php +++ b/app/Support/Preferences.php @@ -38,7 +38,7 @@ class Preferences * @param $name * @param null $default * - * @return Preference|null + * @return \FireflyIII\Models\Preference|null */ public function get($name, $default = null) { @@ -83,7 +83,7 @@ class Preferences /** * @return string */ - public function lastActivity() + public function lastActivity(): string { $preference = $this->get('lastActivity', microtime())->data; @@ -93,7 +93,7 @@ class Preferences /** * @return bool */ - public function mark() + public function mark(): bool { $this->set('lastActivity', microtime()); @@ -106,7 +106,7 @@ class Preferences * * @return Preference */ - public function set($name, $value) + public function set($name, $value): Preference { $user = Auth::user(); if (is_null($user)) { @@ -123,7 +123,7 @@ class Preferences * * @return Preference */ - public function setForUser(User $user, $name, $value) + public function setForUser(User $user, $name, $value): Preference { $fullName = 'preference' . $user->id . $name; Cache::forget($fullName); diff --git a/app/Support/Steam.php b/app/Support/Steam.php index b5c7c1db19..ed5cff9d7b 100644 --- a/app/Support/Steam.php +++ b/app/Support/Steam.php @@ -63,7 +63,7 @@ class Steam * * @return array */ - public function balanceInRange(Account $account, Carbon $start, Carbon $end) + public function balanceInRange(Account $account, Carbon $start, Carbon $end): array { // abuse chart properties: $cache = new CacheProperties; @@ -110,7 +110,7 @@ class Steam * * @return array */ - public function balancesById(array $ids, Carbon $date) + public function balancesById(array $ids, Carbon $date): array { // abuse chart properties: @@ -147,7 +147,7 @@ class Steam * * @return array */ - public function getLastActivities(array $accounts) + public function getLastActivities(array $accounts): array { $list = []; @@ -170,7 +170,7 @@ class Steam * * @return int */ - public function phpBytes($string) + public function phpBytes($string): int { $string = strtolower($string); diff --git a/app/Support/Twig/PiggyBank.php b/app/Support/Twig/PiggyBank.php index dd5d341ffa..5df305d3f8 100644 --- a/app/Support/Twig/PiggyBank.php +++ b/app/Support/Twig/PiggyBank.php @@ -20,7 +20,7 @@ class PiggyBank extends Twig_Extension /** * */ - public function getFunctions() + public function getFunctions(): array { $functions = []; @@ -38,7 +38,7 @@ class PiggyBank extends Twig_Extension * * @return string The extension name */ - public function getName() + public function getName(): string { return 'FireflyIII\Support\Twig\PiggyBank'; } diff --git a/app/Support/Twig/Rule.php b/app/Support/Twig/Rule.php index 8c83e2ca10..e91f16509e 100644 --- a/app/Support/Twig/Rule.php +++ b/app/Support/Twig/Rule.php @@ -18,7 +18,7 @@ class Rule extends Twig_Extension /** * @return Twig_SimpleFunction */ - public function allJournalTriggers() + public function allJournalTriggers(): Twig_SimpleFunction { return new Twig_SimpleFunction( 'allJournalTriggers', function () { @@ -33,7 +33,7 @@ class Rule extends Twig_Extension /** * @return Twig_SimpleFunction */ - public function allRuleTriggers() + public function allRuleTriggers(): Twig_SimpleFunction { return new Twig_SimpleFunction( 'allRuleTriggers', function () { @@ -56,7 +56,7 @@ class Rule extends Twig_Extension /** * @return Twig_SimpleFunction */ - public function allActionTriggers() + public function allActionTriggers(): Twig_SimpleFunction { return new Twig_SimpleFunction( 'allRuleActions', function () { @@ -76,7 +76,7 @@ class Rule extends Twig_Extension /** * @return array */ - public function getFunctions() + public function getFunctions(): array { return [ $this->allJournalTriggers(), @@ -91,7 +91,7 @@ class Rule extends Twig_Extension * * @return string The extension name */ - public function getName() + public function getName(): string { return 'FireflyIII\Support\Twig\Rule'; } diff --git a/app/Support/Twig/Translation.php b/app/Support/Twig/Translation.php index 028cc814a1..a8ebe88da2 100644 --- a/app/Support/Twig/Translation.php +++ b/app/Support/Twig/Translation.php @@ -19,7 +19,7 @@ class Translation extends Twig_Extension /** * @return array */ - public function getFilters() + public function getFilters(): array { $filters = []; @@ -37,7 +37,7 @@ class Translation extends Twig_Extension /** * {@inheritDoc} */ - public function getName() + public function getName(): string { return 'FireflyIII\Support\Twig\Translation'; } diff --git a/resources/views/budgets/index.twig b/resources/views/budgets/index.twig index 562663d137..a3e6fdf9cf 100644 --- a/resources/views/budgets/index.twig +++ b/resources/views/budgets/index.twig @@ -107,7 +107,7 @@