mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-25 17:45:35 +03:00
Add support for PHP 8.1
This commit is contained in:
@@ -14,7 +14,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Fields;
|
||||
|
||||
use ValueError;
|
||||
|
||||
use function base64_decode;
|
||||
use function sprintf;
|
||||
use function strlen;
|
||||
|
||||
/**
|
||||
@@ -42,6 +45,14 @@ trait SerializableFieldsTrait
|
||||
return $this->getBytes();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{bytes: string}
|
||||
*/
|
||||
public function __serialize(): array
|
||||
{
|
||||
return ['bytes' => $this->getBytes()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the object from a serialized string representation
|
||||
*
|
||||
@@ -58,4 +69,16 @@ trait SerializableFieldsTrait
|
||||
$this->__construct(base64_decode($serialized));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{bytes: string} $data
|
||||
*/
|
||||
public function __unserialize(array $data): void
|
||||
{
|
||||
if (!isset($data['bytes'])) {
|
||||
throw new ValueError(sprintf('%s(): Argument #1 ($data) is invalid', __METHOD__));
|
||||
}
|
||||
|
||||
$this->unserialize($data['bytes']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user