GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ResetPasswordController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 48
rs 10
c 1
b 0
f 0
wmc 3
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A showResetForm() 0 8 1
1
<?php
2
3
namespace Afrittella\BackProject\Http\Controllers\Auth;
4
5
use Afrittella\BackProject\Http\Controllers\Controller;
6
use Illuminate\Foundation\Auth\ResetsPasswords;
7
use Illuminate\Http\Request;
8
9
class ResetPasswordController extends Controller
10
{
11
    protected $data = []; // the information we send to the view
12
13
    /*
14
    |--------------------------------------------------------------------------
15
    | Password Reset Controller
16
    |--------------------------------------------------------------------------
17
    |
18
    | This controller is responsible for handling password reset requests
19
    | and uses a simple trait to include this behavior. You're free to
20
    | explore this trait and override any methods you wish to tweak.
21
    |
22
    */
23
24
    use ResetsPasswords;
25
26
    /**
27
     * Create a new controller instance.
28
     *
29
     */
30
    public function __construct()
31
    {
32
        $this->middleware('guest');
33
34
        // where to redirect after password was reset
35
        $this->redirectTo = property_exists($this, 'redirectTo') ? $this->redirectTo : config('back-project.route_prefix', 'admin').'/dashboard';
0 ignored issues
show
Bug introduced by
The property redirectTo does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
36
    }
37
38
    /**
39
     * Display the password reset view for the given token.
40
     *
41
     * If no token is present, display the link request form.
42
     *
43
     * @param \Illuminate\Http\Request $request
44
     * @param string|null              $token
45
     *
46
     * @return \Illuminate\Http\Response
47
     */
48
    public function showResetForm(Request $request, $token = null)
49
    {
50
        $this->data['title'] = trans('back-project::base.reset_password'); // set the page title
51
52
        return view('back-project::auth.passwords.reset', $this->data)->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...
53
            ['token' => $token, 'email' => $request->email]
54
        );
55
    }
56
}
57