Skip to content

Commit 2248640

Browse files
authored
[4.x] Use property promotion (#586)
* property promotion bits * Update tests.yml * god damn full stops
1 parent 95d9cb7 commit 2248640

File tree

6 files changed

+16
-93
lines changed

6 files changed

+16
-93
lines changed

src/Events/TokenAuthenticated.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,12 @@
44

55
class TokenAuthenticated
66
{
7-
/**
8-
* The personal access token that was authenticated.
9-
*
10-
* @var \Laravel\Sanctum\PersonalAccessToken
11-
*/
12-
public $token;
13-
147
/**
158
* Create a new event instance.
169
*
17-
* @param \Laravel\Sanctum\PersonalAccessToken $token
10+
* @param \Laravel\Sanctum\PersonalAccessToken $token The personal access token that was authenticated.
1811
*/
19-
public function __construct($token)
12+
public function __construct(public $token)
2013
{
21-
$this->token = $token;
2214
}
2315
}

src/Exceptions/MissingAbilityException.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,13 @@
77

88
class MissingAbilityException extends AuthorizationException
99
{
10-
/**
11-
* The abilities that the user did not have.
12-
*
13-
* @var array
14-
*/
15-
protected $abilities;
16-
1710
/**
1811
* Create a new missing scope exception.
1912
*
20-
* @param array|string $abilities
13+
* @param array|string $abilities The abilities that the user did not have.
2114
* @param string $message
2215
*/
23-
public function __construct($abilities = [], $message = 'Invalid ability provided.')
16+
public function __construct(protected $abilities = [], $message = 'Invalid ability provided.')
2417
{
2518
parent::__construct($message);
2619

src/Exceptions/MissingScopeException.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,13 @@
1111
*/
1212
class MissingScopeException extends AuthorizationException
1313
{
14-
/**
15-
* The scopes that the user did not have.
16-
*
17-
* @var array
18-
*/
19-
protected $scopes;
20-
2114
/**
2215
* Create a new missing scope exception.
2316
*
24-
* @param array|string $scopes
17+
* @param array|string $scopes The scopes that the user did not have.
2518
* @param string $message
2619
*/
27-
public function __construct($scopes = [], $message = 'Invalid scope(s) provided.')
20+
public function __construct(protected $scopes = [], $message = 'Invalid scope(s) provided.')
2821
{
2922
parent::__construct($message);
3023

src/Guard.php

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,48 +9,17 @@
99

1010
class Guard
1111
{
12-
/**
13-
* The authentication factory implementation.
14-
*
15-
* @var \Illuminate\Contracts\Auth\Factory
16-
*/
17-
protected $auth;
18-
19-
/**
20-
* The number of minutes tokens should be allowed to remain valid.
21-
*
22-
* @var int
23-
*/
24-
protected $expiration;
25-
26-
/**
27-
* The provider name.
28-
*
29-
* @var string
30-
*/
31-
protected $provider;
32-
33-
/**
34-
* Whether to track the last used timestamp.
35-
*
36-
* @var bool
37-
*/
38-
protected $trackLastUsedAt;
3912

4013
/**
4114
* Create a new guard instance.
4215
*
43-
* @param \Illuminate\Contracts\Auth\Factory $auth
44-
* @param int $expiration
45-
* @param string $provider
46-
* @param bool $trackLastUsedAt
16+
* @param \Illuminate\Contracts\Auth\Factory $auth The authentication factory implementation.
17+
* @param int $expiration The number of minutes tokens should be allowed to remain valid.
18+
* @param string $provider The provider name.
19+
* @param bool $trackLastUsedAt Whether to track the last used timestamp.
4720
*/
48-
public function __construct(AuthFactory $auth, $expiration = null, $provider = null, $trackLastUsedAt = true)
21+
public function __construct(protected AuthFactory $auth, protected $expiration = null, protected $provider = null, protected $trackLastUsedAt = true)
4922
{
50-
$this->auth = $auth;
51-
$this->expiration = $expiration;
52-
$this->provider = $provider;
53-
$this->trackLastUsedAt = $trackLastUsedAt;
5423
}
5524

5625
/**

src/Http/Middleware/AuthenticateSession.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,13 @@
1313

1414
class AuthenticateSession
1515
{
16-
/**
17-
* The authentication factory implementation.
18-
*
19-
* @var \Illuminate\Contracts\Auth\Factory
20-
*/
21-
protected $auth;
22-
2316
/**
2417
* Create a new middleware instance.
2518
*
26-
* @param \Illuminate\Contracts\Auth\Factory $auth
19+
* @param \Illuminate\Contracts\Auth\Factory $auth The authentication factory implementation.
2720
*/
28-
public function __construct(AuthFactory $auth)
21+
public function __construct(protected AuthFactory $auth)
2922
{
30-
$this->auth = $auth;
3123
}
3224

3325
/**

src/NewAccessToken.php

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,14 @@
77

88
class NewAccessToken implements Arrayable, Jsonable
99
{
10-
/**
11-
* The access token instance.
12-
*
13-
* @var \Laravel\Sanctum\PersonalAccessToken
14-
*/
15-
public $accessToken;
16-
17-
/**
18-
* The plain text version of the token.
19-
*
20-
* @var string
21-
*/
22-
public $plainTextToken;
23-
2410
/**
2511
* Create a new access token result.
2612
*
27-
* @param \Laravel\Sanctum\PersonalAccessToken $accessToken
28-
* @param string $plainTextToken
13+
* @param \Laravel\Sanctum\PersonalAccessToken $accessToken The access token instance.
14+
* @param string $plainTextToken The plain text version of the token.
2915
*/
30-
public function __construct(PersonalAccessToken $accessToken, string $plainTextToken)
16+
public function __construct(public PersonalAccessToken $accessToken, public string $plainTextToken)
3117
{
32-
$this->accessToken = $accessToken;
33-
$this->plainTextToken = $plainTextToken;
3418
}
3519

3620
/**

0 commit comments

Comments
 (0)