Commit 9c85196e authored by Lukas Buchs's avatar Lukas Buchs
Browse files

PHP 8.1 Compatibility

Fix Serializable  PHP 8.1 Compatibility Issue
No related merge requests found
Showing with 23 additions and 1 deletion
+23 -1
...@@ -211,7 +211,7 @@ class ByteBuffer implements \JsonSerializable, \Serializable { ...@@ -211,7 +211,7 @@ class ByteBuffer implements \JsonSerializable, \Serializable {
/** /**
* jsonSerialize interface * jsonSerialize interface
* return binary data in RFC 1342-Like serialized string * return binary data in RFC 1342-Like serialized string
* @return \stdClass * @return string
*/ */
public function jsonSerialize() { public function jsonSerialize() {
if (ByteBuffer::$useBase64UrlEncoding) { if (ByteBuffer::$useBase64UrlEncoding) {
...@@ -239,6 +239,16 @@ class ByteBuffer implements \JsonSerializable, \Serializable { ...@@ -239,6 +239,16 @@ class ByteBuffer implements \JsonSerializable, \Serializable {
$this->_length = \strlen($this->_data); $this->_length = \strlen($this->_data);
} }
/**
* (PHP 8 deprecates Serializable-Interface)
* @return array
*/
public function __serialize() {
return [
'data' => \serialize($this->_data)
];
}
/** /**
* object to string * object to string
* @return string * @return string
...@@ -247,6 +257,18 @@ class ByteBuffer implements \JsonSerializable, \Serializable { ...@@ -247,6 +257,18 @@ class ByteBuffer implements \JsonSerializable, \Serializable {
return $this->getHex(); return $this->getHex();
} }
/**
* (PHP 8 deprecates Serializable-Interface)
* @param array $data
* @return void
*/
public function __unserialize($data) {
if ($data && isset($data['data'])) {
$this->_data = \unserialize($data['data']);
$this->_length = \strlen($this->_data);
}
}
// ----------------------- // -----------------------
// PROTECTED STATIC // PROTECTED STATIC
// ----------------------- // -----------------------
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment