Skip to content

Firefly III: a personal finances manager

Various small optimisations [skip ci]

James Cole4538ef3cf996
diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php
index 8549e18907..af0fd7b24f 100644
--- a/app/Http/Controllers/AccountController.php
+++ b/app/Http/Controllers/AccountController.php
@@ -65,7 +65,7 @@ class AccountController extends Controller
/**
* @param string $what
*
- * @return View
+ * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory|View
*/
public function create(string $what = 'asset')
{
diff --git a/app/Http/Controllers/AttachmentController.php b/app/Http/Controllers/AttachmentController.php
index 0b5d09d776..8febccf3e4 100644
--- a/app/Http/Controllers/AttachmentController.php
+++ b/app/Http/Controllers/AttachmentController.php
@@ -88,10 +88,11 @@ class AttachmentController extends Controller
}
/**
- * @param Attachment $attachment
+ * @param AttachmentRepositoryInterface $repository
+ * @param Attachment $attachment
*
+ * @return mixed
* @throws FireflyException
- *
*/
public function download(AttachmentRepositoryInterface $repository, Attachment $attachment)
{
diff --git a/app/Http/Controllers/PiggyBankController.php b/app/Http/Controllers/PiggyBankController.php
index 3279328282..f67464f475 100644
--- a/app/Http/Controllers/PiggyBankController.php
+++ b/app/Http/Controllers/PiggyBankController.php
@@ -414,7 +414,7 @@ class PiggyBankController extends Controller
* @param PiggyBankFormRequest $request
* @param PiggyBank $piggyBank
*
- * @return $this
+ * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function update(PiggyBankRepositoryInterface $repository, PiggyBankFormRequest $request, PiggyBank $piggyBank)
{
diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php
index 30b0553d0b..aebec981cb 100644
--- a/app/Http/Controllers/ProfileController.php
+++ b/app/Http/Controllers/ProfileController.php
@@ -13,6 +13,7 @@ declare(strict_types = 1);
namespace FireflyIII\Http\Controllers;
+use FireflyIII\Exceptions\ValidationException;
use FireflyIII\Http\Requests\DeleteAccountFormRequest;
use FireflyIII\Http\Requests\ProfileFormRequest;
use FireflyIII\Repositories\User\UserRepositoryInterface;
@@ -114,9 +115,11 @@ class ProfileController extends Controller
return redirect(route('profile.change-password'));
}
- $result = $this->validatePassword($request->get('current_password'), $request->get('new_password'));
- if (!($result === true)) {
- Session::flash('error', $result);
+
+ try {
+ $this->validatePassword($request->get('current_password'), $request->get('new_password'));
+ } catch (ValidationException $e) {
+ Session::flash('error', $e->getMessage());
return redirect(route('profile.change-password'));
}
@@ -163,16 +166,16 @@ class ProfileController extends Controller
}
/**
- *
* @param string $old
- * @param string $new1
+ * @param string $new
*
- * @return string|bool
+ * @return bool
+ * @throws ValidationException
*/
- protected function validatePassword(string $old, string $new1)
+ protected function validatePassword(string $old, string $new): bool
{
- if ($new1 == $old) {
- return trans('firefly.should_change');
+ if ($new === $old) {
+ throw new ValidationException(strval(trans('firefly.should_change')));
}
return true;
diff --git a/app/Support/Navigation.php b/app/Support/Navigation.php
index 189b48437e..cbdeafbabc 100644
--- a/app/Support/Navigation.php
+++ b/app/Support/Navigation.php
@@ -129,12 +129,11 @@ class Navigation
}
/**
+ * @param \Carbon\Carbon $theCurrentEnd
+ * @param string $repeatFreq
+ * @param \Carbon\Carbon|null $maxDate
*
- * @param \Carbon\Carbon $theCurrentEnd
- * @param $repeatFreq
- * @param \Carbon\Carbon $maxDate
- *
- * @return \Carbon\Carbon
+ * @return Carbon
*/
public function endOfX(Carbon $theCurrentEnd, string $repeatFreq, Carbon $maxDate = null): Carbon
{
diff --git a/app/Support/Preferences.php b/app/Support/Preferences.php
index 8507f3d806..999b8847ef 100644
--- a/app/Support/Preferences.php
+++ b/app/Support/Preferences.php
@@ -85,7 +85,7 @@ class Preferences
/**
* @param \FireflyIII\User $user
* @param string $name
- * @param string $default
+ * @param null|string $default
*
* @return \FireflyIII\Models\Preference|null
*/