PHP7 compatible type hinting [skip ci]

This commit is contained in:
James Cole 2016-02-18 07:21:48 +01:00
parent 7a7ce7fcea
commit e7be4e3e49
22 changed files with 87 additions and 139 deletions

View File

@ -29,7 +29,7 @@ interface AccountChartGeneratorInterface
*
* @return array
*/
public function expenseAccounts(Collection $accounts, Carbon $start, Carbon $end);
public function expenseAccounts(Collection $accounts, Carbon $start, Carbon $end): array;
/**
* @param Collection $accounts
@ -38,7 +38,7 @@ interface AccountChartGeneratorInterface
*
* @return array
*/
public function frontpage(Collection $accounts, Carbon $start, Carbon $end);
public function frontpage(Collection $accounts, Carbon $start, Carbon $end): array;
/**
* @param Account $account
@ -47,5 +47,5 @@ interface AccountChartGeneratorInterface
*
* @return array
*/
public function single(Account $account, Carbon $start, Carbon $end);
public function single(Account $account, Carbon $start, Carbon $end): array;
}

View File

@ -22,7 +22,7 @@ class ChartJsAccountChartGenerator implements AccountChartGeneratorInterface
*
* @return array
*/
public function expenseAccounts(Collection $accounts, Carbon $start, Carbon $end)
public function expenseAccounts(Collection $accounts, Carbon $start, Carbon $end): array
{
$data = [
'count' => 1,
@ -69,7 +69,7 @@ class ChartJsAccountChartGenerator implements AccountChartGeneratorInterface
*
* @return array
*/
public function frontpage(Collection $accounts, Carbon $start, Carbon $end)
public function frontpage(Collection $accounts, Carbon $start, Carbon $end): array
{
// language:
$format = (string)trans('config.month_and_day');
@ -116,7 +116,7 @@ class ChartJsAccountChartGenerator implements AccountChartGeneratorInterface
*
* @return array
*/
public function single(Account $account, Carbon $start, Carbon $end)
public function single(Account $account, Carbon $start, Carbon $end): array
{
// language:
$format = (string)trans('config.month_and_day');
@ -153,7 +153,7 @@ class ChartJsAccountChartGenerator implements AccountChartGeneratorInterface
*
* @return array
*/
protected function getIdsFromCollection(Collection $collection)
protected function getIdsFromCollection(Collection $collection): array
{
$ids = [];
foreach ($collection as $entry) {
@ -170,7 +170,7 @@ class ChartJsAccountChartGenerator implements AccountChartGeneratorInterface
*
* @return string
*/
protected function isInArray($array, $entryId)
protected function isInArray($array, $entryId): string
{
if (isset($array[$entryId])) {
return $array[$entryId];

View File

@ -28,7 +28,7 @@ interface BillChartGeneratorInterface
*
* @return array
*/
public function frontpage(string $paid, string $unpaid);
public function frontpage(string $paid, string $unpaid): array;
/**
* @param Bill $bill
@ -36,6 +36,6 @@ interface BillChartGeneratorInterface
*
* @return array
*/
public function single(Bill $bill, Collection $entries);
public function single(Bill $bill, Collection $entries): array;
}

View File

@ -28,7 +28,7 @@ class ChartJsBillChartGenerator implements BillChartGeneratorInterface
*
* @return array
*/
public function frontpage(string $paid, string $unpaid)
public function frontpage(string $paid, string $unpaid): array
{
bcscale(2);
$data = [
@ -55,7 +55,7 @@ class ChartJsBillChartGenerator implements BillChartGeneratorInterface
*
* @return array
*/
public function single(Bill $bill, Collection $entries)
public function single(Bill $bill, Collection $entries): array
{
bcscale(2);
$format = (string)trans('config.month');

View File

@ -24,28 +24,28 @@ interface BudgetChartGeneratorInterface
*
* @return array
*/
public function budget(Collection $entries);
public function budget(Collection $entries): array;
/**
* @param Collection $entries
*
* @return array
*/
public function budgetLimit(Collection $entries);
public function budgetLimit(Collection $entries): array;
/**
* @param Collection $entries
*
* @return array
*/
public function frontpage(Collection $entries);
public function frontpage(Collection $entries): array;
/**
* @param Collection $entries
*
* @return array
*/
public function multiYear(Collection $entries);
public function multiYear(Collection $entries): array;
/**
* @param Collection $budgets
@ -53,6 +53,6 @@ interface BudgetChartGeneratorInterface
*
* @return array
*/
public function year(Collection $budgets, Collection $entries);
public function year(Collection $budgets, Collection $entries): array;
}

View File

@ -21,7 +21,7 @@ class ChartJsBudgetChartGenerator implements BudgetChartGeneratorInterface
*
* @return array
*/
public function budget(Collection $entries, $dateFormat = 'month')
public function budget(Collection $entries, $dateFormat = 'month'): array
{
// language:
$language = Preferences::get('language', env('DEFAULT_LANGUAGE', 'en_US'))->data;
@ -56,7 +56,7 @@ class ChartJsBudgetChartGenerator implements BudgetChartGeneratorInterface
*
* @return array
*/
public function budgetLimit(Collection $entries)
public function budgetLimit(Collection $entries): array
{
return $this->budget($entries, 'monthAndDay');
}
@ -66,7 +66,7 @@ class ChartJsBudgetChartGenerator implements BudgetChartGeneratorInterface
*
* @return array
*/
public function frontpage(Collection $entries)
public function frontpage(Collection $entries): array
{
bcscale(2);
$data = [
@ -112,7 +112,7 @@ class ChartJsBudgetChartGenerator implements BudgetChartGeneratorInterface
*
* @return array
*/
public function multiYear(Collection $entries)
public function multiYear(Collection $entries): array
{
// dataset:
$data = [
@ -147,7 +147,7 @@ class ChartJsBudgetChartGenerator implements BudgetChartGeneratorInterface
*
* @return array
*/
public function year(Collection $budgets, Collection $entries)
public function year(Collection $budgets, Collection $entries): array
{
// language:
$format = (string)trans('config.month');

View File

@ -33,28 +33,28 @@ interface CategoryChartGeneratorInterface
*
* @return array
*/
public function earnedInPeriod(Collection $categories, Collection $entries);
public function earnedInPeriod(Collection $categories, Collection $entries): array;
/**
* @param Collection $entries
*
* @return array
*/
public function frontpage(Collection $entries);
public function frontpage(Collection $entries): array;
/**
* @param Collection $entries
*
* @return array
*/
public function multiYear(Collection $entries);
public function multiYear(Collection $entries): array;
/**
* @param Collection $entries
*
* @return array
*/
public function period(Collection $entries);
public function period(Collection $entries): array;
/**
* @param Collection $categories
@ -62,5 +62,5 @@ interface CategoryChartGeneratorInterface
*
* @return array
*/
public function spentInPeriod(Collection $categories, Collection $entries);
public function spentInPeriod(Collection $categories, Collection $entries): array;
}

View File

@ -18,7 +18,7 @@ class ChartJsCategoryChartGenerator implements CategoryChartGeneratorInterface
*
* @return array
*/
public function all(Collection $entries)
public function all(Collection $entries): array
{
@ -55,7 +55,7 @@ class ChartJsCategoryChartGenerator implements CategoryChartGeneratorInterface
*
* @return array
*/
public function earnedInPeriod(Collection $categories, Collection $entries)
public function earnedInPeriod(Collection $categories, Collection $entries): array
{
// language:
@ -87,7 +87,7 @@ class ChartJsCategoryChartGenerator implements CategoryChartGeneratorInterface
*
* @return array
*/
public function frontpage(Collection $entries)
public function frontpage(Collection $entries): array
{
bcscale(2);
$data = [
@ -115,7 +115,7 @@ class ChartJsCategoryChartGenerator implements CategoryChartGeneratorInterface
*
* @return array
*/
public function multiYear(Collection $entries)
public function multiYear(Collection $entries): array
{
// dataset:
$data = [
@ -155,7 +155,7 @@ class ChartJsCategoryChartGenerator implements CategoryChartGeneratorInterface
*
* @return array
*/
public function period(Collection $entries)
public function period(Collection $entries): array
{
return $this->all($entries);
@ -167,7 +167,7 @@ class ChartJsCategoryChartGenerator implements CategoryChartGeneratorInterface
*
* @return array
*/
public function spentInPeriod(Collection $categories, Collection $entries)
public function spentInPeriod(Collection $categories, Collection $entries): array
{
// language:

View File

@ -19,7 +19,7 @@ class ChartJsPiggyBankChartGenerator implements PiggyBankChartGeneratorInterface
*
* @return array
*/
public function history(Collection $set)
public function history(Collection $set): array
{
// language:

View File

@ -24,5 +24,5 @@ interface PiggyBankChartGeneratorInterface
*
* @return array
*/
public function history(Collection $set);
public function history(Collection $set): array;
}

View File

@ -19,7 +19,7 @@ class ChartJsReportChartGenerator implements ReportChartGeneratorInterface
*
* @return array
*/
public function multiYearInOut(Collection $entries)
public function multiYearInOut(Collection $entries): array
{
$data = [
'count' => 2,
@ -52,7 +52,7 @@ class ChartJsReportChartGenerator implements ReportChartGeneratorInterface
*
* @return array
*/
public function multiYearInOutSummarized(string $income, string $expense, int $count)
public function multiYearInOutSummarized(string $income, string $expense, int $count): array
{
$data = [
'count' => 2,
@ -81,7 +81,7 @@ class ChartJsReportChartGenerator implements ReportChartGeneratorInterface
*
* @return array
*/
public function yearInOut(Collection $entries)
public function yearInOut(Collection $entries): array
{
// language:
$format = (string)trans('config.month');
@ -117,7 +117,7 @@ class ChartJsReportChartGenerator implements ReportChartGeneratorInterface
*
* @return array
*/
public function yearInOutSummarized(string $income, string $expense, int $count)
public function yearInOutSummarized(string $income, string $expense, int $count): array
{
$data = [

View File

@ -25,7 +25,7 @@ interface ReportChartGeneratorInterface
*
* @return array
*/
public function multiYearInOut(Collection $entries);
public function multiYearInOut(Collection $entries): array;
/**
* @param string $income
@ -34,14 +34,14 @@ interface ReportChartGeneratorInterface
*
* @return array
*/
public function multiYearInOutSummarized(string $income, string $expense, int $count);
public function multiYearInOutSummarized(string $income, string $expense, int $count): array;
/**
* @param Collection $entries
*
* @return array
*/
public function yearInOut(Collection $entries);
public function yearInOut(Collection $entries): array;
/**
* @param string $income
@ -50,6 +50,6 @@ interface ReportChartGeneratorInterface
*
* @return array
*/
public function yearInOutSummarized(string $income, string $expense, int $count);
public function yearInOutSummarized(string $income, string $expense, int $count): array;
}

View File

@ -17,25 +17,14 @@ use FireflyIII\Models\TransactionJournal;
class ConnectJournalToPiggyBank
{
/**
* Create the event handler.
*
* @codeCoverageIgnore
*
*/
public function __construct()
{
//
}
/**
* Connect a new transaction journal to any related piggy banks.
*
* @param TransactionJournalStored $event
*
* @return boolean
* @return bool
*/
public function handle(TransactionJournalStored $event)
public function handle(TransactionJournalStored $event): bool
{
/** @var TransactionJournal $journal */
$journal = $event->journal;

View File

@ -26,25 +26,15 @@ use Log;
*/
class FireRulesForStore
{
/**
* Create the event handler.
*
* @codeCoverageIgnore
*
*/
public function __construct()
{
//
}
/**
* Connect a new transaction journal to any related piggy banks.
*
* @param TransactionJournalStored $event
*
* @return boolean
* @return bool
*/
public function handle(TransactionJournalStored $event)
public function handle(TransactionJournalStored $event): bool
{
// get all the user's rule groups, with the rules, order by 'order'.
/** @var User $user */

View File

@ -25,23 +25,14 @@ use Log;
*/
class FireRulesForUpdate
{
/**
* Create the event handler.
*
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param TransactionJournalUpdated $event
*
* @return void
* @return bool
*/
public function handle(TransactionJournalUpdated $event)
public function handle(TransactionJournalUpdated $event): bool
{
// get all the user's rule groups, with the rules, order by 'order'.
/** @var User $user */
@ -71,5 +62,6 @@ class FireRulesForUpdate
}
}
return true;
}
}

View File

@ -22,26 +22,18 @@ use FireflyIII\Support\Events\BillScanner;
class ScanForBillsAfterStore
{
/**
* Create the event handler.
*
*/
public function __construct()
{
//
}
/**
* Scan a transaction journal for possible links to bills, right after storing.
*
* @param TransactionJournalStored $event
*
* @return void
* @return bool
*/
public function handle(TransactionJournalStored $event)
public function handle(TransactionJournalStored $event): bool
{
$journal = $event->journal;
BillScanner::scan($journal);
return true;
}
}

View File

@ -21,27 +21,18 @@ use FireflyIII\Support\Events\BillScanner;
*/
class ScanForBillsAfterUpdate
{
/**
* Create the event handler.
*
*/
public function __construct()
{
//
}
/**
* Scan a transaction journal for possibly related bills after it has been updated.
*
* @param TransactionJournalUpdated $event
*
* @return void
* @return bool
*/
public function handle(TransactionJournalUpdated $event)
public function handle(TransactionJournalUpdated $event): bool
{
$journal = $event->journal;
BillScanner::scan($journal);
return true;
}
}

View File

@ -15,23 +15,14 @@ use FireflyIII\Models\PiggyBankRepetition;
class UpdateJournalConnection
{
/**
* Create the event handler.
*
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param TransactionJournalUpdated $event
*
* @return void
* @return bool
*/
public function handle(TransactionJournalUpdated $event)
public function handle(TransactionJournalUpdated $event):bool
{
$journal = $event->journal;
@ -39,7 +30,7 @@ class UpdateJournalConnection
/** @var PiggyBankEvent $event */
$event = PiggyBankEvent::where('transaction_journal_id', $journal->id)->first();
if (is_null($event)) {
return;
return false;
}
$piggyBank = $event->piggyBank()->first();
$repetition = null;
@ -49,7 +40,7 @@ class UpdateJournalConnection
}
if (is_null($repetition)) {
return;
return false;
}
bcscale(2);
@ -62,6 +53,8 @@ class UpdateJournalConnection
$event->amount = $amount;
$event->save();
return true;
}
}

View File

@ -46,7 +46,7 @@ class AttachmentHelper implements AttachmentHelperInterface
*
* @return string
*/
public function getAttachmentLocation(Attachment $attachment)
public function getAttachmentLocation(Attachment $attachment): string
{
$path = storage_path('upload') . DIRECTORY_SEPARATOR . 'at-' . $attachment->id . '.data';
@ -56,7 +56,7 @@ class AttachmentHelper implements AttachmentHelperInterface
/**
* @return MessageBag
*/
public function getErrors()
public function getErrors(): MessageBag
{
return $this->errors;
}
@ -64,7 +64,7 @@ class AttachmentHelper implements AttachmentHelperInterface
/**
* @return MessageBag
*/
public function getMessages()
public function getMessages(): MessageBag
{
return $this->messages;
}
@ -74,7 +74,7 @@ class AttachmentHelper implements AttachmentHelperInterface
*
* @return bool
*/
public function saveAttachmentsForModel(Model $model)
public function saveAttachmentsForModel(Model $model): bool
{
$files = null;
try {
@ -107,7 +107,7 @@ class AttachmentHelper implements AttachmentHelperInterface
*
* @return bool
*/
protected function hasFile(UploadedFile $file, Model $model)
protected function hasFile(UploadedFile $file, Model $model): bool
{
$md5 = md5_file($file->getRealPath());
$name = $file->getClientOriginalName();
@ -125,16 +125,17 @@ class AttachmentHelper implements AttachmentHelperInterface
}
/**
*
* @param UploadedFile $file
* @param Model $model
*
* @return bool|Attachment
* @return Attachment
*/
protected function processFile(UploadedFile $file, Model $model)
protected function processFile(UploadedFile $file, Model $model): Attachment
{
$validation = $this->validateUpload($file, $model);
if ($validation === false) {
return false;
return new Attachment;
}
$attachment = new Attachment; // create Attachment object.
@ -175,7 +176,7 @@ class AttachmentHelper implements AttachmentHelperInterface
*
* @return bool
*/
protected function validMime(UploadedFile $file)
protected function validMime(UploadedFile $file): bool
{
$mime = e($file->getMimeType());
$name = e($file->getClientOriginalName());
@ -195,7 +196,7 @@ class AttachmentHelper implements AttachmentHelperInterface
*
* @return bool
*/
protected function validSize(UploadedFile $file)
protected function validSize(UploadedFile $file): bool
{
$size = $file->getSize();
$name = e($file->getClientOriginalName());
@ -215,7 +216,7 @@ class AttachmentHelper implements AttachmentHelperInterface
*
* @return bool
*/
protected function validateUpload(UploadedFile $file, Model $model)
protected function validateUpload(UploadedFile $file, Model $model): bool
{
if (!$this->validMime($file)) {
return false;

View File

@ -17,25 +17,25 @@ interface AttachmentHelperInterface
/**
* @param Attachment $attachment
*
* @return mixed
* @return string
*/
public function getAttachmentLocation(Attachment $attachment);
public function getAttachmentLocation(Attachment $attachment): string;
/**
* @return MessageBag
*/
public function getErrors();
public function getErrors(): MessageBag;
/**
* @return MessageBag
*/
public function getMessages();
public function getMessages(): MessageBag;
/**
* @param Model $model
*
* @return bool
*/
public function saveAttachmentsForModel(Model $model);
public function saveAttachmentsForModel(Model $model): bool;
}

View File

@ -23,9 +23,9 @@ class Account
protected $start;
/**
* @return \Illuminate\Support\Collection
* @return Collection
*/
public function getAccounts()
public function getAccounts(): Collection
{
return $this->accounts;
}
@ -41,7 +41,7 @@ class Account
/**
* @return string
*/
public function getDifference()
public function getDifference(): string
{
return $this->difference;
}
@ -57,7 +57,7 @@ class Account
/**
* @return string
*/
public function getEnd()
public function getEnd(): string
{
return $this->end;
}
@ -73,7 +73,7 @@ class Account
/**
* @return string
*/
public function getStart()
public function getStart(): string
{
return $this->start;
}

View File

@ -39,7 +39,7 @@ class Balance
/**
* @return BalanceHeader
*/
public function getBalanceHeader()
public function getBalanceHeader(): BalanceHeader
{
return $this->balanceHeader;
}
@ -53,9 +53,9 @@ class Balance
}
/**
* @return \Illuminate\Support\Collection
* @return Collection
*/
public function getBalanceLines()
public function getBalanceLines(): Collection
{
return $this->balanceLines;
}