mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Added PHP7 return type statements.
This commit is contained in:
@@ -36,7 +36,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function countAccounts(array $types)
|
||||
public function countAccounts(array $types): int
|
||||
{
|
||||
$count = Auth::user()->accounts()->accountTypeIn($types)->count();
|
||||
|
||||
@@ -47,9 +47,9 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
* @param Account $account
|
||||
* @param Account $moveTo
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy(Account $account, Account $moveTo = null)
|
||||
public function destroy(Account $account, Account $moveTo = null): bool
|
||||
{
|
||||
if (!is_null($moveTo)) {
|
||||
// update all transactions:
|
||||
@@ -68,7 +68,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*
|
||||
* @return Account
|
||||
*/
|
||||
public function find(int $accountId)
|
||||
public function find(int $accountId): Account
|
||||
{
|
||||
return Auth::user()->accounts()->findOrNew($accountId);
|
||||
}
|
||||
@@ -80,7 +80,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function get(array $ids)
|
||||
public function get(array $ids): Collection
|
||||
{
|
||||
return Auth::user()->accounts()->whereIn('id', $ids)->get(['accounts.*']);
|
||||
}
|
||||
@@ -90,7 +90,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAccounts(array $types)
|
||||
public function getAccounts(array $types): Collection
|
||||
{
|
||||
/** @var Collection $result */
|
||||
$result = Auth::user()->accounts()->with(
|
||||
@@ -119,7 +119,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getCreditCards(Carbon $date)
|
||||
public function getCreditCards(Carbon $date): Collection
|
||||
{
|
||||
$set = Auth::user()->accounts()
|
||||
->hasMetaValue('accountRole', 'ccAsset')
|
||||
@@ -147,7 +147,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*
|
||||
* @return Transaction
|
||||
*/
|
||||
public function getFirstTransaction(TransactionJournal $journal, Account $account)
|
||||
public function getFirstTransaction(TransactionJournal $journal, Account $account): Transaction
|
||||
{
|
||||
$transaction = $journal->transactions()->where('account_id', $account->id)->first();
|
||||
|
||||
@@ -159,7 +159,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getFrontpageAccounts(Preference $preference)
|
||||
public function getFrontpageAccounts(Preference $preference): Collection
|
||||
{
|
||||
$query = Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account']);
|
||||
|
||||
@@ -181,9 +181,9 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return mixed
|
||||
* @return Collection
|
||||
*/
|
||||
public function getFrontpageTransactions(Account $account, Carbon $start, Carbon $end)
|
||||
public function getFrontpageTransactions(Account $account, Carbon $start, Carbon $end): Collection
|
||||
{
|
||||
$set = Auth::user()
|
||||
->transactionjournals()
|
||||
@@ -209,7 +209,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*
|
||||
* @return LengthAwarePaginator
|
||||
*/
|
||||
public function getJournals(Account $account, $page)
|
||||
public function getJournals(Account $account, $page): LengthAwarePaginator
|
||||
{
|
||||
$offset = ($page - 1) * 50;
|
||||
$query = Auth::user()
|
||||
@@ -235,7 +235,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getPiggyBankAccounts()
|
||||
public function getPiggyBankAccounts(): Collection
|
||||
{
|
||||
$start = clone session('start', new Carbon);
|
||||
$end = clone session('end', new Carbon);
|
||||
@@ -277,7 +277,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getSavingsAccounts()
|
||||
public function getSavingsAccounts(): Collection
|
||||
{
|
||||
$accounts = Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account'])->orderBy('accounts.name', 'ASC')
|
||||
->leftJoin('account_meta', 'account_meta.account_id', '=', 'accounts.id')
|
||||
@@ -322,9 +322,9 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
* @param Account $account
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return float
|
||||
* @return string
|
||||
*/
|
||||
public function leftOnAccount(Account $account, Carbon $date)
|
||||
public function leftOnAccount(Account $account, Carbon $date): string
|
||||
{
|
||||
|
||||
$balance = Steam::balance($account, $date, true);
|
||||
@@ -342,7 +342,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*
|
||||
* @return TransactionJournal|null
|
||||
*/
|
||||
public function openingBalanceTransaction(Account $account)
|
||||
public function openingBalanceTransaction(Account $account): TransactionJournal
|
||||
{
|
||||
$journal = TransactionJournal
|
||||
::orderBy('transaction_journals.date', 'ASC')
|
||||
@@ -351,6 +351,9 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
->transactionTypes([TransactionType::OPENING_BALANCE])
|
||||
->orderBy('created_at', 'ASC')
|
||||
->first(['transaction_journals.*']);
|
||||
if(is_null($journal)) {
|
||||
return new TransactionJournal;
|
||||
}
|
||||
|
||||
return $journal;
|
||||
}
|
||||
@@ -360,7 +363,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*
|
||||
* @return Account
|
||||
*/
|
||||
public function store(array $data)
|
||||
public function store(array $data): Account
|
||||
{
|
||||
$newAccount = $this->storeAccount($data);
|
||||
if (!is_null($newAccount)) {
|
||||
@@ -392,7 +395,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function sumOfEverything()
|
||||
public function sumOfEverything(): string
|
||||
{
|
||||
return Auth::user()->transactions()->sum('amount');
|
||||
}
|
||||
@@ -405,7 +408,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*
|
||||
* @return Account
|
||||
*/
|
||||
public function update(Account $account, array $data)
|
||||
public function update(Account $account, array $data): Account
|
||||
{
|
||||
// update the account:
|
||||
$account->name = $data['name'];
|
||||
@@ -449,7 +452,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*
|
||||
* @return Account
|
||||
*/
|
||||
protected function storeAccount(array $data)
|
||||
private function storeAccount(array $data): Account
|
||||
{
|
||||
$type = Config::get('firefly.accountTypeByIdentifier.' . $data['accountType']);
|
||||
$accountType = AccountType::whereType($type)->first();
|
||||
@@ -493,7 +496,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*
|
||||
* @return TransactionJournal
|
||||
*/
|
||||
protected function storeInitialBalance(Account $account, Account $opposing, array $data)
|
||||
private function storeInitialBalance(Account $account, Account $opposing, array $data): TransactionJournal
|
||||
{
|
||||
$transactionType = TransactionType::whereType(TransactionType::OPENING_BALANCE)->first();
|
||||
$journal = TransactionJournal::create(
|
||||
@@ -534,8 +537,10 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function storeMetadata(Account $account, array $data)
|
||||
private function storeMetadata(Account $account, array $data): bool
|
||||
{
|
||||
$validFields = ['accountRole', 'ccMonthlyPaymentDate', 'ccType'];
|
||||
foreach ($validFields as $field) {
|
||||
@@ -549,9 +554,9 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
);
|
||||
$metaData->save();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -561,7 +566,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*
|
||||
* @return TransactionJournal
|
||||
*/
|
||||
protected function updateInitialBalance(Account $account, TransactionJournal $journal, array $data)
|
||||
private function updateInitialBalance(Account $account, TransactionJournal $journal, array $data): TransactionJournal
|
||||
{
|
||||
$journal->date = $data['openingBalanceDate'];
|
||||
$journal->save();
|
||||
@@ -585,8 +590,9 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
* @param Account $account
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function updateMetadata(Account $account, array $data)
|
||||
private function updateMetadata(Account $account, array $data): bool
|
||||
{
|
||||
$validFields = ['accountRole', 'ccMonthlyPaymentDate', 'ccType'];
|
||||
|
||||
@@ -611,5 +617,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user