From 55693967d70cdd21839ac9a9bb8a64ff87dd9b3b Mon Sep 17 00:00:00 2001 From: Ben Ramsey Date: Fri, 5 Aug 2022 17:28:11 -0500 Subject: [PATCH 1/3] Deprecate direct instantiation of Ramsey\Uuid\Uuid --- src/Uuid.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Uuid.php b/src/Uuid.php index 12afc9f..7f9958e 100644 --- a/src/Uuid.php +++ b/src/Uuid.php @@ -247,6 +247,10 @@ class Uuid implements UuidInterface * $namespaceSha1Uuid = Uuid::uuid5(Uuid::NAMESPACE_URL, 'http://php.net/'); * ``` * + * @deprecated ramsey/uuid version 5 will no longer allow direct + * instantiation of the base Ramsey\Uuid\Uuid class. Instead, you must + * use factories to create UUID objects. + * * @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 From 7b3eaf32c71f5dadb84f2c23ef8b8c917a6cb7fa Mon Sep 17 00:00:00 2001 From: Ben Ramsey Date: Fri, 5 Aug 2022 17:28:37 -0500 Subject: [PATCH 2/3] Deprecate Uuid::setFactory() and Uuid::getFactory() --- psalm-baseline.xml | 73 ++++++++++++++++++++++++++++++++++++++++++---- psalm.xml | 2 +- src/Uuid.php | 8 +++++ 3 files changed, 76 insertions(+), 7 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 402c2ac..e2f6c78 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + DegradedUuid @@ -38,14 +38,18 @@ BigNumberTimeConverter + + + Uuid + + - + $calculator $dceSecurityGenerator $numberConverter $timeConverter $timeGenerator - $timeProvider @@ -60,6 +64,11 @@ uuid_parse + + + parent::__construct($fields, $numberConverter, $codec, $timeConverter) + + $this @@ -72,6 +81,11 @@ unserialize + + + parent::__construct($fields, $numberConverter, $codec, $timeConverter) + + $this @@ -79,6 +93,11 @@ $this + + + parent::__construct($fields, $numberConverter, $codec, $timeConverter) + + shell_exec('id -g') @@ -92,13 +111,15 @@ $macs - - $macs - $macs[] + + + Uuid + + $this @@ -118,6 +139,31 @@ $this + + + parent::__construct($fields, $numberConverter, $codec, $timeConverter) + + + + + parent::__construct($fields, $numberConverter, $codec, $timeConverter) + + + + + parent::__construct($fields, $numberConverter, $codec, $timeConverter) + + + + + parent::__construct($fields, $numberConverter, $codec, $timeConverter) + + + + + parent::__construct($fields, $numberConverter, $codec, $timeConverter) + + unserialize @@ -139,6 +185,21 @@ + + self::getFactory() + self::getFactory() + self::getFactory() + self::getFactory() + self::getFactory() + self::getFactory() + self::getFactory() + self::getFactory() + self::getFactory() + self::getFactory() + self::getFactory() + self::getFactory() + self::getFactory() + getFactory getFactory diff --git a/psalm.xml b/psalm.xml index a871b73..0489226 100644 --- a/psalm.xml +++ b/psalm.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" errorLevel="1" cacheDirectory="./build/cache/psalm" - errorBaseline="./psalm-baseline.xml"> + errorBaseline="psalm-baseline.xml"> diff --git a/src/Uuid.php b/src/Uuid.php index 7f9958e..ed7093f 100644 --- a/src/Uuid.php +++ b/src/Uuid.php @@ -403,6 +403,9 @@ class Uuid implements UuidInterface /** * Returns the factory used to create UUIDs + * + * @deprecated ramsey/uuid version 5 will no longer support getting a + * factory instance from the base Ramsey\Uuid\Uuid class. */ public static function getFactory(): UuidFactoryInterface { @@ -416,6 +419,11 @@ class Uuid implements UuidInterface /** * Sets the factory used to create UUIDs * + * @deprecated ramsey/uuid version 5 will no longer support setting a + * factory instance on the base Ramsey\Uuid\Uuid class. If you need to + * customize the properties used to build a UUID, use one of the + * dedicated factories that version 5 will introduce. + * * @param UuidFactoryInterface $factory A factory that will be used by this * class to create UUIDs */ From 2da480d7a33c382c650a8ac6f6da94bd1f4d5793 Mon Sep 17 00:00:00 2001 From: Ben Ramsey Date: Fri, 5 Aug 2022 17:36:05 -0500 Subject: [PATCH 3/3] Fix function type hinting --- src/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/functions.php b/src/functions.php index f5df148..d722f06 100644 --- a/src/functions.php +++ b/src/functions.php @@ -25,7 +25,7 @@ use Ramsey\Uuid\Type\Integer as IntegerObject; * @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 $clockSeq A 14-bit number used to help avoid duplicates that + * @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 * @@ -111,7 +111,7 @@ function v5($ns, string $name): string * * @param Hexadecimal|null $node A 48-bit number representing the hardware * address - * @param int $clockSeq A 14-bit number used to help avoid duplicates that + * @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 *