From eed2aecc1758a7f60f3395e4a95bdc7d961a3193 Mon Sep 17 00:00:00 2001 From: Ben Ramsey Date: Sun, 27 Mar 2022 18:58:06 -0500 Subject: [PATCH] Remove deprecated getMostSignificantBits*() methods --- CHANGELOG.md | 2 ++ src/DeprecatedUuidInterface.php | 7 ------- src/DeprecatedUuidMethodsTrait.php | 23 --------------------- src/Lazy/LazyUuidFromString.php | 25 ----------------------- tests/ExpectedBehaviorTest.php | 1 - tests/UuidTest.php | 14 ------------- tests/static-analysis/UuidIsImmutable.php | 1 - 7 files changed, 2 insertions(+), 71 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a0529b..3893d89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. * `getClockSequenceHex()` * `getLeastSignificantBits()` * `getLeastSignificantBitsHex()` + * `getMostSignificantBits()` + * `getMostSignificantBitsHex()` * Remove dependency on ramsey/collection package. diff --git a/src/DeprecatedUuidInterface.php b/src/DeprecatedUuidInterface.php index ade9759..49d2a4b 100644 --- a/src/DeprecatedUuidInterface.php +++ b/src/DeprecatedUuidInterface.php @@ -45,13 +45,6 @@ interface DeprecatedUuidInterface */ public function getDateTime(): DateTimeInterface; - /** - * @deprecated This method will be removed in 5.0.0. There is no direct - * alternative, but the same information may be obtained by splitting - * in half the value returned by {@see UuidInterface::getHex()}. - */ - public function getMostSignificantBitsHex(): string; - /** * @deprecated Use {@see UuidInterface::getFields()} to get a * {@see FieldsInterface} instance. If it is a diff --git a/src/DeprecatedUuidMethodsTrait.php b/src/DeprecatedUuidMethodsTrait.php index 7f071ce..0946476 100644 --- a/src/DeprecatedUuidMethodsTrait.php +++ b/src/DeprecatedUuidMethodsTrait.php @@ -24,7 +24,6 @@ use Ramsey\Uuid\Rfc4122\FieldsInterface as Rfc4122FieldsInterface; use Throwable; use function str_pad; -use function substr; use const STR_PAD_LEFT; @@ -143,28 +142,6 @@ trait DeprecatedUuidMethodsTrait ]; } - /** - * @deprecated This method will be removed in 5.0.0. There is no direct - * alternative, but the same information may be obtained by splitting - * in half the value returned by {@see UuidInterface::getHex()}. - */ - public function getMostSignificantBits(): string - { - $mostSignificantHex = substr($this->getHex()->toString(), 0, 16); - - return $this->numberConverter->fromHex($mostSignificantHex); - } - - /** - * @deprecated This method will be removed in 5.0.0. There is no direct - * alternative, but the same information may be obtained by splitting - * in half the value returned by {@see UuidInterface::getHex()}. - */ - public function getMostSignificantBitsHex(): string - { - return substr($this->getHex()->toString(), 0, 16); - } - /** * @deprecated Use {@see UuidInterface::getFields()} to get a * {@see FieldsInterface} instance. If it is a {@see Rfc4122FieldsInterface} diff --git a/src/Lazy/LazyUuidFromString.php b/src/Lazy/LazyUuidFromString.php index 017a02d..b884188 100644 --- a/src/Lazy/LazyUuidFromString.php +++ b/src/Lazy/LazyUuidFromString.php @@ -155,13 +155,6 @@ final class LazyUuidFromString implements UuidInterface ->getDateTime(); } - /** @psalm-suppress DeprecatedMethod */ - public function getMostSignificantBitsHex(): string - { - return ($this->unwrapped ?? $this->unwrap()) - ->getMostSignificantBitsHex(); - } - /** @psalm-suppress DeprecatedMethod */ public function getNodeHex(): string { @@ -351,24 +344,6 @@ final class LazyUuidFromString implements UuidInterface ); } - /** - * @deprecated This method will be removed in 5.0.0. There is no direct - * alternative, but the same information may be obtained by splitting - * in half the value returned by {@see UuidInterface::getHex()}. - * - * @psalm-suppress UndefinedInterfaceMethod - * @psalm-suppress DeprecatedMethod - * @psalm-suppress MixedArgument - * @psalm-suppress MixedMethodCall - */ - public function getMostSignificantBits(): string - { - $instance = ($this->unwrapped ?? $this->unwrap()); - - return $instance->getNumberConverter() - ->fromHex(substr($instance->getHex()->toString(), 0, 16)); - } - /** * @deprecated Use {@see UuidInterface::getFields()} to get a * {@see FieldsInterface} instance. If it is a {@see Rfc4122FieldsInterface} diff --git a/tests/ExpectedBehaviorTest.php b/tests/ExpectedBehaviorTest.php index 71bfc50..ee98b47 100644 --- a/tests/ExpectedBehaviorTest.php +++ b/tests/ExpectedBehaviorTest.php @@ -63,7 +63,6 @@ class ExpectedBehaviorTest extends TestCase $this->assertSame($uuid->getFieldsHex()['clock_seq_hi_and_reserved'], $uuid->getFields()->getClockSeqHiAndReserved()->toString()); $this->assertSame($uuid->getFieldsHex()['clock_seq_low'], $uuid->getFields()->getClockSeqLow()->toString()); $this->assertSame($uuid->getFieldsHex()['node'], $uuid->getNodeHex()); - $this->assertSame(substr((string) $uuid->getHex(), 0, 16), $uuid->getMostSignificantBitsHex()); $this->assertSame( (string) $uuid->getHex(), diff --git a/tests/UuidTest.php b/tests/UuidTest.php index 7d80677..21dec03 100644 --- a/tests/UuidTest.php +++ b/tests/UuidTest.php @@ -304,20 +304,6 @@ class UuidTest extends TestCase $this->assertSame($fields, $uuid->getFieldsHex()); } - public function testGetMostSignificantBits(): void - { - /** @var Uuid $uuid */ - $uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66'); - - $this->assertSame('18406084892941947361', $uuid->getMostSignificantBits()); - } - - public function testGetMostSignificantBitsHex(): void - { - $uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66'); - $this->assertSame('ff6f8cb0c57d11e1', $uuid->getMostSignificantBitsHex()); - } - public function testGetNode(): void { /** @var Uuid $uuid */ diff --git a/tests/static-analysis/UuidIsImmutable.php b/tests/static-analysis/UuidIsImmutable.php index ef460fe..80d2f24 100644 --- a/tests/static-analysis/UuidIsImmutable.php +++ b/tests/static-analysis/UuidIsImmutable.php @@ -56,7 +56,6 @@ final class UuidIsImmutable $a->getFieldsHex(), $a->getDateTime(), $a->getInteger(), - $a->getMostSignificantBitsHex(), $a->getNodeHex(), $a->getTimeHiAndVersionHex(), $a->getTimeLowHex(),