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 5, 2021
1 parent daaabe2 commit 74cf4fd
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 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,25 @@ public function eraseCredentials()
public function serialize()
{
return \serialize(
[
$this->id,
$this->password,
$this->salt,
$this->username,
$this->locked,
$this->enabled,
]
$this->__serialize()
);
}

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

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

/**
* @param mixed[] $data
*/
public function __unserialize(array $data): void
{
list(
$this->id, $this->password, $this->salt, $this->username, $this->locked, $this->enabled
) = \unserialize($serialized);
) = $data;
}

/**
Expand Down

0 comments on commit 74cf4fd

Please sign in to comment.