Completed
Pull Request — master (#17)
by Fèvre
04:45 queued 02:31
created

ResetPasswordController::sendResetResponse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
namespace Xetaravel\Http\Controllers\Auth;
3
4
use Illuminate\Foundation\Auth\ResetsPasswords;
5
use Illuminate\Http\Request;
6
use Xetaravel\Http\Controllers\Controller;
7
8
class ResetPasswordController extends Controller
9
{
10
    /*
11
    |--------------------------------------------------------------------------
12
    | Password Reset Controller
13
    |--------------------------------------------------------------------------
14
    |
15
    | This controller is responsible for handling password reset requests
16
    | and uses a simple trait to include this behavior. You're free to
17
    | explore this trait and override any methods you wish to tweak.
18
    |
19
    */
20
    use ResetsPasswords;
21
22
    /**
23
     * Where to redirect users after resetting their password.
24
     *
25
     * @var string
26
     */
27
    protected $redirectTo = '/';
28
29
    /**
30
     * Create a new controller instance.
31
     */
32
    public function __construct()
33
    {
34
        $this->middleware('guest');
35
    }
36
37
    /**
38
     * Display the password reset view for the given token.
39
     *
40
     * If no token is present, display the link request form.
41
     *
42
     * @param  \Illuminate\Http\Request  $request
43
     * @param  string|null  $token
44
     *
45
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
46
     */
47
    public function showResetForm(Request $request, $token = null)
48
    {
49
        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...
50
            ['token' => $token, 'email' => $request->email]
51
        );
52
    }
53
54
    /**
55
     * Get the response for a successful password reset.
56
     *
57
     * @param  string  $response
58
     *
59
     * @return \Illuminate\Http\RedirectResponse
60
     */
61
    protected function sendResetResponse($response)
62
    {
63
        return redirect($this->redirectPath())
64
            ->with('success', $response);
65
    }
66
}
67