Skip to content

Commit

Permalink
used promoted properties
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jan 21, 2024
1 parent 0e93577 commit b5f6be6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 29 deletions.
12 changes: 4 additions & 8 deletions src/Security/Passwords.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [],
) {
}


Expand Down
14 changes: 3 additions & 11 deletions src/Security/SimpleAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,17 @@
*/
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[]
* @param array $data list of pairs username => mixed[]
*/
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;
}


Expand Down
13 changes: 3 additions & 10 deletions src/Security/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down

0 comments on commit b5f6be6

Please sign in to comment.