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.
Completed
Push — master ( a30bac...5b98f6 )
by Freek
01:09
created

WelcomeController::sendPasswordSavedResponse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Spatie\WelcomeNotification;
4
5
use Illuminate\Foundation\Auth\ResetsPasswords;
6
use Illuminate\Foundation\Auth\User;
7
use Illuminate\Http\Request;
8
use Symfony\Component\HttpFoundation\Response;
9
10
class WelcomeController
11
{
12
    use ResetsPasswords;
13
14
    public function showWelcomeForm(Request $request, string $userId, string $token = null)
15
    {
16
        if (! $user = User::find($userId)) {
17
            return $this->invalidLinkResponse();
18
        }
19
20
        if (! $this->broker()->tokenExists($user, $token)) {
21
            return $this->invalidLinkResponse();
22
        }
23
24
        return view('welcomeNotification::welcome')->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...
25
            'token' => $token,
26
            'email' => $request->email,
27
            'user' => $user,
28
        ]);
29
    }
30
31
    public function savePassword(Request $request)
32
    {
33
        return $this->reset($request);
34
    }
35
36
    protected function invalidLinkResponse()
37
    {
38
        return response()->view('welcomeNotification::invalidWelcomeLink', [], 404);
0 ignored issues
show
Bug introduced by
The method view does only exist in Illuminate\Contracts\Routing\ResponseFactory, but not in Illuminate\Http\Response.

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...
39
    }
40
41
    protected function sendPasswordSavedResponse(): Response
42
    {
43
        return redirect()->to($this->redirectPath())->with('status', 'Welcome! You are now logged in!');
44
    }
45
46
    protected function sendResetResponse(): Response
47
    {
48
        return $this->afterPasswordSavedReponse();
0 ignored issues
show
Bug introduced by
The method afterPasswordSavedReponse() does not seem to exist on object<Spatie\WelcomeNot...tion\WelcomeController>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
49
    }
50
}
51