PHP7 type declarations.

This commit is contained in:
James Cole 2016-02-18 10:04:26 +01:00
parent e7be4e3e49
commit f0f47530bf
14 changed files with 48 additions and 42 deletions

View File

@ -58,10 +58,11 @@ class FireRulesForStore
$processor->handleTransactionJournal($event->journal);
if ($rule->stop_processing) {
break;
return true;
}
}
}
return true;
}
}

View File

@ -25,7 +25,7 @@ class BalanceEntry
/**
* @return AccountModel
*/
public function getAccount()
public function getAccount(): AccountModel
{
return $this->account;
}
@ -41,7 +41,7 @@ class BalanceEntry
/**
* @return string
*/
public function getLeft()
public function getLeft(): string
{
return $this->left;
}
@ -57,7 +57,7 @@ class BalanceEntry
/**
* @return string
*/
public function getSpent()
public function getSpent(): string
{
return $this->spent;
}

View File

@ -37,7 +37,7 @@ class BalanceHeader
/**
* @return Collection
*/
public function getAccounts()
public function getAccounts(): Collection
{
return $this->accounts;
}

View File

@ -34,6 +34,7 @@ class BalanceLine
public function __construct()
{
$this->balanceEntries = new Collection;
}
/**
@ -47,7 +48,7 @@ class BalanceLine
/**
* @return Collection
*/
public function getBalanceEntries()
public function getBalanceEntries(): Collection
{
return $this->balanceEntries;
}
@ -63,9 +64,9 @@ class BalanceLine
/**
* @return BudgetModel
*/
public function getBudget()
public function getBudget(): BudgetModel
{
return $this->budget;
return $this->budget ?? new BudgetModel;
}
/**
@ -79,7 +80,7 @@ class BalanceLine
/**
* @return int
*/
public function getRole()
public function getRole(): int
{
return $this->role;
}
@ -95,9 +96,9 @@ class BalanceLine
/**
* @return string
*/
public function getTitle()
public function getTitle(): string
{
if ($this->getBudget() instanceof BudgetModel) {
if ($this->getBudget() instanceof BudgetModel && !is_null($this->getBudget()->id)) {
return $this->getBudget()->name;
}
if ($this->getRole() == self::ROLE_DEFAULTROLE) {
@ -121,7 +122,7 @@ class BalanceLine
*
* @return string
*/
public function leftOfRepetition()
public function leftOfRepetition(): string
{
bcscale(2);
$start = $this->budget->amount ?? '0';

View File

@ -38,7 +38,7 @@ class Bill
/**
* @return Collection
*/
public function getBills()
public function getBills(): Collection
{
$set = $this->bills->sortBy(
function (BillLine $bill) {

View File

@ -33,7 +33,7 @@ class BillLine
/**
* @return string
*/
public function getAmount()
public function getAmount(): string
{
return $this->amount;
}
@ -49,7 +49,7 @@ class BillLine
/**
* @return BillModel
*/
public function getBill()
public function getBill(): BillModel
{
return $this->bill;
}
@ -65,7 +65,7 @@ class BillLine
/**
* @return string
*/
public function getMax()
public function getMax(): string
{
return $this->max;
}
@ -81,7 +81,7 @@ class BillLine
/**
* @return string
*/
public function getMin()
public function getMin(): string
{
return $this->min;
}
@ -113,7 +113,7 @@ class BillLine
/**
* @return boolean
*/
public function isActive()
public function isActive(): bool
{
return $this->active;
}
@ -129,7 +129,7 @@ class BillLine
/**
* @return boolean
*/
public function isHit()
public function isHit(): bool
{
return $this->hit;
}

View File

@ -83,7 +83,7 @@ class Budget
/**
* @return \Illuminate\Support\Collection
*/
public function getBudgetLines()
public function getBudgetLines(): Collection
{
return $this->budgetLines;
}
@ -91,7 +91,7 @@ class Budget
/**
* @return string
*/
public function getBudgeted()
public function getBudgeted(): string
{
return $this->budgeted;
}
@ -107,7 +107,7 @@ class Budget
/**
* @return string
*/
public function getLeft()
public function getLeft(): string
{
return $this->left;
}
@ -123,7 +123,7 @@ class Budget
/**
* @return string
*/
public function getOverspent()
public function getOverspent(): string
{
return $this->overspent;
}
@ -139,7 +139,7 @@ class Budget
/**
* @return string
*/
public function getSpent()
public function getSpent(): string
{
return $this->spent;
}

View File

@ -54,7 +54,7 @@ class Category
/**
* @return Collection
*/
public function getCategories()
public function getCategories(): Collection
{
$set = $this->categories->sortBy(
function (CategoryModel $category) {
@ -69,7 +69,7 @@ class Category
/**
* @return string
*/
public function getTotal()
public function getTotal(): string
{
return strval(round($this->total, 2));
}

View File

@ -80,7 +80,7 @@ class Expense
/**
* @return Collection
*/
public function getExpenses()
public function getExpenses(): Collection
{
$set = $this->expenses->sortBy(
function (stdClass $object) {
@ -94,7 +94,7 @@ class Expense
/**
* @return string
*/
public function getTotal()
public function getTotal(): string
{
return strval(round($this->total, 2));
}

View File

@ -66,7 +66,7 @@ class Income
/**
* @return Collection
*/
public function getIncomes()
public function getIncomes(): Collection
{
$set = $this->incomes->sortByDesc(
function (stdClass $object) {
@ -80,7 +80,7 @@ class Income
/**
* @return string
*/
public function getTotal()
public function getTotal(): string
{
return strval(round($this->total, 2));
}

View File

@ -31,6 +31,9 @@ class AccountId extends BasicConverter implements ConverterInterface
if (!is_null($account)) {
Log::debug('Found ' . $account->accountType->type . ' named "******" with ID: ' . $this->value . ' (not mapped) ');
} else {
// new account to prevent TypeErrors.
$account = new Account;
}
}

View File

@ -11,12 +11,12 @@ class Amount extends BasicConverter implements ConverterInterface
{
/**
* @return string|int
* @return string
*/
public function convert()
public function convert(): string
{
if (is_numeric($this->value)) {
return $this->value;
return strval($this->value);
}
return '0';

View File

@ -17,10 +17,10 @@ class AmountComma extends BasicConverter implements ConverterInterface
*/
public function convert()
{
$value = str_replace(',', '.', $this->value);
$value = str_replace(',', '.', str_val($this->value));
if (is_numeric($value)) {
return $value;
return strval($value);
}
return '0';

View File

@ -15,10 +15,11 @@ class AssetAccountIban extends BasicConverter implements ConverterInterface
{
/**
* @return Account|null
* @return Account
*/
public function convert()
public function convert(): Account
{
// is mapped? Then it's easy!
if (isset($this->mapped[$this->index][$this->value])) {
$account = Auth::user()->accounts()->find($this->mapped[$this->index][$this->value]);
@ -29,7 +30,7 @@ class AssetAccountIban extends BasicConverter implements ConverterInterface
// find or create new account:
$account = $this->findAccount();
if (is_null($account)) {
if (is_null($account->id)) {
// create it if doesn't exist.
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
@ -55,13 +56,13 @@ class AssetAccountIban extends BasicConverter implements ConverterInterface
return $account;
}
return null;
return new Account;
}
/**
* @return Account|null
* @return Account
*/
protected function findAccount()
protected function findAccount(): Account
{
$set = Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account'])->get(['accounts.*']);
/** @var Account $entry */
@ -72,6 +73,6 @@ class AssetAccountIban extends BasicConverter implements ConverterInterface
}
}
return null;
return new Account;
}
}