Skip to content

Commit a339ef7

Browse files
authored
chore: php8.1 __serialize & __unserialize
to remove the php8.1 warning
1 parent 248d60e commit a339ef7

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/Mongo/MongoId.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,22 @@ public function unserialize($serialized)
142142
$this->createObjectID($serialized);
143143
}
144144

145+
/**
146+
* @return string
147+
*/
148+
public function __serialize()
149+
{
150+
return (string) $this->objectID;
151+
}
152+
153+
/**
154+
* @param string $serialized
155+
*/
156+
public function __unserialize($serialized)
157+
{
158+
$this->createObjectID($serialized);
159+
}
160+
145161
/**
146162
* Gets the incremented value to create this id
147163
* @link http://php.net/manual/en/mongoid.getinc.php

0 commit comments

Comments
 (0)