Added PHP7 return type statements.

This commit is contained in:
James Cole
2016-02-06 18:59:48 +01:00
parent 95c4c4a238
commit 060b031272
4 changed files with 54 additions and 51 deletions

View File

@@ -18,7 +18,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface
* *
* @return bool * @return bool
*/ */
public function destroy(Attachment $attachment) public function destroy(Attachment $attachment): bool
{ {
/** @var \FireflyIII\Helpers\Attachments\AttachmentHelperInterface $helper */ /** @var \FireflyIII\Helpers\Attachments\AttachmentHelperInterface $helper */
$helper = app('FireflyIII\Helpers\Attachments\AttachmentHelperInterface'); $helper = app('FireflyIII\Helpers\Attachments\AttachmentHelperInterface');
@@ -26,6 +26,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface
$file = $helper->getAttachmentLocation($attachment); $file = $helper->getAttachmentLocation($attachment);
unlink($file); unlink($file);
$attachment->delete(); $attachment->delete();
return true;
} }
/** /**
@@ -34,7 +35,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface
* *
* @return Attachment * @return Attachment
*/ */
public function update(Attachment $attachment, array $data) public function update(Attachment $attachment, array $data): Attachment
{ {
$attachment->title = $data['title']; $attachment->title = $data['title'];

View File

@@ -18,7 +18,7 @@ interface AttachmentRepositoryInterface
* *
* @return bool * @return bool
*/ */
public function destroy(Attachment $attachment); public function destroy(Attachment $attachment): bool;
/** /**
* @param Attachment $attachment * @param Attachment $attachment
@@ -26,6 +26,6 @@ interface AttachmentRepositoryInterface
* *
* @return Attachment * @return Attachment
*/ */
public function update(Attachment $attachment, array $attachmentData); public function update(Attachment $attachment, array $attachmentData): Attachment;
} }

View File

@@ -28,17 +28,19 @@ class BillRepository implements BillRepositoryInterface
/** /**
* @param Bill $bill * @param Bill $bill
* *
* @return boolean|null * @return boolean
*/ */
public function destroy(Bill $bill) public function destroy(Bill $bill): bool
{ {
return $bill->delete(); $bill->delete();
return true;
} }
/** /**
* @return Collection * @return Collection
*/ */
public function getActiveBills() public function getActiveBills(): Collection
{ {
/** @var Collection $set */ /** @var Collection $set */
$set = Auth::user()->bills() $set = Auth::user()->bills()
@@ -63,7 +65,7 @@ class BillRepository implements BillRepositoryInterface
* *
* @return Collection * @return Collection
*/ */
public function getAllJournalsInRange(Collection $bills, Carbon $start, Carbon $end) public function getAllJournalsInRange(Collection $bills, Carbon $start, Carbon $end): Collection
{ {
$ids = $bills->pluck('id')->toArray(); $ids = $bills->pluck('id')->toArray();
@@ -90,7 +92,7 @@ class BillRepository implements BillRepositoryInterface
/** /**
* @return Collection * @return Collection
*/ */
public function getBills() public function getBills(): Collection
{ {
/** @var Collection $set */ /** @var Collection $set */
$set = Auth::user()->bills()->orderBy('name', 'ASC')->get(); $set = Auth::user()->bills()->orderBy('name', 'ASC')->get();
@@ -112,7 +114,7 @@ class BillRepository implements BillRepositoryInterface
* *
* @return Collection * @return Collection
*/ */
public function getBillsForAccounts(Collection $accounts) public function getBillsForAccounts(Collection $accounts): Collection
{ {
$ids = $accounts->pluck('id')->toArray(); $ids = $accounts->pluck('id')->toArray();
$set = Auth::user()->bills() $set = Auth::user()->bills()
@@ -152,7 +154,7 @@ class BillRepository implements BillRepositoryInterface
* *
* @return string * @return string
*/ */
public function getBillsPaidInRange(Carbon $start, Carbon $end) public function getBillsPaidInRange(Carbon $start, Carbon $end): string
{ {
$amount = '0'; $amount = '0';
$bills = $this->getActiveBills(); $bills = $this->getActiveBills();
@@ -187,7 +189,7 @@ class BillRepository implements BillRepositoryInterface
* *
* @return string * @return string
*/ */
public function getBillsUnpaidInRange(Carbon $start, Carbon $end) public function getBillsUnpaidInRange(Carbon $start, Carbon $end): string
{ {
$amount = '0'; $amount = '0';
$bills = $this->getActiveBills(); $bills = $this->getActiveBills();
@@ -226,7 +228,7 @@ class BillRepository implements BillRepositoryInterface
* *
* @return string * @return string
*/ */
public function getCreditCardBill(Carbon $start, Carbon $end) public function getCreditCardBill(Carbon $start, Carbon $end): string
{ {
/** @var AccountRepositoryInterface $accountRepository */ /** @var AccountRepositoryInterface $accountRepository */
@@ -274,7 +276,7 @@ class BillRepository implements BillRepositoryInterface
* *
* @return Collection * @return Collection
*/ */
public function getJournals(Bill $bill) public function getJournals(Bill $bill): Collection
{ {
$set = $bill->transactionjournals() $set = $bill->transactionjournals()
->leftJoin( ->leftJoin(
@@ -302,7 +304,7 @@ class BillRepository implements BillRepositoryInterface
* *
* @return Collection * @return Collection
*/ */
public function getJournalsInRange(Bill $bill, Carbon $start, Carbon $end) public function getJournalsInRange(Bill $bill, Carbon $start, Carbon $end): Collection
{ {
return $bill->transactionjournals()->before($end)->after($start)->get(); return $bill->transactionjournals()->before($end)->after($start)->get();
} }
@@ -312,7 +314,7 @@ class BillRepository implements BillRepositoryInterface
* *
* @return Collection * @return Collection
*/ */
public function getPossiblyRelatedJournals(Bill $bill) public function getPossiblyRelatedJournals(Bill $bill): Collection
{ {
$set = new Collection( $set = new Collection(
DB::table('transactions')->where('amount', '>', 0)->where('amount', '>=', $bill->amount_min)->where('amount', '<=', $bill->amount_max) DB::table('transactions')->where('amount', '>', 0)->where('amount', '>=', $bill->amount_min)->where('amount', '<=', $bill->amount_max)
@@ -339,9 +341,9 @@ class BillRepository implements BillRepositoryInterface
* @param Carbon $start * @param Carbon $start
* @param Carbon $end * @param Carbon $end
* *
* @return mixed * @return array
*/ */
public function getRanges(Bill $bill, Carbon $start, Carbon $end) public function getRanges(Bill $bill, Carbon $start, Carbon $end): array
{ {
$startOfBill = $bill->date; $startOfBill = $bill->date;
$startOfBill = Navigation::startOfPeriod($startOfBill, $bill->repeat_freq); $startOfBill = Navigation::startOfPeriod($startOfBill, $bill->repeat_freq);
@@ -376,16 +378,16 @@ class BillRepository implements BillRepositoryInterface
/** /**
* @param Bill $bill * @param Bill $bill
* *
* @return Carbon|null * @return \Carbon\Carbon
*/ */
public function lastFoundMatch(Bill $bill) public function lastFoundMatch(Bill $bill): Carbon
{ {
$last = $bill->transactionjournals()->orderBy('date', 'DESC')->first(); $last = $bill->transactionjournals()->orderBy('date', 'DESC')->first();
if ($last) { if ($last) {
return $last->date; return $last->date;
} }
return null; return Carbon::now()->addDays(2); // in the future!
} }
/** /**
@@ -393,10 +395,10 @@ class BillRepository implements BillRepositoryInterface
* *
* @return \Carbon\Carbon * @return \Carbon\Carbon
*/ */
public function nextExpectedMatch(Bill $bill) public function nextExpectedMatch(Bill $bill): Carbon
{ {
$finalDate = null; $finalDate = Carbon::now()->subDays(2);
if ($bill->active == 0) { if ($bill->active == 0) {
return $finalDate; return $finalDate;
} }
@@ -440,9 +442,9 @@ class BillRepository implements BillRepositoryInterface
* @param Bill $bill * @param Bill $bill
* @param TransactionJournal $journal * @param TransactionJournal $journal
* *
* @return boolean|null * @return bool
*/ */
public function scan(Bill $bill, TransactionJournal $journal) public function scan(Bill $bill, TransactionJournal $journal): bool
{ {
/* /*
@@ -487,7 +489,7 @@ class BillRepository implements BillRepositoryInterface
* *
* @return Bill * @return Bill
*/ */
public function store(array $data) public function store(array $data): Bill
{ {
@@ -516,7 +518,7 @@ class BillRepository implements BillRepositoryInterface
* *
* @return Bill * @return Bill
*/ */
public function update(Bill $bill, array $data) public function update(Bill $bill, array $data): Bill
{ {
@@ -541,7 +543,7 @@ class BillRepository implements BillRepositoryInterface
* *
* @return bool * @return bool
*/ */
protected function doAmountMatch($amount, $min, $max) protected function doAmountMatch($amount, $min, $max): bool
{ {
if ($amount >= $min && $amount <= $max) { if ($amount >= $min && $amount <= $max) {
return true; return true;
@@ -556,7 +558,7 @@ class BillRepository implements BillRepositoryInterface
* *
* @return bool * @return bool
*/ */
protected function doWordMatch(array $matches, $description) protected function doWordMatch(array $matches, $description): bool
{ {
$wordMatch = false; $wordMatch = false;
$count = 0; $count = 0;

View File

@@ -19,14 +19,14 @@ interface BillRepositoryInterface
/** /**
* @param Bill $bill * @param Bill $bill
* *
* @return mixed * @return bool
*/ */
public function destroy(Bill $bill); public function destroy(Bill $bill): bool;
/** /**
* @return Collection * @return Collection
*/ */
public function getActiveBills(); public function getActiveBills(): Collection;
/** /**
* Returns all journals connected to these bills in the given range. Amount paid * Returns all journals connected to these bills in the given range. Amount paid
@@ -38,12 +38,12 @@ interface BillRepositoryInterface
* *
* @return Collection * @return Collection
*/ */
public function getAllJournalsInRange(Collection $bills, Carbon $start, Carbon $end); public function getAllJournalsInRange(Collection $bills, Carbon $start, Carbon $end): Collection;
/** /**
* @return Collection * @return Collection
*/ */
public function getBills(); public function getBills(): Collection;
/** /**
* Gets the bills which have some kind of relevance to the accounts mentioned. * Gets the bills which have some kind of relevance to the accounts mentioned.
@@ -52,7 +52,7 @@ interface BillRepositoryInterface
* *
* @return Collection * @return Collection
*/ */
public function getBillsForAccounts(Collection $accounts); public function getBillsForAccounts(Collection $accounts): Collection;
/** /**
* Get the total amount of money paid for the users active bills in the date range given. * Get the total amount of money paid for the users active bills in the date range given.
@@ -62,7 +62,7 @@ interface BillRepositoryInterface
* *
* @return string * @return string
*/ */
public function getBillsPaidInRange(Carbon $start, Carbon $end); public function getBillsPaidInRange(Carbon $start, Carbon $end): string;
/** /**
* Get the total amount of money due for the users active bills in the date range given. * Get the total amount of money due for the users active bills in the date range given.
@@ -72,7 +72,7 @@ interface BillRepositoryInterface
* *
* @return string * @return string
*/ */
public function getBillsUnpaidInRange(Carbon $start, Carbon $end); public function getBillsUnpaidInRange(Carbon $start, Carbon $end): string;
/** /**
* This method will tell you if you still have a CC bill to pay. Amount will be negative if the amount * This method will tell you if you still have a CC bill to pay. Amount will be negative if the amount
@@ -83,14 +83,14 @@ interface BillRepositoryInterface
* *
* @return string * @return string
*/ */
public function getCreditCardBill(Carbon $start, Carbon $end); public function getCreditCardBill(Carbon $start, Carbon $end): string;
/** /**
* @param Bill $bill * @param Bill $bill
* *
* @return Collection * @return Collection
*/ */
public function getJournals(Bill $bill); public function getJournals(Bill $bill): Collection;
/** /**
* Get all journals that were recorded on this bill between these dates. * Get all journals that were recorded on this bill between these dates.
@@ -101,14 +101,14 @@ interface BillRepositoryInterface
* *
* @return Collection * @return Collection
*/ */
public function getJournalsInRange(Bill $bill, Carbon $start, Carbon $end); public function getJournalsInRange(Bill $bill, Carbon $start, Carbon $end): Collection;
/** /**
* @param Bill $bill * @param Bill $bill
* *
* @return Collection * @return Collection
*/ */
public function getPossiblyRelatedJournals(Bill $bill); public function getPossiblyRelatedJournals(Bill $bill): Collection;
/** /**
* Every bill repeats itself weekly, monthly or yearly (or whatever). This method takes a date-range (usually the view-range of Firefly itself) * Every bill repeats itself weekly, monthly or yearly (or whatever). This method takes a date-range (usually the view-range of Firefly itself)
@@ -119,16 +119,16 @@ interface BillRepositoryInterface
* @param Carbon $start * @param Carbon $start
* @param Carbon $end * @param Carbon $end
* *
* @return mixed * @return array
*/ */
public function getRanges(Bill $bill, Carbon $start, Carbon $end); public function getRanges(Bill $bill, Carbon $start, Carbon $end): array;
/** /**
* @param Bill $bill * @param Bill $bill
* *
* @return Carbon|null * @return \Carbon\Carbon
*/ */
public function lastFoundMatch(Bill $bill); public function lastFoundMatch(Bill $bill): Carbon;
/** /**
@@ -136,7 +136,7 @@ interface BillRepositoryInterface
* *
* @return \Carbon\Carbon * @return \Carbon\Carbon
*/ */
public function nextExpectedMatch(Bill $bill); public function nextExpectedMatch(Bill $bill): Carbon;
/** /**
* @param Bill $bill * @param Bill $bill
@@ -144,21 +144,21 @@ interface BillRepositoryInterface
* *
* @return bool * @return bool
*/ */
public function scan(Bill $bill, TransactionJournal $journal); public function scan(Bill $bill, TransactionJournal $journal): bool;
/** /**
* @param array $data * @param array $data
* *
* @return Bill * @return Bill
*/ */
public function store(array $data); public function store(array $data): Bill;
/** /**
* @param Bill $bill * @param Bill $bill
* @param array $data * @param array $data
* *
* @return mixed * @return Bill
*/ */
public function update(Bill $bill, array $data); public function update(Bill $bill, array $data): Bill;
} }