Skip to content

Commit

Permalink
use promoted properties for Auth events (#53847)
Browse files Browse the repository at this point in the history
- move comments to constructor docblocks
  • Loading branch information
browner12 authored Dec 11, 2024
1 parent 4ce3658 commit b76b46d
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 231 deletions.
37 changes: 8 additions & 29 deletions Events/Attempting.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,18 @@

class Attempting
{
/**
* The authentication guard name.
*
* @var string
*/
public $guard;

/**
* The credentials for the user.
*
* @var array
*/
public $credentials;

/**
* Indicates if the user should be "remembered".
*
* @var bool
*/
public $remember;

/**
* Create a new event instance.
*
* @param string $guard
* @param array $credentials
* @param bool $remember
* @param string $guard The authentication guard name.
* @param array $credentials The credentials for the user.
* @param bool $remember Indicates if the user should be "remembered".
* @return void
*/
public function __construct($guard, #[\SensitiveParameter] $credentials, $remember)
{
$this->guard = $guard;
$this->remember = $remember;
$this->credentials = $credentials;
public function __construct(
public $guard,
#[\SensitiveParameter] public $credentials,
public $remember,
) {
}
}
26 changes: 6 additions & 20 deletions Events/Authenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,16 @@ class Authenticated
{
use SerializesModels;

/**
* The authentication guard name.
*
* @var string
*/
public $guard;

/**
* The authenticated user.
*
* @var \Illuminate\Contracts\Auth\Authenticatable
*/
public $user;

/**
* Create a new event instance.
*
* @param string $guard
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param string $guard The authentication guard name.
* @param \Illuminate\Contracts\Auth\Authenticatable $user The authenticated user.
* @return void
*/
public function __construct($guard, $user)
{
$this->user = $user;
$this->guard = $guard;
public function __construct(
public $guard,
public $user,
) {
}
}
26 changes: 6 additions & 20 deletions Events/CurrentDeviceLogout.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,16 @@ class CurrentDeviceLogout
{
use SerializesModels;

/**
* The authentication guard name.
*
* @var string
*/
public $guard;

/**
* The authenticated user.
*
* @var \Illuminate\Contracts\Auth\Authenticatable
*/
public $user;

/**
* Create a new event instance.
*
* @param string $guard
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param string $guard The authentication guard name.
* @param \Illuminate\Contracts\Auth\Authenticatable $user The authenticated user.
* @return void
*/
public function __construct($guard, $user)
{
$this->user = $user;
$this->guard = $guard;
public function __construct(
public $guard,
public $user,
) {
}
}
37 changes: 8 additions & 29 deletions Events/Failed.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,18 @@

class Failed
{
/**
* The authentication guard name.
*
* @var string
*/
public $guard;

/**
* The user the attempter was trying to authenticate as.
*
* @var \Illuminate\Contracts\Auth\Authenticatable|null
*/
public $user;

/**
* The credentials provided by the attempter.
*
* @var array
*/
public $credentials;

/**
* Create a new event instance.
*
* @param string $guard
* @param \Illuminate\Contracts\Auth\Authenticatable|null $user
* @param array $credentials
* @param string $guard The authentication guard name.
* @param \Illuminate\Contracts\Auth\Authenticatable|null $user The user the attempter was trying to authenticate as.
* @param array $credentials The credentials provided by the attempter.
* @return void
*/
public function __construct($guard, $user, #[\SensitiveParameter] $credentials)
{
$this->user = $user;
$this->guard = $guard;
$this->credentials = $credentials;
public function __construct(
public $guard,
public $user,
#[\SensitiveParameter] public $credentials,
) {
}
}
37 changes: 8 additions & 29 deletions Events/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,18 @@ class Login
{
use SerializesModels;

/**
* The authentication guard name.
*
* @var string
*/
public $guard;

/**
* The authenticated user.
*
* @var \Illuminate\Contracts\Auth\Authenticatable
*/
public $user;

/**
* Indicates if the user should be "remembered".
*
* @var bool
*/
public $remember;

/**
* Create a new event instance.
*
* @param string $guard
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param bool $remember
* @param string $guard The authentication guard name.
* @param \Illuminate\Contracts\Auth\Authenticatable $user The authenticated user.
* @param bool $remember Indicates if the user should be "remembered".
* @return void
*/
public function __construct($guard, $user, $remember)
{
$this->user = $user;
$this->guard = $guard;
$this->remember = $remember;
public function __construct(
public $guard,
public $user,
public $remember,
) {
}
}
26 changes: 6 additions & 20 deletions Events/Logout.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,16 @@ class Logout
{
use SerializesModels;

/**
* The authentication guard name.
*
* @var string
*/
public $guard;

/**
* The authenticated user.
*
* @var \Illuminate\Contracts\Auth\Authenticatable
*/
public $user;

/**
* Create a new event instance.
*
* @param string $guard
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param string $guard The authentication guard name.
* @param \Illuminate\Contracts\Auth\Authenticatable $user The authenticated user.
* @return void
*/
public function __construct($guard, $user)
{
$this->user = $user;
$this->guard = $guard;
public function __construct(
public $guard,
public $user,
) {
}
}
26 changes: 6 additions & 20 deletions Events/OtherDeviceLogout.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,16 @@ class OtherDeviceLogout
{
use SerializesModels;

/**
* The authentication guard name.
*
* @var string
*/
public $guard;

/**
* The authenticated user.
*
* @var \Illuminate\Contracts\Auth\Authenticatable
*/
public $user;

/**
* Create a new event instance.
*
* @param string $guard
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param string $guard The authentication guard name.
* @param \Illuminate\Contracts\Auth\Authenticatable $user \Illuminate\Contracts\Auth\Authenticatable
* @return void
*/
public function __construct($guard, $user)
{
$this->user = $user;
$this->guard = $guard;
public function __construct(
public $guard,
public $user,
) {
}
}
15 changes: 4 additions & 11 deletions Events/PasswordReset.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,14 @@ class PasswordReset
{
use SerializesModels;

/**
* The user.
*
* @var \Illuminate\Contracts\Auth\Authenticatable
*/
public $user;

/**
* Create a new event instance.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param \Illuminate\Contracts\Auth\Authenticatable $user The user.
* @return void
*/
public function __construct($user)
{
$this->user = $user;
public function __construct(
public $user,
) {
}
}
15 changes: 4 additions & 11 deletions Events/PasswordResetLinkSent.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,14 @@ class PasswordResetLinkSent
{
use SerializesModels;

/**
* The user instance.
*
* @var \Illuminate\Contracts\Auth\CanResetPassword
*/
public $user;

/**
* Create a new event instance.
*
* @param \Illuminate\Contracts\Auth\CanResetPassword $user
* @param \Illuminate\Contracts\Auth\CanResetPassword $user The user instance.
* @return void
*/
public function __construct($user)
{
$this->user = $user;
public function __construct(
public $user,
) {
}
}
15 changes: 4 additions & 11 deletions Events/Registered.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,14 @@ class Registered
{
use SerializesModels;

/**
* The authenticated user.
*
* @var \Illuminate\Contracts\Auth\Authenticatable
*/
public $user;

/**
* Create a new event instance.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param \Illuminate\Contracts\Auth\Authenticatable $user The authenticated user.
* @return void
*/
public function __construct($user)
{
$this->user = $user;
public function __construct(
public $user,
) {
}
}
Loading

0 comments on commit b76b46d

Please sign in to comment.