From 67abb86aafb37338a2bb7a9ee114b1465dbf818c Mon Sep 17 00:00:00 2001 From: Ben Ramsey Date: Sun, 27 Mar 2022 20:32:00 -0500 Subject: [PATCH] Remove remaining deprecated getClockSeq*() methods --- CHANGELOG.md | 3 ++ phpstan.neon.dist | 5 --- src/DeprecatedUuidMethodsTrait.php | 36 --------------- src/Lazy/LazyUuidFromString.php | 72 ------------------------------ tests/ExpectedBehaviorTest.php | 1 - tests/UuidTest.php | 25 +---------- 6 files changed, 5 insertions(+), 137 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7efa7da..649890c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,8 +21,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. * `Ramsey\Uuid\Generator\RandomLibAdapter` * `Ramsey\Uuid\Provider\Node\NodeProviderCollection` * Remove the following deprecated methods from Uuid classes: + * `getClockSeqHiAndReserved()` * `getClockSeqHiAndReservedHex()` + * `getClockSeqLow()` * `getClockSeqLowHex()` + * `getClockSequence()` * `getClockSequenceHex()` * `getLeastSignificantBits()` * `getLeastSignificantBitsHex()` diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 21f2850..b26818b 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -11,11 +11,6 @@ parameters: message: '#^Comparison operation ">" between 6 and 0 is always true\.$#' count: 1 path: ./src/Generator/CombGenerator.php - - - # Legacy methods of `Ramsey\Uuid` use interface methods that are NOT defined on `FieldsInterface` - message: '#^Call to an undefined method Ramsey\\Uuid\\Fields\\FieldsInterface::get.*$#' - count: 3 - path: ./src/Lazy/LazyUuidFromString.php - message: '#^Result of \|\| is always false\.$#' count: 1 diff --git a/src/DeprecatedUuidMethodsTrait.php b/src/DeprecatedUuidMethodsTrait.php index 356221a..812af6a 100644 --- a/src/DeprecatedUuidMethodsTrait.php +++ b/src/DeprecatedUuidMethodsTrait.php @@ -50,42 +50,6 @@ trait DeprecatedUuidMethodsTrait */ protected $timeConverter; - /** - * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@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. - */ - public function getClockSeqHiAndReserved(): string - { - return $this->numberConverter->fromHex($this->fields->getClockSeqHiAndReserved()->toString()); - } - - /** - * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@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. - */ - public function getClockSeqLow(): string - { - return $this->numberConverter->fromHex($this->fields->getClockSeqLow()->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()} - * and use the arbitrary-precision math library of your choice to - * convert it to a string integer. - */ - public function getClockSequence(): string - { - return $this->numberConverter->fromHex($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 f5fa150..cd6a586 100644 --- a/src/Lazy/LazyUuidFromString.php +++ b/src/Lazy/LazyUuidFromString.php @@ -236,78 +236,6 @@ final class LazyUuidFromString implements UuidInterface return $this->uuid; } - /** - * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@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. - * - * @psalm-suppress UndefinedInterfaceMethod - * @psalm-suppress DeprecatedMethod - * @psalm-suppress MixedArgument - * @psalm-suppress MixedMethodCall - */ - public function getClockSeqHiAndReserved(): string - { - $instance = ($this->unwrapped ?? $this->unwrap()); - - return $instance->getNumberConverter() - ->fromHex( - $instance->getFields() - ->getClockSeqHiAndReserved() - ->toString() - ); - } - - /** - * @deprecated Use {@see UuidInterface::getFields()} to get a - * {@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. - * - * @psalm-suppress UndefinedInterfaceMethod - * @psalm-suppress DeprecatedMethod - * @psalm-suppress MixedArgument - * @psalm-suppress MixedMethodCall - */ - public function getClockSeqLow(): string - { - $instance = ($this->unwrapped ?? $this->unwrap()); - - return $instance->getNumberConverter() - ->fromHex( - $instance->getFields() - ->getClockSeqLow() - ->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()} - * and use the arbitrary-precision math library of your choice to - * convert it to a string integer. - * - * @psalm-suppress UndefinedInterfaceMethod - * @psalm-suppress DeprecatedMethod - * @psalm-suppress MixedArgument - * @psalm-suppress MixedMethodCall - */ - public function getClockSequence(): string - { - $instance = ($this->unwrapped ?? $this->unwrap()); - - return $instance->getNumberConverter() - ->fromHex( - $instance->getFields() - ->getClockSeq() - ->toString() - ); - } - public function toUuidV1(): UuidV1 { $instance = ($this->unwrapped ?? $this->unwrap()); diff --git a/tests/ExpectedBehaviorTest.php b/tests/ExpectedBehaviorTest.php index a798820..a013370 100644 --- a/tests/ExpectedBehaviorTest.php +++ b/tests/ExpectedBehaviorTest.php @@ -139,7 +139,6 @@ class ExpectedBehaviorTest extends TestCase $this->assertInstanceOf('DateTimeInterface', $uuid->getDateTime()); $this->assertSame('00000fffffff', $uuid->getFields()->getNode()->toString()); $this->assertSame('3fff', $uuid->getFields()->getClockSeq()->toString()); - $this->assertSame('16383', (string) $uuid->getClockSequence()); } /** diff --git a/tests/UuidTest.php b/tests/UuidTest.php index f52a03e..06f1d65 100644 --- a/tests/UuidTest.php +++ b/tests/UuidTest.php @@ -145,13 +145,6 @@ class UuidTest extends TestCase $this->assertSame('/2+MsMV9EeGbIQgAIAyaZg==', base64_encode($uuid->getBytes())); } - public function testGetClockSeqHiAndReserved(): void - { - /** @var Uuid $uuid */ - $uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66'); - $this->assertSame('155', $uuid->getClockSeqHiAndReserved()); - } - public function testGetClockSeqHiAndReservedHex(): void { /** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */ @@ -159,13 +152,6 @@ class UuidTest extends TestCase $this->assertSame('9b', $uuid->getFields()->getClockSeqHiAndReserved()->toString()); } - public function testGetClockSeqLow(): void - { - /** @var Uuid $uuid */ - $uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66'); - $this->assertSame('33', $uuid->getClockSeqLow()); - } - public function testGetClockSeqLowHex(): void { /** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */ @@ -173,13 +159,6 @@ class UuidTest extends TestCase $this->assertSame('21', $uuid->getFields()->getClockSeqLow()->toString()); } - public function testGetClockSequence(): void - { - /** @var Uuid $uuid */ - $uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66'); - $this->assertSame('6945', $uuid->getClockSequence()); - } - public function testGetClockSequenceHex(): void { /** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */ @@ -456,7 +435,7 @@ class UuidTest extends TestCase $this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime()); $this->assertSame(2, $uuid->getVariant()); $this->assertSame(1, $uuid->getVersion()); - $this->assertSame('5737', $uuid->getClockSequence()); + $this->assertSame('1669', $uuid->getFields()->getClockSeq()->toString()); $this->assertSame('0800200c9a66', $uuid->getFields()->getNode()->toString()); $this->assertSame('9669-0800200c9a66', substr($uuid->toString(), 19)); } @@ -468,7 +447,7 @@ class UuidTest extends TestCase $this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime()); $this->assertSame(2, $uuid->getVariant()); $this->assertSame(1, $uuid->getVersion()); - $this->assertSame('5737', $uuid->getClockSequence()); + $this->assertSame('1669', $uuid->getFields()->getClockSeq()->toString()); $this->assertSame('0800200c9a66', $uuid->getFields()->getNode()->toString()); $this->assertSame('9669-0800200c9a66', substr($uuid->toString(), 19)); }