From b5f6be63d6d562815538e60e7b0720075c635fab Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 11 Dec 2023 13:26:37 +0100 Subject: [PATCH] used promoted properties --- src/Security/Passwords.php | 12 ++++-------- src/Security/SimpleAuthenticator.php | 14 +++----------- src/Security/User.php | 13 +++---------- 3 files changed, 10 insertions(+), 29 deletions(-) diff --git a/src/Security/Passwords.php b/src/Security/Passwords.php index 10329d65..ffc4927f 100644 --- a/src/Security/Passwords.php +++ b/src/Security/Passwords.php @@ -17,18 +17,14 @@ */ class Passwords { - private string $algo; - private array $options; - - /** * Chooses which secure algorithm is used for hashing and how to configure it. * @see https://php.net/manual/en/password.constants.php */ - public function __construct(string $algo = PASSWORD_DEFAULT, array $options = []) - { - $this->algo = $algo; - $this->options = $options; + public function __construct( + private string $algo = PASSWORD_DEFAULT, + private array $options = [], + ) { } diff --git a/src/Security/SimpleAuthenticator.php b/src/Security/SimpleAuthenticator.php index bb6ab13f..eb5b2b27 100644 --- a/src/Security/SimpleAuthenticator.php +++ b/src/Security/SimpleAuthenticator.php @@ -15,11 +15,6 @@ */ class SimpleAuthenticator implements Authenticator { - private array $passwords; - private array $roles; - private array $data; - - /** * @param array $passwords list of pairs username => password * @param array $roles list of pairs username => role[] @@ -27,13 +22,10 @@ class SimpleAuthenticator implements Authenticator */ public function __construct( #[\SensitiveParameter] - array $passwords, - array $roles = [], - array $data = [], + private array $passwords, + private array $roles = [], + private array $data = [], ) { - $this->passwords = $passwords; - $this->roles = $roles; - $this->data = $data; } diff --git a/src/Security/User.php b/src/Security/User.php index 3748db48..b2acb47e 100644 --- a/src/Security/User.php +++ b/src/Security/User.php @@ -53,23 +53,16 @@ class User /** @var callable[] function (User $sender): void; Occurs when the user is logged out */ public array $onLoggedOut = []; - /** Session storage for current user */ - private UserStorage $storage; - private ?IAuthenticator $authenticator; - private ?Authorizator $authorizator; private ?IIdentity $identity = null; private ?bool $authenticated = null; private ?int $logoutReason = null; public function __construct( - UserStorage $storage, - ?IAuthenticator $authenticator = null, - ?Authorizator $authorizator = null, + private UserStorage $storage, + private ?IAuthenticator $authenticator = null, + private ?Authorizator $authorizator = null, ) { - $this->storage = $storage; - $this->authenticator = $authenticator; - $this->authorizator = $authorizator; }