Skip to content

Commit

Permalink
Convert deprecated Serializable to magic methods
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-3 committed Feb 1, 2022
1 parent f61c3c8 commit 04052db
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
* @ORM\Table(name="users")
*/
class User implements UserInterface, \Serializable, JsonSerializable
class User implements UserInterface, JsonSerializable
{
/**
* @ORM\Id()
Expand Down Expand Up @@ -225,24 +225,18 @@ public function setLastLogin(\DateTimeInterface $lastLogin): self
return $this;
}

/** @see \Serializable::serialize() */
public function serialize()
public function __serialize(): array
{
return serialize(array(
return [
$this->id,
$this->username,
$this->lmsUserId
));
];
}

/** @see \Serializable::unserialize() */
public function unserialize($serialized)
public function __unserialize(array $data): void
{
list(
$this->id,
$this->username,
$this->lmsUserId
) = unserialize($serialized);
[$this->id, $this->username, $this->lmsUserId] = $data;
}

public function jsonSerialize(): array
Expand Down

0 comments on commit 04052db

Please sign in to comment.