Skip to content

Commit

Permalink
Upgrade User Serializable for PHP 8.1 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Sep 2, 2021
1 parent 29f54ca commit 96e7771
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/Sulu/Bundle/SecurityBundle/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,17 +306,22 @@ public function eraseCredentials()
public function serialize()
{
return \serialize(
[
$this->id,
$this->password,
$this->salt,
$this->username,
$this->locked,
$this->enabled,
]
$this->__serialize()
);
}

public function __serialize(): array
{
return [
$this->id,
$this->password,
$this->salt,
$this->username,
$this->locked,
$this->enabled,
];
}

/**
* Constructs the object.
*
Expand All @@ -325,10 +330,15 @@ public function serialize()
* @param string $serialized The string representation of the object
*/
public function unserialize($serialized)
{
$this->__unserialize($serialized);
}

public function __unserialize(string $serialized): array
{
list(
$this->id, $this->password, $this->salt, $this->username, $this->locked, $this->enabled
) = \unserialize($serialized);
) = \unserialize($serialized);
}

/**
Expand Down

0 comments on commit 96e7771

Please sign in to comment.