Skip to content

Commit ced27de

Browse files
committed
use request attributes instead of dynamic property
1 parent 853dab3 commit ced27de

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ build
22
composer.lock
33
vendor
44
.idea
5+
.phpunit.result.cache

.phpunit.result.cache

-1
This file was deleted.

src/JWTServiceProvider.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class JWTServiceProvider extends ServiceProvider
1010
{
11-
public function boot()
11+
public function boot(): void
1212
{
1313
$this->publishes([
1414
__DIR__.'/../config/jwt.php' => config_path('jwt.php'),
@@ -17,17 +17,17 @@ public function boot()
1717
$this->app['router']->aliasMiddleware('jwt', JwtValidateMiddleware::class);
1818

1919
Request::macro('setToken', function(ParsedToken $token) {
20-
$this->token = $token;
20+
$this->attributes->set('token', $token);
2121
});
2222

2323
Request::macro('getClaim', function($name, $default = null) {
24-
return $this->token && $this->token instanceof ParsedToken
25-
? $this->token->get($name, $default)
24+
return $this->attributes->has('token') && $this->attributes->get('token') instanceof ParsedToken
25+
? $this->attributes->get('token')->get($name, $default)
2626
: $default;
2727
});
2828
}
2929

30-
public function register()
30+
public function register(): void
3131
{
3232
$this->mergeConfigFrom(__DIR__.'/../config/jwt.php', 'jwt');
3333

@@ -45,7 +45,7 @@ public function register()
4545
});
4646
}
4747

48-
public function provides()
48+
public function provides(): array
4949
{
5050
return [Client::class];
5151
}

0 commit comments

Comments
 (0)