ResetPasswordController::showResetForm()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 4
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 2
1
<?php
2
3
namespace App\Http\Controllers\Auth;
4
5
use App\Http\Controllers\Controller;
6
use Illuminate\Foundation\Auth\ResetsPasswords;
7
use Illuminate\Http\Request;
8
9
class ResetPasswordController extends Controller
10
{
11
    /*
12
    |--------------------------------------------------------------------------
13
    | Password Reset Controller
14
    |--------------------------------------------------------------------------
15
    |
16
    | This controller is responsible for handling password reset requests
17
    | and uses a simple trait to include this behavior. You're free to
18
    | explore this trait and override any methods you wish to tweak.
19
    |
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
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
35
     */
36
    public function __construct()
37
    {
38
        $this->middleware('guest');
39
    }
40
41
    public function showResetForm(Request $request, $token = null)
42
    {
43
        return view('frontend.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...
44
            ['token' => $token, 'email' => $request->email]
45
        );
46
    }
47
}
48