Completed
Pull Request — master (#113)
by Pascal
01:10
created

SessionGuardMixin::quietLogout()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
namespace Lab404\Impersonate\Guard;
4
5
use Illuminate\Contracts\Auth\Authenticatable;
6
7
class SessionGuardMixin
8
{
9
    /**
10
     * Log a user into the application without firing the Login event.
11
     *
12
     * @param  \Illuminate\Contracts\Auth\Authenticatable  $user
0 ignored issues
show
Bug introduced by
There is no parameter named $user. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
13
     * @return void
14
     */
15
    public function quietLogin()
16
    {
17
        return function (Authenticatable $user) {
18
            $this->updateSession($user->getAuthIdentifier());
0 ignored issues
show
Bug introduced by
The method updateSession() does not seem to exist on object<Lab404\Impersonat...uard\SessionGuardMixin>.

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...
19
20
            $this->setUser($user);
0 ignored issues
show
Bug introduced by
The method setUser() does not seem to exist on object<Lab404\Impersonat...uard\SessionGuardMixin>.

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...
21
        };
22
    }
23
24
    /**
25
     * Logout the user without updating remember_token
26
     * and without firing the Logout event.
27
     *
28
     * @param   void
29
     * @return  void
30
     */
31
    public function quietLogout()
32
    {
33
        return function () {
34
            $this->clearUserDataFromStorage();
0 ignored issues
show
Bug introduced by
The method clearUserDataFromStorage() does not seem to exist on object<Lab404\Impersonat...uard\SessionGuardMixin>.

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...
35
36
            $this->user = null;
0 ignored issues
show
Bug introduced by
The property user 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...
37
38
            $this->loggedOut = true;
0 ignored issues
show
Bug introduced by
The property loggedOut 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...
39
        };
40
    }
41
}
42