Skip to content

Commit 18e7bc3

Browse files
committed
Convert deprecated Serializable to magic methods
See https://php.watch/versions/8.1/serializable-deprecated
1 parent 99f4b5d commit 18e7bc3

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/Entity/User.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
1414
* @ORM\Table(name="users")
1515
*/
16-
class User implements UserInterface, \Serializable, JsonSerializable
16+
class User implements UserInterface, JsonSerializable
1717
{
1818
/**
1919
* @ORM\Id()
@@ -225,24 +225,18 @@ public function setLastLogin(\DateTimeInterface $lastLogin): self
225225
return $this;
226226
}
227227

228-
/** @see \Serializable::serialize() */
229-
public function serialize()
228+
public function __serialize(): array
230229
{
231-
return serialize(array(
230+
return [
232231
$this->id,
233232
$this->username,
234233
$this->lmsUserId
235-
));
234+
];
236235
}
237236

238-
/** @see \Serializable::unserialize() */
239-
public function unserialize($serialized)
237+
public function __unserialize(array $data): void
240238
{
241-
list(
242-
$this->id,
243-
$this->username,
244-
$this->lmsUserId
245-
) = unserialize($serialized);
239+
[$this->id, $this->username, $this->lmsUserId] = $data;
246240
}
247241

248242
public function jsonSerialize(): array

0 commit comments

Comments
 (0)