Remove deprecated getNode*() methods

This commit is contained in:
Ben Ramsey
2022-03-27 20:22:45 -05:00
parent 23d54b85cb
commit e4c7ea0755
8 changed files with 24 additions and 107 deletions
+2
View File
@@ -28,6 +28,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* `getLeastSignificantBitsHex()`
* `getMostSignificantBits()`
* `getMostSignificantBitsHex()`
* `getNode()`
* `getNodeHex()`
* `getTimeHiAndVersion()`
* `getTimeHiAndVersionHex()`
* `getTimeLow()`
+1 -1
View File
@@ -14,7 +14,7 @@ parameters:
-
# 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: 4
count: 3
path: ./src/Lazy/LazyUuidFromString.php
-
message: '#^Result of \|\| is always false\.$#'
-8
View File
@@ -45,14 +45,6 @@ interface DeprecatedUuidInterface
*/
public function getDateTime(): DateTimeInterface;
/**
* @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::getNode()}.
*/
public function getNodeHex(): 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()}.
-22
View File
@@ -142,28 +142,6 @@ trait DeprecatedUuidMethodsTrait
];
}
/**
* @deprecated Use {@see UuidInterface::getFields()} to get a
* {@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
{
return $this->numberConverter->fromHex($this->fields->getNode()->toString());
}
/**
* @deprecated Use {@see UuidInterface::getFields()} to get a
* {@see FieldsInterface} instance. If it is a {@see Rfc4122FieldsInterface}
* instance, you may call {@see Rfc4122FieldsInterface::getNode()}.
*/
public function getNodeHex(): string
{
return $this->fields->getNode()->toString();
}
/**
* @deprecated This has moved to {@see Rfc4122FieldsInterface::getUrn()} and
* is available on {@see \Ramsey\Uuid\Rfc4122\UuidV1},
-31
View File
@@ -154,13 +154,6 @@ final class LazyUuidFromString implements UuidInterface
->getDateTime();
}
/** @psalm-suppress DeprecatedMethod */
public function getNodeHex(): string
{
return ($this->unwrapped ?? $this->unwrap())
->getNodeHex();
}
/** @psalm-suppress DeprecatedMethod */
public function getUrn(): string
{
@@ -315,30 +308,6 @@ final class LazyUuidFromString implements UuidInterface
);
}
/**
* @deprecated Use {@see UuidInterface::getFields()} to get a
* {@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.
*
* @psalm-suppress UndefinedInterfaceMethod
* @psalm-suppress DeprecatedMethod
* @psalm-suppress MixedArgument
* @psalm-suppress MixedMethodCall
*/
public function getNode(): string
{
$instance = ($this->unwrapped ?? $this->unwrap());
return $instance->getNumberConverter()
->fromHex(
$instance->getFields()
->getNode()
->toString()
);
}
public function toUuidV1(): UuidV1
{
$instance = ($this->unwrapped ?? $this->unwrap());
+8 -24
View File
@@ -53,10 +53,6 @@ class ExpectedBehaviorTest extends TestCase
$this->assertArrayHasKey('clock_seq_hi_and_reserved', $uuid->getFieldsHex());
$this->assertArrayHasKey('clock_seq_low', $uuid->getFieldsHex());
$this->assertArrayHasKey('node', $uuid->getFieldsHex());
$this->assertIsString($uuid->getFields()->getTimeLow()->toString());
$this->assertIsString($uuid->getFields()->getTimeMid()->toString());
$this->assertIsString($uuid->getFields()->getTimeHiAndVersion()->toString());
$this->assertIsString($uuid->getNodeHex());
$this->assertSame($uuid->getFieldsHex()['time_low'], $uuid->getFields()->getTimeLow()->toString());
$this->assertSame($uuid->getFieldsHex()['time_mid'], $uuid->getFields()->getTimeMid()->toString());
$this->assertSame(
@@ -65,7 +61,7 @@ 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($uuid->getFieldsHex()['node'], $uuid->getFields()->getNode()->toString());
$this->assertSame(
(string) $uuid->getHex(),
@@ -74,7 +70,7 @@ class ExpectedBehaviorTest extends TestCase
. $uuid->getFields()->getTimeHiAndVersion()->toString()
. $uuid->getFields()->getClockSeqHiAndReserved()->toString()
. $uuid->getFields()->getClockSeqLow()->toString()
. $uuid->getNodeHex()
. $uuid->getFields()->getNode()->toString()
);
$this->assertSame(
@@ -100,7 +96,7 @@ class ExpectedBehaviorTest extends TestCase
. $uuid->getFields()->getTimeHiAndVersion()->toString() . '-'
. $uuid->getFields()->getClockSeqHiAndReserved()->toString()
. $uuid->getFields()->getClockSeqLow()->toString() . '-'
. $uuid->getNodeHex()
. $uuid->getFields()->getNode()->toString()
);
$this->assertSame(
@@ -110,7 +106,7 @@ class ExpectedBehaviorTest extends TestCase
. $uuid->getFields()->getTimeHiAndVersion()->toString() . '-'
. $uuid->getFields()->getClockSeqHiAndReserved()->toString()
. $uuid->getFields()->getClockSeqLow()->toString() . '-'
. $uuid->getNodeHex()
. $uuid->getFields()->getNode()->toString()
);
$this->assertSame(2, $uuid->getVariant());
@@ -141,19 +137,7 @@ class ExpectedBehaviorTest extends TestCase
$uuid = Uuid::uuid1('00000fffffff', 0xffff);
$this->assertInstanceOf('DateTimeInterface', $uuid->getDateTime());
$this->assertSame('00000fffffff', $uuid->getNodeHex());
$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('00000fffffff', $uuid->getFields()->getNode()->toString());
$this->assertSame('3fff', $uuid->getFields()->getClockSeq()->toString());
$this->assertSame('16383', (string) $uuid->getClockSequence());
}
@@ -261,7 +245,7 @@ class ExpectedBehaviorTest extends TestCase
$uuid->getFields()->getClockSeqHiAndReserved()->toString()
. $uuid->getFields()->getClockSeqLow()->toString(),
);
$this->assertSame($components[4], $uuid->getNodeHex());
$this->assertSame($components[4], $uuid->getFields()->getNode()->toString());
$this->assertSame($integer, (string) $uuid->getInteger());
$this->assertSame($bytes, $uuid->getBytes());
}
@@ -291,7 +275,7 @@ class ExpectedBehaviorTest extends TestCase
$uuid->getFields()->getClockSeqHiAndReserved()->toString()
. $uuid->getFields()->getClockSeqLow()->toString(),
);
$this->assertSame($components[4], $uuid->getNodeHex());
$this->assertSame($components[4], $uuid->getFields()->getNode()->toString());
$this->assertSame($integer, (string) $uuid->getInteger());
$this->assertSame($bytes, $uuid->getBytes());
}
@@ -321,7 +305,7 @@ class ExpectedBehaviorTest extends TestCase
$uuid->getFields()->getClockSeqHiAndReserved()->toString()
. $uuid->getFields()->getClockSeqLow()->toString(),
);
$this->assertSame($components[4], $uuid->getNodeHex());
$this->assertSame($components[4], $uuid->getFields()->getNode()->toString());
$this->assertSame($integer, (string) $uuid->getInteger());
$this->assertSame($bytes, $uuid->getBytes());
}
+13 -20
View File
@@ -304,17 +304,11 @@ class UuidTest extends TestCase
$this->assertSame($fields, $uuid->getFieldsHex());
}
public function testGetNode(): void
{
/** @var Uuid $uuid */
$uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
$this->assertSame('8796630719078', $uuid->getNode());
}
public function testGetNodeHex(): void
{
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
$uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
$this->assertSame('0800200c9a66', $uuid->getNodeHex());
$this->assertSame('0800200c9a66', $uuid->getFields()->getNode()->toString());
}
public function testGetTimeHiAndVersionHex(): void
@@ -463,7 +457,7 @@ class UuidTest extends TestCase
$this->assertSame(2, $uuid->getVariant());
$this->assertSame(1, $uuid->getVersion());
$this->assertSame('5737', $uuid->getClockSequence());
$this->assertSame('8796630719078', $uuid->getNode());
$this->assertSame('0800200c9a66', $uuid->getFields()->getNode()->toString());
$this->assertSame('9669-0800200c9a66', substr($uuid->toString(), 19));
}
@@ -475,7 +469,7 @@ class UuidTest extends TestCase
$this->assertSame(2, $uuid->getVariant());
$this->assertSame(1, $uuid->getVersion());
$this->assertSame('5737', $uuid->getClockSequence());
$this->assertSame('8796630719078', $uuid->getNode());
$this->assertSame('0800200c9a66', $uuid->getFields()->getNode()->toString());
$this->assertSame('9669-0800200c9a66', substr($uuid->toString(), 19));
}
@@ -487,8 +481,7 @@ class UuidTest extends TestCase
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame(2, $uuid->getVariant());
$this->assertSame(1, $uuid->getVersion());
$this->assertSame('00007160355e', $uuid->getNodeHex());
$this->assertSame('1902130526', $uuid->getNode());
$this->assertSame('00007160355e', $uuid->getFields()->getNode()->toString());
}
public function testUuid1WithHexadecimalObjectNode(): void
@@ -499,8 +492,7 @@ class UuidTest extends TestCase
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame(2, $uuid->getVariant());
$this->assertSame(1, $uuid->getVersion());
$this->assertSame('00007160355e', $uuid->getNodeHex());
$this->assertSame('1902130526', $uuid->getNode());
$this->assertSame('00007160355e', $uuid->getFields()->getNode()->toString());
}
public function testUuid1WithMixedCaseHexadecimalNode(): void
@@ -511,8 +503,7 @@ class UuidTest extends TestCase
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame(2, $uuid->getVariant());
$this->assertSame(1, $uuid->getVersion());
$this->assertSame('000071b0ad5e', $uuid->getNodeHex());
$this->assertSame('1907404126', $uuid->getNode());
$this->assertSame('000071b0ad5e', $uuid->getFields()->getNode()->toString());
}
public function testUuid1WithOutOfBoundsNode(): void
@@ -573,28 +564,30 @@ class UuidTest extends TestCase
$this->assertSame(2, $uuid->getVariant());
$this->assertSame(6, $uuid->getVersion());
$this->assertSame('1669', $uuid->getFields()->getClockSeq()->toString());
$this->assertSame('0800200c9a66', $uuid->getNodeHex());
$this->assertSame('0800200c9a66', $uuid->getFields()->getNode()->toString());
$this->assertSame('9669-0800200c9a66', substr($uuid->toString(), 19));
}
public function testUuid6WithHexadecimalNode(): void
{
/** @var UuidV6 $uuid */
$uuid = Uuid::uuid6(new Hexadecimal('7160355e'));
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame(2, $uuid->getVariant());
$this->assertSame(6, $uuid->getVersion());
$this->assertSame('00007160355e', $uuid->getNodeHex());
$this->assertSame('00007160355e', $uuid->getFields()->getNode()->toString());
}
public function testUuid6WithMixedCaseHexadecimalNode(): void
{
/** @var UuidV6 $uuid */
$uuid = Uuid::uuid6(new Hexadecimal('71B0aD5e'));
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame(2, $uuid->getVariant());
$this->assertSame(6, $uuid->getVersion());
$this->assertSame('000071b0ad5e', $uuid->getNodeHex());
$this->assertSame('000071b0ad5e', $uuid->getFields()->getNode()->toString());
}
public function testUuid6WithOutOfBoundsNode(): void
@@ -1163,7 +1156,7 @@ class UuidTest extends TestCase
$fields['clock_seq_low'],
$uuid->getFields()->getClockSeqLow()->toString(),
);
$this->assertSame($fields['node'], $uuid->getNodeHex());
$this->assertSame($fields['node'], $uuid->getFields()->getNode()->toString());
$this->assertSame($urn, $uuid->getUrn());
$this->assertSame($time, $uuid->getFields()->getTimestamp()->toString());
$this->assertSame($clockSeq, $uuid->getFields()->getClockSeq()->toString());
@@ -56,7 +56,6 @@ final class UuidIsImmutable
$a->getFieldsHex(),
$a->getDateTime(),
$a->getInteger(),
$a->getNodeHex(),
$a->getUrn(),
$a->getVariant(),
$a->getVersion(),