Skip to content

Firefly III: a personal finances manager

Changed a lot of parameters.

James Cole78bcd3e1bbad
diff --git a/app/Events/TransactionJournalStored.php b/app/Events/TransactionJournalStored.php
index d2a0610485..0e5be2027b 100644
--- a/app/Events/TransactionJournalStored.php
+++ b/app/Events/TransactionJournalStored.php
@@ -30,9 +30,9 @@ class TransactionJournalStored extends Event
* Create a new event instance.
*
* @param TransactionJournal $journal
- * @param $piggyBankId
+ * @param int $piggyBankId
*/
- public function __construct(TransactionJournal $journal, $piggyBankId)
+ public function __construct(TransactionJournal $journal, int $piggyBankId)
{
//
$this->journal = $journal;
diff --git a/app/Export/Collector/BasicCollector.php b/app/Export/Collector/BasicCollector.php
index b6b98cf397..723d5ee637 100644
--- a/app/Export/Collector/BasicCollector.php
+++ b/app/Export/Collector/BasicCollector.php
@@ -46,7 +46,7 @@ class BasicCollector
/**
* @param Collection $files
*/
- public function setFiles($files)
+ public function setFiles(Collection $files)
{
$this->files = $files;
}
diff --git a/app/Export/Collector/CollectorInterface.php b/app/Export/Collector/CollectorInterface.php
index 313816d4a2..21007a871d 100644
--- a/app/Export/Collector/CollectorInterface.php
+++ b/app/Export/Collector/CollectorInterface.php
@@ -8,6 +8,7 @@
*/
namespace FireflyIII\Export\Collector;
+use Illuminate\Support\Collection;
/**
* Interface CollectorInterface
@@ -16,6 +17,20 @@ namespace FireflyIII\Export\Collector;
*/
interface CollectorInterface
{
+ /**
+ * @return bool
+ */
public function run();
+ /**
+ * @return Collection
+ */
+ public function getFiles();
+
+ /**
+ * @param Collection $files
+ *
+ */
+ public function setFiles(Collection $files);
+
}
\ No newline at end of file
diff --git a/app/Export/Collector/UploadCollector.php b/app/Export/Collector/UploadCollector.php
index 1162d22099..6cf04b52ac 100644
--- a/app/Export/Collector/UploadCollector.php
+++ b/app/Export/Collector/UploadCollector.php
@@ -31,6 +31,9 @@ class UploadCollector extends BasicCollector implements CollectorInterface
parent::__construct($job);
}
+ /**
+ *
+ */
public function run()
{
// grab upload directory.
diff --git a/app/Export/Entry.php b/app/Export/Entry.php
index 559327871a..557abe33f3 100644
--- a/app/Export/Entry.php
+++ b/app/Export/Entry.php
@@ -79,7 +79,7 @@ class Entry
/**
* @param string $amount
*/
- public function setAmount($amount)
+ public function setAmount(string $amount)
{
$this->amount = $amount;
}
@@ -95,7 +95,7 @@ class Entry
/**
* @param string $date
*/
- public function setDate($date)
+ public function setDate(string $date)
{
$this->date = $date;
}
@@ -111,7 +111,7 @@ class Entry
/**
* @param string $description
*/
- public function setDescription($description)
+ public function setDescription(string $description)
{
$this->description = $description;
}
diff --git a/app/Generator/Chart/Bill/BillChartGeneratorInterface.php b/app/Generator/Chart/Bill/BillChartGeneratorInterface.php
index 077443ed94..a30220b410 100644
--- a/app/Generator/Chart/Bill/BillChartGeneratorInterface.php
+++ b/app/Generator/Chart/Bill/BillChartGeneratorInterface.php
@@ -27,7 +27,7 @@ interface BillChartGeneratorInterface
*
* @return array
*/
- public function frontpage($paid, $unpaid);
+ public function frontpage(string $paid, string $unpaid);
/**
* @param Bill $bill
diff --git a/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php b/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php
index 879724d194..f191b48877 100644
--- a/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php
+++ b/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php
@@ -27,7 +27,7 @@ class ChartJsBillChartGenerator implements BillChartGeneratorInterface
*
* @return array
*/
- public function frontpage($paid, $unpaid)
+ public function frontpage(string $paid, string $unpaid)
{
bcscale(2);
$data = [
diff --git a/app/Generator/Chart/Report/ChartJsReportChartGenerator.php b/app/Generator/Chart/Report/ChartJsReportChartGenerator.php
index 9f13aa892e..fd749dfbaa 100644
--- a/app/Generator/Chart/Report/ChartJsReportChartGenerator.php
+++ b/app/Generator/Chart/Report/ChartJsReportChartGenerator.php
@@ -52,7 +52,7 @@ class ChartJsReportChartGenerator implements ReportChartGeneratorInterface
*
* @return array
*/
- public function multiYearInOutSummarized($income, $expense, $count)
+ public function multiYearInOutSummarized(string $income, string $expense, int $count)
{
$data = [
'count' => 2,
@@ -117,7 +117,7 @@ class ChartJsReportChartGenerator implements ReportChartGeneratorInterface
*
* @return array
*/
- public function yearInOutSummarized($income, $expense, $count)
+ public function yearInOutSummarized(string $income, string $expense, int $count)
{
$data = [
diff --git a/app/Generator/Chart/Report/ReportChartGeneratorInterface.php b/app/Generator/Chart/Report/ReportChartGeneratorInterface.php
index 8b5f753232..25060a8f46 100644
--- a/app/Generator/Chart/Report/ReportChartGeneratorInterface.php
+++ b/app/Generator/Chart/Report/ReportChartGeneratorInterface.php
@@ -33,7 +33,7 @@ interface ReportChartGeneratorInterface
*
* @return array
*/
- public function multiYearInOutSummarized($income, $expense, $count);
+ public function multiYearInOutSummarized(string $income, string $expense, int $count);
/**
* @param Collection $entries
@@ -49,6 +49,6 @@ interface ReportChartGeneratorInterface
*
* @return array
*/
- public function yearInOutSummarized($income, $expense, $count);
+ public function yearInOutSummarized(string $income, string $expense, int $count);
}
diff --git a/app/Helpers/Collection/Account.php b/app/Helpers/Collection/Account.php
index 1906c651db..893d771a9f 100644
--- a/app/Helpers/Collection/Account.php
+++ b/app/Helpers/Collection/Account.php
@@ -15,11 +15,11 @@ class Account
/** @var Collection */
protected $accounts;
- /** @var float */
+ /** @var string */
protected $difference;
- /** @var float */
+ /** @var string */
protected $end;
- /** @var float */
+ /** @var string */
protected $start;
/**
@@ -31,15 +31,15 @@ class Account
}
/**
- * @param \Illuminate\Support\Collection $accounts
+ * @param Collection $accounts
*/
- public function setAccounts($accounts)
+ public function setAccounts(Collection $accounts)
{
$this->accounts = $accounts;
}
/**
- * @return float
+ * @return string
*/
public function getDifference()
{
@@ -47,15 +47,15 @@ class Account
}
/**
- * @param float $difference
+ * @param string $difference
*/
- public function setDifference($difference)
+ public function setDifference(string $difference)
{
$this->difference = $difference;
}
/**
- * @return float
+ * @return string
*/
public function getEnd()
{
@@ -63,15 +63,15 @@ class Account
}
/**
- * @param float $end
+ * @param string $end
*/
- public function setEnd($end)
+ public function setEnd(string $end)
{
$this->end = $end;
}
/**
- * @return float
+ * @return string
*/
public function getStart()
{
@@ -79,9 +79,9 @@ class Account
}
/**
- * @param float $start
+ * @param string $start
*/
- public function setStart($start)
+ public function setStart(string $start)
{
$this->start = $start;
}
diff --git a/app/Helpers/Collection/Balance.php b/app/Helpers/Collection/Balance.php
index 48d8433c2f..9cc6887660 100644
--- a/app/Helpers/Collection/Balance.php
+++ b/app/Helpers/Collection/Balance.php
@@ -47,7 +47,7 @@ class Balance
/**
* @param BalanceHeader $balanceHeader
*/
- public function setBalanceHeader($balanceHeader)
+ public function setBalanceHeader(BalanceHeader $balanceHeader)
{
$this->balanceHeader = $balanceHeader;
}
diff --git a/app/Helpers/Collection/BalanceEntry.php b/app/Helpers/Collection/BalanceEntry.php
index 7749226b82..f92ed56691 100644
--- a/app/Helpers/Collection/BalanceEntry.php
+++ b/app/Helpers/Collection/BalanceEntry.php
@@ -17,10 +17,10 @@ class BalanceEntry
/** @var AccountModel */
protected $account;
- /** @var float */
- protected $left = 0.0;
- /** @var float */
- protected $spent = 0.0;
+ /** @var string */
+ protected $left = '0';
+ /** @var string */
+ protected $spent = '0';
/**
* @return AccountModel
@@ -33,13 +33,13 @@ class BalanceEntry
/**
* @param AccountModel $account
*/
- public function setAccount($account)
+ public function setAccount(AccountModel $account)
{
$this->account = $account;
}
/**
- * @return float
+ * @return string
*/
public function getLeft()
{
@@ -47,15 +47,15 @@ class BalanceEntry
}
/**
- * @param float $left
+ * @param string $left
*/
- public function setLeft($left)
+ public function setLeft(string $left)
{
$this->left = $left;
}
/**
- * @return float
+ * @return string
*/
public function getSpent()
{
@@ -63,9 +63,9 @@ class BalanceEntry
}
/**
- * @param float $spent
+ * @param string $spent
*/
- public function setSpent($spent)
+ public function setSpent(string $spent)
{
$this->spent = $spent;
}
diff --git a/app/Helpers/Collection/BalanceLine.php b/app/Helpers/Collection/BalanceLine.php
index f1debc6313..928a3c6f05 100644
--- a/app/Helpers/Collection/BalanceLine.php
+++ b/app/Helpers/Collection/BalanceLine.php
@@ -25,6 +25,7 @@ class BalanceLine
/** @var BudgetModel */
protected $budget;
+ /** @var int */
protected $role = self::ROLE_DEFAULTROLE;
/**
@@ -54,7 +55,7 @@ class BalanceLine
/**
* @param Collection $balanceEntries
*/
- public function setBalanceEntries($balanceEntries)
+ public function setBalanceEntries(Collection $balanceEntries)
{
$this->balanceEntries = $balanceEntries;
}
@@ -70,7 +71,7 @@ class BalanceLine
/**
* @param BudgetModel $budget
*/
- public function setBudget($budget)
+ public function setBudget(BudgetModel $budget)
{
$this->budget = $budget;
}
@@ -86,7 +87,7 @@ class BalanceLine
/**
* @param int $role
*/
- public function setRole($role)
+ public function setRole(int $role)
{
$this->role = $role;
}
@@ -118,14 +119,15 @@ class BalanceLine
* on the given budget/repetition. If you subtract all those amounts from the budget/repetition's
* total amount, this is returned:
*
- * @return float
+ * @return string
*/
public function leftOfRepetition()
{
- $start = $this->budget->amount ?? 0;
+ bcscale(2);
+ $start = $this->budget->amount ?? '0';
/** @var BalanceEntry $balanceEntry */
foreach ($this->getBalanceEntries() as $balanceEntry) {
- $start += $balanceEntry->getSpent();
+ $start = bcadd($balanceEntry->getSpent(), $start);
}
return $start;
diff --git a/app/Helpers/Collection/BillLine.php b/app/Helpers/Collection/BillLine.php
index 5091747577..ba6703f0b5 100644
--- a/app/Helpers/Collection/BillLine.php
+++ b/app/Helpers/Collection/BillLine.php
@@ -38,7 +38,7 @@ class BillLine
/**
* @param string $amount
*/
- public function setAmount($amount)
+ public function setAmount(string $amount)
{
$this->amount = $amount;
}
@@ -54,7 +54,7 @@ class BillLine
/**
* @param BillModel $bill
*/
- public function setBill($bill)
+ public function setBill(BillModel $bill)
{
$this->bill = $bill;
}
@@ -70,7 +70,7 @@ class BillLine
/**
* @param string $max
*/
- public function setMax($max)
+ public function setMax(string $max)
{
$this->max = $max;
}
@@ -86,7 +86,7 @@ class BillLine
/**
* @param string $min
*/
- public function setMin($min)
+ public function setMin(string $min)
{
$this->min = $min;
}
@@ -100,9 +100,9 @@ class BillLine
}
/**
- * @param boolean $active
+ * @param bool $active
*/
- public function setActive($active)
+ public function setActive(bool $active)
{
$this->active = $active;
}
@@ -116,9 +116,9 @@ class BillLine
}
/**
- * @param boolean $hit
+ * @param bool $hit
*/
- public function setHit($hit)
+ public function setHit(bool $hit)
{
$this->hit = $hit;
}
diff --git a/app/Helpers/Collection/Budget.php b/app/Helpers/Collection/Budget.php
index 53548291de..8bb3e1385f 100644
--- a/app/Helpers/Collection/Budget.php
+++ b/app/Helpers/Collection/Budget.php
@@ -41,9 +41,9 @@ class Budget
}
/**
- * @param float $add
+ * @param string $add
*/
- public function addBudgeted($add)
+ public function addBudgeted(string $add)
{
$add = strval(round($add, 2));
bcscale(2);
@@ -51,9 +51,9 @@ class Budget
}
/**
- * @param float $add
+ * @param string $add
*/
- public function addLeft($add)
+ public function addLeft(string $add)
{
$add = strval(round($add, 2));
bcscale(2);
@@ -61,9 +61,9 @@ class Budget
}
/**
- * @param float $add
+ * @param string $add
*/
- public function addOverspent($add)
+ public function addOverspent(string $add)
{
$add = strval(round($add, 2));
bcscale(2);
@@ -71,9 +71,9 @@ class Budget
}
/**
- * @param float $add
+ * @param string $add
*/
- public function addSpent($add)
+ public function addSpent(string $add)
{
$add = strval(round($add, 2));
bcscale(2);
@@ -99,7 +99,7 @@ class Budget
/**
* @param string $budgeted
*/
- public function setBudgeted($budgeted)
+ public function setBudgeted(string $budgeted)
{
$this->budgeted = $budgeted;
}
@@ -115,7 +115,7 @@ class Budget
/**
* @param string $left
*/
- public function setLeft($left)
+ public function setLeft(string $left)
{
$this->left = $left;
}
@@ -131,7 +131,7 @@ class Budget
/**
* @param string $overspent
*/
- public function setOverspent($overspent)
+ public function setOverspent(string $overspent)
{
$this->overspent = strval(round($overspent, 2));
}
@@ -147,7 +147,7 @@ class Budget
/**
* @param string $spent
*/
- public function setSpent($spent)
+ public function setSpent(string $spent)
{
$this->spent = strval(round($spent, 2));
}
diff --git a/app/Helpers/Collection/BudgetLine.php b/app/Helpers/Collection/BudgetLine.php
index f26950f9f9..d906da3fe6 100644
--- a/app/Helpers/Collection/BudgetLine.php
+++ b/app/Helpers/Collection/BudgetLine.php
@@ -17,16 +17,16 @@ class BudgetLine
/** @var BudgetModel */
protected $budget;
- /** @var float */
- protected $budgeted = 0;
- /** @var float */
- protected $left = 0;
- /** @var float */
- protected $overspent = 0;
+ /** @var string */
+ protected $budgeted = '0';
+ /** @var string */
+ protected $left = '0';
+ /** @var string */
+ protected $overspent = '0';
/** @var LimitRepetition */
protected $repetition;
- /** @var float */
- protected $spent = 0;
+ /** @var string */
+ protected $spent = '0';
/**
* @return BudgetModel
@@ -39,13 +39,13 @@ class BudgetLine
/**
* @param BudgetModel $budget
*/
- public function setBudget($budget)
+ public function setBudget(BudgetModel $budget)
{
$this->budget = $budget;
}
/**
- * @return float
+ * @return string
*/
public function getBudgeted()
{
@@ -53,15 +53,15 @@ class BudgetLine
}
/**
- * @param float $budgeted
+ * @param string $budgeted
*/
- public function setBudgeted($budgeted)
+ public function setBudgeted(string $budgeted)
{
$this->budgeted = $budgeted;
}
/**
- * @return float
+ * @return string
*/
public function getLeft()
{
@@ -69,15 +69,15 @@ class BudgetLine
}
/**
- * @param float $left
+ * @param string $left
*/
- public function setLeft($left)
+ public function setLeft(string $left)
{
$this->left = $left;
}
/**
- * @return float
+ * @return string
*/
public function getOverspent()
{
@@ -85,9 +85,9 @@ class BudgetLine
}
/**
- * @param float $overspent
+ * @param string $overspent
*/
- public function setOverspent($overspent)
+ public function setOverspent(string $overspent)
{
$this->overspent = $overspent;
}
@@ -103,13 +103,13 @@ class BudgetLine
/**
* @param LimitRepetition $repetition
*/
- public function setRepetition($repetition)
+ public function setRepetition(LimitRepetition $repetition)
{
$this->repetition = $repetition;
}
/**
- * @return float
+ * @return string
*/
public function getSpent()
{
@@ -117,9 +117,9 @@ class BudgetLine
}
/**
- * @param float $spent
+ * @param string $spent
*/
- public function setSpent($spent)
+ public function setSpent(string $spent)
{
$this->spent = $spent;
}
diff --git a/app/Helpers/Collection/Category.php b/app/Helpers/Collection/Category.php
index 6e243a7631..d6dd0ac76a 100644
--- a/app/Helpers/Collection/Category.php
+++ b/app/Helpers/Collection/Category.php
@@ -42,9 +42,9 @@ class Category
}
/**
- * @param float $add
+ * @param string $add
*/
- public function addTotal($add)
+ public function addTotal(string $add)
{
$add = strval(round($add, 2));
bcscale(2);
diff --git a/app/Helpers/Collection/Expense.php b/app/Helpers/Collection/Expense.php
index ce489c5118..de31ab76d1 100644
--- a/app/Helpers/Collection/Expense.php
+++ b/app/Helpers/Collection/Expense.php
@@ -58,9 +58,9 @@ class Expense
}
/**
- * @param $add
+ * @param string $add
*/
- public function addToTotal($add)
+ public function addToTotal(string $add)
{
bcscale(2);
diff --git a/app/Helpers/Collection/Income.php b/app/Helpers/Collection/Income.php
index 6a66de8fef..ddaf21cdcb 100644
--- a/app/Helpers/Collection/Income.php
+++ b/app/Helpers/Collection/Income.php
@@ -20,7 +20,7 @@ class Income
/** @var Collection */
protected $incomes;
/** @var string */
- protected $total;
+ protected $total = '0';
/**
*
@@ -54,9 +54,9 @@ class Income
}
/**
- * @param $add
+ * @param string $add
*/
- public function addToTotal($add)
+ public function addToTotal(string $add)
{
$add = strval(round($add, 2));
bcscale(2);
diff --git a/app/Helpers/Csv/Converter/Amount.php b/app/Helpers/Csv/Converter/Amount.php
index 7ec25ce17e..b33e15c9d4 100644
--- a/app/Helpers/Csv/Converter/Amount.php
+++ b/app/Helpers/Csv/Converter/Amount.php
@@ -19,6 +19,6 @@ class Amount extends BasicConverter implements ConverterInterface
return $this->value;
}
- return 0;
+ return '0';
}
}
diff --git a/app/Helpers/Csv/Converter/AmountComma.php b/app/Helpers/Csv/Converter/AmountComma.php
index 5fed5587b9..49ce80cbb0 100644
--- a/app/Helpers/Csv/Converter/AmountComma.php
+++ b/app/Helpers/Csv/Converter/AmountComma.php
@@ -23,6 +23,6 @@ class AmountComma extends BasicConverter implements ConverterInterface
return floatval($value);
}
- return 0;
+ return '0';
}
}
diff --git a/app/Helpers/Csv/Data.php b/app/Helpers/Csv/Data.php
index da4cc224fb..5b0fc93474 100644
--- a/app/Helpers/Csv/Data.php
+++ b/app/Helpers/Csv/Data.php
@@ -64,7 +64,7 @@ class Data
*
* @param string $csvFileContent
*/
- public function setCsvFileContent($csvFileContent)
+ public function setCsvFileContent(string $csvFileContent)
{
$this->csvFileContent = $csvFileContent;
}
@@ -82,7 +82,7 @@ class Data
*
* @param string $csvFileLocation
*/
- public function setCsvFileLocation($csvFileLocation)
+ public function setCsvFileLocation(string $csvFileLocation)
{
Session::put('csv-file', $csvFileLocation);
$this->csvFileLocation = $csvFileLocation;
@@ -99,9 +99,9 @@ class Data
/**
*
- * @param mixed $dateFormat
+ * @param string $dateFormat
*/
- public function setDateFormat($dateFormat)
+ public function setDateFormat(string $dateFormat)
{
Session::put('csv-date-format', $dateFormat);
$this->dateFormat = $dateFormat;
@@ -120,7 +120,7 @@ class Data
*
* @param string $delimiter
*/
- public function setDelimiter($delimiter)
+ public function setDelimiter(string $delimiter)
{
Session::put('csv-delimiter', $delimiter);
$this->delimiter = $delimiter;
@@ -233,7 +233,7 @@ class Data
*
* @param bool $hasHeaders
*/
- public function setHasHeaders($hasHeaders)
+ public function setHasHeaders(bool $hasHeaders)
{
Session::put('csv-has-headers', $hasHeaders);
$this->hasHeaders = $hasHeaders;
@@ -243,7 +243,7 @@ class Data
*
* @param int $importAccount
*/
- public function setImportAccount($importAccount)
+ public function setImportAccount(int $importAccount)
{
Session::put('csv-import-account', $importAccount);
$this->importAccount = $importAccount;
diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php
index e72a127a24..48750670a9 100644
--- a/app/Helpers/Csv/Importer.php
+++ b/app/Helpers/Csv/Importer.php
@@ -136,7 +136,7 @@ class Importer
/**
* @param Data $data
*/
- public function setData($data)
+ public function setData(Data $data)
{
$this->data = $data;
}
@@ -218,12 +218,12 @@ class Importer
}
/**
- * @param $row
+ * @param array $row
*
* @throws FireflyException
* @return string|bool
*/
- protected function importRow($row)
+ protected function importRow(array $row)
{
$data = $this->getFiller(); // These fields are necessary to create a new transaction journal. Some are optional
@@ -266,7 +266,7 @@ class Importer
*
* @return bool
*/
- protected function parseRow($index)
+ protected function parseRow(int $index)
{
return (($this->data->hasHeaders() && $index >= 1) || !$this->data->hasHeaders());
}
diff --git a/app/Helpers/Csv/Specifix/AbnAmroDescription.php b/app/Helpers/Csv/Specifix/AbnAmroDescription.php
index dac1899557..19655ef599 100644
--- a/app/Helpers/Csv/Specifix/AbnAmroDescription.php
+++ b/app/Helpers/Csv/Specifix/AbnAmroDescription.php
@@ -49,7 +49,7 @@ class AbnAmroDescription extends Specifix implements SpecifixInterface
/**
* @param array $data
*/
- public function setData($data)
+ public function setData(array $data)
{
$this->data = $data;
}
@@ -57,7 +57,7 @@ class AbnAmroDescription extends Specifix implements SpecifixInterface
/**
* @param array $row
*/
- public function setRow($row)
+ public function setRow(array $row)
{
$this->row = $row;
}
diff --git a/app/Helpers/Csv/Specifix/Dummy.php b/app/Helpers/Csv/Specifix/Dummy.php
index 915e87bd37..3dc94e5cb0 100644
--- a/app/Helpers/Csv/Specifix/Dummy.php
+++ b/app/Helpers/Csv/Specifix/Dummy.php
@@ -35,7 +35,7 @@ class Dummy extends Specifix implements SpecifixInterface
/**
* @param array $data
*/
- public function setData($data)
+ public function setData(array $data)
{
$this->data = $data;
}
@@ -43,7 +43,7 @@ class Dummy extends Specifix implements SpecifixInterface
/**
* @param array $row
*/
- public function setRow($row)
+ public function setRow(array $row)
{
$this->row = $row;
}
diff --git a/app/Helpers/Csv/Specifix/RabobankDescription.php b/app/Helpers/Csv/Specifix/RabobankDescription.php
index a8fced085a..83c6039184 100644
--- a/app/Helpers/Csv/Specifix/RabobankDescription.php
+++ b/app/Helpers/Csv/Specifix/RabobankDescription.php
@@ -40,7 +40,7 @@ class RabobankDescription extends Specifix implements SpecifixInterface
/**
* @param array $data
*/
- public function setData($data)
+ public function setData(array $data)
{
$this->data = $data;
}
@@ -48,7 +48,7 @@ class RabobankDescription extends Specifix implements SpecifixInterface
/**
* @param array $row
*/
- public function setRow($row)
+ public function setRow(array $row)
{
$this->row = $row;
}
diff --git a/app/Helpers/Csv/Specifix/Specifix.php b/app/Helpers/Csv/Specifix/Specifix.php
index 2c2a191811..9a855b32a1 100644
--- a/app/Helpers/Csv/Specifix/Specifix.php
+++ b/app/Helpers/Csv/Specifix/Specifix.php
@@ -29,11 +29,11 @@ class Specifix
}
/**
- * @param $processorType
+ * @param int $processorType
*
* @return $this
*/
- public function setProcessorType($processorType)
+ public function setProcessorType(int $processorType)
{
$this->processorType = $processorType;
diff --git a/app/Helpers/Csv/Specifix/SpecifixInterface.php b/app/Helpers/Csv/Specifix/SpecifixInterface.php
index 805df80083..852ea96cca 100644
--- a/app/Helpers/Csv/Specifix/SpecifixInterface.php
+++ b/app/Helpers/Csv/Specifix/SpecifixInterface.php
@@ -24,17 +24,17 @@ interface SpecifixInterface
/**
* @param array $data
*/
- public function setData($data);
+ public function setData(array $data);
/**
* @param int $processorType
*
* @return $this
*/
- public function setProcessorType($processorType);
+ public function setProcessorType(int $processorType);
/**
* @param array $row
*/
- public function setRow($row);
+ public function setRow(array $row);
}
diff --git a/app/Helpers/Csv/Wizard.php b/app/Helpers/Csv/Wizard.php
index bf93c16ec8..92e2bc6e0f 100644
--- a/app/Helpers/Csv/Wizard.php
+++ b/app/Helpers/Csv/Wizard.php
@@ -26,7 +26,7 @@ class Wizard implements WizardInterface
*
* @return array
*/
- public function getMappableValues($reader, array $map, $hasHeaders)
+ public function getMappableValues(Reader $reader, array $map, bool $hasHeaders)
{
$values = [];
/*
@@ -52,11 +52,11 @@ class Wizard implements WizardInterface
/**
* @param array $roles
- * @param mixed $map
+ * @param array $map
*
* @return array
*/
- public function processSelectedMapping(array $roles, $map)
+ public function processSelectedMapping(array $roles, array $map)
{
$configRoles = Config::get('csv.roles');
$maps = [];
@@ -79,11 +79,11 @@ class Wizard implements WizardInterface
}
/**
- * @param mixed $input
+ * @param array $input
*
* @return array
*/
- public function processSelectedRoles($input)
+ public function processSelectedRoles(array $input)
{
$roles = [];
@@ -150,11 +150,11 @@ class Wizard implements WizardInterface
}
/**
- * @param $path
+ * @param string $path
*
* @return string
*/
- public function storeCsvFile($path)
+ public function storeCsvFile(string $path)
{
$time = str_replace(' ', '-', microtime());
$fileName = 'csv-upload-' . Auth::user()->id . '-' . $time . '.csv.encrypted';
@@ -188,7 +188,7 @@ class Wizard implements WizardInterface
*
* @return bool
*/
- protected function useRow($hasHeaders, $index)
+ protected function useRow(bool $hasHeaders, int $index)
{
return ($hasHeaders && $index > 1) || !$hasHeaders;
}
diff --git a/app/Helpers/Csv/WizardInterface.php b/app/Helpers/Csv/WizardInterface.php
index 6257a85694..1905f42d61 100644
--- a/app/Helpers/Csv/WizardInterface.php
+++ b/app/Helpers/Csv/WizardInterface.php
@@ -18,22 +18,22 @@ interface WizardInterface
*
* @return array
*/
- public function getMappableValues($reader, array $map, $hasHeaders);
+ public function getMappableValues(Reader $reader, array $map, bool $hasHeaders);
/**
* @param array $roles
- * @param mixed $map
+ * @param array $map
*
* @return array
*/
- public function processSelectedMapping(array $roles, $map);
+ public function processSelectedMapping(array $roles, array $map);
/**
- * @param mixed $input
+ * @param array $input
*
* @return array
*/
- public function processSelectedRoles($input);
+ public function processSelectedRoles(array $input);
/**
* @param array $fields
@@ -50,10 +50,10 @@ interface WizardInterface
public function showOptions(array $map);
/**
- * @param $path
+ * @param string $path
*
* @return string
*/
- public function storeCsvFile($path);
+ public function storeCsvFile(string $path);
}
diff --git a/app/Helpers/Help/Help.php b/app/Helpers/Help/Help.php
index 87b7703ef8..8bbb038627 100644
--- a/app/Helpers/Help/Help.php
+++ b/app/Helpers/Help/Help.php
@@ -19,11 +19,11 @@ class Help implements HelpInterface
/**
* @codeCoverageIgnore
*
- * @param $key
+ * @param string $key
*
* @return string
*/
- public function getFromCache($key)
+ public function getFromCache(string $key)
{
return Cache::get($key);
}
@@ -31,11 +31,11 @@ class Help implements HelpInterface
/**
* @codeCoverageIgnore
*
- * @param $route
+ * @param string $route
*
* @return array
*/
- public function getFromGithub($route)
+ public function getFromGithub(string $route)
{
$uri = 'https://raw.githubusercontent.com/JC5/firefly-iii-help/master/en/' . e($route) . '.md';
$routeIndex = str_replace('.', '-', $route);
@@ -62,11 +62,11 @@ class Help implements HelpInterface
/**
* @codeCoverageIgnore
*
- * @param $route
+ * @param string $route
*
* @return bool
*/
- public function hasRoute($route)
+ public function hasRoute(string $route)
{
return Route::has($route);
}
@@ -74,11 +74,11 @@ class Help implements HelpInterface
/**
* @codeCoverageIgnore
*
- * @param $route
+ * @param string $route
*
* @return bool
*/
- public function inCache($route)
+ public function inCache(string $route)
{
return Cache::has('help.' . $route . '.title') && Cache::has('help.' . $route . '.text');
}
@@ -86,12 +86,12 @@ class Help implements HelpInterface
/**
* @codeCoverageIgnore
*
- * @param $route
- * @param array $content
+ * @param string $route
+ * @param array $content
*
* @internal param $title
*/
- public function putInCache($route, array $content)
+ public function putInCache(string $route, array $content)
{
Cache::put('help.' . $route . '.text', $content['text'], 10080); // a week.
Cache::put('help.' . $route . '.title', $content['title'], 10080);
diff --git a/app/Helpers/Help/HelpInterface.php b/app/Helpers/Help/HelpInterface.php
index 3807c2c1ff..892e554f9e 100644
--- a/app/Helpers/Help/HelpInterface.php
+++ b/app/Helpers/Help/HelpInterface.php
@@ -11,38 +11,38 @@ interface HelpInterface
{
/**
- * @param $key
+ * @param string $key
*
* @return string
*/
- public function getFromCache($key);
+ public function getFromCache(string $key);
/**
- * @param $route
+ * @param string $route
*
* @return array
*/
- public function getFromGithub($route);
+ public function getFromGithub(string $route);
/**
- * @param $route
+ * @param string $route
*
* @return bool
*/
- public function hasRoute($route);
+ public function hasRoute(string $route);
/**
- * @param $route
+ * @param string $route
*
* @return bool
*/
- public function inCache($route);
+ public function inCache(string $route);
/**
- * @param $route
- * @param array $content
+ * @param string $route
+ * @param array $content
*
* @return void
*/
- public function putInCache($route, array $content);
+ public function putInCache(string $route, array $content);
}
diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.php
index 5b2759a675..6717282493 100644
--- a/app/Helpers/Report/ReportHelper.php
+++ b/app/Helpers/Report/ReportHelper.php
@@ -132,7 +132,7 @@ class ReportHelper implements ReportHelperInterface
*
* @return Expense
*/
- public function getExpenseReport($start, $end, Collection $accounts)
+ public function getExpenseReport(Carbon $start, Carbon $end, Collection $accounts)
{
$object = new Expense;
$set = $this->query->expense($accounts, $start, $end);
@@ -154,7 +154,7 @@ class ReportHelper implements ReportHelperInterface
*
* @return Income
*/
- public function getIncomeReport($start, $end, Collection $accounts)
+ public function getIncomeReport(Carbon $start, Carbon $end, Collection $accounts)
{
$object = new Income;
$set = $this->query->income($accounts, $start, $end);
diff --git a/app/Helpers/Report/ReportHelperInterface.php b/app/Helpers/Report/ReportHelperInterface.php
index 7a1833a230..1ff2fc08ef 100644
--- a/app/Helpers/Report/ReportHelperInterface.php
+++ b/app/Helpers/Report/ReportHelperInterface.php
@@ -49,7 +49,7 @@ interface ReportHelperInterface
*
* @return Expense
*/
- public function getExpenseReport($start, $end, Collection $accounts);
+ public function getExpenseReport(Carbon $start, Carbon $end, Collection $accounts);
/**
* Get a full report on the users incomes during the period for the given accounts.
@@ -60,7 +60,7 @@ interface ReportHelperInterface
*
* @return Income
*/
- public function getIncomeReport($start, $end, Collection $accounts);
+ public function getIncomeReport(Carbon $start, Carbon $end, Collection $accounts);
/**
* @param Carbon $date
diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php
index 2c2083522b..7bda3cb6c3 100644
--- a/app/Http/Controllers/AccountController.php
+++ b/app/Http/Controllers/AccountController.php
@@ -36,7 +36,7 @@ class AccountController extends Controller
*
* @return \Illuminate\View\View
*/
- public function create($what = 'asset')
+ public function create(string $what = 'asset')
{
@@ -148,7 +148,7 @@ class AccountController extends Controller
*
* @return \Illuminate\View\View
*/
- public function index(ARI $repository, $what)
+ public function index(ARI $repository, string $what)
{
$subTitle = trans('firefly.' . $what . '_accounts');
$subTitleIcon = Config::get('firefly.subIconsByIdentifier.' . $what);
@@ -275,11 +275,11 @@ class AccountController extends Controller
/**
* @param array $array
- * @param $entryId
+ * @param int $entryId
*
* @return null|mixed
*/
- protected function isInArray(array $array, $entryId)
+ protected function isInArray(array $array, int $entryId)
{
if (isset($array[$entryId])) {
return $array[$entryId];
diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php
index 9d430846bb..09c88dfeb3 100644
--- a/app/Http/Controllers/Auth/AuthController.php
+++ b/app/Http/Controllers/Auth/AuthController.php
@@ -205,11 +205,11 @@ class AuthController extends Controller
/**
* Get the failed login message.
*
- * @param $message
+ * @param string $message
*
* @return string
*/
- protected function getFailedLoginMessage($message)
+ protected function getFailedLoginMessage(string $message)
{
if (strlen($message) > 0) {
return $message;
@@ -221,11 +221,11 @@ class AuthController extends Controller
}
/**
- * @param $email
+ * @param string $email
*
* @return bool
*/
- protected function isBlockedDomain($email)
+ protected function isBlockedDomain(string $email)
{
$parts = explode('@', $email);
$blocked = $this->getBlockedDomains();
@@ -241,12 +241,11 @@ class AuthController extends Controller
* Get the failed login response instance.
*
* @param \Illuminate\Http\Request $request
- *
- * @param $message
+ * @param string $message
*
* @return \Illuminate\Http\Response
*/
- protected function sendFailedLoginResponse(Request $request, $message)
+ protected function sendFailedLoginResponse(Request $request, string $message)
{
return redirect()->back()
->withInput($request->only($this->loginUsername(), 'remember'))
diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php
index 325f5a0352..33801802e6 100644
--- a/app/Http/Controllers/BudgetController.php
+++ b/app/Http/Controllers/BudgetController.php
@@ -229,7 +229,7 @@ class BudgetController extends Controller
return view('error', compact('message'));
}
- $journals = $repository->getJournals($budget, $repetition);
+ $journals = $repository->getJournals($budget, $repetition, 50);
if (is_null($repetition->id)) {
$start = $repository->firstActivity($budget);
diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php
index 1a9f305b8e..c2e4bf1b32 100644
--- a/app/Http/Controllers/CategoryController.php
+++ b/app/Http/Controllers/CategoryController.php
@@ -213,7 +213,7 @@ class CategoryController extends Controller
*
* @return \Illuminate\View\View
*/
- public function showWithDate(SCRI $repository, Category $category, $date)
+ public function showWithDate(SCRI $repository, Category $category, string $date)
{
$carbon = new Carbon($date);
$range = Preferences::get('viewRange', '1M')->data;
diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php
index 6a5a3ea715..ff79d24537 100644
--- a/app/Http/Controllers/Chart/AccountController.php
+++ b/app/Http/Controllers/Chart/AccountController.php
@@ -43,7 +43,7 @@ class AccountController extends Controller
*
* @return \Illuminate\Http\JsonResponse
*/
- public function report($reportType, Carbon $start, Carbon $end, Collection $accounts)
+ public function report(string $reportType, Carbon $start, Carbon $end, Collection $accounts)
{
// chart properties for cache:
$cache = new CacheProperties();
diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php
index 1677b2b817..7e947476c2 100644
--- a/app/Http/Controllers/Chart/BudgetController.php
+++ b/app/Http/Controllers/Chart/BudgetController.php
@@ -35,87 +35,6 @@ class BudgetController extends Controller
$this->generator = app('FireflyIII\Generator\Chart\Budget\BudgetChartGeneratorInterface');
}
- /**
- *
- * @param BudgetRepositoryInterface $repository
- * @param $reportType
- * @param Carbon $start
- * @param Carbon $end
- * @param Collection $accounts
- * @param Collection $budgets
- *
- * @SuppressWarnings(PHPMD.ExcessiveParameterList) // need all parameters
- *
- * @return \Illuminate\Http\JsonResponse
- */
- public function multiYear(BudgetRepositoryInterface $repository, $reportType, Carbon $start, Carbon $end, Collection $accounts, Collection $budgets)
- {
- // chart properties for cache:
- $cache = new CacheProperties();
- $cache->addProperty($reportType);
- $cache->addProperty($start);
- $cache->addProperty($end);
- $cache->addProperty($accounts);
- $cache->addProperty($budgets);
- $cache->addProperty('multiYearBudget');
-
- if ($cache->has()) {
- return Response::json($cache->get()); // @codeCoverageIgnore
- }
-
- /*
- * Get the budgeted amounts for each budgets in each year.
- */
- $budgetedSet = $repository->getBudgetedPerYear($budgets, $start, $end);
- $budgetedArray = [];
- /** @var Budget $entry */
- foreach ($budgetedSet as $entry) {
- $budgetedArray[$entry->id][$entry->dateFormatted] = $entry->budgeted;
- }
-
- $set = $repository->getBudgetsAndExpensesPerYear($budgets, $accounts, $start, $end);
- $entries = new Collection;
- // go by budget, not by year.
- /** @var Budget $budget */
- foreach ($budgets as $budget) {
- $entry = ['name' => '', 'spent' => [], 'budgeted' => []];
- $id = $budget->id;
- $currentStart = clone $start;
- while ($currentStart < $end) {
- // fix the date:
- $currentEnd = clone $currentStart;
- $currentEnd->endOfYear();
-
- // save to array:
- $year = $currentStart->year;
- $entry['name'] = $budget->name;
- $spent = 0;
- $budgeted = 0;
- if (isset($set[$id]['entries'][$year])) {
- $spent = $set[$id]['entries'][$year] * -1;
- }
-
- if (isset($budgetedArray[$id][$year])) {
- $budgeted = round($budgetedArray[$id][$year], 2);
- }
-
- $entry['spent'][$year] = $spent;
- $entry['budgeted'][$year] = $budgeted;
-
- // jump to next year.
- $currentStart = clone $currentEnd;
- $currentStart->addDay();
- }
- $entries->push($entry);
- }
- // generate chart with data:
- $data = $this->generator->multiYear($entries);
- $cache->store($data);
-
- return Response::json($data);
-
- }
-
/**
* @param BudgetRepositoryInterface $repository
* @param Budget $budget
@@ -291,6 +210,87 @@ class BudgetController extends Controller
return Response::json($data);
}
+ /**
+ *
+ * @param BudgetRepositoryInterface $repository
+ * @param $reportType
+ * @param Carbon $start
+ * @param Carbon $end
+ * @param Collection $accounts
+ * @param Collection $budgets
+ *
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList) // need all parameters
+ *
+ * @return \Illuminate\Http\JsonResponse
+ */
+ public function multiYear(BudgetRepositoryInterface $repository, string $reportType, Carbon $start, Carbon $end, Collection $accounts, Collection $budgets)
+ {
+ // chart properties for cache:
+ $cache = new CacheProperties();
+ $cache->addProperty($reportType);
+ $cache->addProperty($start);
+ $cache->addProperty($end);
+ $cache->addProperty($accounts);
+ $cache->addProperty($budgets);
+ $cache->addProperty('multiYearBudget');
+
+ if ($cache->has()) {
+ return Response::json($cache->get()); // @codeCoverageIgnore
+ }
+
+ /*
+ * Get the budgeted amounts for each budgets in each year.
+ */
+ $budgetedSet = $repository->getBudgetedPerYear($budgets, $start, $end);
+ $budgetedArray = [];
+ /** @var Budget $entry */
+ foreach ($budgetedSet as $entry) {
+ $budgetedArray[$entry->id][$entry->dateFormatted] = $entry->budgeted;
+ }
+
+ $set = $repository->getBudgetsAndExpensesPerYear($budgets, $accounts, $start, $end);
+ $entries = new Collection;
+ // go by budget, not by year.
+ /** @var Budget $budget */
+ foreach ($budgets as $budget) {
+ $entry = ['name' => '', 'spent' => [], 'budgeted' => []];
+ $id = $budget->id;
+ $currentStart = clone $start;
+ while ($currentStart < $end) {
+ // fix the date:
+ $currentEnd = clone $currentStart;
+ $currentEnd->endOfYear();
+
+ // save to array:
+ $year = $currentStart->year;
+ $entry['name'] = $budget->name;
+ $spent = 0;
+ $budgeted = 0;
+ if (isset($set[$id]['entries'][$year])) {
+ $spent = $set[$id]['entries'][$year] * -1;
+ }
+
+ if (isset($budgetedArray[$id][$year])) {
+ $budgeted = round($budgetedArray[$id][$year], 2);
+ }
+
+ $entry['spent'][$year] = $spent;
+ $entry['budgeted'][$year] = $budgeted;
+
+ // jump to next year.
+ $currentStart = clone $currentEnd;
+ $currentStart->addDay();
+ }
+ $entries->push($entry);
+ }
+ // generate chart with data:
+ $data = $this->generator->multiYear($entries);
+ $cache->store($data);
+
+ return Response::json($data);
+
+ }
+
/**
*
* @param BudgetRepositoryInterface $repository
@@ -301,7 +301,7 @@ class BudgetController extends Controller
*
* @return \Illuminate\Http\JsonResponse
*/
- public function year(BudgetRepositoryInterface $repository, $reportType, Carbon $start, Carbon $end, Collection $accounts)
+ public function year(BudgetRepositoryInterface $repository, string $reportType, Carbon $start, Carbon $end, Collection $accounts)
{
// chart properties for cache:
$cache = new CacheProperties();
diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.php
index 409c2bf72c..99482bf2ea 100644
--- a/app/Http/Controllers/Chart/CategoryController.php
+++ b/app/Http/Controllers/Chart/CategoryController.php
@@ -114,7 +114,7 @@ class CategoryController extends Controller
*
* @return \Illuminate\Http\JsonResponse
*/
- public function earnedInPeriod(CRI $repository, $reportType, Carbon $start, Carbon $end, Collection $accounts)
+ public function earnedInPeriod(CRI $repository, string $reportType, Carbon $start, Carbon $end, Collection $accounts)
{
$cache = new CacheProperties; // chart properties for cache:
$cache->addProperty($start);
@@ -215,7 +215,7 @@ class CategoryController extends Controller
*
* @return \Illuminate\Http\JsonResponse
*/
- public function multiYear($reportType, Carbon $start, Carbon $end, Collection $accounts, Collection $categories)
+ public function multiYear(string $reportType, Carbon $start, Carbon $end, Collection $accounts, Collection $categories)
{
/** @var CRI $repository */
$repository = app('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
diff --git a/app/Http/Controllers/Chart/ReportController.php b/app/Http/Controllers/Chart/ReportController.php
index a4b558876c..1832a8ab6f 100644
--- a/app/Http/Controllers/Chart/ReportController.php
+++ b/app/Http/Controllers/Chart/ReportController.php
@@ -45,7 +45,7 @@ class ReportController extends Controller
*
* @return \Illuminate\Http\JsonResponse
*/
- public function yearInOut(ReportQueryInterface $query, $reportType, Carbon $start, Carbon $end, Collection $accounts)
+ public function yearInOut(ReportQueryInterface $query, string $reportType, Carbon $start, Carbon $end, Collection $accounts)
{
// chart properties for cache:
$cache = new CacheProperties;
@@ -88,7 +88,7 @@ class ReportController extends Controller
*
* @return \Illuminate\Http\JsonResponse
*/
- public function yearInOutSummarized(ReportQueryInterface $query, $reportType, Carbon $start, Carbon $end, Collection $accounts)
+ public function yearInOutSummarized(ReportQueryInterface $query, string $reportType, Carbon $start, Carbon $end, Collection $accounts)
{
// chart properties for cache:
diff --git a/app/Http/Controllers/HelpController.php b/app/Http/Controllers/HelpController.php
index 667aef28f3..4b346ec8fd 100644
--- a/app/Http/Controllers/HelpController.php
+++ b/app/Http/Controllers/HelpController.php
@@ -25,7 +25,7 @@ class HelpController extends Controller
*
* @return \Illuminate\Http\JsonResponse
*/
- public function show(HelpInterface $help, $route)
+ public function show(HelpInterface $help, string $route)
{
$content = [
'text' => '<p>There is no help for this route!</p>',
diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php
index 89c82545b6..a6509cd9f2 100644
--- a/app/Http/Controllers/ProfileController.php
+++ b/app/Http/Controllers/ProfileController.php
@@ -122,7 +122,7 @@ class ProfileController extends Controller
*
* @return string|bool
*/
- protected function validatePassword($old, $new1)
+ protected function validatePassword(string $old, string $new1)
{
if ($new1 == $old) {
return trans('firefly.should_change');
diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php
index c5640d0b5a..3cab30df27 100644
--- a/app/Http/Controllers/ReportController.php
+++ b/app/Http/Controllers/ReportController.php
@@ -78,7 +78,7 @@ class ReportController extends Controller
*
* @return View
*/
- public function report($reportType, Carbon $start, Carbon $end, Collection $accounts)
+ public function report(string $reportType, Carbon $start, Carbon $end, Collection $accounts)
{
// throw an error if necessary.
if ($end < $start) {
@@ -130,7 +130,7 @@ class ReportController extends Controller
*
* @return View
*/
- private function defaultMonth($reportType, Carbon $start, Carbon $end, Collection $accounts)
+ private function defaultMonth(string $reportType, Carbon $start, Carbon $end, Collection $accounts)
{
$incomeTopLength = 8;
$expenseTopLength = 8;
@@ -171,7 +171,7 @@ class ReportController extends Controller
*
* @return View
*/
- private function defaultMultiYear($reportType, $start, $end, $accounts)
+ private function defaultMultiYear(string $reportType, Carbon $start, Carbon $end, Collection $accounts)
{
$incomeTopLength = 8;
@@ -208,7 +208,7 @@ class ReportController extends Controller
*
* @return View
*/
- private function defaultYear($reportType, Carbon $start, Carbon $end, Collection $accounts)
+ private function defaultYear(string $reportType, Carbon $start, Carbon $end, Collection $accounts)
{
$incomeTopLength = 8;
$expenseTopLength = 8;
diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php
index be29b9ec53..a61d1e2d75 100644
--- a/app/Http/Controllers/TagController.php
+++ b/app/Http/Controllers/TagController.php
@@ -159,11 +159,11 @@ class TagController extends Controller
*
* @return \Symfony\Component\HttpFoundation\Response
*/
- public function hideTagHelp($state)
+ public function hideTagHelp(string $state)
{
- $state = $state == 'true' ? true : false;
- Preferences::set('hideTagHelp', $state);
+ $newState = $state == 'true' ? true : false;
+ Preferences::set('hideTagHelp', $newState);
return Response::json([true]);
}
diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php
index e8b92dadba..4081278afb 100644
--- a/app/Http/Controllers/TransactionController.php
+++ b/app/Http/Controllers/TransactionController.php
@@ -49,7 +49,7 @@ class TransactionController extends Controller
*
* @return \Illuminate\View\View
*/
- public function create(ARI $repository, $what = TransactionType::DEPOSIT)
+ public function create(ARI $repository, string $what = TransactionType::DEPOSIT)
{
$what = strtolower($what);
$maxFileSize = Steam::phpBytes(ini_get('upload_max_filesize'));
@@ -211,7 +211,7 @@ class TransactionController extends Controller
*
* @return \Illuminate\View\View
*/
- public function index(JournalRepositoryInterface $repository, $what)
+ public function index(JournalRepositoryInterface $repository, string $what)
{
$subTitleIcon = Config::get('firefly.transactionIconsByWhat.' . $what);
$types = Config::get('firefly.transactionTypesByWhat.' . $what);
diff --git a/app/Http/breadcrumbs.php b/app/Http/breadcrumbs.php
index 71b894a813..df5ff587a2 100644
--- a/app/Http/breadcrumbs.php
+++ b/app/Http/breadcrumbs.php
@@ -33,14 +33,14 @@ Breadcrumbs::register(
// accounts
Breadcrumbs::register(
- 'accounts.index', function (BreadCrumbGenerator $breadcrumbs, $what) {
+ 'accounts.index', function (BreadCrumbGenerator $breadcrumbs, string $what) {
$breadcrumbs->parent('home');
$breadcrumbs->push(trans('firefly.' . strtolower(e($what)) . '_accounts'), route('accounts.index', [$what]));
}
);
Breadcrumbs::register(
- 'accounts.create', function (BreadCrumbGenerator $breadcrumbs, $what) {
+ 'accounts.create', function (BreadCrumbGenerator $breadcrumbs, string $what) {
$breadcrumbs->parent('accounts.index', $what);
$breadcrumbs->push(trans('firefly.new_' . strtolower(e($what)) . '_account'), route('accounts.create', [$what]));
}
@@ -384,13 +384,13 @@ Breadcrumbs::register(
// transactions
Breadcrumbs::register(
- 'transactions.index', function (BreadCrumbGenerator $breadcrumbs, $what) {
+ 'transactions.index', function (BreadCrumbGenerator $breadcrumbs, string $what) {
$breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.' . $what . '_list'), route('transactions.index', [$what]));
}
);
Breadcrumbs::register(
- 'transactions.create', function (BreadCrumbGenerator $breadcrumbs, $what) {
+ 'transactions.create', function (BreadCrumbGenerator $breadcrumbs, string $what) {
$breadcrumbs->parent('transactions.index', $what);
$breadcrumbs->push(trans('breadcrumbs.create_' . e($what)), route('transactions.create', [$what]));
}
diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php
index 38bf2f0caa..5b6c7deeb8 100644
--- a/app/Repositories/Account/AccountRepository.php
+++ b/app/Repositories/Account/AccountRepository.php
@@ -63,11 +63,11 @@ class AccountRepository implements AccountRepositoryInterface
/**
* @deprecated
*
- * @param $accountId
+ * @param int $accountId
*
* @return Account
*/
- public function find($accountId)
+ public function find(int $accountId)
{
return Auth::user()->accounts()->findOrNew($accountId);
}
diff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.php
index 9b10c383c7..8f0d460abb 100644
--- a/app/Repositories/Account/AccountRepositoryInterface.php
+++ b/app/Repositories/Account/AccountRepositoryInterface.php
@@ -34,13 +34,13 @@ interface AccountRepositoryInterface
public function destroy(Account $account, Account $moveTo = null);
/**
- * @param $accountId
+ * @param int $accountId
*
* @deprecated
*
* @return Account
*/
- public function find($accountId);
+ public function find(int $accountId);
/**
* Gets all the accounts by ID, for a given set.
diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php
index dbf9d47c31..c789390f05 100644
--- a/app/Repositories/Budget/BudgetRepository.php
+++ b/app/Repositories/Budget/BudgetRepository.php
@@ -443,7 +443,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
*
* @return LengthAwarePaginator
*/
- public function getJournals(Budget $budget, LimitRepetition $repetition = null, $take = 50)
+ public function getJournals(Budget $budget, LimitRepetition $repetition, int $take)
{
$offset = intval(Input::get('page')) > 0 ? intval(Input::get('page')) * $take : 0;
$setQuery = $budget->transactionJournals()->withRelevantData()->take($take)->offset($offset)
@@ -493,7 +493,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
* @param Carbon $start
* @param Carbon $end
*
- * @return double
+ * @return string
*/
public function getWithoutBudgetSum(Carbon $start, Carbon $end)
{
@@ -519,6 +519,9 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
)
->transactionTypes([TransactionType::WITHDRAWAL])
->first([DB::Raw('SUM(`transactions`.`amount`) as `journalAmount`')]);
+ if (is_null($entry->journalAmount)) {
+ return '';
+ }
return $entry->journalAmount;
}
diff --git a/app/Repositories/Budget/BudgetRepositoryInterface.php b/app/Repositories/Budget/BudgetRepositoryInterface.php
index 0aec8c451a..67ba9bf499 100644
--- a/app/Repositories/Budget/BudgetRepositoryInterface.php
+++ b/app/Repositories/Budget/BudgetRepositoryInterface.php
@@ -168,7 +168,7 @@ interface BudgetRepositoryInterface
*
* @return LengthAwarePaginator
*/
- public function getJournals(Budget $budget, LimitRepetition $repetition = null, $take = 50);
+ public function getJournals(Budget $budget, LimitRepetition $repetition, int $take);
/**
* @param Carbon $start
diff --git a/app/Repositories/ExportJob/ExportJobRepository.php b/app/Repositories/ExportJob/ExportJobRepository.php
index db5e1450e8..de0a41bab4 100644
--- a/app/Repositories/ExportJob/ExportJobRepository.php
+++ b/app/Repositories/ExportJob/ExportJobRepository.php
@@ -68,11 +68,11 @@ class ExportJobRepository implements ExportJobRepositoryInterface
}
/**
- * @param $key
+ * @param string $key
*
* @return ExportJob|null
*/
- public function findByKey($key)
+ public function findByKey(string $key)
{
return Auth::user()->exportJobs()->where('key', $key)->first();
}
diff --git a/app/Repositories/ExportJob/ExportJobRepositoryInterface.php b/app/Repositories/ExportJob/ExportJobRepositoryInterface.php
index 68265b2bc5..e270a0227d 100644
--- a/app/Repositories/ExportJob/ExportJobRepositoryInterface.php
+++ b/app/Repositories/ExportJob/ExportJobRepositoryInterface.php
@@ -29,10 +29,10 @@ interface ExportJobRepositoryInterface
public function create();
/**
- * @param $key
+ * @param string $key
*
* @return ExportJob|null
*/
- public function findByKey($key);
+ public function findByKey(string $key);
}
\ No newline at end of file
diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php
index ba3b4200e3..cc152e2ff9 100644
--- a/app/Repositories/Journal/JournalRepository.php
+++ b/app/Repositories/Journal/JournalRepository.php
@@ -90,7 +90,7 @@ class JournalRepository implements JournalRepositoryInterface
*
* @return LengthAwarePaginator
*/
- public function getJournalsOfTypes(array $types, $offset, $page)
+ public function getJournalsOfTypes(array $types, int $offset, int $page)
{
$set = Auth::user()->transactionJournals()->transactionTypes($types)->withRelevantData()->take(50)->offset($offset)
->orderBy('date', 'DESC')
@@ -106,11 +106,11 @@ class JournalRepository implements JournalRepositoryInterface
}
/**
- * @param $type
+ * @param string $type
*
* @return TransactionType
*/
- public function getTransactionType($type)
+ public function getTransactionType(string $type)
{
return TransactionType::whereType($type)->first();
}
@@ -121,7 +121,7 @@ class JournalRepository implements JournalRepositoryInterface
*
* @return TransactionJournal
*/
- public function getWithDate($journalId, Carbon $date)
+ public function getWithDate(int $journalId, Carbon $date)
{
return Auth::user()->transactionjournals()->where('id', $journalId)->where('date', $date->format('Y-m-d 00:00:00'))->first();
}
diff --git a/app/Repositories/Journal/JournalRepositoryInterface.php b/app/Repositories/Journal/JournalRepositoryInterface.php
index fb7ccb6cc9..de65cf94ad 100644
--- a/app/Repositories/Journal/JournalRepositoryInterface.php
+++ b/app/Repositories/Journal/JournalRepositoryInterface.php
@@ -52,14 +52,14 @@ interface JournalRepositoryInterface
*
* @return LengthAwarePaginator
*/
- public function getJournalsOfTypes(array $types, $offset, $page);
+ public function getJournalsOfTypes(array $types, int $offset, int $page);
/**
- * @param $type
+ * @param string $type
*
* @return TransactionType
*/
- public function getTransactionType($type);
+ public function getTransactionType(string $type);
/**
* @param int $journalId
@@ -67,7 +67,7 @@ interface JournalRepositoryInterface
*
* @return TransactionJournal
*/
- public function getWithDate($journalId, Carbon $date);
+ public function getWithDate(int $journalId, Carbon $date);
/**
* @param TransactionJournal $journal
diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php
index 8d49f3c74f..cec8eeec5e 100644
--- a/app/Repositories/PiggyBank/PiggyBankRepository.php
+++ b/app/Repositories/PiggyBank/PiggyBankRepository.php
@@ -19,11 +19,11 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
/**
* @param PiggyBank $piggyBank
- * @param $amount
+ * @param string $amount
*
* @return bool
*/
- public function createEvent(PiggyBank $piggyBank, $amount)
+ public function createEvent(PiggyBank $piggyBank, string $amount)
{
PiggyBankEvent::create(['date' => Carbon::now(), 'amount' => $amount, 'piggy_bank_id' => $piggyBank->id]);
@@ -107,7 +107,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
*
* @return void
*/
- public function setOrder($piggyBankId, $order)
+ public function setOrder(int $piggyBankId, int $order)
{
$piggyBank = PiggyBank::leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', Auth::user()->id)
->where('piggy_banks.id', $piggyBankId)->first(['piggy_banks.*']);
diff --git a/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php b/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php
index 8d0f81b654..3ce36c36b6 100644
--- a/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php
+++ b/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php
@@ -15,11 +15,11 @@ interface PiggyBankRepositoryInterface
/**
* @param PiggyBank $piggyBank
- * @param $amount
+ * @param string $amount
*
* @return bool
*/
- public function createEvent(PiggyBank $piggyBank, $amount);
+ public function createEvent(PiggyBank $piggyBank, string $amount);
/**
* @param PiggyBank $piggyBank
@@ -68,7 +68,7 @@ interface PiggyBankRepositoryInterface
*
* @return void
*/
- public function setOrder($piggyBankId, $order);
+ public function setOrder(int $piggyBankId, int $order);
/**
diff --git a/app/Support/Amount.php b/app/Support/Amount.php
index a9ecd74414..8bdabed408 100644
--- a/app/Support/Amount.php
+++ b/app/Support/Amount.php
@@ -18,12 +18,12 @@ class Amount
{
/**
- * @param $amount
- * @param bool $coloured
+ * @param string $amount
+ * @param bool $coloured
*
* @return string
*/
- public function format($amount, $coloured = true)
+ public function format(string $amount, bool $coloured = true)
{
return $this->formatAnything($this->getDefaultCurrency(), $amount, $coloured);
}
@@ -33,16 +33,17 @@ class Amount
* as a currency, given two things: the currency required and the current locale.
*
* @param TransactionCurrency $format
- * @param $amount
+ * @param string $amount
* @param bool $coloured
*
* @return string
*/
- public function formatAnything(TransactionCurrency $format, $amount, $coloured = true)
+ public function formatAnything(TransactionCurrency $format, string $amount, bool $coloured = true)
{
$locale = setlocale(LC_MONETARY, 0);
+ $float = floatval($amount);
$formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY);
- $result = $formatter->formatCurrency($amount, $format->code);
+ $result = $formatter->formatCurrency($float, $format->code);
if ($coloured === true) {
if ($amount == 0) {
@@ -66,7 +67,7 @@ class Amount
*
* @return string
*/
- public function formatJournal(TransactionJournal $journal, $coloured = true)
+ public function formatJournal(TransactionJournal $journal, bool $coloured = true)
{
$cache = new CacheProperties;
$cache->addProperty($journal->id);
@@ -101,7 +102,7 @@ class Amount
*
* @return string
*/
- public function formatTransaction(Transaction $transaction, $coloured = true)
+ public function formatTransaction(Transaction $transaction, bool $coloured = true)
{
$currency = $transaction->transactionJournal->transactionCurrency;
@@ -115,7 +116,7 @@ class Amount
*
* @return string
*/
- public function formatWithSymbol($symbol, $amount, $coloured = true)
+ public function formatWithSymbol(string $symbol, string $amount, $coloured = true)
{
return $this->formatAnything($this->getDefaultCurrency(), $amount, $coloured);
}
diff --git a/app/Support/Binder/AccountList.php b/app/Support/Binder/AccountList.php
index b9cbde52ae..045275fe18 100644
--- a/app/Support/Binder/AccountList.php
+++ b/app/Support/Binder/AccountList.php
@@ -13,6 +13,7 @@ namespace FireflyIII\Support\Binder;
use Auth;
use FireflyIII\Models\Account;
+use Illuminate\Support\Collection;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
@@ -27,7 +28,7 @@ class AccountList implements BinderInterface
* @param $value
* @param $route
*
- * @return mixed
+ * @return Collection
*/
public static function routeBinder($value, $route)
{
diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.php
index 302e26aaa6..62eec09fb4 100644
--- a/app/Support/ExpandedForm.php
+++ b/app/Support/ExpandedForm.php
@@ -26,7 +26,7 @@ class ExpandedForm
*
* @return string
*/
- public function amount($name, $value = null, array $options = [])
+ public function amount(string $name, $value = null, array $options = [])
{
$label = $this->label($name, $options);
$options = $this->expandOptionArray($name, $label, $options);
@@ -51,7 +51,7 @@ class ExpandedForm
*
* @return string
*/
- public function balance($name, $value = null, array $options = [])
+ public function balance(string $name, $value = null, array $options = [])
{
$label = $this->label($name, $options);
$options = $this->expandOptionArray($name, $label, $options);
@@ -75,7 +75,7 @@ class ExpandedForm
*
* @return string
*/
- public function checkbox($name, $value = 1, $checked = null, $options = [])
+ public function checkbox(string $name, $value = 1, $checked = null, $options = [])
{
$options['checked'] = $checked === true ? true : null;
$label = $this->label($name, $options);
@@ -97,7 +97,7 @@ class ExpandedForm
*
* @return string
*/
- public function date($name, $value = null, array $options = [])
+ public function date(string $name, $value = null, array $options = [])
{
$label = $this->label($name, $options);
$options = $this->expandOptionArray($name, $label, $options);
@@ -115,7 +115,7 @@ class ExpandedForm
*
* @return string
*/
- public function file($name, array $options = [])
+ public function file(string $name, array $options = [])
{
$label = $this->label($name, $options);
$options = $this->expandOptionArray($name, $label, $options);
@@ -133,7 +133,7 @@ class ExpandedForm
*
* @return string
*/
- public function integer($name, $value = null, array $options = [])
+ public function integer(string $name, $value = null, array $options = [])
{
$label = $this->label($name, $options);
$options = $this->expandOptionArray($name, $label, $options);
@@ -153,7 +153,7 @@ class ExpandedForm
*
* @return string
*/
- public function location($name, $value = null, array $options = [])
+ public function location(string $name, $value = null, array $options = [])
{
$label = $this->label($name, $options);
$options = $this->expandOptionArray($name, $label, $options);
@@ -174,7 +174,7 @@ class ExpandedForm
*
* @return mixed
*/
- public function makeSelectList(Collection $set, $addEmpty = false)
+ public function makeSelectList(Collection $set, bool $addEmpty = false)
{
$selectList = [];
if ($addEmpty) {
@@ -205,7 +205,7 @@ class ExpandedForm
*
* @return string
*/
- public function multiCheckbox($name, array $list = [], $selected = null, array $options = [])
+ public function multiCheckbox(string $name, array $list = [], $selected = null, array $options = [])
{
$label = $this->label($name, $options);
$options = $this->expandOptionArray($name, $label, $options);
@@ -226,7 +226,7 @@ class ExpandedForm
*
* @return string
*/
- public function multiRadio($name, array $list = [], $selected = null, array $options = [])
+ public function multiRadio(string $name, array $list = [], $selected = null, array $options = [])
{
$label = $this->label($name, $options);
$options = $this->expandOptionArray($name, $label, $options);
@@ -271,7 +271,7 @@ class ExpandedForm
*
* @return string
*/
- public function select($name, array $list = [], $selected = null, array $options = [])
+ public function select(string $name, array $list = [], $selected = null, array $options = [])
{
$label = $this->label($name, $options);
$options = $this->expandOptionArray($name, $label, $options);
diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php
index 8ddcc82c0f..9e0ca7d4e7 100644
--- a/app/Support/Twig/General.php
+++ b/app/Support/Twig/General.php
@@ -67,25 +67,68 @@ class General extends Twig_Extension
}
/**
- * @return Twig_SimpleFilter
+ * Will return "active" when a part of the route matches the argument.
+ * ie. "accounts" will match "accounts.index".
+ *
+ * @return Twig_SimpleFunction
*/
- protected function formatFilesize()
+ protected function activeRoutePartial()
{
- return new Twig_SimpleFilter(
- 'filesize', function ($size) {
- $size = intval($size);
+ return new Twig_SimpleFunction(
+ 'activeRoutePartial', function () {
+ $args = func_get_args();
+ $route = $args[0]; // name of the route.
+ if (!(strpos(Route::getCurrentRoute()->getName(), $route) === false)) {
+ return 'active';
+ }
- // less than one GB, more than one MB
- if ($size < (1024 * 1024 * 2014) && $size >= (1024 * 1024)) {
- return round($size / (1024 * 1024), 2) . ' MB';
+ return '';
+ }
+ );
+ }
+
+ /**
+ * This function will return "active" when the current route matches the first argument (even partly)
+ * but, the variable $what has been set and matches the second argument.
+ *
+ * @return Twig_SimpleFunction
+ */
+ protected function activeRoutePartialWhat()
+ {
+ return new Twig_SimpleFunction(
+ 'activeRoutePartialWhat', function ($context) {
+ $args = func_get_args();
+ $route = $args[1]; // name of the route.
+ $what = $args[2]; // name of the route.
+ $activeWhat = $context['what'] ?? false;
+
+ if ($what == $activeWhat && !(strpos(Route::getCurrentRoute()->getName(), $route) === false)) {
+ return 'active';
}
- // less than one MB
- if ($size < (1024 * 1024)) {
- return round($size / 1024, 2) . ' KB';
+ return '';
+ }, ['needs_context' => true]
+ );
+ }
+
+ /**
+ * Will return "active" when the current route matches the given argument
+ * exactly.
+ *
+ * @return Twig_SimpleFunction
+ */
+ protected function activeRouteStrict()
+ {
+ return new Twig_SimpleFunction(
+ 'activeRouteStrict', function () {
+ $args = func_get_args();
+ $route = $args[0]; // name of the route.
+
+ if (Route::getCurrentRoute()->getName() == $route) {
+ return 'active';
}
- return $size . ' bytes';
+ return '';
}
);
}
@@ -93,20 +136,29 @@ class General extends Twig_Extension
/**
* @return Twig_SimpleFilter
*/
- protected function mimeIcon()
+ protected function balance()
{
return new Twig_SimpleFilter(
- 'mimeIcon', function ($string) {
- switch ($string) {
- default:
- return 'fa-file-o';
- case 'application/pdf':
- return 'fa-file-pdf-o';
- case 'image/png':
- case 'image/jpeg':
- return 'fa-file-image-o';
+ 'balance', function (Account $account = null) {
+ if (is_null($account)) {
+ return 'NULL';
}
- }, ['is_safe' => ['html']]
+ $date = session('end', Carbon::now()->endOfMonth());
+
+ return app('steam')->balance($account, $date);
+ }
+ );
+ }
+
+ /**
+ * @return Twig_SimpleFunction
+ */
+ protected function env()
+ {
+ return new Twig_SimpleFunction(
+ 'env', function ($name, $default) {
+ return env($name, $default);
+ }
);
}
@@ -117,7 +169,9 @@ class General extends Twig_Extension
{
return new Twig_SimpleFilter(
'formatAmount', function ($string) {
- return app('amount')->format($string);
+ $value = is_null($string) ? '0' : $string;
+
+ return app('amount')->format($value);
}, ['is_safe' => ['html']]
);
}
@@ -125,11 +179,11 @@ class General extends Twig_Extension
/**
* @return Twig_SimpleFilter
*/
- protected function formatTransaction()
+ protected function formatAmountPlain()
{
return new Twig_SimpleFilter(
- 'formatTransaction', function (Transaction $transaction) {
- return app('amount')->formatTransaction($transaction);
+ 'formatAmountPlain', function ($string) {
+ return app('amount')->format($string, false);
}, ['is_safe' => ['html']]
);
}
@@ -137,12 +191,24 @@ class General extends Twig_Extension
/**
* @return Twig_SimpleFilter
*/
- protected function formatAmountPlain()
+ protected function formatFilesize()
{
return new Twig_SimpleFilter(
- 'formatAmountPlain', function ($string) {
- return app('amount')->format($string, false);
- }, ['is_safe' => ['html']]
+ 'filesize', function ($size) {
+ $size = intval($size);
+
+ // less than one GB, more than one MB
+ if ($size < (1024 * 1024 * 2014) && $size >= (1024 * 1024)) {
+ return round($size / (1024 * 1024), 2) . ' MB';
+ }
+
+ // less than one MB
+ if ($size < (1024 * 1024)) {
+ return round($size / 1024, 2) . ' KB';
+ }
+
+ return $size . ' bytes';
+ }
);
}
@@ -161,17 +227,12 @@ class General extends Twig_Extension
/**
* @return Twig_SimpleFilter
*/
- protected function balance()
+ protected function formatTransaction()
{
return new Twig_SimpleFilter(
- 'balance', function (Account $account = null) {
- if (is_null($account)) {
- return 'NULL';
- }
- $date = session('end', Carbon::now()->endOfMonth());
-
- return app('steam')->balance($account, $date);
- }
+ 'formatTransaction', function (Transaction $transaction) {
+ return app('amount')->formatTransaction($transaction);
+ }, ['is_safe' => ['html']]
);
}
@@ -212,94 +273,35 @@ class General extends Twig_Extension
}
/**
- * @return Twig_SimpleFunction
- */
- protected function phpdate()
- {
- return new Twig_SimpleFunction(
- 'phpdate', function ($str) {
- return date($str);
- }
- );
- }
-
- /**
- * @return Twig_SimpleFunction
- */
- protected function env()
- {
- return new Twig_SimpleFunction(
- 'env', function ($name, $default) {
- return env($name, $default);
- }
- );
- }
-
- /**
- * Will return "active" when the current route matches the given argument
- * exactly.
- *
- * @return Twig_SimpleFunction
+ * @return Twig_SimpleFilter
*/
- protected function activeRouteStrict()
+ protected function mimeIcon()
{
- return new Twig_SimpleFunction(
- 'activeRouteStrict', function () {
- $args = func_get_args();
- $route = $args[0]; // name of the route.
-
- if (Route::getCurrentRoute()->getName() == $route) {
- return 'active';
+ return new Twig_SimpleFilter(
+ 'mimeIcon', function ($string) {
+ switch ($string) {
+ default:
+ return 'fa-file-o';
+ case 'application/pdf':
+ return 'fa-file-pdf-o';
+ case 'image/png':
+ case 'image/jpeg':
+ return 'fa-file-image-o';
}
-
- return '';
- }
+ }, ['is_safe' => ['html']]
);
}
/**
- * Will return "active" when a part of the route matches the argument.
- * ie. "accounts" will match "accounts.index".
- *
* @return Twig_SimpleFunction
*/
- protected function activeRoutePartial()
+ protected function phpdate()
{
return new Twig_SimpleFunction(
- 'activeRoutePartial', function () {
- $args = func_get_args();
- $route = $args[0]; // name of the route.
- if (!(strpos(Route::getCurrentRoute()->getName(), $route) === false)) {
- return 'active';
- }
-
- return '';
+ 'phpdate', function ($str) {
+ return date($str);
}
);
}
- /**
- * This function will return "active" when the current route matches the first argument (even partly)
- * but, the variable $what has been set and matches the second argument.
- *
- * @return Twig_SimpleFunction
- */
- protected function activeRoutePartialWhat()
- {
- return new Twig_SimpleFunction(
- 'activeRoutePartialWhat', function ($context) {
- $args = func_get_args();
- $route = $args[1]; // name of the route.
- $what = $args[2]; // name of the route.
- $activeWhat = $context['what'] ?? false;
-
- if ($what == $activeWhat && !(strpos(Route::getCurrentRoute()->getName(), $route) === false)) {
- return 'active';
- }
-
- return '';
- }, ['needs_context' => true]
- );
- }
-
}
diff --git a/composer.json b/composer.json
index d2b90cbf55..152fb7130e 100644
--- a/composer.json
+++ b/composer.json
@@ -26,13 +26,14 @@
},
"require-dev": {
"fzaninotto/faker": "~1.4",
- "mockery/mockery": "0.9.*",
+ "mockery/mockery": "dev-master",
"phpunit/phpunit": "~4.0",
"symfony/css-selector": "2.8.*|3.0.*",
"symfony/dom-crawler": "2.8.*|3.0.*",
"barryvdh/laravel-debugbar": "@stable",
"barryvdh/laravel-ide-helper": "~2.0",
- "johnkary/phpunit-speedtrap": "^1.0"
+ "johnkary/phpunit-speedtrap": "^1.0",
+ "hamcrest/hamcrest-php": "^2.0@dev"
},
"autoload": {
"classmap": [
diff --git a/storage/build/test-upload.csv b/storage/build/test-upload.csv
index 1ad0102bb6..b77b81d550 100644
--- a/storage/build/test-upload.csv
+++ b/storage/build/test-upload.csv
@@ -1,63 +1,3 @@
-NL11XOLA6707795988,NL10TAPT8906262744,"Suspendisse tempus eros euismod leo consequat, non malesuada arcu pretium.",20160123,15.03,gifts,holiday
-NL11XOLA6707795988,NL93UPSZ1261542703,"Morbi quis mauris nec tortor egestas blandit.",20160123,47.38,groceries,studies
-NL11XOLA6707795988,NL86IHAL3264575116,"Proin eleifend magna et ante cursus laoreet.",20160123,43.73,"books and such",groceries
-NL11XOLA6707795988,NL63BKBO9993148806,"In scelerisque velit eget ante pharetra pretium.",20160123,39.21,dinner,holiday
-NL11XOLA6707795988,NL22EZVA6611573534,"Donec tincidunt nibh nec diam sodales, feugiat pulvinar ante consequat.",20160123,24.77,taxes,holiday
-NL11XOLA6707795988,NL40KZVR5107424627,"Nam in purus porta, accumsan felis vitae, bibendum leo.",20160123,17.19,dinner,clothes
-NL11XOLA6707795988,NL29RHEE6437366575,"Suspendisse tempus eros euismod leo consequat, non malesuada arcu pretium.",20160123,43.14,cash,studies
-NL11XOLA6707795988,NL63IEPJ7437420074,"Nunc sed leo scelerisque quam consectetur elementum quis consequat dui.",20160123,35.25,gifts,bills
-NL11XOLA6707795988,NL62HQWJ8837203470,"Aenean dictum sem pellentesque, semper est eget, ultricies magna.",20160123,42.07,taxes,holiday
-NL11XOLA6707795988,NL89FPEA1494900858,"Vivamus ultrices tortor vel semper lacinia.",20160123,25.31,gifts,groceries
-NL11XOLA6707795988,NL76MDMU3222445567,"In scelerisque velit eget ante pharetra pretium.",20160123,41.76,cash,clothes
-NL11XOLA6707795988,NL07TDQA3309954056,"Curabitur vitae nisi consectetur, feugiat ipsum vitae, hendrerit sem.",20160123,10.81,food,studies
-NL11XOLA6707795988,NL35MKIY9736938778,"Aenean dictum sem pellentesque, semper est eget, ultricies magna.",20160123,46.82,"books and such",bills
-NL11XOLA6707795988,NL63IEPJ7437420074,"Nullam malesuada orci in vulputate imperdiet.",20160123,10.3,groceries,studies
-NL11XOLA6707795988,NL56DNGY5455310496,"Morbi quis mauris nec tortor egestas blandit.",20160123,22.39,bike,bills
-NL11XOLA6707795988,NL17LKFR7594179781,"Vivamus ultrices tortor vel semper lacinia.",20160123,11.45,gifts,clothes
-NL11XOLA6707795988,NL76UJQI9524250446,"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",20160123,49.23,bike,studies
-NL11XOLA6707795988,NL45YTPP6157249080,"Curabitur vitae nisi consectetur, feugiat ipsum vitae, hendrerit sem.",20160123,22.6,cash,"other stuff"
-NL11XOLA6707795988,NL46TFVH5548690248,"Nam in purus porta, accumsan felis vitae, bibendum leo.",20160123,44.34,bike,holiday
-NL11XOLA6707795988,NL79XZWN0846248670,"Donec tincidunt nibh nec diam sodales, feugiat pulvinar ante consequat.",20160123,12.96,car,groceries
-NL11XOLA6707795988,NL52MKIO8325583045,"Duis fringilla libero eget quam pharetra, non gravida ex fermentum.",20160123,44.47,taxes,bills
-NL11XOLA6707795988,NL47YVJU4419567422,"Curabitur vitae nisi consectetur, feugiat ipsum vitae, hendrerit sem.",20160123,17.51,car,bills
-NL11XOLA6707795988,NL04TNIP4218080631,"Suspendisse tempus eros euismod leo consequat, non malesuada arcu pretium.",20160123,17.36,cash,groceries
-NL11XOLA6707795988,NL68SOAC3516744723,"In scelerisque velit eget ante pharetra pretium.",20160123,34.22,taxes,groceries
-NL11XOLA6707795988,NL53YVTS7223912863,"Nam in purus porta, accumsan felis vitae, bibendum leo.",20160123,27.9,food,"other stuff"
-NL11XOLA6707795988,NL40QRBS9553175317,"Vivamus ultrices tortor vel semper lacinia.",20160123,-10.86,groceries,holiday
-NL11XOLA6707795988,NL79XZWN0846248670,"Duis fringilla libero eget quam pharetra, non gravida ex fermentum.",20160123,-19.57,bike,household
-NL11XOLA6707795988,NL54TZNZ2922111989,"Pellentesque sit amet enim ac tortor euismod ullamcorper vel et massa.",20160123,-12.05,cash,holiday
-NL11XOLA6707795988,NL04BAGX3284775110,"Aenean dictum sem pellentesque, semper est eget, ultricies magna.",20160123,-15.98,groceries,bills
-NL11XOLA6707795988,NL49LULH7261231215,"Nam in purus porta, accumsan felis vitae, bibendum leo.",20160123,-35.67,food,clothes
-NL11XOLA6707795988,NL11YHMI8046080217,"Nunc sed leo scelerisque quam consectetur elementum quis consequat dui.",20160123,-48.94,dinner,clothes
-NL11XOLA6707795988,NL89BXNF2470379032,"Aenean dictum sem pellentesque, semper est eget, ultricies magna.",20160123,-33.82,taxes,holiday
-NL11XOLA6707795988,NL74SHGG7300113478,"In scelerisque velit eget ante pharetra pretium.",20160123,-17.36,food,"other stuff"
-NL11XOLA6707795988,NL48ZPLO1718215436,"Duis fringilla libero eget quam pharetra, non gravida ex fermentum.",20160123,-19.31,food,holiday
-NL11XOLA6707795988,NL13BJMO5341591615,"Pellentesque sit amet enim ac tortor euismod ullamcorper vel et massa.",20160123,-28.47,groceries,"other stuff"
-NL11XOLA6707795988,NL59PKVU0116767154,"Proin eleifend magna et ante cursus laoreet.",20160123,-39.24,taxes,"other stuff"
-NL11XOLA6707795988,NL72BQRL1220175315,"Nulla in neque sed velit ultricies placerat.",20160123,-17.53,groceries,bills
-NL11XOLA6707795988,NL53QHDG0329036955,"Nulla a dui euismod nulla convallis dictum.",20160123,-39.45,"books and such",holiday
-NL11XOLA6707795988,NL29RHEE6437366575,"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",20160123,-23.47,food,studies
-NL11XOLA6707795988,NL48BLDJ9721843563,"Curabitur vitae nisi consectetur, feugiat ipsum vitae, hendrerit sem.",20160123,-16.56,food,"other stuff"
-NL11XOLA6707795988,NL48BHXI9733658006,"Nulla in neque sed velit ultricies placerat.",20160123,-21.89,gifts,household
-NL11XOLA6707795988,NL33VPSU8067103542,"Duis fringilla libero eget quam pharetra, non gravida ex fermentum.",20160123,-11.71,groceries,clothes
-NL11XOLA6707795988,NL62UDLY8957139303,"Nunc sed leo scelerisque quam consectetur elementum quis consequat dui.",20160123,-38.08,gifts,groceries
-NL11XOLA6707795988,NL28EDMD2653501341,"Aenean dictum sem pellentesque, semper est eget, ultricies magna.",20160123,-39.57,cash,holiday
-NL11XOLA6707795988,NL92QMZD6854625548,"Duis fringilla libero eget quam pharetra, non gravida ex fermentum.",20160123,-48.8,car,groceries
-NL11XOLA6707795988,NL37VSLJ0853659915,"Nulla a dui euismod nulla convallis dictum.",20160123,-34.55,bike,household
-NL11XOLA6707795988,NL95NQHS4363870109,"Suspendisse tempus eros euismod leo consequat, non malesuada arcu pretium.",20160123,-34.95,dinner,studies
-NL11XOLA6707795988,NL81LEJP9477634344,"Vivamus ultrices tortor vel semper lacinia.",20160123,-13.18,dinner,"other stuff"
-NL11XOLA6707795988,NL14JYVJ1041891180,"Curabitur vitae nisi consectetur, feugiat ipsum vitae, hendrerit sem.",20160123,-12.79,groceries,bills
-NL11XOLA6707795988,NL57SPBS0788124528,"Nam in purus porta, accumsan felis vitae, bibendum leo.",20160123,-35.53,bike,groceries
-NL11XOLA6707795988,NL96DZCO4665940223,"Proin eleifend magna et ante cursus laoreet.",20160123,34.41,groceries,
-NL11XOLA6707795988,NL96DZCO4665940223,"Curabitur vitae nisi consectetur, feugiat ipsum vitae, hendrerit sem.",20160123,35.8,groceries,
-NL11XOLA6707795988,NL96DZCO4665940223,"Nam in purus porta, accumsan felis vitae, bibendum leo.",20160123,22.46,car,
-NL11XOLA6707795988,NL96DZCO4665940223,"Nam in purus porta, accumsan felis vitae, bibendum leo.",20160123,43.74,bike,
-NL11XOLA6707795988,NL96DZCO4665940223,"Aenean dictum sem pellentesque, semper est eget, ultricies magna.",20160123,28.68,dinner,
-NL11XOLA6707795988,NL96DZCO4665940223,"Duis fringilla libero eget quam pharetra, non gravida ex fermentum.",20160123,32.36,car,
-NL11XOLA6707795988,NL96DZCO4665940223,"Nam in purus porta, accumsan felis vitae, bibendum leo.",20160123,37.76,groceries,
-NL11XOLA6707795988,NL96DZCO4665940223,"Nulla in neque sed velit ultricies placerat.",20160123,19.98,"books and such",
-NL11XOLA6707795988,NL96DZCO4665940223,"Aenean dictum sem pellentesque, semper est eget, ultricies magna.",20160123,26.57,gifts,
-NL11XOLA6707795988,NL96DZCO4665940223,"Morbi quis mauris nec tortor egestas blandit.",20160123,12.09,"books and such",
NL11XOLA6707795988,NL96DZCO4665940223,"Vivamus ultrices tortor vel semper lacinia.",20160123,34.96,dinner,
NL11XOLA6707795988,NL96DZCO4665940223,"Nullam malesuada orci in vulputate imperdiet.",20160123,16.62,food,
NL11XOLA6707795988,NL96DZCO4665940223,"Nulla a dui euismod nulla convallis dictum.",20160123,31.14,car,