Completed
Push — master ( 1f3e01...3b63e9 )
by Roman
10:06
created

GuardTest::testAttemptWithAdditionalCredentials()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 30
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 19
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 30
rs 8.8571
1
<?php
2
3
use Mockery as m;
4
5
class GuardTest extends PHPUnit_Framework_TestCase
6
{
7
    public function testSetRequest()
8
    {
9
        $provider = m::mock(Illuminate\Contracts\Auth\UserProvider::class);
10
        $blacklist = m::mock(Framgia\Jwt\Blacklist::class);
11
        $signer = m::mock(Framgia\Jwt\Contracts\Signer::class);
12
13
        $firstRequest = Illuminate\Http\Request::create('/');
14
15
        $guard = new Framgia\Jwt\Guard($provider, $firstRequest, $blacklist, $signer);
0 ignored issues
show
Compatibility introduced by
$firstRequest of type object<Symfony\Component\HttpFoundation\Request> is not a sub-type of object<Illuminate\Http\Request>. It seems like you assume a child class of the class Symfony\Component\HttpFoundation\Request to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
16
17
        $reflection = new ReflectionClass($guard);
18
        $property = $reflection->getProperty('request');
19
        $property->setAccessible(true);
20
21
        $this->assertEquals($firstRequest, $property->getValue($guard));
22
23
        $newRequest = Illuminate\Http\Request::create('/foo');
24
25
        $guard->setRequest($newRequest);
0 ignored issues
show
Compatibility introduced by
$newRequest of type object<Symfony\Component\HttpFoundation\Request> is not a sub-type of object<Illuminate\Http\Request>. It seems like you assume a child class of the class Symfony\Component\HttpFoundation\Request to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
26
27
        $this->assertEquals($newRequest, $property->getValue($guard));
28
    }
29
30
    public function testUserWithRawToken()
31
    {
32
        $user = m::mock(\Illuminate\Contracts\Auth\Authenticatable::class);
33
34
        $provider = m::mock(Illuminate\Contracts\Auth\UserProvider::class);
35
        $provider->shouldReceive('retrieveById')->once()->andReturn($user);
36
37
        $blacklist = m::mock(Framgia\Jwt\Blacklist::class);
38
        $signer = m::mock(Framgia\Jwt\Contracts\Signer::class);
39
40
        $request = Illuminate\Http\Request::create('/');
41
42
        $token = (new \Lcobucci\JWT\Builder())->setSubject(1)->setExpiration(time() + 3600)->getToken();
43
44
        $signer->shouldReceive('verify')->once()->andReturn(true);
45
46
        $request->headers->set('Authorization', 'Bearer '.$token);
47
48
        $guard = new Framgia\Jwt\Guard($provider, $request, $blacklist, $signer);
0 ignored issues
show
Compatibility introduced by
$request of type object<Symfony\Component\HttpFoundation\Request> is not a sub-type of object<Illuminate\Http\Request>. It seems like you assume a child class of the class Symfony\Component\HttpFoundation\Request to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
49
50
        $this->assertEquals($user, $guard->user());
51
    }
52
53
    public function testUserWithSignedToken()
54
    {
55
        $user = m::mock(\Illuminate\Contracts\Auth\Authenticatable::class);
56
57
        $signer = new Framgia\Jwt\Signers\Hmac('test');
58
59
        $provider = m::mock(Illuminate\Contracts\Auth\UserProvider::class);
60
        $provider->shouldReceive('retrieveById')->once()->andReturn($user);
61
62
        $blacklist = m::mock(Framgia\Jwt\Blacklist::class);
63
64
        $request = Illuminate\Http\Request::create('/');
65
66
        $token = $signer->sign((new \Lcobucci\JWT\Builder())->setSubject(1)->setExpiration(time() + 3600))->getToken();
67
68
        $request->headers->set('Authorization', 'Bearer '.$token);
69
70
        $guard = new Framgia\Jwt\Guard($provider, $request, $blacklist, $signer);
0 ignored issues
show
Compatibility introduced by
$request of type object<Symfony\Component\HttpFoundation\Request> is not a sub-type of object<Illuminate\Http\Request>. It seems like you assume a child class of the class Symfony\Component\HttpFoundation\Request to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
71
72
        $this->assertEquals($user, $guard->user());
73
74
        // Additional check to test if user provider is called once
75
        $this->assertEquals($user, $guard->user());
76
    }
77
78 View Code Duplication
    public function testValidate()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
79
    {
80
        $credentials = ['foo' => 'bar'];
81
82
        $user = m::mock(\Illuminate\Contracts\Auth\Authenticatable::class);
83
        $provider = m::mock(Illuminate\Contracts\Auth\UserProvider::class);
84
        $provider->shouldReceive('retrieveByCredentials')->once()->with($credentials)->andReturn($user);
85
        $provider->shouldReceive('validateCredentials')->once()->with($user, $credentials)->andReturn(true);
86
87
        $blacklist = m::mock(Framgia\Jwt\Blacklist::class);
88
        $signer = m::mock(Framgia\Jwt\Contracts\Signer::class);
89
90
        $request = Illuminate\Http\Request::create('/');
91
92
        $guard = new Framgia\Jwt\Guard($provider, $request, $blacklist, $signer);
0 ignored issues
show
Compatibility introduced by
$request of type object<Symfony\Component\HttpFoundation\Request> is not a sub-type of object<Illuminate\Http\Request>. It seems like you assume a child class of the class Symfony\Component\HttpFoundation\Request to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
93
94
        $this->assertTrue($guard->validate($credentials));
95
    }
96
97
    public function testValidateFailsWithFakeCredentials()
98
    {
99
        $credentials = ['foo' => 'bar'];
100
101
        $provider = m::mock(Illuminate\Contracts\Auth\UserProvider::class);
102
        $provider->shouldReceive('retrieveByCredentials')->once()->with($credentials)->andReturnNull();
0 ignored issues
show
Unused Code introduced by
The call to the method Mockery\Expectation::andReturnNull() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
103
104
        $blacklist = m::mock(Framgia\Jwt\Blacklist::class);
105
        $signer = m::mock(Framgia\Jwt\Contracts\Signer::class);
106
107
        $request = Illuminate\Http\Request::create('/');
108
109
        $guard = new Framgia\Jwt\Guard($provider, $request, $blacklist, $signer);
0 ignored issues
show
Compatibility introduced by
$request of type object<Symfony\Component\HttpFoundation\Request> is not a sub-type of object<Illuminate\Http\Request>. It seems like you assume a child class of the class Symfony\Component\HttpFoundation\Request to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
110
111
        $this->assertFalse($guard->validate($credentials));
112
    }
113
114 View Code Duplication
    public function testAttempt()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
115
    {
116
        $credentials = ['foo' => 'bar'];
117
118
        $user = m::mock(\Illuminate\Contracts\Auth\Authenticatable::class);
119
        $provider = m::mock(Illuminate\Contracts\Auth\UserProvider::class);
120
        $provider->shouldReceive('retrieveByCredentials')->once()->with($credentials)->andReturn($user);
121
        $provider->shouldReceive('validateCredentials')->once()->with($user, $credentials)->andReturn(true);
122
123
        $blacklist = m::mock(Framgia\Jwt\Blacklist::class);
124
        $signer = m::mock(Framgia\Jwt\Contracts\Signer::class);
125
126
        $request = Illuminate\Http\Request::create('/');
127
128
        $guard = new Framgia\Jwt\Guard($provider, $request, $blacklist, $signer);
0 ignored issues
show
Compatibility introduced by
$request of type object<Symfony\Component\HttpFoundation\Request> is not a sub-type of object<Illuminate\Http\Request>. It seems like you assume a child class of the class Symfony\Component\HttpFoundation\Request to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
129
130
        $this->assertTrue($guard->validate($credentials));
131
    }
132
133
    public function testUserReturnsNullWithoutToken()
134
    {
135
        $signer = m::mock(Framgia\Jwt\Signers\Hmac::class);
136
137
        $provider = m::mock(Illuminate\Contracts\Auth\UserProvider::class);
138
        $provider->shouldNotReceive('retrieveById');
0 ignored issues
show
Unused Code introduced by
The call to MockInterface::shouldNotReceive() has too many arguments starting with 'retrieveById'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
139
140
        $blacklist = m::mock(Framgia\Jwt\Blacklist::class);
141
142
        $request = Illuminate\Http\Request::create('/');
143
144
        $guard = new Framgia\Jwt\Guard($provider, $request, $blacklist, $signer);
0 ignored issues
show
Compatibility introduced by
$request of type object<Symfony\Component\HttpFoundation\Request> is not a sub-type of object<Illuminate\Http\Request>. It seems like you assume a child class of the class Symfony\Component\HttpFoundation\Request to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
145
146
        $this->assertNull($guard->user());
147
    }
148
149
    public function testUserReturnsNullWithInvalidToken()
150
    {
151
        $credentials = ['foo' => 'bar'];
0 ignored issues
show
Unused Code introduced by
$credentials is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
152
153
        $provider = m::mock(Illuminate\Contracts\Auth\UserProvider::class);
154
        $provider->shouldNotReceive('retrieveById');
0 ignored issues
show
Unused Code introduced by
The call to MockInterface::shouldNotReceive() has too many arguments starting with 'retrieveById'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
155
156
        $blacklist = m::mock(Framgia\Jwt\Blacklist::class);
157
        $signer = m::mock(Framgia\Jwt\Contracts\Signer::class);
158
159
        $request = Illuminate\Http\Request::create('/');
160
161
        $request->headers->set('Authorization', 'Bearer BAD_TOKEN');
162
163
        $guard = new Framgia\Jwt\Guard($provider, $request, $blacklist, $signer);
0 ignored issues
show
Compatibility introduced by
$request of type object<Symfony\Component\HttpFoundation\Request> is not a sub-type of object<Illuminate\Http\Request>. It seems like you assume a child class of the class Symfony\Component\HttpFoundation\Request to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
164
165
        $this->assertNull($guard->user());
166
    }
167
168
    public function testAttemptReturnsToken()
169
    {
170
        $credentials = ['foo' => 'bar'];
171
172
        $user = m::mock(\Illuminate\Contracts\Auth\Authenticatable::class);
173
        $user->shouldReceive('getAuthIdentifier')->once()->andReturn(1);
174
175
        $provider = m::mock(Illuminate\Contracts\Auth\UserProvider::class);
176
        $provider->shouldReceive('retrieveByCredentials')->once()->with($credentials)->andReturn($user);
177
        $provider->shouldReceive('validateCredentials')->once()->with($user, $credentials)->andReturn(true);
178
179
        $blacklist = m::mock(Framgia\Jwt\Blacklist::class);
180
        $signer = new Framgia\Jwt\Signers\Hmac('test');
181
182
        $request = Illuminate\Http\Request::create('/');
183
184
        $guard = new Framgia\Jwt\Guard($provider, $request, $blacklist, $signer);
0 ignored issues
show
Compatibility introduced by
$request of type object<Symfony\Component\HttpFoundation\Request> is not a sub-type of object<Illuminate\Http\Request>. It seems like you assume a child class of the class Symfony\Component\HttpFoundation\Request to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
185
186
        /**
187
         * @var \Lcobucci\JWT\Token
188
         */
189
        $token = $guard->attempt($credentials);
190
191
        $this->assertInstanceOf(\Lcobucci\JWT\Token::class, $token);
192
        $this->assertEquals(1, $token->getClaim('sub'));
193
        $this->assertLessThan($token->getClaim('exp'), time());
194
        $this->assertNotNull($token->getClaim('jti'));
195
196
        $this->assertTrue($guard->validate($credentials));
197
    }
198
199
    public function testAttemptWithAdditionalCredentials()
200
    {
201
        $credentials = ['foo' => 'bar'];
202
203
        $user = m::mock(UserWithCredentials::class);
204
        $user->shouldReceive('getAuthIdentifier')->once()->andReturn(1);
205
        $user->shouldReceive('getCredentials')->once()->andReturn([
206
            'admin' => true,
207
            'foo' => 'bar',
208
        ]);
209
210
        $provider = m::mock(Illuminate\Contracts\Auth\UserProvider::class);
211
        $provider->shouldReceive('retrieveByCredentials')->once()->with($credentials)->andReturn($user);
212
        $provider->shouldReceive('validateCredentials')->once()->with($user, $credentials)->andReturn(true);
213
214
        $blacklist = m::mock(Framgia\Jwt\Blacklist::class);
215
        $signer = new Framgia\Jwt\Signers\Hmac('test');
216
217
        $request = Illuminate\Http\Request::create('/');
218
219
        $guard = new Framgia\Jwt\Guard($provider, $request, $blacklist, $signer);
0 ignored issues
show
Compatibility introduced by
$request of type object<Symfony\Component\HttpFoundation\Request> is not a sub-type of object<Illuminate\Http\Request>. It seems like you assume a child class of the class Symfony\Component\HttpFoundation\Request to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
220
221
        $token = $guard->attempt($credentials);
222
223
        $this->assertInstanceOf(\Lcobucci\JWT\Token::class, $token);
224
        $this->assertEquals(true, $token->getClaim('admin'));
225
        $this->assertEquals('bar', $token->getClaim('foo'));
226
227
        $this->assertTrue($guard->validate($credentials));
228
    }
229
230
    public function testAttemptNullWithInvalidCredentials()
231
    {
232
        $credentials = ['foo' => 'bar'];
233
234
        $provider = m::mock(Illuminate\Contracts\Auth\UserProvider::class);
235
        $provider->shouldReceive('retrieveByCredentials')->once()->with($credentials)->andReturn(null);
236
237
        $blacklist = m::mock(Framgia\Jwt\Blacklist::class);
238
        $signer = new Framgia\Jwt\Signers\Hmac('test');
239
240
        $request = Illuminate\Http\Request::create('/');
241
242
        $guard = new Framgia\Jwt\Guard($provider, $request, $blacklist, $signer);
0 ignored issues
show
Compatibility introduced by
$request of type object<Symfony\Component\HttpFoundation\Request> is not a sub-type of object<Illuminate\Http\Request>. It seems like you assume a child class of the class Symfony\Component\HttpFoundation\Request to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
243
244
        $this->assertNull($guard->attempt($credentials));
245
    }
246
247
    public function testLogout()
248
    {
249
        $provider = m::mock(Illuminate\Contracts\Auth\UserProvider::class);
250
251
        $blacklist = m::mock(Framgia\Jwt\Blacklist::class);
252
        $token = (new \Lcobucci\JWT\Builder())->setId('foo')->setSubject(1)->setExpiration(time() + 3600)->getToken();
253
        $blacklist->shouldReceive('add')->once()->andReturn(true);
254
255
        $signer = m::mock(Framgia\Jwt\Contracts\Signer::class);
256
257
        $request = Illuminate\Http\Request::create('/');
258
        $signer->shouldReceive('verify')->once()->andReturn(true);
259
260
        $request->headers->set('Authorization', 'Bearer '.$token);
261
262
        $guard = new Framgia\Jwt\Guard($provider, $request, $blacklist, $signer);
0 ignored issues
show
Compatibility introduced by
$request of type object<Symfony\Component\HttpFoundation\Request> is not a sub-type of object<Illuminate\Http\Request>. It seems like you assume a child class of the class Symfony\Component\HttpFoundation\Request to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
263
264
        $this->assertTrue($guard->logout());
265
    }
266
267 View Code Duplication
    public function testLogoutWithoutToken()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
268
    {
269
        $provider = m::mock(Illuminate\Contracts\Auth\UserProvider::class);
270
271
        $blacklist = m::mock(Framgia\Jwt\Blacklist::class);
272
        $blacklist->shouldNotReceive('add');
0 ignored issues
show
Unused Code introduced by
The call to MockInterface::shouldNotReceive() has too many arguments starting with 'add'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
273
274
        $signer = m::mock(Framgia\Jwt\Contracts\Signer::class);
275
276
        $request = Illuminate\Http\Request::create('/');
277
        $signer->shouldReceive('verify')->once()->andReturn(true);
278
279
        $guard = new Framgia\Jwt\Guard($provider, $request, $blacklist, $signer);
0 ignored issues
show
Compatibility introduced by
$request of type object<Symfony\Component\HttpFoundation\Request> is not a sub-type of object<Illuminate\Http\Request>. It seems like you assume a child class of the class Symfony\Component\HttpFoundation\Request to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
280
281
        $this->assertTrue($guard->logout());
282
    }
283
284 View Code Duplication
    public function testLogoutWithInvalidToken()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
285
    {
286
        $provider = m::mock(Illuminate\Contracts\Auth\UserProvider::class);
287
288
        $blacklist = m::mock(Framgia\Jwt\Blacklist::class);
289
        $blacklist->shouldNotReceive('add');
0 ignored issues
show
Unused Code introduced by
The call to MockInterface::shouldNotReceive() has too many arguments starting with 'add'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
290
291
        $signer = m::mock(Framgia\Jwt\Contracts\Signer::class);
292
293
        $request = Illuminate\Http\Request::create('/');
294
        $request->headers->set('Authorization', 'Bearer BAD_TOKEN');
295
        $signer->shouldReceive('verify')->once()->andReturn(true);
296
297
        $guard = new Framgia\Jwt\Guard($provider, $request, $blacklist, $signer);
0 ignored issues
show
Compatibility introduced by
$request of type object<Symfony\Component\HttpFoundation\Request> is not a sub-type of object<Illuminate\Http\Request>. It seems like you assume a child class of the class Symfony\Component\HttpFoundation\Request to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
298
299
        $this->assertFalse($guard->logout());
300
    }
301
}
302
303
abstract class UserWithCredentials implements \Illuminate\Contracts\Auth\Authenticatable, \Framgia\Jwt\Contracts\ProvidesCredentials {}
304