Skip to content

Commit 2aa7588

Browse files
committed
chore: align User.getPassword with the proper interface
Symfony's UserInterface.getPassword is deprecated in favour of the same method from PasswordAuthenticatedUserInterface. This fixes deprecation messages such as this one: User Deprecated: Since symfony/security-http 5.3: Not implementing the "Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface" interface in class "UserBase\Client\Model\User" while using password-based authentication is deprecated.
1 parent decc404 commit 2aa7588

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/Model/User.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55
use LinkORB\Contracts\UserbaseRole\RoleInterface;
66
use RuntimeException;
7+
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
78
use Symfony\Component\Security\Core\User\UserInterface as BaseUserInterface;
89

910
final class User implements
1011
AccountContainerInterface,
1112
BaseUserInterface,
1213
LegacyAdvancedUserInterface,
14+
PasswordAuthenticatedUserInterface,
1315
PolicyContainerInterface,
1416
RoleInterface,
1517
UserInterface
@@ -32,7 +34,7 @@ final class User implements
3234
private $accountNonLocked;
3335

3436
private $name;
35-
private $password;
37+
private $password = '';
3638
private $roles;
3739

3840
private $createdAt;
@@ -49,7 +51,6 @@ public function __construct(string $name)
4951
}
5052

5153
$this->name = $name;
52-
$this->password = null;
5354
$this->enabled = true;
5455
$this->accountNonExpired = true;
5556
$this->credentialsNonExpired = true;
@@ -109,12 +110,12 @@ public function getRoles()
109110
/**
110111
* {@inheritdoc}
111112
*/
112-
public function getPassword()
113+
public function getPassword(): ?string
113114
{
114115
return $this->password;
115116
}
116117

117-
public function setPassword($password)
118+
public function setPassword(string $password)
118119
{
119120
$this->password = $password;
120121
return $this;

0 commit comments

Comments
 (0)