PHP7 compatible function definitions.

This commit is contained in:
James Cole 2016-04-05 22:00:03 +02:00
parent b0b5d90976
commit 37fe2d22b0
56 changed files with 209 additions and 216 deletions

View File

@ -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);

View File

@ -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()

View File

@ -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

View File

@ -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 */

View File

@ -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;
}

View File

@ -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];

View File

@ -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;
}

View File

@ -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'];

View File

@ -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;
}

View File

@ -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'];

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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();

View File

@ -32,5 +32,5 @@ interface ActionInterface
*
* @return bool
*/
public function act(TransactionJournal $journal);
public function act(TransactionJournal $journal): bool;
}

View File

@ -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]);

View File

@ -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();

View File

@ -40,7 +40,7 @@ class ClearBudget implements ActionInterface
*
* @return bool
*/
public function act(TransactionJournal $journal)
public function act(TransactionJournal $journal): bool
{
$journal->budgets()->detach();

View File

@ -40,7 +40,7 @@ class ClearCategory implements ActionInterface
*
* @return bool
*/
public function act(TransactionJournal $journal)
public function act(TransactionJournal $journal): bool
{
$journal->categories()->detach();

View File

@ -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();

View File

@ -39,7 +39,7 @@ class RemoveAllTags implements ActionInterface
*
* @return bool
*/
public function act(TransactionJournal $journal)
public function act(TransactionJournal $journal): bool
{
$journal->tags()->detach();

View File

@ -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;

View File

@ -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');

View File

@ -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]);

View File

@ -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();

View File

@ -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:

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -43,5 +43,5 @@ interface TriggerInterface
*
* @return bool
*/
public function triggered(TransactionJournal $journal);
public function triggered(TransactionJournal $journal): bool;
}

View File

@ -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;
}

View File

@ -1,18 +0,0 @@
<?php
declare(strict_types = 1);
namespace FireflyIII\Sql;
/**
* Class Query
*
* This class holds some useful static constants.
*
* @package FireflyIII\Sql
*/
class Query
{
const SPENT = 1;
const EARNED = 2;
}

View File

@ -112,7 +112,7 @@ class Amount
/**
* @return Collection
*/
public function getAllCurrencies()
public function getAllCurrencies(): Collection
{
return TransactionCurrency::orderBy('code', 'ASC')->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');

View File

@ -246,7 +246,7 @@ class ExpandedForm
*
* @return string
*/
public function optionsList($type, $name): string
public function optionsList(string $type, string $name): string
{
$previousValue = null;

View File

@ -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',

View File

@ -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);

View File

@ -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);

View File

@ -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';
}

View File

@ -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';
}

View File

@ -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';
}

View File

@ -107,7 +107,7 @@
<div class="box-header with-border">
<h3 class="box-title">
<!-- link in header -->
{% if budget.currentRep %}
{% if budget.currentRep.id %}
<a href="{{ route('budgets.show', [budget.id, budget.currentRep.id]) }}" class="budget-link"
data-id="{{ budget.id }}">{{ budget.name }}</a>
{% else %}

View File

@ -23,7 +23,7 @@
<td>
<a href="{{ route('categories.show', category.id) }}" title="{{ category.name }}">{{ category.name }}</a>
</td>
{% if category.lastActivity %}
{% if category.lastActivity.year != "1900" %}
<td class="hidden-sm hidden-xs" data-value="{{ category.lastActivity.format('U') }}">
{{ category.lastActivity.formatLocalized(monthAndDayFormat) }}
</td>