diff options
Diffstat (limited to 'vendor/ramsey/uuid')
57 files changed, 923 insertions, 1013 deletions
diff --git a/vendor/ramsey/uuid/README.md b/vendor/ramsey/uuid/README.md index 1862569fd..97e81a501 100644 --- a/vendor/ramsey/uuid/README.md +++ b/vendor/ramsey/uuid/README.md @@ -8,9 +8,9 @@ <a href="https://github.com/ramsey/uuid"><img src="http://img.shields.io/badge/source-ramsey/uuid-blue.svg?style=flat-square" alt="Source Code"></a> <a href="https://packagist.org/packages/ramsey/uuid"><img src="https://img.shields.io/packagist/v/ramsey/uuid.svg?style=flat-square&label=release" alt="Download Package"></a> <a href="https://php.net"><img src="https://img.shields.io/packagist/php-v/ramsey/uuid.svg?style=flat-square&colorB=%238892BF" alt="PHP Programming Language"></a> - <a href="https://github.com/ramsey/uuid/blob/4.x/LICENSE"><img src="https://img.shields.io/packagist/l/ramsey/uuid.svg?style=flat-square&colorB=darkcyan" alt="Read License"></a> - <a href="https://github.com/ramsey/uuid/actions/workflows/continuous-integration.yml"><img src="https://img.shields.io/github/workflow/status/ramsey/uuid/build/4.x?logo=github&style=flat-square" alt="Build Status"></a> - <a href="https://app.codecov.io/gh/ramsey/uuid/branch/4.x"><img src="https://img.shields.io/codecov/c/github/ramsey/uuid/4.x?label=codecov&logo=codecov&style=flat-square" alt="Codecov Code Coverage"></a> + <a href="https://github.com/ramsey/uuid/blob/main/LICENSE"><img src="https://img.shields.io/packagist/l/ramsey/uuid.svg?style=flat-square&colorB=darkcyan" alt="Read License"></a> + <a href="https://github.com/ramsey/uuid/actions/workflows/continuous-integration.yml"><img src="https://img.shields.io/github/workflow/status/ramsey/uuid/build/main?logo=github&style=flat-square" alt="Build Status"></a> + <a href="https://codecov.io/gh/ramsey/uuid"><img src="https://img.shields.io/codecov/c/gh/ramsey/uuid?label=codecov&logo=codecov&style=flat-square" alt="Codecov Code Coverage"></a> <a href="https://shepherd.dev/github/ramsey/uuid"><img src="https://img.shields.io/endpoint?style=flat-square&url=https%3A%2F%2Fshepherd.dev%2Fgithub%2Framsey%2Fuuid%2Fcoverage" alt="Psalm Type Coverage"></a> </p> @@ -38,7 +38,7 @@ composer require ramsey/uuid See the documentation for a thorough upgrade guide: -* [Upgrading ramsey/uuid Version 3 to 4](https://uuid.ramsey.dev/en/stable/upgrading/3-to-4.html) +* [Upgrading ramsey/uuid Version 3 to 4](https://uuid.ramsey.dev/en/latest/upgrading/3-to-4.html) ## Documentation @@ -74,10 +74,10 @@ licensed for use under the MIT License (MIT). Please see [LICENSE][] for more information. [rfc4122]: http://tools.ietf.org/html/rfc4122 -[conduct]: https://github.com/ramsey/uuid/blob/4.x/CODE_OF_CONDUCT.md +[conduct]: https://github.com/ramsey/uuid/blob/main/CODE_OF_CONDUCT.md [javauuid]: http://docs.oracle.com/javase/6/docs/api/java/util/UUID.html [pyuuid]: http://docs.python.org/3/library/uuid.html [composer]: http://getcomposer.org/ -[contributing.md]: https://github.com/ramsey/uuid/blob/4.x/CONTRIBUTING.md -[security.md]: https://github.com/ramsey/uuid/blob/4.x/SECURITY.md -[license]: https://github.com/ramsey/uuid/blob/4.x/LICENSE +[contributing.md]: https://github.com/ramsey/uuid/blob/main/CONTRIBUTING.md +[security.md]: https://github.com/ramsey/uuid/blob/main/SECURITY.md +[license]: https://github.com/ramsey/uuid/blob/main/LICENSE diff --git a/vendor/ramsey/uuid/composer.json b/vendor/ramsey/uuid/composer.json index 9653cad25..112fabf10 100644 --- a/vendor/ramsey/uuid/composer.json +++ b/vendor/ramsey/uuid/composer.json @@ -12,7 +12,7 @@ "php": "^8.0", "ext-ctype": "*", "ext-json": "*", - "brick/math": "^0.8.8 || ^0.9 || ^0.10", + "brick/math": "^0.8 || ^0.9", "ramsey/collection": "^1.0" }, "require-dev": { @@ -22,18 +22,18 @@ "doctrine/annotations": "^1.8", "ergebnis/composer-normalize": "^2.15", "mockery/mockery": "^1.3", + "moontoast/math": "^1.1", "paragonie/random-lib": "^2", "php-mock/php-mock": "^2.2", "php-mock/php-mock-mockery": "^1.3", "php-parallel-lint/php-parallel-lint": "^1.1", "phpbench/phpbench": "^1.0", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan": "^1.8", - "phpstan/phpstan-mockery": "^1.1", - "phpstan/phpstan-phpunit": "^1.1", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^0.12", + "phpstan/phpstan-mockery": "^0.12", + "phpstan/phpstan-phpunit": "^0.12", "phpunit/phpunit": "^8.5 || ^9", - "ramsey/composer-repl": "^1.4", - "slevomat/coding-standard": "^8.4", + "slevomat/coding-standard": "^7.0", "squizlabs/php_codesniffer": "^3.5", "vimeo/psalm": "^4.9" }, @@ -70,8 +70,7 @@ "captainhook/plugin-composer": true, "ergebnis/composer-normalize": true, "phpstan/extension-installer": true, - "dealerdirect/phpcodesniffer-composer-installer": true, - "ramsey/composer-repl": true + "dealerdirect/phpcodesniffer-composer-installer": true }, "sort-packages": true }, diff --git a/vendor/ramsey/uuid/src/Builder/DegradedUuidBuilder.php b/vendor/ramsey/uuid/src/Builder/DegradedUuidBuilder.php index 20b384212..23931e416 100644 --- a/vendor/ramsey/uuid/src/Builder/DegradedUuidBuilder.php +++ b/vendor/ramsey/uuid/src/Builder/DegradedUuidBuilder.php @@ -30,7 +30,15 @@ use Ramsey\Uuid\UuidInterface; */ class DegradedUuidBuilder implements UuidBuilderInterface { - private TimeConverterInterface $timeConverter; + /** + * @var NumberConverterInterface + */ + private $numberConverter; + + /** + * @var TimeConverterInterface + */ + private $timeConverter; /** * @param NumberConverterInterface $numberConverter The number converter to @@ -39,9 +47,10 @@ class DegradedUuidBuilder implements UuidBuilderInterface * for converting timestamps extracted from a UUID to Unix timestamps */ public function __construct( - private NumberConverterInterface $numberConverter, + NumberConverterInterface $numberConverter, ?TimeConverterInterface $timeConverter = null ) { + $this->numberConverter = $numberConverter; $this->timeConverter = $timeConverter ?: new DegradedTimeConverter(); } diff --git a/vendor/ramsey/uuid/src/Builder/FallbackBuilder.php b/vendor/ramsey/uuid/src/Builder/FallbackBuilder.php index ba5f31fbe..8ab438a19 100644 --- a/vendor/ramsey/uuid/src/Builder/FallbackBuilder.php +++ b/vendor/ramsey/uuid/src/Builder/FallbackBuilder.php @@ -28,10 +28,16 @@ use Ramsey\Uuid\UuidInterface; class FallbackBuilder implements UuidBuilderInterface { /** + * @var iterable<UuidBuilderInterface> + */ + private $builders; + + /** * @param iterable<UuidBuilderInterface> $builders An array of UUID builders */ - public function __construct(private iterable $builders) + public function __construct(iterable $builders) { + $this->builders = $builders; } /** diff --git a/vendor/ramsey/uuid/src/Codec/StringCodec.php b/vendor/ramsey/uuid/src/Codec/StringCodec.php index 4b6e4e5b9..58c9f5806 100644 --- a/vendor/ramsey/uuid/src/Codec/StringCodec.php +++ b/vendor/ramsey/uuid/src/Codec/StringCodec.php @@ -37,12 +37,18 @@ use function substr; class StringCodec implements CodecInterface { /** + * @var UuidBuilderInterface + */ + private $builder; + + /** * Constructs a StringCodec * * @param UuidBuilderInterface $builder The builder to use when encoding UUIDs */ - public function __construct(private UuidBuilderInterface $builder) + public function __construct(UuidBuilderInterface $builder) { + $this->builder = $builder; } public function encode(UuidInterface $uuid): string diff --git a/vendor/ramsey/uuid/src/Converter/Number/BigNumberConverter.php b/vendor/ramsey/uuid/src/Converter/Number/BigNumberConverter.php index 99b88b3bf..fef63fd00 100644 --- a/vendor/ramsey/uuid/src/Converter/Number/BigNumberConverter.php +++ b/vendor/ramsey/uuid/src/Converter/Number/BigNumberConverter.php @@ -27,7 +27,10 @@ use Ramsey\Uuid\Math\BrickMathCalculator; */ class BigNumberConverter implements NumberConverterInterface { - private NumberConverterInterface $converter; + /** + * @var NumberConverterInterface + */ + private $converter; public function __construct() { diff --git a/vendor/ramsey/uuid/src/Converter/Number/GenericNumberConverter.php b/vendor/ramsey/uuid/src/Converter/Number/GenericNumberConverter.php index 043c3c43d..501eac0fa 100644 --- a/vendor/ramsey/uuid/src/Converter/Number/GenericNumberConverter.php +++ b/vendor/ramsey/uuid/src/Converter/Number/GenericNumberConverter.php @@ -26,8 +26,14 @@ use Ramsey\Uuid\Type\Integer as IntegerObject; */ class GenericNumberConverter implements NumberConverterInterface { - public function __construct(private CalculatorInterface $calculator) + /** + * @var CalculatorInterface + */ + private $calculator; + + public function __construct(CalculatorInterface $calculator) { + $this->calculator = $calculator; } /** diff --git a/vendor/ramsey/uuid/src/Converter/Time/BigNumberTimeConverter.php b/vendor/ramsey/uuid/src/Converter/Time/BigNumberTimeConverter.php index b6bca9ee2..7390dad83 100644 --- a/vendor/ramsey/uuid/src/Converter/Time/BigNumberTimeConverter.php +++ b/vendor/ramsey/uuid/src/Converter/Time/BigNumberTimeConverter.php @@ -29,7 +29,10 @@ use Ramsey\Uuid\Type\Time; */ class BigNumberTimeConverter implements TimeConverterInterface { - private TimeConverterInterface $converter; + /** + * @var TimeConverterInterface + */ + private $converter; public function __construct() { diff --git a/vendor/ramsey/uuid/src/Converter/Time/GenericTimeConverter.php b/vendor/ramsey/uuid/src/Converter/Time/GenericTimeConverter.php index f6b60abbe..a8aa64b73 100644 --- a/vendor/ramsey/uuid/src/Converter/Time/GenericTimeConverter.php +++ b/vendor/ramsey/uuid/src/Converter/Time/GenericTimeConverter.php @@ -50,8 +50,14 @@ class GenericTimeConverter implements TimeConverterInterface */ private const MICROSECOND_INTERVALS = '10'; - public function __construct(private CalculatorInterface $calculator) + /** + * @var CalculatorInterface + */ + private $calculator; + + public function __construct(CalculatorInterface $calculator) { + $this->calculator = $calculator; } public function calculateTime(string $seconds, string $microseconds): Hexadecimal diff --git a/vendor/ramsey/uuid/src/Converter/Time/PhpTimeConverter.php b/vendor/ramsey/uuid/src/Converter/Time/PhpTimeConverter.php index 66009f14d..538d2f2f6 100644 --- a/vendor/ramsey/uuid/src/Converter/Time/PhpTimeConverter.php +++ b/vendor/ramsey/uuid/src/Converter/Time/PhpTimeConverter.php @@ -58,9 +58,20 @@ class PhpTimeConverter implements TimeConverterInterface */ private const MICROSECOND_INTERVALS = 10; - private int $phpPrecision; - private CalculatorInterface $calculator; - private TimeConverterInterface $fallbackConverter; + /** + * @var CalculatorInterface + */ + private $calculator; + + /** + * @var TimeConverterInterface + */ + private $fallbackConverter; + + /** + * @var int + */ + private $phpPrecision; public function __construct( ?CalculatorInterface $calculator = null, @@ -121,11 +132,11 @@ class PhpTimeConverter implements TimeConverterInterface } /** - * @param float|int $time The time to split into seconds and microseconds + * @param int|float $time The time to split into seconds and microseconds * * @return string[] */ - private function splitTime(float | int $time): array + private function splitTime($time): array { $split = explode('.', (string) $time, 2); diff --git a/vendor/ramsey/uuid/src/Converter/Time/UnixTimeConverter.php b/vendor/ramsey/uuid/src/Converter/Time/UnixTimeConverter.php deleted file mode 100644 index 4d6d0a8a7..000000000 --- a/vendor/ramsey/uuid/src/Converter/Time/UnixTimeConverter.php +++ /dev/null @@ -1,90 +0,0 @@ -<?php - -/** - * This file is part of the ramsey/uuid library - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - * - * @copyright Copyright (c) Ben Ramsey <ben@benramsey.com> - * @license http://opensource.org/licenses/MIT MIT - */ - -declare(strict_types=1); - -namespace Ramsey\Uuid\Converter\Time; - -use Ramsey\Uuid\Converter\TimeConverterInterface; -use Ramsey\Uuid\Math\CalculatorInterface; -use Ramsey\Uuid\Math\RoundingMode; -use Ramsey\Uuid\Type\Hexadecimal; -use Ramsey\Uuid\Type\Integer as IntegerObject; -use Ramsey\Uuid\Type\Time; - -use function explode; -use function str_pad; - -use const STR_PAD_LEFT; - -/** - * UnixTimeConverter converts Unix Epoch timestamps to/from hexadecimal values - * consisting of milliseconds elapsed since the Unix Epoch - * - * @psalm-immutable - */ -class UnixTimeConverter implements TimeConverterInterface -{ - private const MILLISECONDS = 1000; - - public function __construct(private CalculatorInterface $calculator) - { - } - - public function calculateTime(string $seconds, string $microseconds): Hexadecimal - { - $timestamp = new Time($seconds, $microseconds); - - // Convert the seconds into milliseconds. - $sec = $this->calculator->multiply( - $timestamp->getSeconds(), - new IntegerObject(self::MILLISECONDS), - ); - - // Convert the microseconds into milliseconds; the scale is zero because - // we need to discard the fractional part. - $usec = $this->calculator->divide( - RoundingMode::DOWN, // Always round down to stay in the previous millisecond. - 0, - $timestamp->getMicroseconds(), - new IntegerObject(self::MILLISECONDS), - ); - - /** @var IntegerObject $unixTime */ - $unixTime = $this->calculator->add($sec, $usec); - - $unixTimeHex = str_pad( - $this->calculator->toHexadecimal($unixTime)->toString(), - 12, - '0', - STR_PAD_LEFT - ); - - return new Hexadecimal($unixTimeHex); - } - - public function convertTime(Hexadecimal $uuidTimestamp): Time - { - $milliseconds = $this->calculator->toInteger($uuidTimestamp); - - $unixTimestamp = $this->calculator->divide( - RoundingMode::HALF_UP, - 6, - $milliseconds, - new IntegerObject(self::MILLISECONDS) - ); - - $split = explode('.', (string) $unixTimestamp, 2); - - return new Time($split[0], $split[1] ?? '0'); - } -} diff --git a/vendor/ramsey/uuid/src/DeprecatedUuidInterface.php b/vendor/ramsey/uuid/src/DeprecatedUuidInterface.php index ac01a79cf..ed6d9dec8 100644 --- a/vendor/ramsey/uuid/src/DeprecatedUuidInterface.php +++ b/vendor/ramsey/uuid/src/DeprecatedUuidInterface.php @@ -18,7 +18,8 @@ use DateTimeInterface; use Ramsey\Uuid\Converter\NumberConverterInterface; /** - * This interface encapsulates deprecated methods for ramsey/uuid + * This interface encapsulates deprecated methods for ramsey/uuid; this + * interface and its methods will be removed in ramsey/uuid 5.0.0. * * @psalm-immutable */ @@ -123,6 +124,12 @@ interface DeprecatedUuidInterface public function getTimestampHex(): string; /** + * @deprecated In ramsey/uuid version 5.0.0, this will be removed from this + * interface. It has moved to {@see \Ramsey\Uuid\Rfc4122\UuidInterface::getUrn()}. + */ + public function getUrn(): string; + + /** * @deprecated Use {@see UuidInterface::getFields()} to get a * {@see FieldsInterface} instance. If it is a * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call diff --git a/vendor/ramsey/uuid/src/DeprecatedUuidMethodsTrait.php b/vendor/ramsey/uuid/src/DeprecatedUuidMethodsTrait.php index d3fbb0ccb..342829523 100644 --- a/vendor/ramsey/uuid/src/DeprecatedUuidMethodsTrait.php +++ b/vendor/ramsey/uuid/src/DeprecatedUuidMethodsTrait.php @@ -17,8 +17,10 @@ namespace Ramsey\Uuid; use DateTimeImmutable; use DateTimeInterface; use Ramsey\Uuid\Converter\NumberConverterInterface; +use Ramsey\Uuid\Converter\TimeConverterInterface; use Ramsey\Uuid\Exception\DateTimeException; use Ramsey\Uuid\Exception\UnsupportedOperationException; +use Ramsey\Uuid\Rfc4122\FieldsInterface as Rfc4122FieldsInterface; use Throwable; use function str_pad; @@ -30,17 +32,29 @@ use const STR_PAD_LEFT; * This trait encapsulates deprecated methods for ramsey/uuid; this trait and * its methods will be removed in ramsey/uuid 5.0.0. * - * @deprecated This trait and its methods will be removed in ramsey/uuid 5.0.0. - * * @psalm-immutable */ trait DeprecatedUuidMethodsTrait { /** + * @var Rfc4122FieldsInterface + */ + protected $fields; + + /** + * @var NumberConverterInterface + */ + protected $numberConverter; + + /** + * @var TimeConverterInterface + */ + protected $timeConverter; + + /** * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getClockSeqHiAndReserved()} + * {@see FieldsInterface} instance. If it is a {@see Rfc4122FieldsInterface} + * instance, you may call {@see Rfc4122FieldsInterface::getClockSeqHiAndReserved()} * and use the arbitrary-precision math library of your choice to * convert it to a string integer. */ @@ -51,9 +65,8 @@ trait DeprecatedUuidMethodsTrait /** * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getClockSeqHiAndReserved()}. + * {@see FieldsInterface} instance. If it is a {@see Rfc4122FieldsInterface} + * instance, you may call {@see Rfc4122FieldsInterface::getClockSeqHiAndReserved()}. */ public function getClockSeqHiAndReservedHex(): string { @@ -62,9 +75,8 @@ trait DeprecatedUuidMethodsTrait /** * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getClockSeqLow()} + * {@see FieldsInterface} instance. If it is a {@see Rfc4122FieldsInterface} + * instance, you may call {@see Rfc4122FieldsInterface::getClockSeqLow()} * and use the arbitrary-precision math library of your choice to * convert it to a string integer. */ @@ -75,9 +87,8 @@ trait DeprecatedUuidMethodsTrait /** * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getClockSeqLow()}. + * {@see FieldsInterface} instance. If it is a {@see Rfc4122FieldsInterface} + * instance, you may call {@see Rfc4122FieldsInterface::getClockSeqLow()}. */ public function getClockSeqLowHex(): string { @@ -86,9 +97,8 @@ trait DeprecatedUuidMethodsTrait /** * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getClockSeq()} + * {@see FieldsInterface} instance. If it is a {@see Rfc4122FieldsInterface} + * instance, you may call {@see Rfc4122FieldsInterface::getClockSeq()} * and use the arbitrary-precision math library of your choice to * convert it to a string integer. */ @@ -99,9 +109,8 @@ trait DeprecatedUuidMethodsTrait /** * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getClockSeq()}. + * {@see FieldsInterface} instance. If it is a {@see Rfc4122FieldsInterface} + * instance, you may call {@see Rfc4122FieldsInterface::getClockSeq()}. */ public function getClockSequenceHex(): string { @@ -148,7 +157,7 @@ trait DeprecatedUuidMethodsTrait /** * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. + * {@see FieldsInterface} instance. * * @return string[] */ @@ -210,11 +219,10 @@ trait DeprecatedUuidMethodsTrait /** * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getNode()} and use the - * arbitrary-precision math library of your choice to convert it to a - * string integer. + * {@see FieldsInterface} instance. If it is a {@see Rfc4122FieldsInterface} + * instance, you may call {@see Rfc4122FieldsInterface::getNode()} + * and use the arbitrary-precision math library of your choice to + * convert it to a string integer. */ public function getNode(): string { @@ -223,9 +231,8 @@ trait DeprecatedUuidMethodsTrait /** * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getNode()}. + * {@see FieldsInterface} instance. If it is a {@see Rfc4122FieldsInterface} + * instance, you may call {@see Rfc4122FieldsInterface::getNode()}. */ public function getNodeHex(): string { @@ -234,9 +241,8 @@ trait DeprecatedUuidMethodsTrait /** * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimeHiAndVersion()} + * {@see FieldsInterface} instance. If it is a {@see Rfc4122FieldsInterface} + * instance, you may call {@see Rfc4122FieldsInterface::getTimeHiAndVersion()} * and use the arbitrary-precision math library of your choice to * convert it to a string integer. */ @@ -247,9 +253,8 @@ trait DeprecatedUuidMethodsTrait /** * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimeHiAndVersion()}. + * {@see FieldsInterface} instance. If it is a {@see Rfc4122FieldsInterface} + * instance, you may call {@see Rfc4122FieldsInterface::getTimeHiAndVersion()}. */ public function getTimeHiAndVersionHex(): string { @@ -258,11 +263,10 @@ trait DeprecatedUuidMethodsTrait /** * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimeLow()} and use the - * arbitrary-precision math library of your choice to convert it to a - * string integer. + * {@see FieldsInterface} instance. If it is a {@see Rfc4122FieldsInterface} + * instance, you may call {@see Rfc4122FieldsInterface::getTimeLow()} + * and use the arbitrary-precision math library of your choice to + * convert it to a string integer. */ public function getTimeLow(): string { @@ -271,9 +275,8 @@ trait DeprecatedUuidMethodsTrait /** * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimeLow()}. + * {@see FieldsInterface} instance. If it is a {@see Rfc4122FieldsInterface} + * instance, you may call {@see Rfc4122FieldsInterface::getTimeLow()}. */ public function getTimeLowHex(): string { @@ -282,11 +285,10 @@ trait DeprecatedUuidMethodsTrait /** * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimeMid()} and use the - * arbitrary-precision math library of your choice to convert it to a - * string integer. + * {@see FieldsInterface} instance. If it is a {@see Rfc4122FieldsInterface} + * instance, you may call {@see Rfc4122FieldsInterface::getTimeMid()} + * and use the arbitrary-precision math library of your choice to + * convert it to a string integer. */ public function getTimeMid(): string { @@ -295,9 +297,8 @@ trait DeprecatedUuidMethodsTrait /** * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimeMid()}. + * {@see FieldsInterface} instance. If it is a {@see Rfc4122FieldsInterface} + * instance, you may call {@see Rfc4122FieldsInterface::getTimeMid()}. */ public function getTimeMidHex(): string { @@ -306,11 +307,10 @@ trait DeprecatedUuidMethodsTrait /** * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimestamp()} and use - * the arbitrary-precision math library of your choice to convert it to - * a string integer. + * {@see FieldsInterface} instance. If it is a {@see Rfc4122FieldsInterface} + * instance, you may call {@see Rfc4122FieldsInterface::getTimestamp()} + * and use the arbitrary-precision math library of your choice to + * convert it to a string integer. */ public function getTimestamp(): string { @@ -323,9 +323,8 @@ trait DeprecatedUuidMethodsTrait /** * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimestamp()}. + * {@see FieldsInterface} instance. If it is a {@see Rfc4122FieldsInterface} + * instance, you may call {@see Rfc4122FieldsInterface::getTimestamp()}. */ public function getTimestampHex(): string { @@ -337,8 +336,19 @@ trait DeprecatedUuidMethodsTrait } /** + * @deprecated This has moved to {@see Rfc4122FieldsInterface::getUrn()} and + * is available on {@see \Ramsey\Uuid\Rfc4122\UuidV1}, + * {@see \Ramsey\Uuid\Rfc4122\UuidV3}, {@see \Ramsey\Uuid\Rfc4122\UuidV4}, + * and {@see \Ramsey\Uuid\Rfc4122\UuidV5}. + */ + public function getUrn(): string + { + return 'urn:uuid:' . $this->toString(); + } + + /** * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a + * {@see FieldsInterface} instance. If it is a * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getVariant()}. */ @@ -349,7 +359,7 @@ trait DeprecatedUuidMethodsTrait /** * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a + * {@see FieldsInterface} instance. If it is a * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getVersion()}. */ diff --git a/vendor/ramsey/uuid/src/FeatureSet.php b/vendor/ramsey/uuid/src/FeatureSet.php index 6c8ccb0de..668366601 100644 --- a/vendor/ramsey/uuid/src/FeatureSet.php +++ b/vendor/ramsey/uuid/src/FeatureSet.php @@ -23,7 +23,6 @@ use Ramsey\Uuid\Converter\Number\GenericNumberConverter; use Ramsey\Uuid\Converter\NumberConverterInterface; use Ramsey\Uuid\Converter\Time\GenericTimeConverter; use Ramsey\Uuid\Converter\Time\PhpTimeConverter; -use Ramsey\Uuid\Converter\Time\UnixTimeConverter; use Ramsey\Uuid\Converter\TimeConverterInterface; use Ramsey\Uuid\Generator\DceSecurityGenerator; use Ramsey\Uuid\Generator\DceSecurityGeneratorInterface; @@ -36,7 +35,6 @@ use Ramsey\Uuid\Generator\RandomGeneratorFactory; use Ramsey\Uuid\Generator\RandomGeneratorInterface; use Ramsey\Uuid\Generator\TimeGeneratorFactory; use Ramsey\Uuid\Generator\TimeGeneratorInterface; -use Ramsey\Uuid\Generator\UnixTimeGenerator; use Ramsey\Uuid\Guid\GuidBuilder; use Ramsey\Uuid\Math\BrickMathCalculator; use Ramsey\Uuid\Math\CalculatorInterface; @@ -63,25 +61,92 @@ use const PHP_INT_SIZE; */ class FeatureSet { - private ?TimeProviderInterface $timeProvider = null; - private CalculatorInterface $calculator; - private CodecInterface $codec; - private DceSecurityGeneratorInterface $dceSecurityGenerator; - private NameGeneratorInterface $nameGenerator; - private NodeProviderInterface $nodeProvider; - private NumberConverterInterface $numberConverter; - private RandomGeneratorInterface $randomGenerator; - private TimeConverterInterface $timeConverter; - private TimeGeneratorInterface $timeGenerator; - private TimeGeneratorInterface $unixTimeGenerator; - private UuidBuilderInterface $builder; - private ValidatorInterface $validator; + /** + * @var bool + */ + private $disableBigNumber = false; + + /** + * @var bool + */ + private $disable64Bit = false; + + /** + * @var bool + */ + private $ignoreSystemNode = false; + + /** + * @var bool + */ + private $enablePecl = false; + + /** + * @var UuidBuilderInterface + */ + private $builder; + + /** + * @var CodecInterface + */ + private $codec; + + /** + * @var DceSecurityGeneratorInterface + */ + private $dceSecurityGenerator; + + /** + * @var NameGeneratorInterface + */ + private $nameGenerator; + + /** + * @var NodeProviderInterface + */ + private $nodeProvider; + + /** + * @var NumberConverterInterface + */ + private $numberConverter; + + /** + * @var TimeConverterInterface + */ + private $timeConverter; + + /** + * @var RandomGeneratorInterface + */ + private $randomGenerator; + + /** + * @var TimeGeneratorInterface + */ + private $timeGenerator; + + /** + * @var TimeProviderInterface + */ + private $timeProvider; + + /** + * @var ValidatorInterface + */ + private $validator; + + /** + * @var CalculatorInterface + */ + private $calculator; /** * @param bool $useGuids True build UUIDs using the GuidStringCodec * @param bool $force32Bit True to force the use of 32-bit functionality * (primarily for testing purposes) - * @param bool $forceNoBigNumber (obsolete) + * @param bool $forceNoBigNumber True to disable the use of moontoast/math + * (primarily for testing purposes) * @param bool $ignoreSystemNode True to disable attempts to check for the * system node ID (primarily for testing purposes) * @param bool $enablePecl True to enable the use of the PeclUuidTimeGenerator @@ -89,23 +154,25 @@ class FeatureSet */ public function __construct( bool $useGuids = false, - private bool $force32Bit = false, + bool $force32Bit = false, bool $forceNoBigNumber = false, - private bool $ignoreSystemNode = false, - private bool $enablePecl = false + bool $ignoreSystemNode = false, + bool $enablePecl = false ) { - $this->randomGenerator = $this->buildRandomGenerator(); + $this->disableBigNumber = $forceNoBigNumber; + $this->disable64Bit = $force32Bit; + $this->ignoreSystemNode = $ignoreSystemNode; + $this->enablePecl = $enablePecl; + $this->setCalculator(new BrickMathCalculator()); $this->builder = $this->buildUuidBuilder($useGuids); $this->codec = $this->buildCodec($useGuids); $this->nodeProvider = $this->buildNodeProvider(); $this->nameGenerator = $this->buildNameGenerator(); + $this->randomGenerator = $this->buildRandomGenerator(); $this->setTimeProvider(new SystemTimeProvider()); $this->setDceSecurityProvider(new SystemDceSecurityProvider()); $this->validator = new GenericValidator(); - - assert($this->timeProvider !== null); - $this->unixTimeGenerator = $this->buildUnixTimeGenerator($this->timeProvider); } /** @@ -189,14 +256,6 @@ class FeatureSet } /** - * Returns the Unix Epoch time generator configured for this environment - */ - public function getUnixTimeGenerator(): TimeGeneratorInterface - { - return $this->unixTimeGenerator; - } - - /** * Returns the validator configured for this environment */ public function getValidator(): ValidatorInterface @@ -233,10 +292,7 @@ class FeatureSet public function setNodeProvider(NodeProviderInterface $nodeProvider): void { $this->nodeProvider = $nodeProvider; - - if (isset($this->timeProvider)) { - $this->timeGenerator = $this->buildTimeGenerator($this->timeProvider); - } + $this->timeGenerator = $this->buildTimeGenerator($this->timeProvider); } /** @@ -338,21 +394,6 @@ class FeatureSet } /** - * Returns a Unix Epoch time generator configured for this environment - * - * @param TimeProviderInterface $timeProvider The time provider to use with - * the time generator - */ - private function buildUnixTimeGenerator(TimeProviderInterface $timeProvider): TimeGeneratorInterface - { - return new UnixTimeGenerator( - new UnixTimeConverter(new BrickMathCalculator()), - $timeProvider, - $this->randomGenerator, - ); - } - - /** * Returns a name generator configured for this environment */ private function buildNameGenerator(): NameGeneratorInterface @@ -400,6 +441,6 @@ class FeatureSet */ private function is64BitSystem(): bool { - return PHP_INT_SIZE === 8 && !$this->force32Bit; + return PHP_INT_SIZE === 8 && !$this->disable64Bit; } } diff --git a/vendor/ramsey/uuid/src/Fields/SerializableFieldsTrait.php b/vendor/ramsey/uuid/src/Fields/SerializableFieldsTrait.php index 3d36b6f12..16e6525da 100644 --- a/vendor/ramsey/uuid/src/Fields/SerializableFieldsTrait.php +++ b/vendor/ramsey/uuid/src/Fields/SerializableFieldsTrait.php @@ -56,23 +56,22 @@ trait SerializableFieldsTrait /** * Constructs the object from a serialized string representation * - * @param string $data The serialized string representation of the object + * @param string $serialized The serialized string representation of the object * + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint * @psalm-suppress UnusedMethodCall */ - public function unserialize(string $data): void + public function unserialize($serialized): void { - if (strlen($data) === 16) { - $this->__construct($data); + if (strlen($serialized) === 16) { + $this->__construct($serialized); } else { - $this->__construct(base64_decode($data)); + $this->__construct(base64_decode($serialized)); } } /** - * @param array{bytes?: string} $data - * - * @psalm-suppress UnusedMethodCall + * @param array{bytes: string} $data */ public function __unserialize(array $data): void { diff --git a/vendor/ramsey/uuid/src/Generator/CombGenerator.php b/vendor/ramsey/uuid/src/Generator/CombGenerator.php index 0e8870608..25b7988ec 100644 --- a/vendor/ramsey/uuid/src/Generator/CombGenerator.php +++ b/vendor/ramsey/uuid/src/Generator/CombGenerator.php @@ -61,10 +61,22 @@ class CombGenerator implements RandomGeneratorInterface { public const TIMESTAMP_BYTES = 6; + /** + * @var RandomGeneratorInterface + */ + private $randomGenerator; + + /** + * @var NumberConverterInterface + */ + private $converter; + public function __construct( - private RandomGeneratorInterface $generator, - private NumberConverterInterface $numberConverter + RandomGeneratorInterface $generator, + NumberConverterInterface $numberConverter ) { + $this->converter = $numberConverter; + $this->randomGenerator = $generator; } /** @@ -83,11 +95,11 @@ class CombGenerator implements RandomGeneratorInterface $hash = ''; if (self::TIMESTAMP_BYTES > 0 && $length > self::TIMESTAMP_BYTES) { - $hash = $this->generator->generate($length - self::TIMESTAMP_BYTES); + $hash = $this->randomGenerator->generate($length - self::TIMESTAMP_BYTES); } $lsbTime = str_pad( - $this->numberConverter->toHex($this->timestamp()), + $this->converter->toHex($this->timestamp()), self::TIMESTAMP_BYTES * 2, '0', STR_PAD_LEFT diff --git a/vendor/ramsey/uuid/src/Generator/DceSecurityGenerator.php b/vendor/ramsey/uuid/src/Generator/DceSecurityGenerator.php index 37ba78131..aca8c5db7 100644 --- a/vendor/ramsey/uuid/src/Generator/DceSecurityGenerator.php +++ b/vendor/ramsey/uuid/src/Generator/DceSecurityGenerator.php @@ -52,11 +52,29 @@ class DceSecurityGenerator implements DceSecurityGeneratorInterface */ private const CLOCK_SEQ_LOW = 0; + /** + * @var NumberConverterInterface + */ + private $numberConverter; + + /** + * @var TimeGeneratorInterface + */ + private $timeGenerator; + + /** + * @var DceSecurityProviderInterface + */ + private $dceSecurityProvider; + public function __construct( - private NumberConverterInterface $numberConverter, - private TimeGeneratorInterface $timeGenerator, - private DceSecurityProviderInterface $dceSecurityProvider + NumberConverterInterface $numberConverter, + TimeGeneratorInterface $timeGenerator, + DceSecurityProviderInterface $dceSecurityProvider ) { + $this->numberConverter = $numberConverter; + $this->timeGenerator = $timeGenerator; + $this->dceSecurityProvider = $dceSecurityProvider; } public function generate( @@ -135,7 +153,8 @@ class DceSecurityGenerator implements DceSecurityGeneratorInterface // Replace bytes in the time-based UUID with DCE Security values. $bytes = substr_replace($bytes, $identifierBytes, 0, 4); + $bytes = substr_replace($bytes, $domainByte, 9, 1); - return substr_replace($bytes, $domainByte, 9, 1); + return $bytes; } } diff --git a/vendor/ramsey/uuid/src/Generator/DefaultTimeGenerator.php b/vendor/ramsey/uuid/src/Generator/DefaultTimeGenerator.php index a1b39b04a..d245c7bcc 100644 --- a/vendor/ramsey/uuid/src/Generator/DefaultTimeGenerator.php +++ b/vendor/ramsey/uuid/src/Generator/DefaultTimeGenerator.php @@ -40,11 +40,29 @@ use const STR_PAD_LEFT; */ class DefaultTimeGenerator implements TimeGeneratorInterface { + /** + * @var NodeProviderInterface + */ + private $nodeProvider; + + /** + * @var TimeConverterInterface + */ + private $timeConverter; + + /** + * @var TimeProviderInterface + */ + private $timeProvider; + public function __construct( - private NodeProviderInterface $nodeProvider, - private TimeConverterInterface $timeConverter, - private TimeProviderInterface $timeProvider + NodeProviderInterface $nodeProvider, + TimeConverterInterface $timeConverter, + TimeProviderInterface $timeProvider ) { + $this->nodeProvider = $nodeProvider; + $this->timeConverter = $timeConverter; + $this->timeProvider = $timeProvider; } /** @@ -103,13 +121,13 @@ class DefaultTimeGenerator implements TimeGeneratorInterface * Uses the node provider given when constructing this instance to get * the node ID (usually a MAC address) * - * @param int|string|null $node A node value that may be used to override the node provider + * @param string|int|null $node A node value that may be used to override the node provider * * @return string 6-byte binary string representation of the node * * @throws InvalidArgumentException */ - private function getValidNode(int | string | null $node): string + private function getValidNode($node): string { if ($node === null) { $node = $this->nodeProvider->getNode(); diff --git a/vendor/ramsey/uuid/src/Generator/PeclUuidNameGenerator.php b/vendor/ramsey/uuid/src/Generator/PeclUuidNameGenerator.php index 6a6d1aec3..3780c5c60 100644 --- a/vendor/ramsey/uuid/src/Generator/PeclUuidNameGenerator.php +++ b/vendor/ramsey/uuid/src/Generator/PeclUuidNameGenerator.php @@ -33,16 +33,21 @@ class PeclUuidNameGenerator implements NameGeneratorInterface /** @psalm-pure */ public function generate(UuidInterface $ns, string $name, string $hashAlgorithm): string { - $uuid = match ($hashAlgorithm) { - 'md5' => uuid_generate_md5($ns->toString(), $name), - 'sha1' => uuid_generate_sha1($ns->toString(), $name), - default => throw new NameException( - sprintf( + switch ($hashAlgorithm) { + case 'md5': + $uuid = uuid_generate_md5($ns->toString(), $name); + + break; + case 'sha1': + $uuid = uuid_generate_sha1($ns->toString(), $name); + + break; + default: + throw new NameException(sprintf( 'Unable to hash namespace and name with algorithm \'%s\'', $hashAlgorithm - ) - ), - }; + )); + } return uuid_parse($uuid); } diff --git a/vendor/ramsey/uuid/src/Generator/RandomGeneratorInterface.php b/vendor/ramsey/uuid/src/Generator/RandomGeneratorInterface.php index 1180b9764..5c83cb4d8 100644 --- a/vendor/ramsey/uuid/src/Generator/RandomGeneratorInterface.php +++ b/vendor/ramsey/uuid/src/Generator/RandomGeneratorInterface.php @@ -22,7 +22,7 @@ interface RandomGeneratorInterface /** * Generates a string of randomized binary data * - * @param int<1, max> $length The number of bytes of random binary data to generate + * @param int $length The number of bytes of random binary data to generate * * @return string A binary string */ diff --git a/vendor/ramsey/uuid/src/Generator/RandomLibAdapter.php b/vendor/ramsey/uuid/src/Generator/RandomLibAdapter.php index fd0ccc8aa..793ccd5a4 100644 --- a/vendor/ramsey/uuid/src/Generator/RandomLibAdapter.php +++ b/vendor/ramsey/uuid/src/Generator/RandomLibAdapter.php @@ -29,7 +29,10 @@ use RandomLib\Generator; */ class RandomLibAdapter implements RandomGeneratorInterface { - private Generator $generator; + /** + * @var Generator + */ + private $generator; /** * Constructs a RandomLibAdapter diff --git a/vendor/ramsey/uuid/src/Generator/TimeGeneratorFactory.php b/vendor/ramsey/uuid/src/Generator/TimeGeneratorFactory.php index 8d06fc3ae..3d55fc4d6 100644 --- a/vendor/ramsey/uuid/src/Generator/TimeGeneratorFactory.php +++ b/vendor/ramsey/uuid/src/Generator/TimeGeneratorFactory.php @@ -24,11 +24,29 @@ use Ramsey\Uuid\Provider\TimeProviderInterface; */ class TimeGeneratorFactory { + /** + * @var NodeProviderInterface + */ + private $nodeProvider; + + /** + * @var TimeConverterInterface + */ + private $timeConverter; + + /** + * @var TimeProviderInterface + */ + private $timeProvider; + public function __construct( - private NodeProviderInterface $nodeProvider, - private TimeConverterInterface $timeConverter, - private TimeProviderInterface $timeProvider + NodeProviderInterface $nodeProvider, + TimeConverterInterface $timeConverter, + TimeProviderInterface $timeProvider ) { + $this->nodeProvider = $nodeProvider; + $this->timeConverter = $timeConverter; + $this->timeProvider = $timeProvider; } /** diff --git a/vendor/ramsey/uuid/src/Generator/UnixTimeGenerator.php b/vendor/ramsey/uuid/src/Generator/UnixTimeGenerator.php deleted file mode 100644 index 1aef8699a..000000000 --- a/vendor/ramsey/uuid/src/Generator/UnixTimeGenerator.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php - -/** - * This file is part of the ramsey/uuid library - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - * - * @copyright Copyright (c) Ben Ramsey <ben@benramsey.com> - * @license http://opensource.org/licenses/MIT MIT - */ - -declare(strict_types=1); - -namespace Ramsey\Uuid\Generator; - -use Ramsey\Uuid\Converter\TimeConverterInterface; -use Ramsey\Uuid\Provider\TimeProviderInterface; - -use function hex2bin; - -/** - * UnixTimeGenerator generates bytes that combine a 48-bit timestamp in - * milliseconds since the Unix Epoch with 80 random bits - */ -class UnixTimeGenerator implements TimeGeneratorInterface -{ - public function __construct( - private TimeConverterInterface $timeConverter, - private TimeProviderInterface $timeProvider, - private RandomGeneratorInterface $randomGenerator - ) { - } - - /** - * @inheritDoc - */ - public function generate($node = null, ?int $clockSeq = null): string - { - // Generate 10 random bytes to append to the string returned, since our - // time bytes will consist of 6 bytes. - $random = $this->randomGenerator->generate(10); - - $time = $this->timeProvider->getTime(); - $unixTimeHex = $this->timeConverter->calculateTime( - $time->getSeconds()->toString(), - $time->getMicroseconds()->toString(), - ); - - return hex2bin($unixTimeHex->toString()) . $random; - } -} diff --git a/vendor/ramsey/uuid/src/Guid/Fields.php b/vendor/ramsey/uuid/src/Guid/Fields.php index 0fc5d1c9b..d8a1a2b10 100644 --- a/vendor/ramsey/uuid/src/Guid/Fields.php +++ b/vendor/ramsey/uuid/src/Guid/Fields.php @@ -17,7 +17,6 @@ namespace Ramsey\Uuid\Guid; use Ramsey\Uuid\Exception\InvalidArgumentException; use Ramsey\Uuid\Fields\SerializableFieldsTrait; use Ramsey\Uuid\Rfc4122\FieldsInterface; -use Ramsey\Uuid\Rfc4122\MaxTrait; use Ramsey\Uuid\Rfc4122\NilTrait; use Ramsey\Uuid\Rfc4122\VariantTrait; use Ramsey\Uuid\Rfc4122\VersionTrait; @@ -45,28 +44,34 @@ use const STR_PAD_LEFT; */ final class Fields implements FieldsInterface { - use MaxTrait; use NilTrait; use SerializableFieldsTrait; use VariantTrait; use VersionTrait; /** + * @var string + */ + private $bytes; + + /** * @param string $bytes A 16-byte binary string representation of a UUID * * @throws InvalidArgumentException if the byte string is not exactly 16 bytes * @throws InvalidArgumentException if the byte string does not represent a GUID * @throws InvalidArgumentException if the byte string does not contain a valid version */ - public function __construct(private string $bytes) + public function __construct(string $bytes) { - if (strlen($this->bytes) !== 16) { + if (strlen($bytes) !== 16) { throw new InvalidArgumentException( 'The byte string must be 16 bytes long; ' - . 'received ' . strlen($this->bytes) . ' bytes' + . 'received ' . strlen($bytes) . ' bytes' ); } + $this->bytes = $bytes; + if (!$this->isCorrectVariant()) { throw new InvalidArgumentException( 'The byte string received does not conform to the RFC ' @@ -144,13 +149,7 @@ final class Fields implements FieldsInterface public function getClockSeq(): Hexadecimal { - if ($this->isMax()) { - $clockSeq = 0xffff; - } elseif ($this->isNil()) { - $clockSeq = 0x0000; - } else { - $clockSeq = hexdec(bin2hex(substr($this->bytes, 8, 2))) & 0x3fff; - } + $clockSeq = hexdec(bin2hex(substr($this->bytes, 8, 2))) & 0x3fff; return new Hexadecimal(str_pad(dechex($clockSeq), 4, '0', STR_PAD_LEFT)); } @@ -172,7 +171,7 @@ final class Fields implements FieldsInterface public function getVersion(): ?int { - if ($this->isNil() || $this->isMax()) { + if ($this->isNil()) { return null; } @@ -184,7 +183,7 @@ final class Fields implements FieldsInterface private function isCorrectVariant(): bool { - if ($this->isNil() || $this->isMax()) { + if ($this->isNil()) { return true; } diff --git a/vendor/ramsey/uuid/src/Guid/GuidBuilder.php b/vendor/ramsey/uuid/src/Guid/GuidBuilder.php index c036bb20b..758dd6b7f 100644 --- a/vendor/ramsey/uuid/src/Guid/GuidBuilder.php +++ b/vendor/ramsey/uuid/src/Guid/GuidBuilder.php @@ -32,15 +32,27 @@ use Throwable; class GuidBuilder implements UuidBuilderInterface { /** + * @var NumberConverterInterface + */ + private $numberConverter; + + /** + * @var TimeConverterInterface + */ + private $timeConverter; + + /** * @param NumberConverterInterface $numberConverter The number converter to * use when constructing the Guid * @param TimeConverterInterface $timeConverter The time converter to use * for converting timestamps extracted from a UUID to Unix timestamps */ public function __construct( - private NumberConverterInterface $numberConverter, - private TimeConverterInterface $timeConverter + NumberConverterInterface $numberConverter, + TimeConverterInterface $timeConverter ) { + $this->numberConverter = $numberConverter; + $this->timeConverter = $timeConverter; } /** diff --git a/vendor/ramsey/uuid/src/Lazy/LazyUuidFromString.php b/vendor/ramsey/uuid/src/Lazy/LazyUuidFromString.php index c0b47bbf2..8ba757964 100644 --- a/vendor/ramsey/uuid/src/Lazy/LazyUuidFromString.php +++ b/vendor/ramsey/uuid/src/Lazy/LazyUuidFromString.php @@ -18,8 +18,8 @@ use DateTimeInterface; use Ramsey\Uuid\Converter\NumberConverterInterface; use Ramsey\Uuid\Exception\UnsupportedOperationException; use Ramsey\Uuid\Fields\FieldsInterface; +use Ramsey\Uuid\Nonstandard\UuidV6; use Ramsey\Uuid\Rfc4122\UuidV1; -use Ramsey\Uuid\Rfc4122\UuidV6; use Ramsey\Uuid\Type\Hexadecimal; use Ramsey\Uuid\Type\Integer as IntegerObject; use Ramsey\Uuid\UuidFactory; @@ -55,14 +55,18 @@ use function substr; final class LazyUuidFromString implements UuidInterface { public const VALID_REGEX = '/\A[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\z/ms'; - - private ?UuidInterface $unwrapped = null; - /** - * @psalm-param non-empty-string $uuid + * @var string + * @psalm-var non-empty-string */ - public function __construct(private string $uuid) + private $uuid; + /** @var UuidInterface|null */ + private $unwrapped; + + /** @psalm-param non-empty-string $uuid */ + public function __construct(string $uuid) { + $this->uuid = $uuid; } /** @psalm-pure */ @@ -101,20 +105,19 @@ final class LazyUuidFromString implements UuidInterface /** * {@inheritDoc} * - * @param string $data + * @param string $serialized * - * @psalm-param non-empty-string $data + * @psalm-param non-empty-string $serialized */ - public function unserialize(string $data): void + public function unserialize($serialized): void { - $this->uuid = $data; + $this->uuid = $serialized; } /** - * @param array{string?: string} $data + * @param array{string: string} $data * - * @psalm-param array{string?: non-empty-string} $data - * @psalm-suppress UnusedMethodCall + * @psalm-param array{string: non-empty-string} $data */ public function __unserialize(array $data): void { diff --git a/vendor/ramsey/uuid/src/Nonstandard/Fields.php b/vendor/ramsey/uuid/src/Nonstandard/Fields.php index 5dfe61076..927bc6a26 100644 --- a/vendor/ramsey/uuid/src/Nonstandard/Fields.php +++ b/vendor/ramsey/uuid/src/Nonstandard/Fields.php @@ -48,18 +48,25 @@ final class Fields implements FieldsInterface use VariantTrait; /** + * @var string + */ + private $bytes; + + /** * @param string $bytes A 16-byte binary string representation of a UUID * * @throws InvalidArgumentException if the byte string is not exactly 16 bytes */ - public function __construct(private string $bytes) + public function __construct(string $bytes) { - if (strlen($this->bytes) !== 16) { + if (strlen($bytes) !== 16) { throw new InvalidArgumentException( 'The byte string must be 16 bytes long; ' - . 'received ' . strlen($this->bytes) . ' bytes' + . 'received ' . strlen($bytes) . ' bytes' ); } + + $this->bytes = $bytes; } public function getBytes(): string @@ -123,9 +130,4 @@ final class Fields implements FieldsInterface { return false; } - - public function isMax(): bool - { - return false; - } } diff --git a/vendor/ramsey/uuid/src/Nonstandard/UuidBuilder.php b/vendor/ramsey/uuid/src/Nonstandard/UuidBuilder.php index 82efd402f..0c8927738 100644 --- a/vendor/ramsey/uuid/src/Nonstandard/UuidBuilder.php +++ b/vendor/ramsey/uuid/src/Nonstandard/UuidBuilder.php @@ -30,15 +30,27 @@ use Throwable; class UuidBuilder implements UuidBuilderInterface { /** + * @var NumberConverterInterface + */ + private $numberConverter; + + /** + * @var TimeConverterInterface + */ + private $timeConverter; + + /** * @param NumberConverterInterface $numberConverter The number converter to * use when constructing the Nonstandard\Uuid * @param TimeConverterInterface $timeConverter The time converter to use * for converting timestamps extracted from a UUID to Unix timestamps */ public function __construct( - private NumberConverterInterface $numberConverter, - private TimeConverterInterface $timeConverter + NumberConverterInterface $numberConverter, + TimeConverterInterface $timeConverter ) { + $this->numberConverter = $numberConverter; + $this->timeConverter = $timeConverter; } /** diff --git a/vendor/ramsey/uuid/src/Nonstandard/UuidV6.php b/vendor/ramsey/uuid/src/Nonstandard/UuidV6.php index 1a7bbaf75..05586b3eb 100644 --- a/vendor/ramsey/uuid/src/Nonstandard/UuidV6.php +++ b/vendor/ramsey/uuid/src/Nonstandard/UuidV6.php @@ -14,34 +14,39 @@ declare(strict_types=1); namespace Ramsey\Uuid\Nonstandard; +use DateTimeImmutable; +use DateTimeInterface; use Ramsey\Uuid\Codec\CodecInterface; use Ramsey\Uuid\Converter\NumberConverterInterface; use Ramsey\Uuid\Converter\TimeConverterInterface; +use Ramsey\Uuid\Exception\DateTimeException; use Ramsey\Uuid\Exception\InvalidArgumentException; use Ramsey\Uuid\Lazy\LazyUuidFromString; use Ramsey\Uuid\Rfc4122\FieldsInterface as Rfc4122FieldsInterface; -use Ramsey\Uuid\Rfc4122\TimeTrait; use Ramsey\Uuid\Rfc4122\UuidInterface; use Ramsey\Uuid\Rfc4122\UuidV1; use Ramsey\Uuid\Uuid; +use Throwable; + +use function hex2bin; +use function str_pad; +use function substr; + +use const STR_PAD_LEFT; /** - * Reordered time, or version 6, UUIDs include timestamp, clock sequence, and - * node values that are combined into a 128-bit unsigned integer - * - * @deprecated Use {@see \Ramsey\Uuid\Rfc4122\UuidV6} instead. + * Ordered-time, or version 6, UUIDs include timestamp, clock sequence, and node + * values that are combined into a 128-bit unsigned integer * * @link https://github.com/uuid6/uuid6-ietf-draft UUID version 6 IETF draft * @link http://gh.peabody.io/uuidv6/ "Version 6" UUIDs * * @psalm-immutable */ -class UuidV6 extends Uuid implements UuidInterface +final class UuidV6 extends Uuid implements UuidInterface { - use TimeTrait; - /** - * Creates a version 6 (reordered time) UUID + * Creates a version 6 (time-based) UUID * * @param Rfc4122FieldsInterface $fields The fields from which to construct a UUID * @param NumberConverterInterface $numberConverter The number converter to use @@ -57,10 +62,10 @@ class UuidV6 extends Uuid implements UuidInterface CodecInterface $codec, TimeConverterInterface $timeConverter ) { - if ($fields->getVersion() !== Uuid::UUID_TYPE_REORDERED_TIME) { + if ($fields->getVersion() !== Uuid::UUID_TYPE_PEABODY) { throw new InvalidArgumentException( 'Fields used to create a UuidV6 must represent a ' - . 'version 6 (reordered time) UUID' + . 'version 6 (ordered-time) UUID' ); } @@ -68,6 +73,29 @@ class UuidV6 extends Uuid implements UuidInterface } /** + * Returns a DateTimeInterface object representing the timestamp associated + * with the UUID + * + * @return DateTimeImmutable A PHP DateTimeImmutable instance representing + * the timestamp of a version 6 UUID + */ + public function getDateTime(): DateTimeInterface + { + $time = $this->timeConverter->convertTime($this->fields->getTimestamp()); + + try { + return new DateTimeImmutable( + '@' + . $time->getSeconds()->toString() + . '.' + . str_pad($time->getMicroseconds()->toString(), 6, '0', STR_PAD_LEFT) + ); + } catch (Throwable $e) { + throw new DateTimeException($e->getMessage(), (int) $e->getCode(), $e); + } + } + + /** * Converts this UUID into an instance of a version 1 UUID */ public function toUuidV1(): UuidV1 @@ -88,7 +116,7 @@ class UuidV6 extends Uuid implements UuidInterface /** * Converts a version 1 UUID into an instance of a version 6 UUID */ - public static function fromUuidV1(UuidV1 $uuidV1): \Ramsey\Uuid\Rfc4122\UuidV6 + public static function fromUuidV1(UuidV1 $uuidV1): UuidV6 { $hex = $uuidV1->getHex()->toString(); $hex = substr($hex, 13, 3) diff --git a/vendor/ramsey/uuid/src/Provider/Dce/SystemDceSecurityProvider.php b/vendor/ramsey/uuid/src/Provider/Dce/SystemDceSecurityProvider.php index d5b6cf0c0..7ff407648 100644 --- a/vendor/ramsey/uuid/src/Provider/Dce/SystemDceSecurityProvider.php +++ b/vendor/ramsey/uuid/src/Provider/Dce/SystemDceSecurityProvider.php @@ -21,6 +21,7 @@ use Ramsey\Uuid\Type\Integer as IntegerObject; use function escapeshellarg; use function preg_split; use function str_getcsv; +use function strpos; use function strrpos; use function strtolower; use function strtoupper; @@ -41,7 +42,6 @@ class SystemDceSecurityProvider implements DceSecurityProviderInterface */ public function getUid(): IntegerObject { - /** @var int|float|string|IntegerObject|null $uid */ static $uid = null; if ($uid instanceof IntegerObject) { @@ -72,7 +72,6 @@ class SystemDceSecurityProvider implements DceSecurityProviderInterface */ public function getGid(): IntegerObject { - /** @var int|float|string|IntegerObject|null $gid */ static $gid = null; if ($gid instanceof IntegerObject) { @@ -105,10 +104,15 @@ class SystemDceSecurityProvider implements DceSecurityProviderInterface return ''; } - return match ($this->getOs()) { - 'WIN' => $this->getWindowsUid(), - default => trim((string) shell_exec('id -u')), - }; + switch ($this->getOs()) { + case 'WIN': + return $this->getWindowsUid(); + case 'DAR': + case 'FRE': + case 'LIN': + default: + return trim((string) shell_exec('id -u')); + } } /** @@ -120,10 +124,15 @@ class SystemDceSecurityProvider implements DceSecurityProviderInterface return ''; } - return match ($this->getOs()) { - 'WIN' => $this->getWindowsGid(), - default => trim((string) shell_exec('id -g')), - }; + switch ($this->getOs()) { + case 'WIN': + return $this->getWindowsGid(); + case 'DAR': + case 'FRE': + case 'LIN': + default: + return trim((string) shell_exec('id -g')); + } } /** @@ -133,7 +142,7 @@ class SystemDceSecurityProvider implements DceSecurityProviderInterface { $disabledFunctions = strtolower((string) ini_get('disable_functions')); - return !str_contains($disabledFunctions, 'shell_exec'); + return strpos($disabledFunctions, 'shell_exec') === false; } /** @@ -141,13 +150,7 @@ class SystemDceSecurityProvider implements DceSecurityProviderInterface */ private function getOs(): string { - /** - * @psalm-suppress UnnecessaryVarAnnotation - * @var string $phpOs - */ - $phpOs = constant('PHP_OS'); - - return strtoupper(substr($phpOs, 0, 3)); + return strtoupper(substr(constant('PHP_OS'), 0, 3)); } /** diff --git a/vendor/ramsey/uuid/src/Provider/Node/FallbackNodeProvider.php b/vendor/ramsey/uuid/src/Provider/Node/FallbackNodeProvider.php index d2eb20b70..fe890cc4d 100644 --- a/vendor/ramsey/uuid/src/Provider/Node/FallbackNodeProvider.php +++ b/vendor/ramsey/uuid/src/Provider/Node/FallbackNodeProvider.php @@ -25,17 +25,23 @@ use Ramsey\Uuid\Type\Hexadecimal; class FallbackNodeProvider implements NodeProviderInterface { /** + * @var iterable<NodeProviderInterface> + */ + private $nodeProviders; + + /** * @param iterable<NodeProviderInterface> $providers Array of node providers */ - public function __construct(private iterable $providers) + public function __construct(iterable $providers) { + $this->nodeProviders = $providers; } public function getNode(): Hexadecimal { $lastProviderException = null; - foreach ($this->providers as $provider) { + foreach ($this->nodeProviders as $provider) { try { return $provider->getNode(); } catch (NodeException $exception) { diff --git a/vendor/ramsey/uuid/src/Provider/Node/StaticNodeProvider.php b/vendor/ramsey/uuid/src/Provider/Node/StaticNodeProvider.php index 0f7536a82..51f1b02ea 100644 --- a/vendor/ramsey/uuid/src/Provider/Node/StaticNodeProvider.php +++ b/vendor/ramsey/uuid/src/Provider/Node/StaticNodeProvider.php @@ -32,7 +32,10 @@ use const STR_PAD_LEFT; */ class StaticNodeProvider implements NodeProviderInterface { - private Hexadecimal $node; + /** + * @var Hexadecimal + */ + private $node; /** * @param Hexadecimal $node The static node value to use diff --git a/vendor/ramsey/uuid/src/Provider/Node/SystemNodeProvider.php b/vendor/ramsey/uuid/src/Provider/Node/SystemNodeProvider.php index d0a1e697f..d512f22aa 100644 --- a/vendor/ramsey/uuid/src/Provider/Node/SystemNodeProvider.php +++ b/vendor/ramsey/uuid/src/Provider/Node/SystemNodeProvider.php @@ -27,8 +27,8 @@ use function ob_start; use function preg_match; use function preg_match_all; use function reset; -use function str_contains; use function str_replace; +use function strpos; use function strtolower; use function strtoupper; use function substr; @@ -100,18 +100,12 @@ class SystemNodeProvider implements NodeProviderInterface { $disabledFunctions = strtolower((string) ini_get('disable_functions')); - if (str_contains($disabledFunctions, 'passthru')) { + if (strpos($disabledFunctions, 'passthru') !== false) { return ''; } - /** - * @psalm-suppress UnnecessaryVarAnnotation - * @var string $phpOs - */ - $phpOs = constant('PHP_OS'); - ob_start(); - switch (strtoupper(substr($phpOs, 0, 3))) { + switch (strtoupper(substr(constant('PHP_OS'), 0, 3))) { case 'WIN': passthru('ipconfig /all 2>&1'); @@ -148,20 +142,13 @@ class SystemNodeProvider implements NodeProviderInterface { $mac = ''; - /** - * @psalm-suppress UnnecessaryVarAnnotation - * @var string $phpOs - */ - $phpOs = constant('PHP_OS'); - - if (strtoupper($phpOs) === 'LINUX') { + if (strtoupper(constant('PHP_OS')) === 'LINUX') { $addressPaths = glob('/sys/class/net/*/address', GLOB_NOSORT); if ($addressPaths === false || count($addressPaths) === 0) { return ''; } - /** @var array<array-key, string> $macs */ $macs = []; array_walk($addressPaths, function (string $addressPath) use (&$macs): void { @@ -170,10 +157,7 @@ class SystemNodeProvider implements NodeProviderInterface } }); - /** @var callable $trim */ - $trim = 'trim'; - - $macs = array_map($trim, $macs); + $macs = array_map('trim', $macs); // Remove invalid entries. $macs = array_filter($macs, function (string $address) { @@ -181,7 +165,6 @@ class SystemNodeProvider implements NodeProviderInterface && preg_match(self::SYSFS_PATTERN, $address); }); - /** @var string|bool $mac */ $mac = reset($macs); } diff --git a/vendor/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php b/vendor/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php index 526c8ff46..b8bfd7215 100644 --- a/vendor/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php +++ b/vendor/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php @@ -19,15 +19,21 @@ use Ramsey\Uuid\Type\Integer as IntegerObject; use Ramsey\Uuid\Type\Time; /** - * FixedTimeProvider uses a known time to provide the time + * FixedTimeProvider uses an known time to provide the time * * This provider allows the use of a previously-generated, or known, time * when generating time-based UUIDs. */ class FixedTimeProvider implements TimeProviderInterface { - public function __construct(private Time $time) + /** + * @var Time + */ + private $fixedTime; + + public function __construct(Time $time) { + $this->fixedTime = $time; } /** @@ -37,7 +43,7 @@ class FixedTimeProvider implements TimeProviderInterface */ public function setUsec($value): void { - $this->time = new Time($this->time->getSeconds(), $value); + $this->fixedTime = new Time($this->fixedTime->getSeconds(), $value); } /** @@ -47,11 +53,11 @@ class FixedTimeProvider implements TimeProviderInterface */ public function setSec($value): void { - $this->time = new Time($value, $this->time->getMicroseconds()); + $this->fixedTime = new Time($value, $this->fixedTime->getMicroseconds()); } public function getTime(): Time { - return $this->time; + return $this->fixedTime; } } diff --git a/vendor/ramsey/uuid/src/Rfc4122/Fields.php b/vendor/ramsey/uuid/src/Rfc4122/Fields.php index 9acf810c2..2ccc20bb6 100644 --- a/vendor/ramsey/uuid/src/Rfc4122/Fields.php +++ b/vendor/ramsey/uuid/src/Rfc4122/Fields.php @@ -40,28 +40,34 @@ use const STR_PAD_LEFT; */ final class Fields implements FieldsInterface { - use MaxTrait; use NilTrait; use SerializableFieldsTrait; use VariantTrait; use VersionTrait; /** + * @var string + */ + private $bytes; + + /** * @param string $bytes A 16-byte binary string representation of a UUID * * @throws InvalidArgumentException if the byte string is not exactly 16 bytes * @throws InvalidArgumentException if the byte string does not represent an RFC 4122 UUID * @throws InvalidArgumentException if the byte string does not contain a valid version */ - public function __construct(private string $bytes) + public function __construct(string $bytes) { - if (strlen($this->bytes) !== 16) { + if (strlen($bytes) !== 16) { throw new InvalidArgumentException( 'The byte string must be 16 bytes long; ' - . 'received ' . strlen($this->bytes) . ' bytes' + . 'received ' . strlen($bytes) . ' bytes' ); } + $this->bytes = $bytes; + if (!$this->isCorrectVariant()) { throw new InvalidArgumentException( 'The byte string received does not conform to the RFC 4122 variant' @@ -82,13 +88,7 @@ final class Fields implements FieldsInterface public function getClockSeq(): Hexadecimal { - if ($this->isMax()) { - $clockSeq = 0xffff; - } elseif ($this->isNil()) { - $clockSeq = 0x0000; - } else { - $clockSeq = hexdec(bin2hex(substr($this->bytes, 8, 2))) & 0x3fff; - } + $clockSeq = hexdec(bin2hex(substr($this->bytes, 8, 2))) & 0x3fff; return new Hexadecimal(str_pad(dechex($clockSeq), 4, '0', STR_PAD_LEFT)); } @@ -140,53 +140,52 @@ final class Fields implements FieldsInterface */ public function getTimestamp(): Hexadecimal { - $timestamp = match ($this->getVersion()) { - Uuid::UUID_TYPE_DCE_SECURITY => sprintf( - '%03x%04s%08s', - hexdec($this->getTimeHiAndVersion()->toString()) & 0x0fff, - $this->getTimeMid()->toString(), - '' - ), - Uuid::UUID_TYPE_REORDERED_TIME => sprintf( - '%08s%04s%03x', - $this->getTimeLow()->toString(), - $this->getTimeMid()->toString(), - hexdec($this->getTimeHiAndVersion()->toString()) & 0x0fff - ), - // The Unix timestamp in version 7 UUIDs is a 48-bit number, - // but for consistency, we will return a 60-bit number, padded - // to the left with zeros. - Uuid::UUID_TYPE_UNIX_TIME => sprintf( - '%011s%04s', - $this->getTimeLow()->toString(), - $this->getTimeMid()->toString(), - ), - default => sprintf( - '%03x%04s%08s', - hexdec($this->getTimeHiAndVersion()->toString()) & 0x0fff, - $this->getTimeMid()->toString(), - $this->getTimeLow()->toString() - ), - }; + switch ($this->getVersion()) { + case Uuid::UUID_TYPE_DCE_SECURITY: + $timestamp = sprintf( + '%03x%04s%08s', + hexdec($this->getTimeHiAndVersion()->toString()) & 0x0fff, + $this->getTimeMid()->toString(), + '' + ); + + break; + case Uuid::UUID_TYPE_PEABODY: + $timestamp = sprintf( + '%08s%04s%03x', + $this->getTimeLow()->toString(), + $this->getTimeMid()->toString(), + hexdec($this->getTimeHiAndVersion()->toString()) & 0x0fff + ); + + break; + default: + $timestamp = sprintf( + '%03x%04s%08s', + hexdec($this->getTimeHiAndVersion()->toString()) & 0x0fff, + $this->getTimeMid()->toString(), + $this->getTimeLow()->toString() + ); + } return new Hexadecimal($timestamp); } public function getVersion(): ?int { - if ($this->isNil() || $this->isMax()) { + if ($this->isNil()) { return null; } - /** @var int[] $parts */ + /** @var array $parts */ $parts = unpack('n*', $this->bytes); - return $parts[4] >> 12; + return (int) $parts[4] >> 12; } private function isCorrectVariant(): bool { - if ($this->isNil() || $this->isMax()) { + if ($this->isNil()) { return true; } diff --git a/vendor/ramsey/uuid/src/Rfc4122/FieldsInterface.php b/vendor/ramsey/uuid/src/Rfc4122/FieldsInterface.php index 2241cf574..a303525d6 100644 --- a/vendor/ramsey/uuid/src/Rfc4122/FieldsInterface.php +++ b/vendor/ramsey/uuid/src/Rfc4122/FieldsInterface.php @@ -103,13 +103,11 @@ interface FieldsInterface extends BaseFieldsInterface * The version number describes how the UUID was generated and has the * following meaning: * - * 1. Gregorian time UUID + * 1. Time-based UUID * 2. DCE security UUID * 3. Name-based UUID hashed with MD5 * 4. Randomly generated UUID * 5. Name-based UUID hashed with SHA-1 - * 6. Reordered time UUID - * 7. Unix Epoch time UUID * * This returns `null` if the UUID is not an RFC 4122 variant, since version * is only meaningful for this variant. diff --git a/vendor/ramsey/uuid/src/Rfc4122/MaxTrait.php b/vendor/ramsey/uuid/src/Rfc4122/MaxTrait.php deleted file mode 100644 index 2ec304723..000000000 --- a/vendor/ramsey/uuid/src/Rfc4122/MaxTrait.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php - -/** - * This file is part of the ramsey/uuid library - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - * - * @copyright Copyright (c) Ben Ramsey <ben@benramsey.com> - * @license http://opensource.org/licenses/MIT MIT - */ - -declare(strict_types=1); - -namespace Ramsey\Uuid\Rfc4122; - -/** - * Provides common functionality for max UUIDs - * - * The max UUID is special form of UUID that is specified to have all 128 bits - * set to one. It is the inverse of the nil UUID. - * - * @link https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-04#section-5.4 Max UUID - * - * @psalm-immutable - */ -trait MaxTrait -{ - /** - * Returns the bytes that comprise the fields - */ - abstract public function getBytes(): string; - - /** - * Returns true if the byte string represents a max UUID - */ - public function isMax(): bool - { - return $this->getBytes() === "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"; - } -} diff --git a/vendor/ramsey/uuid/src/Rfc4122/MaxUuid.php b/vendor/ramsey/uuid/src/Rfc4122/MaxUuid.php deleted file mode 100644 index e5ffa72c6..000000000 --- a/vendor/ramsey/uuid/src/Rfc4122/MaxUuid.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php - -/** - * This file is part of the ramsey/uuid library - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - * - * @copyright Copyright (c) Ben Ramsey <ben@benramsey.com> - * @license http://opensource.org/licenses/MIT MIT - */ - -declare(strict_types=1); - -namespace Ramsey\Uuid\Rfc4122; - -use Ramsey\Uuid\Uuid; - -/** - * The max UUID is special form of UUID that is specified to have all 128 bits - * set to one - * - * @psalm-immutable - */ -final class MaxUuid extends Uuid implements UuidInterface -{ -} diff --git a/vendor/ramsey/uuid/src/Rfc4122/TimeTrait.php b/vendor/ramsey/uuid/src/Rfc4122/TimeTrait.php deleted file mode 100644 index 5d939fac6..000000000 --- a/vendor/ramsey/uuid/src/Rfc4122/TimeTrait.php +++ /dev/null @@ -1,55 +0,0 @@ -<?php - -/** - * This file is part of the ramsey/uuid library - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - * - * @copyright Copyright (c) Ben Ramsey <ben@benramsey.com> - * @license http://opensource.org/licenses/MIT MIT - */ - -declare(strict_types=1); - -namespace Ramsey\Uuid\Rfc4122; - -use DateTimeImmutable; -use DateTimeInterface; -use Ramsey\Uuid\Exception\DateTimeException; -use Throwable; - -use function str_pad; - -use const STR_PAD_LEFT; - -/** - * Provides common functionality for getting the time from a time-based UUID - * - * @psalm-immutable - */ -trait TimeTrait -{ - /** - * Returns a DateTimeInterface object representing the timestamp associated - * with the UUID - * - * @return DateTimeImmutable A PHP DateTimeImmutable instance representing - * the timestamp of a time-based UUID - */ - public function getDateTime(): DateTimeInterface - { - $time = $this->timeConverter->convertTime($this->fields->getTimestamp()); - - try { - return new DateTimeImmutable( - '@' - . $time->getSeconds()->toString() - . '.' - . str_pad($time->getMicroseconds()->toString(), 6, '0', STR_PAD_LEFT) - ); - } catch (Throwable $e) { - throw new DateTimeException($e->getMessage(), (int) $e->getCode(), $e); - } - } -} diff --git a/vendor/ramsey/uuid/src/Rfc4122/UuidBuilder.php b/vendor/ramsey/uuid/src/Rfc4122/UuidBuilder.php index 859649fd9..736931af2 100644 --- a/vendor/ramsey/uuid/src/Rfc4122/UuidBuilder.php +++ b/vendor/ramsey/uuid/src/Rfc4122/UuidBuilder.php @@ -17,13 +17,11 @@ namespace Ramsey\Uuid\Rfc4122; use Ramsey\Uuid\Builder\UuidBuilderInterface; use Ramsey\Uuid\Codec\CodecInterface; use Ramsey\Uuid\Converter\NumberConverterInterface; -use Ramsey\Uuid\Converter\Time\UnixTimeConverter; use Ramsey\Uuid\Converter\TimeConverterInterface; use Ramsey\Uuid\Exception\UnableToBuildUuidException; use Ramsey\Uuid\Exception\UnsupportedOperationException; -use Ramsey\Uuid\Math\BrickMathCalculator; +use Ramsey\Uuid\Nonstandard\UuidV6; use Ramsey\Uuid\Rfc4122\UuidInterface as Rfc4122UuidInterface; -use Ramsey\Uuid\Uuid; use Ramsey\Uuid\UuidInterface; use Throwable; @@ -34,7 +32,15 @@ use Throwable; */ class UuidBuilder implements UuidBuilderInterface { - private TimeConverterInterface $unixTimeConverter; + /** + * @var NumberConverterInterface + */ + private $numberConverter; + + /** + * @var TimeConverterInterface + */ + private $timeConverter; /** * Constructs the DefaultUuidBuilder @@ -42,18 +48,14 @@ class UuidBuilder implements UuidBuilderInterface * @param NumberConverterInterface $numberConverter The number converter to * use when constructing the Uuid * @param TimeConverterInterface $timeConverter The time converter to use - * for converting Gregorian time extracted from version 1, 2, and 6 - * UUIDs to Unix timestamps - * @param TimeConverterInterface|null $unixTimeConverter The time converter - * to use for converter Unix Epoch time extracted from version 7 UUIDs - * to Unix timestamps + * for converting timestamps extracted from a UUID to Unix timestamps */ public function __construct( - private NumberConverterInterface $numberConverter, - private TimeConverterInterface $timeConverter, - ?TimeConverterInterface $unixTimeConverter = null + NumberConverterInterface $numberConverter, + TimeConverterInterface $timeConverter ) { - $this->unixTimeConverter = $unixTimeConverter ?? new UnixTimeConverter(new BrickMathCalculator()); + $this->numberConverter = $numberConverter; + $this->timeConverter = $timeConverter; } /** @@ -69,32 +71,25 @@ class UuidBuilder implements UuidBuilderInterface public function build(CodecInterface $codec, string $bytes): UuidInterface { try { - /** @var Fields $fields */ $fields = $this->buildFields($bytes); if ($fields->isNil()) { return new NilUuid($fields, $this->numberConverter, $codec, $this->timeConverter); } - if ($fields->isMax()) { - return new MaxUuid($fields, $this->numberConverter, $codec, $this->timeConverter); - } - switch ($fields->getVersion()) { - case Uuid::UUID_TYPE_TIME: + case 1: return new UuidV1($fields, $this->numberConverter, $codec, $this->timeConverter); - case Uuid::UUID_TYPE_DCE_SECURITY: + case 2: return new UuidV2($fields, $this->numberConverter, $codec, $this->timeConverter); - case Uuid::UUID_TYPE_HASH_MD5: + case 3: return new UuidV3($fields, $this->numberConverter, $codec, $this->timeConverter); - case Uuid::UUID_TYPE_RANDOM: + case 4: return new UuidV4($fields, $this->numberConverter, $codec, $this->timeConverter); - case Uuid::UUID_TYPE_HASH_SHA1: + case 5: return new UuidV5($fields, $this->numberConverter, $codec, $this->timeConverter); - case Uuid::UUID_TYPE_REORDERED_TIME: + case 6: return new UuidV6($fields, $this->numberConverter, $codec, $this->timeConverter); - case Uuid::UUID_TYPE_UNIX_TIME: - return new UuidV7($fields, $this->numberConverter, $codec, $this->unixTimeConverter); } throw new UnsupportedOperationException( diff --git a/vendor/ramsey/uuid/src/Rfc4122/UuidInterface.php b/vendor/ramsey/uuid/src/Rfc4122/UuidInterface.php index e80f33bef..3e4d9faee 100644 --- a/vendor/ramsey/uuid/src/Rfc4122/UuidInterface.php +++ b/vendor/ramsey/uuid/src/Rfc4122/UuidInterface.php @@ -26,4 +26,11 @@ use Ramsey\Uuid\UuidInterface as BaseUuidInterface; */ interface UuidInterface extends BaseUuidInterface { + /** + * Returns the string standard representation of the UUID as a URN + * + * @link http://en.wikipedia.org/wiki/Uniform_Resource_Name Uniform Resource Name + * @link https://tools.ietf.org/html/rfc4122#section-3 RFC 4122, § 3: Namespace Registration Template + */ + public function getUrn(): string; } diff --git a/vendor/ramsey/uuid/src/Rfc4122/UuidV1.php b/vendor/ramsey/uuid/src/Rfc4122/UuidV1.php index 515c038d9..764e42f84 100644 --- a/vendor/ramsey/uuid/src/Rfc4122/UuidV1.php +++ b/vendor/ramsey/uuid/src/Rfc4122/UuidV1.php @@ -14,25 +14,31 @@ declare(strict_types=1); namespace Ramsey\Uuid\Rfc4122; +use DateTimeImmutable; +use DateTimeInterface; use Ramsey\Uuid\Codec\CodecInterface; use Ramsey\Uuid\Converter\NumberConverterInterface; use Ramsey\Uuid\Converter\TimeConverterInterface; +use Ramsey\Uuid\Exception\DateTimeException; use Ramsey\Uuid\Exception\InvalidArgumentException; use Ramsey\Uuid\Rfc4122\FieldsInterface as Rfc4122FieldsInterface; use Ramsey\Uuid\Uuid; +use Throwable; + +use function str_pad; + +use const STR_PAD_LEFT; /** - * Gregorian time, or version 1, UUIDs include timestamp, clock sequence, and node + * Time-based, or version 1, UUIDs include timestamp, clock sequence, and node * values that are combined into a 128-bit unsigned integer * * @psalm-immutable */ final class UuidV1 extends Uuid implements UuidInterface { - use TimeTrait; - /** - * Creates a version 1 (Gregorian time) UUID + * Creates a version 1 (time-based) UUID * * @param Rfc4122FieldsInterface $fields The fields from which to construct a UUID * @param NumberConverterInterface $numberConverter The number converter to use @@ -57,4 +63,30 @@ final class UuidV1 extends Uuid implements UuidInterface parent::__construct($fields, $numberConverter, $codec, $timeConverter); } + + /** + * Returns a DateTimeInterface object representing the timestamp associated + * with the UUID + * + * The timestamp value is only meaningful in a time-based UUID, which + * has version type 1. + * + * @return DateTimeImmutable A PHP DateTimeImmutable instance representing + * the timestamp of a version 1 UUID + */ + public function getDateTime(): DateTimeInterface + { + $time = $this->timeConverter->convertTime($this->fields->getTimestamp()); + + try { + return new DateTimeImmutable( + '@' + . $time->getSeconds()->toString() + . '.' + . str_pad($time->getMicroseconds()->toString(), 6, '0', STR_PAD_LEFT) + ); + } catch (Throwable $e) { + throw new DateTimeException($e->getMessage(), (int) $e->getCode(), $e); + } + } } diff --git a/vendor/ramsey/uuid/src/Rfc4122/UuidV2.php b/vendor/ramsey/uuid/src/Rfc4122/UuidV2.php index c8ccbe422..74906f050 100644 --- a/vendor/ramsey/uuid/src/Rfc4122/UuidV2.php +++ b/vendor/ramsey/uuid/src/Rfc4122/UuidV2.php @@ -14,33 +14,28 @@ declare(strict_types=1); namespace Ramsey\Uuid\Rfc4122; +use DateTimeImmutable; +use DateTimeInterface; use Ramsey\Uuid\Codec\CodecInterface; use Ramsey\Uuid\Converter\NumberConverterInterface; use Ramsey\Uuid\Converter\TimeConverterInterface; +use Ramsey\Uuid\Exception\DateTimeException; use Ramsey\Uuid\Exception\InvalidArgumentException; use Ramsey\Uuid\Rfc4122\FieldsInterface as Rfc4122FieldsInterface; use Ramsey\Uuid\Type\Integer as IntegerObject; use Ramsey\Uuid\Uuid; +use Throwable; use function hexdec; +use function str_pad; + +use const STR_PAD_LEFT; /** * DCE Security version, or version 2, UUIDs include local domain identifier, * local ID for the specified domain, and node values that are combined into a * 128-bit unsigned integer * - * It is important to note that a version 2 UUID suffers from some loss of - * fidelity of the timestamp, due to replacing the time_low field with the - * local identifier. When constructing the timestamp value for date - * purposes, we replace the local identifier bits with zeros. As a result, - * the timestamp can be off by a range of 0 to 429.4967295 seconds (or 7 - * minutes, 9 seconds, and 496730 microseconds). - * - * Astute observers might note this value directly corresponds to 2^32 - 1, - * or 0xffffffff. The local identifier is 32-bits, and we have set each of - * these bits to 0, so the maximum range of timestamp drift is 0x00000000 - * to 0xffffffff (counted in 100-nanosecond intervals). - * * @link https://publications.opengroup.org/c311 DCE 1.1: Authentication and Security Services * @link https://publications.opengroup.org/c706 DCE 1.1: Remote Procedure Call * @link https://pubs.opengroup.org/onlinepubs/9696989899/chap5.htm#tagcjh_08_02_01_01 DCE 1.1: Auth & Sec, §5.2.1.1 @@ -52,8 +47,6 @@ use function hexdec; */ final class UuidV2 extends Uuid implements UuidInterface { - use TimeTrait; - /** * Creates a version 2 (DCE Security) UUID * @@ -82,6 +75,41 @@ final class UuidV2 extends Uuid implements UuidInterface } /** + * Returns a DateTimeInterface object representing the timestamp associated + * with the UUID + * + * It is important to note that a version 2 UUID suffers from some loss of + * fidelity of the timestamp, due to replacing the time_low field with the + * local identifier. When constructing the timestamp value for date + * purposes, we replace the local identifier bits with zeros. As a result, + * the timestamp can be off by a range of 0 to 429.4967295 seconds (or 7 + * minutes, 9 seconds, and 496730 microseconds). + * + * Astute observers might note this value directly corresponds to 2^32 - 1, + * or 0xffffffff. The local identifier is 32-bits, and we have set each of + * these bits to 0, so the maximum range of timestamp drift is 0x00000000 + * to 0xffffffff (counted in 100-nanosecond intervals). + * + * @return DateTimeImmutable A PHP DateTimeImmutable instance representing + * the timestamp of a version 2 UUID + */ + public function getDateTime(): DateTimeInterface + { + $time = $this->timeConverter->convertTime($this->fields->getTimestamp()); + + try { + return new DateTimeImmutable( + '@' + . $time->getSeconds()->toString() + . '.' + . str_pad($time->getMicroseconds()->toString(), 6, '0', STR_PAD_LEFT) + ); + } catch (Throwable $e) { + throw new DateTimeException($e->getMessage(), (int) $e->getCode(), $e); + } + } + + /** * Returns the local domain used to create this version 2 UUID */ public function getLocalDomain(): int diff --git a/vendor/ramsey/uuid/src/Rfc4122/UuidV6.php b/vendor/ramsey/uuid/src/Rfc4122/UuidV6.php deleted file mode 100644 index 9b2ddee00..000000000 --- a/vendor/ramsey/uuid/src/Rfc4122/UuidV6.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php - -/** - * This file is part of the ramsey/uuid library - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - * - * @copyright Copyright (c) Ben Ramsey <ben@benramsey.com> - * @license http://opensource.org/licenses/MIT MIT - */ - -declare(strict_types=1); - -namespace Ramsey\Uuid\Rfc4122; - -use Ramsey\Uuid\Nonstandard\UuidV6 as NonstandardUuidV6; - -/** - * Reordered time, or version 6, UUIDs include timestamp, clock sequence, and - * node values that are combined into a 128-bit unsigned integer - * - * @link https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-04#section-5.1 UUID Version 6 - * - * @psalm-immutable - */ -final class UuidV6 extends NonstandardUuidV6 implements UuidInterface -{ -} diff --git a/vendor/ramsey/uuid/src/Rfc4122/UuidV7.php b/vendor/ramsey/uuid/src/Rfc4122/UuidV7.php deleted file mode 100644 index 90c2471ac..000000000 --- a/vendor/ramsey/uuid/src/Rfc4122/UuidV7.php +++ /dev/null @@ -1,60 +0,0 @@ -<?php - -/** - * This file is part of the ramsey/uuid library - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - * - * @copyright Copyright (c) Ben Ramsey <ben@benramsey.com> - * @license http://opensource.org/licenses/MIT MIT - */ - -declare(strict_types=1); - -namespace Ramsey\Uuid\Rfc4122; - -use Ramsey\Uuid\Codec\CodecInterface; -use Ramsey\Uuid\Converter\NumberConverterInterface; -use Ramsey\Uuid\Converter\TimeConverterInterface; -use Ramsey\Uuid\Exception\InvalidArgumentException; -use Ramsey\Uuid\Rfc4122\FieldsInterface as Rfc4122FieldsInterface; -use Ramsey\Uuid\Uuid; - -/** - * Gregorian time, or version 1, UUIDs include timestamp, clock sequence, and node - * values that are combined into a 128-bit unsigned integer - * - * @psalm-immutable - */ -final class UuidV7 extends Uuid implements UuidInterface -{ - use TimeTrait; - - /** - * Creates a version 7 (Unix Epoch time) UUID - * - * @param Rfc4122FieldsInterface $fields The fields from which to construct a UUID - * @param NumberConverterInterface $numberConverter The number converter to use - * for converting hex values to/from integers - * @param CodecInterface $codec The codec to use when encoding or decoding - * UUID strings - * @param TimeConverterInterface $timeConverter The time converter to use - * for converting timestamps extracted from a UUID to unix timestamps - */ - public function __construct( - Rfc4122FieldsInterface $fields, - NumberConverterInterface $numberConverter, - CodecInterface $codec, - TimeConverterInterface $timeConverter - ) { - if ($fields->getVersion() !== Uuid::UUID_TYPE_UNIX_TIME) { - throw new InvalidArgumentException( - 'Fields used to create a UuidV7 must represent a ' - . 'version 7 (Unix Epoch time) UUID' - ); - } - - parent::__construct($fields, $numberConverter, $codec, $timeConverter); - } -} diff --git a/vendor/ramsey/uuid/src/Rfc4122/Validator.php b/vendor/ramsey/uuid/src/Rfc4122/Validator.php index 6b1f0de06..ed43c982f 100644 --- a/vendor/ramsey/uuid/src/Rfc4122/Validator.php +++ b/vendor/ramsey/uuid/src/Rfc4122/Validator.php @@ -28,7 +28,7 @@ use function str_replace; final class Validator implements ValidatorInterface { private const VALID_PATTERN = '\A[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-' - . '[1-7][0-9A-Fa-f]{3}-[ABab89][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}\z'; + . '[1-5]{1}[0-9A-Fa-f]{3}-[ABab89]{1}[0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}\z'; /** * @psalm-return non-empty-string @@ -43,8 +43,7 @@ final class Validator implements ValidatorInterface public function validate(string $uuid): bool { $uuid = str_replace(['urn:', 'uuid:', 'URN:', 'UUID:', '{', '}'], '', $uuid); - $uuid = strtolower($uuid); - return $uuid === Uuid::NIL || $uuid === Uuid::MAX || preg_match('/' . self::VALID_PATTERN . '/Dms', $uuid); + return $uuid === Uuid::NIL || preg_match('/' . self::VALID_PATTERN . '/Dms', $uuid); } } diff --git a/vendor/ramsey/uuid/src/Rfc4122/VariantTrait.php b/vendor/ramsey/uuid/src/Rfc4122/VariantTrait.php index 1041de51e..4c981658f 100644 --- a/vendor/ramsey/uuid/src/Rfc4122/VariantTrait.php +++ b/vendor/ramsey/uuid/src/Rfc4122/VariantTrait.php @@ -19,8 +19,8 @@ use Ramsey\Uuid\Uuid; use function decbin; use function str_pad; -use function str_starts_with; use function strlen; +use function strpos; use function substr; use function unpack; @@ -58,13 +58,7 @@ trait VariantTrait throw new InvalidBytesException('Invalid number of bytes'); } - if ($this->isMax() || $this->isNil()) { - // RFC 4122 defines these special types of UUID, so we will consider - // them as belonging to the RFC 4122 variant. - return Uuid::RFC_4122; - } - - /** @var int[] $parts */ + /** @var array $parts */ $parts = unpack('n*', $this->getBytes()); // $parts[5] is a 16-bit, unsigned integer containing the variant bits @@ -73,7 +67,7 @@ trait VariantTrait // three characters (three most-significant bits) to determine the // variant. $binary = str_pad( - decbin($parts[5]), + decbin((int) $parts[5]), 16, '0', STR_PAD_LEFT @@ -82,13 +76,15 @@ trait VariantTrait $msb = substr($binary, 0, 3); if ($msb === '111') { - return Uuid::RESERVED_FUTURE; + $variant = Uuid::RESERVED_FUTURE; } elseif ($msb === '110') { - return Uuid::RESERVED_MICROSOFT; - } elseif (str_starts_with($msb, '10')) { - return Uuid::RFC_4122; + $variant = Uuid::RESERVED_MICROSOFT; + } elseif (strpos($msb, '10') === 0) { + $variant = Uuid::RFC_4122; + } else { + $variant = Uuid::RESERVED_NCS; } - return Uuid::RESERVED_NCS; + return $variant; } } diff --git a/vendor/ramsey/uuid/src/Rfc4122/VersionTrait.php b/vendor/ramsey/uuid/src/Rfc4122/VersionTrait.php index 316f780c4..cee55fbef 100644 --- a/vendor/ramsey/uuid/src/Rfc4122/VersionTrait.php +++ b/vendor/ramsey/uuid/src/Rfc4122/VersionTrait.php @@ -14,8 +14,6 @@ declare(strict_types=1); namespace Ramsey\Uuid\Rfc4122; -use Ramsey\Uuid\Uuid; - /** * Provides common functionality for handling the version, as defined by RFC 4122 * @@ -29,11 +27,6 @@ trait VersionTrait abstract public function getVersion(): ?int; /** - * Returns true if these fields represent a max UUID - */ - abstract public function isMax(): bool; - - /** * Returns true if these fields represent a nil UUID */ abstract public function isNil(): bool; @@ -45,16 +38,20 @@ trait VersionTrait */ private function isCorrectVersion(): bool { - if ($this->isNil() || $this->isMax()) { + if ($this->isNil()) { return true; } - return match ($this->getVersion()) { - Uuid::UUID_TYPE_TIME, Uuid::UUID_TYPE_DCE_SECURITY, - Uuid::UUID_TYPE_HASH_MD5, Uuid::UUID_TYPE_RANDOM, - Uuid::UUID_TYPE_HASH_SHA1, Uuid::UUID_TYPE_REORDERED_TIME, - Uuid::UUID_TYPE_UNIX_TIME => true, - default => false, - }; + switch ($this->getVersion()) { + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + return true; + } + + return false; } } diff --git a/vendor/ramsey/uuid/src/Type/Decimal.php b/vendor/ramsey/uuid/src/Type/Decimal.php index acc5e754b..10f93845b 100644 --- a/vendor/ramsey/uuid/src/Type/Decimal.php +++ b/vendor/ramsey/uuid/src/Type/Decimal.php @@ -19,7 +19,6 @@ use ValueError; use function is_numeric; use function sprintf; -use function str_starts_with; /** * A value object representing a decimal @@ -35,10 +34,20 @@ use function str_starts_with; */ final class Decimal implements NumberInterface { - private string $value; - private bool $isNegative = false; + /** + * @var string + */ + private $value; + + /** + * @var bool + */ + private $isNegative = false; - public function __construct(float | int | string | self $value) + /** + * @param mixed $value The decimal value to store + */ + public function __construct($value) { $value = (string) $value; @@ -50,7 +59,7 @@ final class Decimal implements NumberInterface } // Remove the leading +-symbol. - if (str_starts_with($value, '+')) { + if (strpos($value, '+') === 0) { $value = substr($value, 1); } @@ -59,7 +68,7 @@ final class Decimal implements NumberInterface $value = '0'; } - if (str_starts_with($value, '-')) { + if (strpos($value, '-') === 0) { $this->isNegative = true; } @@ -102,19 +111,18 @@ final class Decimal implements NumberInterface /** * Constructs the object from a serialized string representation * - * @param string $data The serialized string representation of the object + * @param string $serialized The serialized string representation of the object * + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint * @psalm-suppress UnusedMethodCall */ - public function unserialize(string $data): void + public function unserialize($serialized): void { - $this->__construct($data); + $this->__construct($serialized); } /** - * @param array{string?: string} $data - * - * @psalm-suppress UnusedMethodCall + * @param array{string: string} $data */ public function __unserialize(array $data): void { diff --git a/vendor/ramsey/uuid/src/Type/Hexadecimal.php b/vendor/ramsey/uuid/src/Type/Hexadecimal.php index 3c8f30adf..88adc2e7e 100644 --- a/vendor/ramsey/uuid/src/Type/Hexadecimal.php +++ b/vendor/ramsey/uuid/src/Type/Hexadecimal.php @@ -19,7 +19,7 @@ use ValueError; use function ctype_xdigit; use function sprintf; -use function str_starts_with; +use function strpos; use function strtolower; use function substr; @@ -34,7 +34,10 @@ use function substr; */ final class Hexadecimal implements TypeInterface { - private string $value; + /** + * @var string + */ + private $value; /** * @param string $value The hexadecimal value to store @@ -43,7 +46,7 @@ final class Hexadecimal implements TypeInterface { $value = strtolower($value); - if (str_starts_with($value, '0x')) { + if (strpos($value, '0x') === 0) { $value = substr($value, 2); } @@ -87,17 +90,18 @@ final class Hexadecimal implements TypeInterface /** * Constructs the object from a serialized string representation * - * @param string $data The serialized string representation of the object + * @param string $serialized The serialized string representation of the object * + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint * @psalm-suppress UnusedMethodCall */ - public function unserialize(string $data): void + public function unserialize($serialized): void { - $this->__construct($data); + $this->__construct($serialized); } /** - * @param array{string?: string} $data + * @param array{string: string} $data */ public function __unserialize(array $data): void { diff --git a/vendor/ramsey/uuid/src/Type/Integer.php b/vendor/ramsey/uuid/src/Type/Integer.php index e41b3cad5..7690f6cd8 100644 --- a/vendor/ramsey/uuid/src/Type/Integer.php +++ b/vendor/ramsey/uuid/src/Type/Integer.php @@ -20,7 +20,7 @@ use ValueError; use function ctype_digit; use function ltrim; use function sprintf; -use function str_starts_with; +use function strpos; use function substr; /** @@ -40,17 +40,23 @@ final class Integer implements NumberInterface /** * @psalm-var numeric-string */ - private string $value; + private $value; - private bool $isNegative = false; + /** + * @var bool + */ + private $isNegative = false; - public function __construct(float | int | string | self $value) + /** + * @param mixed $value The integer value to store + */ + public function __construct($value) { $value = (string) $value; $sign = '+'; // If the value contains a sign, remove it for ctype_digit() check. - if (str_starts_with($value, '-') || str_starts_with($value, '+')) { + if (strpos($value, '-') === 0 || strpos($value, '+') === 0) { $sign = substr($value, 0, 1); $value = substr($value, 1); } @@ -121,17 +127,18 @@ final class Integer implements NumberInterface /** * Constructs the object from a serialized string representation * - * @param string $data The serialized string representation of the object + * @param string $serialized The serialized string representation of the object * + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint * @psalm-suppress UnusedMethodCall */ - public function unserialize(string $data): void + public function unserialize($serialized): void { - $this->__construct($data); + $this->__construct($serialized); } /** - * @param array{string?: string} $data + * @param array{string: string} $data */ public function __unserialize(array $data): void { diff --git a/vendor/ramsey/uuid/src/Type/Time.php b/vendor/ramsey/uuid/src/Type/Time.php index 745b5ccab..dd1b8bc28 100644 --- a/vendor/ramsey/uuid/src/Type/Time.php +++ b/vendor/ramsey/uuid/src/Type/Time.php @@ -17,6 +17,7 @@ namespace Ramsey\Uuid\Type; use Ramsey\Uuid\Exception\UnsupportedOperationException; use Ramsey\Uuid\Type\Integer as IntegerObject; use ValueError; +use stdClass; use function json_decode; use function json_encode; @@ -33,13 +34,22 @@ use function sprintf; */ final class Time implements TypeInterface { - private IntegerObject $seconds; - private IntegerObject $microseconds; + /** + * @var IntegerObject + */ + private $seconds; + + /** + * @var IntegerObject + */ + private $microseconds; - public function __construct( - float | int | string | IntegerObject $seconds, - float | int | string | IntegerObject $microseconds = 0, - ) { + /** + * @param mixed $seconds + * @param mixed $microseconds + */ + public function __construct($seconds, $microseconds = 0) + { $this->seconds = new IntegerObject($seconds); $this->microseconds = new IntegerObject($microseconds); } @@ -94,26 +104,27 @@ final class Time implements TypeInterface /** * Constructs the object from a serialized string representation * - * @param string $data The serialized string representation of the object + * @param string $serialized The serialized string representation of the object * + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint * @psalm-suppress UnusedMethodCall */ - public function unserialize(string $data): void + public function unserialize($serialized): void { - /** @var array{seconds?: int|float|string, microseconds?: int|float|string} $time */ - $time = json_decode($data, true); + /** @var stdClass $time */ + $time = json_decode($serialized); - if (!isset($time['seconds']) || !isset($time['microseconds'])) { + if (!isset($time->seconds) || !isset($time->microseconds)) { throw new UnsupportedOperationException( 'Attempted to unserialize an invalid value' ); } - $this->__construct($time['seconds'], $time['microseconds']); + $this->__construct($time->seconds, $time->microseconds); } /** - * @param array{seconds?: string, microseconds?: string} $data + * @param array{seconds: string, microseconds: string} $data */ public function __unserialize(array $data): void { diff --git a/vendor/ramsey/uuid/src/Uuid.php b/vendor/ramsey/uuid/src/Uuid.php index 6656aba02..5f0922b9c 100644 --- a/vendor/ramsey/uuid/src/Uuid.php +++ b/vendor/ramsey/uuid/src/Uuid.php @@ -18,7 +18,6 @@ use DateTimeInterface; use Ramsey\Uuid\Codec\CodecInterface; use Ramsey\Uuid\Converter\NumberConverterInterface; use Ramsey\Uuid\Converter\TimeConverterInterface; -use Ramsey\Uuid\Exception\UnsupportedOperationException; use Ramsey\Uuid\Fields\FieldsInterface; use Ramsey\Uuid\Lazy\LazyUuidFromString; use Ramsey\Uuid\Rfc4122\FieldsInterface as Rfc4122FieldsInterface; @@ -28,7 +27,6 @@ use ValueError; use function assert; use function bin2hex; -use function method_exists; use function preg_match; use function sprintf; use function str_replace; @@ -85,14 +83,6 @@ class Uuid implements UuidInterface public const NIL = '00000000-0000-0000-0000-000000000000'; /** - * The max UUID is a special form of UUID that is specified to have all 128 - * bits set to one - * - * @link https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-04#section-5.4 Max UUID - */ - public const MAX = 'ffffffff-ffff-ffff-ffff-ffffffffffff'; - - /** * Variant: reserved, NCS backward compatibility * * @link http://tools.ietf.org/html/rfc4122#section-4.1.1 RFC 4122, § 4.1.1: Variant @@ -126,7 +116,7 @@ class Uuid implements UuidInterface public const VALID_PATTERN = '^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$'; /** - * Version 1 (Gregorian time) UUID + * Version 1 (time-based) UUID * * @link https://tools.ietf.org/html/rfc4122#section-4.1.3 RFC 4122, § 4.1.3: Version */ @@ -166,23 +156,15 @@ class Uuid implements UuidInterface public const UUID_TYPE_HASH_SHA1 = 5; /** - * @deprecated Use {@see Uuid::UUID_TYPE_REORDERED_TIME} instead. - */ - public const UUID_TYPE_PEABODY = 6; - - /** - * Version 6 (reordered time) UUID + * Version 6 (ordered-time) UUID * - * @link https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-04#section-5.1 UUID Version 6 - */ - public const UUID_TYPE_REORDERED_TIME = 6; - - /** - * Version 7 (Unix Epoch time) UUID + * This is named `UUID_TYPE_PEABODY`, since the specification is still in + * draft form, and the primary author/editor's name is Brad Peabody. * - * @link https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-04#section-5.2 UUID Version 7 + * @link https://github.com/uuid6/uuid6-ietf-draft UUID version 6 IETF draft + * @link http://gh.peabody.io/uuidv6/ "Version 6" UUIDs */ - public const UUID_TYPE_UNIX_TIME = 7; + public const UUID_TYPE_PEABODY = 6; /** * DCE Security principal domain @@ -216,19 +198,38 @@ class Uuid implements UuidInterface self::DCE_DOMAIN_ORG => 'org', ]; - private static ?UuidFactoryInterface $factory = null; + /** + * @var UuidFactoryInterface|null + */ + private static $factory = null; + + /** + * @var bool flag to detect if the UUID factory was replaced internally, which disables all optimizations + * for the default/happy path internal scenarios + */ + private static $factoryReplaced = false; + + /** + * @var CodecInterface + */ + protected $codec; + + /** + * The fields that make up this UUID + * + * @var Rfc4122FieldsInterface + */ + protected $fields; /** - * @var bool flag to detect if the UUID factory was replaced internally, - * which disables all optimizations for the default/happy path internal - * scenarios + * @var NumberConverterInterface */ - private static bool $factoryReplaced = false; + protected $numberConverter; - protected CodecInterface $codec; - protected NumberConverterInterface $numberConverter; - protected Rfc4122FieldsInterface $fields; - protected TimeConverterInterface $timeConverter; + /** + * @var TimeConverterInterface + */ + protected $timeConverter; /** * Creates a universally unique identifier (UUID) from an array of fields @@ -301,17 +302,19 @@ class Uuid implements UuidInterface /** * Re-constructs the object from its serialized form * - * @param string $data The serialized PHP string to unserialize into + * @param string $serialized The serialized PHP string to unserialize into * a UuidInterface instance + * + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint */ - public function unserialize(string $data): void + public function unserialize($serialized): void { - if (strlen($data) === 16) { + if (strlen($serialized) === 16) { /** @var Uuid $uuid */ - $uuid = self::getFactory()->fromBytes($data); + $uuid = self::getFactory()->fromBytes($serialized); } else { /** @var Uuid $uuid */ - $uuid = self::getFactory()->fromString($data); + $uuid = self::getFactory()->fromString($serialized); } $this->codec = $uuid->codec; @@ -321,7 +324,7 @@ class Uuid implements UuidInterface } /** - * @param array{bytes?: string} $data + * @param array{bytes: string} $data */ public function __unserialize(array $data): void { @@ -381,11 +384,6 @@ class Uuid implements UuidInterface return new IntegerObject($this->numberConverter->fromHex($this->getHex()->toString())); } - public function getUrn(): string - { - return 'urn:uuid:' . $this->toString(); - } - /** * @psalm-return non-empty-string */ @@ -534,8 +532,6 @@ class Uuid implements UuidInterface * * @psalm-pure note: changing the internal factory is an edge case not covered by purity invariants, * but under constant factory setups, this method operates in functionally pure manners - * - * @psalm-assert-if-true non-empty-string $uuid */ public static function isValid(string $uuid): bool { @@ -543,7 +539,7 @@ class Uuid implements UuidInterface } /** - * Returns a version 1 (Gregorian time) UUID from a host ID, sequence number, + * Returns a version 1 (time-based) UUID from a host ID, sequence number, * and the current time * * @param Hexadecimal|int|string|null $node A 48-bit number representing the @@ -648,7 +644,7 @@ class Uuid implements UuidInterface } /** - * Returns a version 6 (reordered time) UUID from a host ID, sequence number, + * Returns a version 6 (ordered-time) UUID from a host ID, sequence number, * and the current time * * @param Hexadecimal|null $node A 48-bit number representing the hardware @@ -666,28 +662,4 @@ class Uuid implements UuidInterface ): UuidInterface { return self::getFactory()->uuid6($node, $clockSeq); } - - /** - * Returns a version 7 (Unix Epoch time) UUID - * - * @param DateTimeInterface|null $dateTime An optional date/time from which - * to create the version 7 UUID. If not provided, the UUID is generated - * using the current date/time. - * - * @return UuidInterface A UuidInterface instance that represents a - * version 7 UUID - */ - public static function uuid7(?DateTimeInterface $dateTime = null): UuidInterface - { - $factory = self::getFactory(); - - if (method_exists($factory, 'uuid7')) { - /** @var UuidInterface */ - return $factory->uuid7($dateTime); - } - - throw new UnsupportedOperationException( - 'The provided factory does not support the uuid7() method', - ); - } } diff --git a/vendor/ramsey/uuid/src/UuidFactory.php b/vendor/ramsey/uuid/src/UuidFactory.php index ab730f741..6f2cea061 100644 --- a/vendor/ramsey/uuid/src/UuidFactory.php +++ b/vendor/ramsey/uuid/src/UuidFactory.php @@ -18,16 +18,13 @@ use DateTimeInterface; use Ramsey\Uuid\Builder\UuidBuilderInterface; use Ramsey\Uuid\Codec\CodecInterface; use Ramsey\Uuid\Converter\NumberConverterInterface; -use Ramsey\Uuid\Converter\Time\UnixTimeConverter; use Ramsey\Uuid\Converter\TimeConverterInterface; use Ramsey\Uuid\Generator\DceSecurityGeneratorInterface; use Ramsey\Uuid\Generator\DefaultTimeGenerator; use Ramsey\Uuid\Generator\NameGeneratorInterface; use Ramsey\Uuid\Generator\RandomGeneratorInterface; use Ramsey\Uuid\Generator\TimeGeneratorInterface; -use Ramsey\Uuid\Generator\UnixTimeGenerator; use Ramsey\Uuid\Lazy\LazyUuidFromString; -use Ramsey\Uuid\Math\BrickMathCalculator; use Ramsey\Uuid\Provider\NodeProviderInterface; use Ramsey\Uuid\Provider\Time\FixedTimeProvider; use Ramsey\Uuid\Type\Hexadecimal; @@ -48,26 +45,61 @@ use const STR_PAD_LEFT; class UuidFactory implements UuidFactoryInterface { - private CodecInterface $codec; - private DceSecurityGeneratorInterface $dceSecurityGenerator; - private NameGeneratorInterface $nameGenerator; - private NodeProviderInterface $nodeProvider; - private NumberConverterInterface $numberConverter; - private RandomGeneratorInterface $randomGenerator; - private TimeConverterInterface $timeConverter; - private TimeGeneratorInterface $timeGenerator; - private TimeGeneratorInterface $unixTimeGenerator; - private UuidBuilderInterface $uuidBuilder; - private ValidatorInterface $validator; + /** + * @var CodecInterface + */ + private $codec; + + /** + * @var DceSecurityGeneratorInterface + */ + private $dceSecurityGenerator; + + /** + * @var NameGeneratorInterface + */ + private $nameGenerator; + + /** + * @var NodeProviderInterface + */ + private $nodeProvider; + + /** + * @var NumberConverterInterface + */ + private $numberConverter; + + /** + * @var RandomGeneratorInterface + */ + private $randomGenerator; + + /** + * @var TimeConverterInterface + */ + private $timeConverter; + + /** + * @var TimeGeneratorInterface + */ + private $timeGenerator; + + /** + * @var UuidBuilderInterface + */ + private $uuidBuilder; /** - * @var bool whether the feature set was provided from outside, or we can - * operate under "default" assumptions + * @var ValidatorInterface */ - private bool $isDefaultFeatureSet; + private $validator; + + /** @var bool whether the feature set was provided from outside, or we can operate under "default" assumptions */ + private $isDefaultFeatureSet; /** - * @param FeatureSet|null $features A set of available features in the current environment + * @param FeatureSet $features A set of available features in the current environment */ public function __construct(?FeatureSet $features = null) { @@ -85,7 +117,6 @@ class UuidFactory implements UuidFactoryInterface $this->timeGenerator = $features->getTimeGenerator(); $this->uuidBuilder = $features->getBuilder(); $this->validator = $features->getValidator(); - $this->unixTimeGenerator = $features->getUnixTimeGenerator(); } /** @@ -311,7 +342,7 @@ class UuidFactory implements UuidFactoryInterface $bytes = $timeGenerator->generate($nodeHex, $clockSeq); - return $this->uuidFromBytesAndVersion($bytes, Uuid::UUID_TYPE_TIME); + return $this->uuidFromBytesAndVersion($bytes, 1); } /** @@ -321,7 +352,7 @@ class UuidFactory implements UuidFactoryInterface { $bytes = $this->timeGenerator->generate($node, $clockSeq); - return $this->uuidFromBytesAndVersion($bytes, Uuid::UUID_TYPE_TIME); + return $this->uuidFromBytesAndVersion($bytes, 1); } public function uuid2( @@ -337,7 +368,7 @@ class UuidFactory implements UuidFactoryInterface $clockSeq ); - return $this->uuidFromBytesAndVersion($bytes, Uuid::UUID_TYPE_DCE_SECURITY); + return $this->uuidFromBytesAndVersion($bytes, 2); } /** @@ -346,14 +377,14 @@ class UuidFactory implements UuidFactoryInterface */ public function uuid3($ns, string $name): UuidInterface { - return $this->uuidFromNsAndName($ns, $name, Uuid::UUID_TYPE_HASH_MD5, 'md5'); + return $this->uuidFromNsAndName($ns, $name, 3, 'md5'); } public function uuid4(): UuidInterface { $bytes = $this->randomGenerator->generate(16); - return $this->uuidFromBytesAndVersion($bytes, Uuid::UUID_TYPE_RANDOM); + return $this->uuidFromBytesAndVersion($bytes, 4); } /** @@ -362,7 +393,7 @@ class UuidFactory implements UuidFactoryInterface */ public function uuid5($ns, string $name): UuidInterface { - return $this->uuidFromNsAndName($ns, $name, Uuid::UUID_TYPE_HASH_SHA1, 'sha1'); + return $this->uuidFromNsAndName($ns, $name, 5, 'sha1'); } public function uuid6(?Hexadecimal $node = null, ?int $clockSeq = null): UuidInterface @@ -381,38 +412,7 @@ class UuidFactory implements UuidFactoryInterface $v6Bytes = hex2bin(substr($v6, 1, 12) . '0' . substr($v6, -3)); $v6Bytes .= substr($bytes, 8); - return $this->uuidFromBytesAndVersion($v6Bytes, Uuid::UUID_TYPE_REORDERED_TIME); - } - - /** - * Returns a version 7 (Unix Epoch time) UUID - * - * @param DateTimeInterface|null $dateTime An optional date/time from which - * to create the version 7 UUID. If not provided, the UUID is generated - * using the current date/time. - * - * @return UuidInterface A UuidInterface instance that represents a - * version 7 UUID - */ - public function uuid7(?DateTimeInterface $dateTime = null): UuidInterface - { - if ($dateTime !== null) { - $timeProvider = new FixedTimeProvider( - new Time($dateTime->format('U'), $dateTime->format('u')) - ); - - $timeGenerator = new UnixTimeGenerator( - new UnixTimeConverter(new BrickMathCalculator()), - $timeProvider, - $this->randomGenerator, - ); - - $bytes = $timeGenerator->generate(); - } else { - $bytes = $this->unixTimeGenerator->generate(); - } - - return $this->uuidFromBytesAndVersion($bytes, Uuid::UUID_TYPE_UNIX_TIME); + return $this->uuidFromBytesAndVersion($v6Bytes, 6); } /** @@ -447,12 +447,8 @@ class UuidFactory implements UuidFactoryInterface * * @psalm-pure */ - private function uuidFromNsAndName( - UuidInterface | string $ns, - string $name, - int $version, - string $hashAlgorithm - ): UuidInterface { + private function uuidFromNsAndName($ns, string $name, int $version, string $hashAlgorithm): UuidInterface + { if (!($ns instanceof UuidInterface)) { $ns = $this->fromString($ns); } diff --git a/vendor/ramsey/uuid/src/UuidFactoryInterface.php b/vendor/ramsey/uuid/src/UuidFactoryInterface.php index d99fc9d58..468cc6377 100644 --- a/vendor/ramsey/uuid/src/UuidFactoryInterface.php +++ b/vendor/ramsey/uuid/src/UuidFactoryInterface.php @@ -26,61 +26,6 @@ use Ramsey\Uuid\Validator\ValidatorInterface; interface UuidFactoryInterface { /** - * Creates a UUID from a byte string - * - * @param string $bytes A binary string - * - * @return UuidInterface A UuidInterface instance created from a binary - * string representation - * - * @psalm-pure - */ - public function fromBytes(string $bytes): UuidInterface; - - /** - * Creates a UUID from a DateTimeInterface instance - * - * @param DateTimeInterface $dateTime The date and time - * @param Hexadecimal|null $node A 48-bit number representing the hardware - * address - * @param int|null $clockSeq A 14-bit number used to help avoid duplicates - * that could arise when the clock is set backwards in time or if the - * node ID changes - * - * @return UuidInterface A UuidInterface instance that represents a - * version 1 UUID created from a DateTimeInterface instance - */ - public function fromDateTime( - DateTimeInterface $dateTime, - ?Hexadecimal $node = null, - ?int $clockSeq = null - ): UuidInterface; - - /** - * Creates a UUID from a 128-bit integer string - * - * @param string $integer String representation of 128-bit integer - * - * @return UuidInterface A UuidInterface instance created from the string - * representation of a 128-bit integer - * - * @psalm-pure - */ - public function fromInteger(string $integer): UuidInterface; - - /** - * Creates a UUID from the string standard representation - * - * @param string $uuid A hexadecimal string - * - * @return UuidInterface A UuidInterface instance created from a hexadecimal - * string representation - * - * @psalm-pure - */ - public function fromString(string $uuid): UuidInterface; - - /** * Returns the validator to use for the factory * * @psalm-mutation-free @@ -88,7 +33,7 @@ interface UuidFactoryInterface public function getValidator(): ValidatorInterface; /** - * Returns a version 1 (Gregorian time) UUID from a host ID, sequence number, + * Returns a version 1 (time-based) UUID from a host ID, sequence number, * and the current time * * @param Hexadecimal|int|string|null $node A 48-bit number representing the @@ -166,7 +111,7 @@ interface UuidFactoryInterface public function uuid5($ns, string $name): UuidInterface; /** - * Returns a version 6 (reordered time) UUID from a host ID, sequence number, + * Returns a version 6 (ordered-time) UUID from a host ID, sequence number, * and the current time * * @param Hexadecimal|null $node A 48-bit number representing the hardware @@ -179,4 +124,59 @@ interface UuidFactoryInterface * version 6 UUID */ public function uuid6(?Hexadecimal $node = null, ?int $clockSeq = null): UuidInterface; + + /** + * Creates a UUID from a byte string + * + * @param string $bytes A binary string + * + * @return UuidInterface A UuidInterface instance created from a binary + * string representation + * + * @psalm-pure + */ + public function fromBytes(string $bytes): UuidInterface; + + /** + * Creates a UUID from the string standard representation + * + * @param string $uuid A hexadecimal string + * + * @return UuidInterface A UuidInterface instance created from a hexadecimal + * string representation + * + * @psalm-pure + */ + public function fromString(string $uuid): UuidInterface; + + /** + * Creates a UUID from a 128-bit integer string + * + * @param string $integer String representation of 128-bit integer + * + * @return UuidInterface A UuidInterface instance created from the string + * representation of a 128-bit integer + * + * @psalm-pure + */ + public function fromInteger(string $integer): UuidInterface; + + /** + * Creates a UUID from a DateTimeInterface instance + * + * @param DateTimeInterface $dateTime The date and time + * @param Hexadecimal|null $node A 48-bit number representing the hardware + * address + * @param int|null $clockSeq A 14-bit number used to help avoid duplicates + * that could arise when the clock is set backwards in time or if the + * node ID changes + * + * @return UuidInterface A UuidInterface instance that represents a + * version 1 UUID created from a DateTimeInterface instance + */ + public function fromDateTime( + DateTimeInterface $dateTime, + ?Hexadecimal $node = null, + ?int $clockSeq = null + ): UuidInterface; } diff --git a/vendor/ramsey/uuid/src/UuidInterface.php b/vendor/ramsey/uuid/src/UuidInterface.php index 5f41675bf..f22eb0f99 100644 --- a/vendor/ramsey/uuid/src/UuidInterface.php +++ b/vendor/ramsey/uuid/src/UuidInterface.php @@ -84,14 +84,6 @@ interface UuidInterface extends public function getInteger(): IntegerObject; /** - * Returns the string standard representation of the UUID as a URN - * - * @link http://en.wikipedia.org/wiki/Uniform_Resource_Name Uniform Resource Name - * @link https://tools.ietf.org/html/rfc4122#section-3 RFC 4122, § 3: Namespace Registration Template - */ - public function getUrn(): string; - - /** * Returns the string standard representation of the UUID * * @psalm-return non-empty-string diff --git a/vendor/ramsey/uuid/src/functions.php b/vendor/ramsey/uuid/src/functions.php index fa80f4e85..f5df1488d 100644 --- a/vendor/ramsey/uuid/src/functions.php +++ b/vendor/ramsey/uuid/src/functions.php @@ -15,18 +15,17 @@ declare(strict_types=1); namespace Ramsey\Uuid; -use DateTimeInterface; use Ramsey\Uuid\Type\Hexadecimal; use Ramsey\Uuid\Type\Integer as IntegerObject; /** - * Returns a version 1 (Gregorian time) UUID from a host ID, sequence number, + * Returns a version 1 (time-based) UUID from a host ID, sequence number, * and the current time * * @param Hexadecimal|int|string|null $node A 48-bit number representing the * hardware address; this number may be represented as an integer or a * hexadecimal string - * @param int|null $clockSeq A 14-bit number used to help avoid duplicates that + * @param int $clockSeq A 14-bit number used to help avoid duplicates that * could arise when the clock is set backwards in time or if the node ID * changes * @@ -107,12 +106,12 @@ function v5($ns, string $name): string } /** - * Returns a version 6 (reordered time) UUID from a host ID, sequence number, + * Returns a version 6 (ordered-time) UUID from a host ID, sequence number, * and the current time * * @param Hexadecimal|null $node A 48-bit number representing the hardware * address - * @param int|null $clockSeq A 14-bit number used to help avoid duplicates that + * @param int $clockSeq A 14-bit number used to help avoid duplicates that * could arise when the clock is set backwards in time or if the node ID * changes * @@ -122,17 +121,3 @@ function v6(?Hexadecimal $node = null, ?int $clockSeq = null): string { return Uuid::uuid6($node, $clockSeq)->toString(); } - -/** - * Returns a version 7 (Unix Epoch time) UUID - * - * @param DateTimeInterface|null $dateTime An optional date/time from which - * to create the version 7 UUID. If not provided, the UUID is generated - * using the current date/time. - * - * @return non-empty-string Version 7 UUID as a string - */ -function v7(?DateTimeInterface $dateTime = null): string -{ - return Uuid::uuid7($dateTime)->toString(); -} |