Skip to content

Firefly III: a personal finances manager

These are the first commits that make FF require php 7.

James Cole554640c34544
diff --git a/app/Console/Commands/UpgradeFireflyInstructions.php b/app/Console/Commands/UpgradeFireflyInstructions.php
index bb99309c05..36c4d7f472 100644
--- a/app/Console/Commands/UpgradeFireflyInstructions.php
+++ b/app/Console/Commands/UpgradeFireflyInstructions.php
@@ -44,7 +44,7 @@ class UpgradeFireflyInstructions extends Command
//
$version = Config::get('firefly.version');
$config = Config::get('upgrade.text');
- $text = isset($config[$version]) ? $config[$version] : null;
+ $text = $config[$version] ?? null;
$this->line('+------------------------------------------------------------------------------+');
$this->line('');
diff --git a/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php b/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php
index db4b9ed1ad..95892049cc 100644
--- a/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php
+++ b/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php
@@ -137,7 +137,7 @@ class ChartJsAccountChartGenerator implements AccountChartGeneratorInterface
while ($end >= $current) {
$theDate = $current->format('Y-m-d');
- $balance = isset($range[$theDate]) ? $range[$theDate] : $previous;
+ $balance = $range[$theDate] ?? $previous;
$data['labels'][] = $current->formatLocalized($format);
$data['datasets'][0]['data'][] = $balance;
diff --git a/app/Helpers/Collection/BalanceLine.php b/app/Helpers/Collection/BalanceLine.php
index 0800010c42..f1debc6313 100644
--- a/app/Helpers/Collection/BalanceLine.php
+++ b/app/Helpers/Collection/BalanceLine.php
@@ -122,7 +122,7 @@ class BalanceLine
*/
public function leftOfRepetition()
{
- $start = isset($this->budget->amount) ? $this->budget->amount : 0;
+ $start = $this->budget->amount ?? 0;
/** @var BalanceEntry $balanceEntry */
foreach ($this->getBalanceEntries() as $balanceEntry) {
$start += $balanceEntry->getSpent();
diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php
index 0386f71819..e72a127a24 100644
--- a/app/Helpers/Csv/Importer.php
+++ b/app/Helpers/Csv/Importer.php
@@ -228,7 +228,7 @@ class Importer
$data = $this->getFiller(); // These fields are necessary to create a new transaction journal. Some are optional
foreach ($row as $index => $value) {
- $role = isset($this->roles[$index]) ? $this->roles[$index] : '_ignore';
+ $role = $this->roles[$index] ?? '_ignore';
$class = Config::get('csv.roles.' . $role . '.converter');
$field = Config::get('csv.roles.' . $role . '.field');
diff --git a/app/Helpers/Report/BudgetReportHelper.php b/app/Helpers/Report/BudgetReportHelper.php
index 3191a36665..fbd49a8c89 100644
--- a/app/Helpers/Report/BudgetReportHelper.php
+++ b/app/Helpers/Report/BudgetReportHelper.php
@@ -48,7 +48,7 @@ class BudgetReportHelper implements BudgetReportHelperInterface
return $rep->budget_id == $budget->id;
}
);
- $totalSpent = isset($allTotalSpent[$budget->id]) ? $allTotalSpent[$budget->id] : [];
+ $totalSpent = $allTotalSpent[$budget->id] ?? [];
// no repetition(s) for this budget:
if ($repetitions->count() == 0) {
diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.php
index e571535670..409c2bf72c 100644
--- a/app/Http/Controllers/Chart/CategoryController.php
+++ b/app/Http/Controllers/Chart/CategoryController.php
@@ -405,8 +405,8 @@ class CategoryController extends Controller
while ($start <= $end) {
$str = $start->format('Y-m-d');
- $spent = isset($spentArray[$str]) ? $spentArray[$str] : 0;
- $earned = isset($earnedArray[$str]) ? $earnedArray[$str] : 0;
+ $spent = $spentArray[$str] ?? 0;
+ $earned = $earnedArray[$str] ?? 0;
$date = Navigation::periodShow($start, '1D');
$entries->push([clone $start, $date, $spent, $earned]);
$start->addDay();
diff --git a/app/Http/Controllers/Chart/ReportController.php b/app/Http/Controllers/Chart/ReportController.php
index 43e0928f90..a4b558876c 100644
--- a/app/Http/Controllers/Chart/ReportController.php
+++ b/app/Http/Controllers/Chart/ReportController.php
@@ -133,7 +133,7 @@ class ReportController extends Controller
$count = 0;
while ($start < $end) {
$date = $start->format('Y-m');
- $currentIncome = isset($earned[$date]) ? $earned[$date] : 0;
+ $currentIncome = $earned[$date] ?? 0;
$currentExpense = isset($spent[$date]) ? ($spent[$date] * -1) : 0;
$income = bcadd($income, $currentIncome);
$expense = bcadd($expense, $currentExpense);
@@ -218,7 +218,7 @@ class ReportController extends Controller
while ($start < $end) {
// total income and total expenses:
$date = $start->format('Y-m');
- $incomeSum = isset($earned[$date]) ? $earned[$date] : 0;
+ $incomeSum = $earned[$date] ?? 0;
$expenseSum = isset($spent[$date]) ? ($spent[$date] * -1) : 0;
$entries->push([clone $start, $incomeSum, $expenseSum]);
diff --git a/app/Models/Tag.php b/app/Models/Tag.php
index 2ca139f9bd..a9b9e108d5 100644
--- a/app/Models/Tag.php
+++ b/app/Models/Tag.php
@@ -56,7 +56,7 @@ class Tag extends Model
}
// create it!
$fields['tagMode'] = 'nothing';
- $fields['description'] = isset($fields['description']) && !is_null($fields['description']) ? $fields['description'] : '';
+ $fields['description'] = $fields['description'] ?? '';
$tag = Tag::create($fields);
return $tag;
diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php
index c95751acf8..8ddcc82c0f 100644
--- a/app/Support/Twig/General.php
+++ b/app/Support/Twig/General.php
@@ -291,7 +291,7 @@ class General extends Twig_Extension
$args = func_get_args();
$route = $args[1]; // name of the route.
$what = $args[2]; // name of the route.
- $activeWhat = isset($context['what']) ? $context['what'] : false;
+ $activeWhat = $context['what'] ?? false;
if ($what == $activeWhat && !(strpos(Route::getCurrentRoute()->getName(), $route) === false)) {
return 'active';
diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php
index 29672b9645..4e18f0fa50 100644
--- a/app/Validation/FireflyValidator.php
+++ b/app/Validation/FireflyValidator.php
@@ -49,7 +49,7 @@ class FireflyValidator extends Validator
*/
public function validateBelongsToUser($attribute, $value, $parameters)
{
- $field = isset($parameters[1]) ? $parameters[1] : 'id';
+ $field = $parameters[1] ?? 'id';
$count = DB::table($parameters[0])->where('user_id', Auth::user()->id)->where($field, $value)->count();
@@ -105,8 +105,8 @@ class FireflyValidator extends Validator
// check if rule-action-value matches the thing.
if (is_array($this->data['rule-action'])) {
- $name = isset($this->data['rule-action'][$index]) ? $this->data['rule-action'][$index] : 'invalid';
- $value = isset($this->data['rule-action-value'][$index]) ? $this->data['rule-action-value'][$index] : false;
+ $name = $this->data['rule-action'][$index] ?? 'invalid';
+ $value = $this->data['rule-action-value'][$index] ?? false;
switch ($name) {
default:
Log::debug(' (' . $attribute . ') (index:' . $index . ') Name is "' . $name . '" so no action is taken.');
@@ -243,7 +243,7 @@ class FireflyValidator extends Validator
// exclude?
$table = $parameters[0];
$field = $parameters[1];
- $exclude = isset($parameters[2]) ? intval($parameters[2]) : 0;
+ $exclude = $parameters[2] ?? 0;
// get entries from table
$set = DB::table($table)->where('user_id', Auth::user()->id)
@@ -272,7 +272,7 @@ class FireflyValidator extends Validator
*/
public function validateUniquePiggyBankForUser($attribute, $value, $parameters)
{
- $exclude = isset($parameters[0]) ? $parameters[0] : null;
+ $exclude = $parameters[0] ?? null;
$query = DB::table('piggy_banks')->whereNull('piggy_banks.deleted_at')
->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', Auth::user()->id);
if (!is_null($exclude)) {
@@ -369,7 +369,7 @@ class FireflyValidator extends Validator
protected function validateByAccountTypeId($value, $parameters)
{
$type = AccountType::find($this->data['account_type_id'])->first();
- $ignore = isset($parameters[0]) ? intval($parameters[0]) : 0;
+ $ignore = $parameters[0] ?? 0;
$value = $this->tryDecrypt($value);
$set = Auth::user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)->get();
@@ -394,7 +394,7 @@ class FireflyValidator extends Validator
{
$search = Config::get('firefly.accountTypeByIdentifier.' . $this->data['what']);
$type = AccountType::whereType($search)->first();
- $ignore = isset($parameters[0]) ? intval($parameters[0]) : 0;
+ $ignore = $parameters[0] ?? 0;
$set = Auth::user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)->get();
/** @var Account $entry */
@@ -414,7 +414,7 @@ class FireflyValidator extends Validator
*/
private function getRuleTriggerName($index)
{
- return isset($this->data['rule-trigger'][$index]) ? $this->data['rule-trigger'][$index] : 'invalid';
+ return $this->data['rule-trigger'][$index] ?? 'invalid';
}
@@ -425,7 +425,7 @@ class FireflyValidator extends Validator
*/
private function getRuleTriggerValue($index)
{
- return isset($this->data['rule-trigger-value'][$index]) ? $this->data['rule-trigger-value'][$index] : '';
+ return $this->data['rule-trigger-value'][$index] ?? '';
}
}