From f810c0a50c72c449efd90e279ba4b0852fc4467b Mon Sep 17 00:00:00 2001 From: Ben Ramsey Date: Sun, 27 Mar 2022 18:44:47 -0500 Subject: [PATCH] Remove deprecated getClockSequenceHex() method --- CHANGELOG.md | 1 + src/DeprecatedUuidInterface.php | 8 -------- src/DeprecatedUuidMethodsTrait.php | 10 ---------- src/Lazy/LazyUuidFromString.php | 7 ------- tests/ExpectedBehaviorTest.php | 7 +++++-- tests/UuidTest.php | 10 ++++++---- tests/static-analysis/UuidIsImmutable.php | 1 - 7 files changed, 12 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 383969c..ca27e51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. * Remove the following deprecated methods from Uuid classes: * `getClockSeqHiAndReservedHex()` * `getClockSeqLowHex()` + * `getClockSequenceHex()` * Remove dependency on ramsey/collection package. diff --git a/src/DeprecatedUuidInterface.php b/src/DeprecatedUuidInterface.php index 36bb2e4..42b063f 100644 --- a/src/DeprecatedUuidInterface.php +++ b/src/DeprecatedUuidInterface.php @@ -39,14 +39,6 @@ interface DeprecatedUuidInterface */ public function getFieldsHex(): array; - /** - * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@see FieldsInterface} instance. If it is a - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call - * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getClockSeq()}. - */ - public function getClockSequenceHex(): string; - /** * @deprecated In ramsey/uuid version 5.0.0, this will be removed from the * interface. It is available at {@see UuidV1::getDateTime()}. diff --git a/src/DeprecatedUuidMethodsTrait.php b/src/DeprecatedUuidMethodsTrait.php index 5af30f8..e84f210 100644 --- a/src/DeprecatedUuidMethodsTrait.php +++ b/src/DeprecatedUuidMethodsTrait.php @@ -87,16 +87,6 @@ trait DeprecatedUuidMethodsTrait return $this->numberConverter->fromHex($this->fields->getClockSeq()->toString()); } - /** - * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@see FieldsInterface} instance. If it is a {@see Rfc4122FieldsInterface} - * instance, you may call {@see Rfc4122FieldsInterface::getClockSeq()}. - */ - public function getClockSequenceHex(): string - { - return $this->fields->getClockSeq()->toString(); - } - /** * @deprecated This method will be removed in 5.0.0. There is no alternative * recommendation, so plan accordingly. diff --git a/src/Lazy/LazyUuidFromString.php b/src/Lazy/LazyUuidFromString.php index 1dd0b65..fe99fa3 100644 --- a/src/Lazy/LazyUuidFromString.php +++ b/src/Lazy/LazyUuidFromString.php @@ -148,13 +148,6 @@ final class LazyUuidFromString implements UuidInterface ->getFieldsHex(); } - /** @psalm-suppress DeprecatedMethod */ - public function getClockSequenceHex(): string - { - return ($this->unwrapped ?? $this->unwrap()) - ->getClockSequenceHex(); - } - /** @psalm-suppress DeprecatedMethod */ public function getDateTime(): DateTimeInterface { diff --git a/tests/ExpectedBehaviorTest.php b/tests/ExpectedBehaviorTest.php index 39dbb81..319db37 100644 --- a/tests/ExpectedBehaviorTest.php +++ b/tests/ExpectedBehaviorTest.php @@ -9,6 +9,7 @@ use Ramsey\Uuid\Generator\CombGenerator; use Ramsey\Uuid\Generator\DefaultTimeGenerator; use Ramsey\Uuid\Math\BrickMathCalculator; use Ramsey\Uuid\Rfc4122\UuidInterface; +use Ramsey\Uuid\Rfc4122\UuidV1; use Ramsey\Uuid\Type\Hexadecimal; use Ramsey\Uuid\Type\Time; use Ramsey\Uuid\Uuid; @@ -135,22 +136,24 @@ class ExpectedBehaviorTest extends TestCase public function testUuidVersion1MethodBehavior() { + /** @var UuidV1 $uuid */ $uuid = Uuid::uuid1('00000fffffff', 0xffff); $this->assertInstanceOf('DateTimeInterface', $uuid->getDateTime()); $this->assertSame('00000fffffff', $uuid->getNodeHex()); - $this->assertSame('3fff', $uuid->getClockSequenceHex()); + $this->assertSame('3fff', $uuid->getFields()->getClockSeq()->toString()); $this->assertSame('16383', (string) $uuid->getClockSequence()); } public function testUuidVersion1MethodBehavior64Bit() { + /** @var UuidV1 $uuid */ $uuid = Uuid::uuid1('ffffffffffff', 0xffff); $this->assertInstanceOf('DateTimeInterface', $uuid->getDateTime()); $this->assertSame('ffffffffffff', $uuid->getNodeHex()); $this->assertSame('281474976710655', (string) $uuid->getNode()); - $this->assertSame('3fff', $uuid->getClockSequenceHex()); + $this->assertSame('3fff', $uuid->getFields()->getClockSeq()->toString()); $this->assertSame('16383', (string) $uuid->getClockSequence()); $this->assertTrue(ctype_digit((string) $uuid->getTimestamp())); } diff --git a/tests/UuidTest.php b/tests/UuidTest.php index bbddc23..60a4103 100644 --- a/tests/UuidTest.php +++ b/tests/UuidTest.php @@ -19,6 +19,7 @@ use Ramsey\Uuid\Generator\RandomGeneratorFactory; use Ramsey\Uuid\Generator\RandomGeneratorInterface; use Ramsey\Uuid\Guid\Guid; use Ramsey\Uuid\Lazy\LazyUuidFromString; +use Ramsey\Uuid\Nonstandard\UuidV6; use Ramsey\Uuid\Provider\Node\RandomNodeProvider; use Ramsey\Uuid\Provider\Time\FixedTimeProvider; use Ramsey\Uuid\Rfc4122\FieldsInterface; @@ -181,9 +182,9 @@ class UuidTest extends TestCase public function testGetClockSequenceHex(): void { - /** @var Uuid $uuid */ + /** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */ $uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66'); - $this->assertSame('1b21', $uuid->getClockSequenceHex()); + $this->assertSame('1b21', $uuid->getFields()->getClockSeq()->toString()); } public function testGetDateTime(): void @@ -636,11 +637,12 @@ class UuidTest extends TestCase public function testUuid6WithNodeAndClockSequence(): void { + /** @var UuidV6 $uuid */ $uuid = Uuid::uuid6(new Hexadecimal('0800200c9a66'), 0x1669); $this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime()); $this->assertSame(2, $uuid->getVariant()); $this->assertSame(6, $uuid->getVersion()); - $this->assertSame('1669', $uuid->getClockSequenceHex()); + $this->assertSame('1669', $uuid->getFields()->getClockSeq()->toString()); $this->assertSame('0800200c9a66', $uuid->getNodeHex()); $this->assertSame('9669-0800200c9a66', substr($uuid->toString(), 19)); } @@ -1226,7 +1228,7 @@ class UuidTest extends TestCase if ($uuid->getVersion() === 1) { $this->assertSame($time, $uuid->getTimestampHex()); } - $this->assertSame($clockSeq, $uuid->getClockSequenceHex()); + $this->assertSame($clockSeq, $uuid->getFields()->getClockSeq()->toString()); $this->assertSame($variant, $uuid->getVariant()); $this->assertSame($version, $uuid->getVersion()); } diff --git a/tests/static-analysis/UuidIsImmutable.php b/tests/static-analysis/UuidIsImmutable.php index cb462a0..c22b616 100644 --- a/tests/static-analysis/UuidIsImmutable.php +++ b/tests/static-analysis/UuidIsImmutable.php @@ -54,7 +54,6 @@ final class UuidIsImmutable $a->getNumberConverter(), $a->getHex(), $a->getFieldsHex(), - $a->getClockSequenceHex(), $a->getDateTime(), $a->getInteger(), $a->getLeastSignificantBitsHex(),