Completed
Pull Request — master (#17)
by Fèvre
02:48
created

ResetPasswordController::showResetForm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
namespace Xetaravel\Http\Controllers\Auth;
3
4
use Illuminate\Foundation\Auth\ResetsPasswords;
5
use Illuminate\Http\Request;
6
use Illuminate\Http\RedirectResponse;
7
use Illuminate\View\View;
8
use Xetaravel\Http\Controllers\Controller;
9
10
class ResetPasswordController extends Controller
11
{
12
    /*
13
    |--------------------------------------------------------------------------
14
    | Password Reset Controller
15
    |--------------------------------------------------------------------------
16
    |
17
    | This controller is responsible for handling password reset requests
18
    | and uses a simple trait to include this behavior. You're free to
19
    | explore this trait and override any methods you wish to tweak.
20
    |
21
    */
22
    use ResetsPasswords;
23
24
    /**
25
     * Where to redirect users after resetting their password.
26
     *
27
     * @var string
28
     */
29
    protected $redirectTo = '/';
30
31
    /**
32
     * Create a new controller instance.
33
     */
34
    public function __construct()
35
    {
36
        $this->middleware('guest');
37
    }
38
39
    /**
40
     * Display the password reset view for the given token.
41
     *
42
     * If no token is present, display the link request form.
43
     *
44
     * @param \Illuminate\Http\Request $request
45
     * @param string|null $token
46
     *
47
     * @return \Illuminate\View\View
48
     */
49
    public function showResetForm(Request $request, $token = null): View
50
    {
51
        return view('Auth.passwords.reset')->with(
0 ignored issues
show
Bug introduced by
The method with does only exist in Illuminate\View\View, but not in Illuminate\Contracts\View\Factory.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
52
            ['token' => $token, 'email' => $request->email]
53
        );
54
    }
55
56
    /**
57
     * Get the response for a successful password reset.
58
     *
59
     * @param string $response
60
     *
61
     * @return \Illuminate\Http\RedirectResponse
62
     */
63
    protected function sendResetResponse($response): RedirectResponse
0 ignored issues
show
Unused Code introduced by
The parameter $response is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
64
    {
65
        return redirect($this->redirectPath())
66
            ->with('success', 'Your password has been reset!');
67
    }
68
}
69