Code cleanup

This commit is contained in:
James Cole
2018-04-02 15:10:40 +02:00
parent fa7ab45a40
commit a3c34e6b3c
151 changed files with 802 additions and 990 deletions

View File

@@ -73,7 +73,7 @@ class ForgotPasswordController extends Controller
// verify if the user is not a demo user. If so, we give him back an error.
$user = User::where('email', $request->get('email'))->first();
if (!is_null($user) && $repository->hasRole($user, 'demo')) {
if (null !== $user && $repository->hasRole($user, 'demo')) {
return back()->withErrors(['email' => trans('firefly.cannot_reset_demo_user')]);
}

View File

@@ -65,7 +65,6 @@ class LoginController extends Controller
*
* @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
*
* @throws \RuntimeException
* @throws \Illuminate\Validation\ValidationException
*/
public function login(Request $request)
@@ -103,7 +102,6 @@ class LoginController extends Controller
* @param CookieJar $cookieJar
*
* @return $this|\Illuminate\Http\RedirectResponse
* @throws \RuntimeException
*/
public function logout(Request $request, CookieJar $cookieJar)
{
@@ -121,7 +119,6 @@ class LoginController extends Controller
* @param Request $request
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @throws \RuntimeException
*/
public function showLoginForm(Request $request)
{

View File

@@ -83,7 +83,7 @@ class RegisterController extends Controller
$this->guard()->login($user);
Session::flash('success', strval(trans('firefly.registered')));
Session::flash('success', (string)trans('firefly.registered'));
return $this->registered($request, $user)
?: redirect($this->redirectPath());

View File

@@ -40,7 +40,6 @@ class TwoFactorController extends Controller
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
*
* @throws \RuntimeException
* @throws FireflyException
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
@@ -52,7 +51,7 @@ class TwoFactorController extends Controller
// to make sure the validator in the next step gets the secret, we push it in session
$secretPreference = Preferences::get('twoFactorAuthSecret', null);
$secret = null === $secretPreference ? null : $secretPreference->data;
$title = strval(trans('firefly.two_factor_title'));
$title = (string)trans('firefly.two_factor_title');
// make sure the user has two factor configured:
$has2FA = Preferences::get('twoFactorAuthEnabled', false)->data;
@@ -60,7 +59,7 @@ class TwoFactorController extends Controller
return redirect(route('index'));
}
if (0 === strlen(strval($secret))) {
if (0 === strlen((string)$secret)) {
throw new FireflyException('Your two factor authentication secret is empty, which it cannot be at this point. Please check the log files.');
}
$request->session()->flash('two-factor-secret', $secret);
@@ -75,7 +74,7 @@ class TwoFactorController extends Controller
{
$user = auth()->user();
$siteOwner = env('SITE_OWNER', '');
$title = strval(trans('firefly.two_factor_forgot_title'));
$title = (string)trans('firefly.two_factor_forgot_title');
Log::info(
'To reset the two factor authentication for user #' . $user->id .
@@ -92,7 +91,6 @@ class TwoFactorController extends Controller
*
* @return mixed
* @SuppressWarnings(PHPMD.UnusedFormalParameter) // it's unused but the class does some validation.
* @throws \RuntimeException
*/
public function postIndex(TokenFormRequest $request, CookieJar $cookieJar)
{