Skip to content

Firefly III: a personal finances manager

Various code cleanup.

James Colee247aace8d43
diff --git a/app/Helpers/Collector/JournalCollector.php b/app/Helpers/Collector/JournalCollector.php
index eafacdc363..76f66a0019 100644
--- a/app/Helpers/Collector/JournalCollector.php
+++ b/app/Helpers/Collector/JournalCollector.php
@@ -709,7 +709,7 @@ class JournalCollector implements JournalCollectorInterface
*/
private function startQuery(): EloquentBuilder
{
-
+ /** @var EloquentBuilder $query */
$query = Transaction::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->leftJoin('transaction_currencies', 'transaction_currencies.id', 'transaction_journals.transaction_currency_id')
->leftJoin('transaction_types', 'transaction_types.id', 'transaction_journals.transaction_type_id')
diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php
index 28c9726917..2372e7e101 100644
--- a/app/Http/Controllers/AccountController.php
+++ b/app/Http/Controllers/AccountController.php
@@ -235,6 +235,7 @@ class AccountController extends Controller
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);
$subTitle = $account->name;
$range = Preferences::get('viewRange', '1M')->data;
+
$start = session('start', Navigation::startOfPeriod(new Carbon, $range));
$end = session('end', Navigation::endOfPeriod(new Carbon, $range));
$page = intval(Input::get('page')) === 0 ? 1 : intval(Input::get('page'));
diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php
index 189fc1f174..dd2b9ec905 100755
--- a/app/Http/Controllers/Auth/RegisterController.php
+++ b/app/Http/Controllers/Auth/RegisterController.php
@@ -96,7 +96,6 @@ class RegisterController extends Controller
$validator->getMessageBag()->add('email', (string)trans('validation.invalid_domain'));
event(new BlockedUseOfDomain($data['email'], $request->ip()));
- // $this->reportBlockedDomainRegistrationAttempt($data['email'], $request->ip());
$this->throwValidationException($request, $validator);
}
@@ -109,7 +108,6 @@ class RegisterController extends Controller
if (in_array($hash, $set)) {
$validator->getMessageBag()->add('email', (string)trans('validation.deleted_user'));
event(new BlockedUseOfEmail($data['email'], $request->ip()));
- //$this->reportBlockedDomainRegistrationAttempt($data['email'], $request->ip());
$this->throwValidationException($request, $validator);
}
@@ -217,31 +215,4 @@ class RegisterController extends Controller
return false;
}
- /**
- * Send a message home about a blocked domain and the address attempted to register.
- *
- * @param string $registrationMail
- * @param string $ipAddress
- */
- private function reportBlockedDomainRegistrationAttempt(string $registrationMail, string $ipAddress)
- {
- try {
- $email = env('SITE_OWNER', false);
- $parts = explode('@', $registrationMail);
- $domain = $parts[1];
- $fields = [
- 'email_address' => $registrationMail,
- 'blocked_domain' => $domain,
- 'ip' => $ipAddress,
- ];
-
- Mail::send(
- ['emails.blocked-registration-html', 'emails.blocked-registration-text'], $fields, function (Message $message) use ($email, $domain) {
- $message->to($email, $email)->subject('Blocked a registration attempt with domain ' . $domain . '.');
- }
- );
- } catch (Swift_TransportException $e) {
- Log::error($e->getMessage());
- }
- }
}
diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php
index 3cd14bbfe5..f1e20b369a 100644
--- a/app/Http/Controllers/Chart/AccountController.php
+++ b/app/Http/Controllers/Chart/AccountController.php
@@ -129,7 +129,7 @@ class AccountController extends Controller
}
}
arsort($chartData);
- $data = $this->generator->singleSet(trans('firefly.spent'), $chartData);
+ $data = $this->generator->singleSet(strval(trans('firefly.spent')), $chartData);
$cache->store($data);
return Response::json($data);
@@ -393,7 +393,7 @@ class AccountController extends Controller
}
arsort($chartData);
- $data = $this->generator->singleSet(trans('firefly.spent'), $chartData);
+ $data = $this->generator->singleSet(strval(trans('firefly.spent')), $chartData);
$cache->store($data);
return Response::json($data);
diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php
index b17bac12fe..4fcb736e0f 100644
--- a/app/Http/Controllers/Chart/BudgetController.php
+++ b/app/Http/Controllers/Chart/BudgetController.php
@@ -154,7 +154,7 @@ class BudgetController extends Controller
$cache->addProperty($end);
$cache->addProperty('chart.budget.frontpage');
if ($cache->has()) {
- //return Response::json($cache->get());
+ return Response::json($cache->get());
}
$budgets = $repository->getActiveBudgets();
$repetitions = $repository->getAllBudgetLimitRepetitions($start, $end);
@@ -394,7 +394,6 @@ class BudgetController extends Controller
'repetition_overspent' => $overspent,
'spent' => $spent,
];
- //$array = [$name, $left, $spent, $overspent, $amount, $spent];
}
return $return;
diff --git a/app/Http/Controllers/Report/CategoryController.php b/app/Http/Controllers/Report/CategoryController.php
index 475e0ce67f..0d5f3e3f07 100644
--- a/app/Http/Controllers/Report/CategoryController.php
+++ b/app/Http/Controllers/Report/CategoryController.php
@@ -99,12 +99,12 @@ class CategoryController extends Controller
}
/**
- * @param ReportHelperInterface $helper
- * @param Collection $accounts
- * @param Carbon $start
- * @param Carbon $end
+ * @param Collection $accounts
+ * @param Carbon $start
+ * @param Carbon $end
*
* @return mixed|string
+ * @internal param ReportHelperInterface $helper
*/
public function operations(Collection $accounts, Carbon $start, Carbon $end)
{
diff --git a/app/Http/Controllers/Report/OperationsController.php b/app/Http/Controllers/Report/OperationsController.php
index 5241e5f12a..3282e98d80 100644
--- a/app/Http/Controllers/Report/OperationsController.php
+++ b/app/Http/Controllers/Report/OperationsController.php
@@ -72,7 +72,7 @@ class OperationsController extends Controller
$cache->addProperty('income-report');
$cache->addProperty($accounts->pluck('id')->toArray());
if ($cache->has()) {
- //return $cache->get();
+ return $cache->get();
}
$income = $this->getIncomeReport($start, $end, $accounts);
diff --git a/app/Repositories/Budget/BudgetRepositoryInterface.php b/app/Repositories/Budget/BudgetRepositoryInterface.php
index 6161545760..30633beff9 100644
--- a/app/Repositories/Budget/BudgetRepositoryInterface.php
+++ b/app/Repositories/Budget/BudgetRepositoryInterface.php
@@ -112,8 +112,9 @@ interface BudgetRepositoryInterface
public function getInactiveBudgets(): Collection;
/**
- * @param Carbon $start
- * @param Carbon $end
+ * @param Collection $accounts
+ * @param Carbon $start
+ * @param Carbon $end
*
* @return array
*/
diff --git a/tests/acceptance/Controllers/Auth/TwoFactorControllerTest.php b/tests/acceptance/Controllers/Auth/TwoFactorControllerTest.php
index d23aeb4928..5661e5823c 100644
--- a/tests/acceptance/Controllers/Auth/TwoFactorControllerTest.php
+++ b/tests/acceptance/Controllers/Auth/TwoFactorControllerTest.php
@@ -13,7 +13,6 @@ namespace Auth;
use FireflyIII\Models\Preference;
use FireflyIII\Support\Facades\Preferences;
-use Google2FA;
use TestCase;
/**
@@ -46,7 +45,6 @@ class TwoFactorControllerTest extends TestCase
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthEnabled', false])->andReturn($falsePreference);
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret', null])->andReturn($secretPreference);
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->andReturn($secretPreference);
- //$has2faSecret = !is_null(Preferences::get('twoFactorAuthSecret'));
$this->call('get', route('two-factor.index'));
$this->assertResponseStatus(200);
}
@@ -65,7 +63,6 @@ class TwoFactorControllerTest extends TestCase
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthEnabled', false])->andReturn($truePreference);
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret', null])->andReturn($secretPreference);
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->andReturn($secretPreference);
- //$has2faSecret = !is_null(Preferences::get('twoFactorAuthSecret'));
$this->call('get', route('two-factor.lost'));
$this->assertResponseStatus(200);
}
diff --git a/tests/acceptance/Controllers/BudgetControllerTest.php b/tests/acceptance/Controllers/BudgetControllerTest.php
index e79442a55a..06d86c3bd1 100644
--- a/tests/acceptance/Controllers/BudgetControllerTest.php
+++ b/tests/acceptance/Controllers/BudgetControllerTest.php
@@ -36,7 +36,7 @@ class BudgetControllerTest extends TestCase
'amount' => 200,
];
$this->be($this->user());
- $this->call('post', route('budgets.amount', [1], $data));
+ $this->call('post', route('budgets.amount', [1]), $data);
$this->assertResponseStatus(200);
}
@@ -94,6 +94,8 @@ class BudgetControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\BudgetController::index
* @dataProvider dateRangeProvider
+ *
+ * @param string $range
*/
public function testIndex(string $range)
{
@@ -108,6 +110,8 @@ class BudgetControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\BudgetController::noBudget
* @dataProvider dateRangeProvider
+ *
+ * @param string $range
*/
public function testNoBudget(string $range)
{
@@ -135,6 +139,8 @@ class BudgetControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\BudgetController::show
* @dataProvider dateRangeProvider
+ *
+ * @param string $range
*/
public function testShow(string $range)
{
@@ -148,6 +154,8 @@ class BudgetControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\BudgetController::showByRepetition
* @dataProvider dateRangeProvider
+ *
+ * @param string $range
*/
public function testShowByRepetition(string $range)
{
diff --git a/tests/acceptance/Controllers/CategoryControllerTest.php b/tests/acceptance/Controllers/CategoryControllerTest.php
index d715dfc21c..d4cf7bb736 100644
--- a/tests/acceptance/Controllers/CategoryControllerTest.php
+++ b/tests/acceptance/Controllers/CategoryControllerTest.php
@@ -93,6 +93,8 @@ class CategoryControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\CategoryController::noCategory
* @dataProvider dateRangeProvider
+ *
+ * @param string $range
*/
public function testNoCategory(string $range)
{
@@ -107,6 +109,8 @@ class CategoryControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\CategoryController::show
* @dataProvider dateRangeProvider
+ *
+ * @param string $range
*/
public function testShow(string $range)
{
@@ -120,6 +124,8 @@ class CategoryControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\CategoryController::showByDate
* @dataProvider dateRangeProvider
+ *
+ * @param string $range
*/
public function testShowByDate(string $range)
{
diff --git a/tests/acceptance/Controllers/Chart/AccountControllerTest.php b/tests/acceptance/Controllers/Chart/AccountControllerTest.php
index 38ff8191bf..ab19fe167b 100644
--- a/tests/acceptance/Controllers/Chart/AccountControllerTest.php
+++ b/tests/acceptance/Controllers/Chart/AccountControllerTest.php
@@ -32,6 +32,8 @@ class AccountControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\Chart\AccountController::expenseAccounts
* @dataProvider dateRangeProvider
+ *
+ * @param string $range
*/
public function testExpenseAccounts(string $range)
{
@@ -44,6 +46,8 @@ class AccountControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\Chart\AccountController::expenseBudget
* @dataProvider dateRangeProvider
+ *
+ * @param string $range
*/
public function testExpenseBudget(string $range)
{
@@ -56,6 +60,8 @@ class AccountControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\Chart\AccountController::expenseCategory
* @dataProvider dateRangeProvider
+ *
+ * @param string $range
*/
public function testExpenseCategory(string $range)
{
@@ -68,6 +74,8 @@ class AccountControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\Chart\AccountController::frontpage
* @dataProvider dateRangeProvider
+ *
+ * @param string $range
*/
public function testFrontpage(string $range)
{
@@ -80,6 +88,8 @@ class AccountControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\Chart\AccountController::incomeCategory
* @dataProvider dateRangeProvider
+ *
+ * @param string $range
*/
public function testIncomeCategory(string $range)
{
@@ -92,6 +102,8 @@ class AccountControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\Chart\AccountController::period
* @dataProvider dateRangeProvider
+ *
+ * @param string $range
*/
public function testPeriod(string $range)
{
@@ -114,6 +126,8 @@ class AccountControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\Chart\AccountController::revenueAccounts
* @dataProvider dateRangeProvider
+ *
+ * @param string $range
*/
public function testRevenueAccounts(string $range)
{
@@ -126,6 +140,8 @@ class AccountControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\Chart\AccountController::single
* @dataProvider dateRangeProvider
+ *
+ * @param string $range
*/
public function testSingle(string $range)
{
diff --git a/tests/acceptance/Controllers/Chart/BillControllerTest.php b/tests/acceptance/Controllers/Chart/BillControllerTest.php
index 63b4644ee8..657c934f28 100644
--- a/tests/acceptance/Controllers/Chart/BillControllerTest.php
+++ b/tests/acceptance/Controllers/Chart/BillControllerTest.php
@@ -30,8 +30,10 @@ class BillControllerTest extends TestCase
}
/**
- * @covers \FireflyIII\Http\Controllers\Chart\BillController::frontpage
+ * @covers \FireflyIII\Http\Controllers\Chart\BillController::frontpage
* @dataProvider dateRangeProvider
+ *
+ * @param string $range
*/
public function testFrontpage(string $range)
{
diff --git a/tests/acceptance/Controllers/Chart/BudgetControllerTest.php b/tests/acceptance/Controllers/Chart/BudgetControllerTest.php
index 49e1a45c1e..a42033a4ef 100644
--- a/tests/acceptance/Controllers/Chart/BudgetControllerTest.php
+++ b/tests/acceptance/Controllers/Chart/BudgetControllerTest.php
@@ -30,8 +30,10 @@ class BudgetControllerTest extends TestCase
}
/**
- * @covers \FireflyIII\Http\Controllers\Chart\BudgetController::budget
+ * @covers \FireflyIII\Http\Controllers\Chart\BudgetController::budget
* @dataProvider dateRangeProvider
+ *
+ * @param string $range
*/
public function testBudget(string $range)
{
@@ -42,8 +44,10 @@ class BudgetControllerTest extends TestCase
}
/**
- * @covers \FireflyIII\Http\Controllers\Chart\BudgetController::budgetLimit
+ * @covers \FireflyIII\Http\Controllers\Chart\BudgetController::budgetLimit
* @dataProvider dateRangeProvider
+ *
+ * @param string $range
*/
public function testBudgetLimit(string $range)
{
@@ -54,8 +58,10 @@ class BudgetControllerTest extends TestCase
}
/**
- * @covers \FireflyIII\Http\Controllers\Chart\BudgetController::frontpage
+ * @covers \FireflyIII\Http\Controllers\Chart\BudgetController::frontpage
* @dataProvider dateRangeProvider
+ *
+ * @param string $range
*/
public function testFrontpage(string $range)
{
diff --git a/tests/acceptance/Controllers/Chart/CategoryControllerTest.php b/tests/acceptance/Controllers/Chart/CategoryControllerTest.php
index 74b258349a..13d91768ad 100644
--- a/tests/acceptance/Controllers/Chart/CategoryControllerTest.php
+++ b/tests/acceptance/Controllers/Chart/CategoryControllerTest.php
@@ -32,6 +32,8 @@ class CategoryControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\Chart\CategoryController::all
* @dataProvider dateRangeProvider
+ *
+ * @param string $range
*/
public function testAll(string $range)
{
@@ -44,6 +46,8 @@ class CategoryControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\Chart\CategoryController::currentPeriod
* @dataProvider dateRangeProvider
+ *
+ * @param string $range
*/
public function testCurrentPeriod(string $range)
{
@@ -56,6 +60,8 @@ class CategoryControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\Chart\CategoryController::frontpage
* @dataProvider dateRangeProvider
+ *
+ * @param string $range
*/
public function testFrontpage(string $range)
{
@@ -86,8 +92,10 @@ class CategoryControllerTest extends TestCase
}
/**
- * @covers \FireflyIII\Http\Controllers\Chart\CategoryController::specificPeriod
+ * @covers \FireflyIII\Http\Controllers\Chart\CategoryController::specificPeriod
* @dataProvider dateRangeProvider
+ *
+ * @param string $range
*/
public function testSpecificPeriod(string $range)
{