Various small optimisations [skip ci]

This commit is contained in:
James Cole
2017-01-05 10:06:46 +01:00
parent a872cf7061
commit 4538ef3cf9
6 changed files with 22 additions and 19 deletions

View File

@@ -65,7 +65,7 @@ class AccountController extends Controller
/** /**
* @param string $what * @param string $what
* *
* @return View * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory|View
*/ */
public function create(string $what = 'asset') public function create(string $what = 'asset')
{ {

View File

@@ -88,10 +88,11 @@ class AttachmentController extends Controller
} }
/** /**
* @param AttachmentRepositoryInterface $repository
* @param Attachment $attachment * @param Attachment $attachment
* *
* @return mixed
* @throws FireflyException * @throws FireflyException
*
*/ */
public function download(AttachmentRepositoryInterface $repository, Attachment $attachment) public function download(AttachmentRepositoryInterface $repository, Attachment $attachment)
{ {

View File

@@ -414,7 +414,7 @@ class PiggyBankController extends Controller
* @param PiggyBankFormRequest $request * @param PiggyBankFormRequest $request
* @param PiggyBank $piggyBank * @param PiggyBank $piggyBank
* *
* @return $this * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/ */
public function update(PiggyBankRepositoryInterface $repository, PiggyBankFormRequest $request, PiggyBank $piggyBank) public function update(PiggyBankRepositoryInterface $repository, PiggyBankFormRequest $request, PiggyBank $piggyBank)
{ {

View File

@@ -13,6 +13,7 @@ declare(strict_types = 1);
namespace FireflyIII\Http\Controllers; namespace FireflyIII\Http\Controllers;
use FireflyIII\Exceptions\ValidationException;
use FireflyIII\Http\Requests\DeleteAccountFormRequest; use FireflyIII\Http\Requests\DeleteAccountFormRequest;
use FireflyIII\Http\Requests\ProfileFormRequest; use FireflyIII\Http\Requests\ProfileFormRequest;
use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\Repositories\User\UserRepositoryInterface;
@@ -114,9 +115,11 @@ class ProfileController extends Controller
return redirect(route('profile.change-password')); return redirect(route('profile.change-password'));
} }
$result = $this->validatePassword($request->get('current_password'), $request->get('new_password'));
if (!($result === true)) { try {
Session::flash('error', $result); $this->validatePassword($request->get('current_password'), $request->get('new_password'));
} catch (ValidationException $e) {
Session::flash('error', $e->getMessage());
return redirect(route('profile.change-password')); return redirect(route('profile.change-password'));
} }
@@ -163,16 +166,16 @@ class ProfileController extends Controller
} }
/** /**
*
* @param string $old * @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) { if ($new === $old) {
return trans('firefly.should_change'); throw new ValidationException(strval(trans('firefly.should_change')));
} }
return true; return true;

View File

@@ -129,12 +129,11 @@ class Navigation
} }
/** /**
*
* @param \Carbon\Carbon $theCurrentEnd * @param \Carbon\Carbon $theCurrentEnd
* @param $repeatFreq * @param string $repeatFreq
* @param \Carbon\Carbon $maxDate * @param \Carbon\Carbon|null $maxDate
* *
* @return \Carbon\Carbon * @return Carbon
*/ */
public function endOfX(Carbon $theCurrentEnd, string $repeatFreq, Carbon $maxDate = null): Carbon public function endOfX(Carbon $theCurrentEnd, string $repeatFreq, Carbon $maxDate = null): Carbon
{ {

View File

@@ -85,7 +85,7 @@ class Preferences
/** /**
* @param \FireflyIII\User $user * @param \FireflyIII\User $user
* @param string $name * @param string $name
* @param string $default * @param null|string $default
* *
* @return \FireflyIII\Models\Preference|null * @return \FireflyIII\Models\Preference|null
*/ */