From e6dac085cb1d601da1fc63bfd59d811612fa6ef4 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 8 Oct 2021 12:24:19 +0000 Subject: update composer libs --- vendor/ramsey/uuid/src/Lazy/LazyUuidFromString.php | 33 ++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'vendor/ramsey/uuid/src/Lazy/LazyUuidFromString.php') diff --git a/vendor/ramsey/uuid/src/Lazy/LazyUuidFromString.php b/vendor/ramsey/uuid/src/Lazy/LazyUuidFromString.php index 3d4ddcb21..8ba757964 100644 --- a/vendor/ramsey/uuid/src/Lazy/LazyUuidFromString.php +++ b/vendor/ramsey/uuid/src/Lazy/LazyUuidFromString.php @@ -7,7 +7,7 @@ * file that was distributed with this source code. * * @copyright Copyright (c) Ben Ramsey - * @license http://opensource.org/licenses/MIT MIT + * @license http://opensource.org/licenses/MIT MIT */ declare(strict_types=1); @@ -24,10 +24,12 @@ use Ramsey\Uuid\Type\Hexadecimal; use Ramsey\Uuid\Type\Integer as IntegerObject; use Ramsey\Uuid\UuidFactory; use Ramsey\Uuid\UuidInterface; +use ValueError; use function assert; use function bin2hex; use function hex2bin; +use function sprintf; use function str_replace; use function substr; @@ -90,6 +92,16 @@ final class LazyUuidFromString implements UuidInterface return $this->uuid; } + /** + * @return array{string: string} + * + * @psalm-return array{string: non-empty-string} + */ + public function __serialize(): array + { + return ['string' => $this->uuid]; + } + /** * {@inheritDoc} * @@ -102,6 +114,22 @@ final class LazyUuidFromString implements UuidInterface $this->uuid = $serialized; } + /** + * @param array{string: string} $data + * + * @psalm-param array{string: non-empty-string} $data + */ + public function __unserialize(array $data): void + { + // @codeCoverageIgnoreStart + if (!isset($data['string'])) { + throw new ValueError(sprintf('%s(): Argument #1 ($data) is invalid', __METHOD__)); + } + // @codeCoverageIgnoreEnd + + $this->unserialize($data['string']); + } + /** @psalm-suppress DeprecatedMethod */ public function getNumberConverter(): NumberConverterInterface { @@ -242,6 +270,7 @@ final class LazyUuidFromString implements UuidInterface */ public function getBytes(): string { + /** @phpstan-ignore-next-line PHPStan complains that this is not a non-empty-string. */ return (string) hex2bin(str_replace('-', '', $this->uuid)); } @@ -497,7 +526,7 @@ final class LazyUuidFromString implements UuidInterface public function getTimestamp(): string { $instance = ($this->unwrapped ?? $this->unwrap()); - $fields = $instance->getFields(); + $fields = $instance->getFields(); if ($fields->getVersion() !== 1) { throw new UnsupportedOperationException('Not a time-based UUID'); -- cgit v1.2.3