Add support for PHP 8.1

This commit is contained in:
Graham Campbell
2021-09-05 12:41:13 +01:00
parent fe665a03df
commit 0997de99a2
11 changed files with 203 additions and 6 deletions
+22
View File
@@ -15,9 +15,11 @@ declare(strict_types=1);
namespace Ramsey\Uuid\Type;
use Ramsey\Uuid\Exception\InvalidArgumentException;
use ValueError;
use function ctype_digit;
use function ltrim;
use function sprintf;
use function strpos;
use function substr;
@@ -114,6 +116,14 @@ final class Integer implements NumberInterface
return $this->toString();
}
/**
* @return array{string: string}
*/
public function __serialize(): array
{
return ['string' => $this->toString()];
}
/**
* Constructs the object from a serialized string representation
*
@@ -126,4 +136,16 @@ final class Integer implements NumberInterface
{
$this->__construct($serialized);
}
/**
* @param array{string: string} $data
*/
public function __unserialize(array $data): void
{
if (!isset($data['string'])) {
throw new ValueError(sprintf('%s(): Argument #1 ($data) is invalid', __METHOD__));
}
$this->unserialize($data['string']);
}
}