Remove deprecated getClockSeqHiAndReservedHex() method

This commit is contained in:
Ben Ramsey
2022-03-27 16:37:53 -05:00
parent eebc792d6f
commit 1d4077d213
10 changed files with 34 additions and 50 deletions
+2
View File
@@ -21,6 +21,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* `Ramsey\Uuid\DegradedUuid`
* `Ramsey\Uuid\Generator\RandomLibAdapter`
* `Ramsey\Uuid\Provider\Node\NodeProviderCollection`
* Remove the following deprecated methods from Uuid classes:
* `getClockSeqHiAndReservedHex()`
* Remove dependency on ramsey/collection package.
### Deprecated
-8
View File
@@ -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::getClockSeqHiAndReserved()}.
*/
public function getClockSeqHiAndReservedHex(): string;
/**
* @deprecated Use {@see UuidInterface::getFields()} to get a
* {@see FieldsInterface} instance. If it is a
-10
View File
@@ -63,16 +63,6 @@ trait DeprecatedUuidMethodsTrait
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::getClockSeqHiAndReserved()}.
*/
public function getClockSeqHiAndReservedHex(): string
{
return $this->fields->getClockSeqHiAndReserved()->toString();
}
/**
* @deprecated Use {@see UuidInterface::getFields()} to get a
* {@see FieldsInterface} instance. If it is a {@see Rfc4122FieldsInterface}
-7
View File
@@ -148,13 +148,6 @@ final class LazyUuidFromString implements UuidInterface
->getFieldsHex();
}
/** @psalm-suppress DeprecatedMethod */
public function getClockSeqHiAndReservedHex(): string
{
return ($this->unwrapped ?? $this->unwrap())
->getClockSeqHiAndReservedHex();
}
/** @psalm-suppress DeprecatedMethod */
public function getClockSeqLowHex(): string
{
+2
View File
@@ -33,4 +33,6 @@ interface UuidInterface extends BaseUuidInterface
* @link https://tools.ietf.org/html/rfc4122#section-3 RFC 4122, § 3: Namespace Registration Template
*/
public function getUrn(): string;
public function getFields(): FieldsInterface;
}
-2
View File
@@ -114,7 +114,6 @@ final class UuidV2 extends Uuid implements UuidInterface
*/
public function getLocalDomain(): int
{
/** @var Rfc4122FieldsInterface $fields */
$fields = $this->getFields();
return (int) hexdec($fields->getClockSeqLow()->toString());
@@ -133,7 +132,6 @@ final class UuidV2 extends Uuid implements UuidInterface
*/
public function getLocalIdentifier(): IntegerObject
{
/** @var Rfc4122FieldsInterface $fields */
$fields = $this->getFields();
return new IntegerObject(
+3 -3
View File
@@ -18,9 +18,9 @@ use DateTimeInterface;
use Ramsey\Uuid\Codec\CodecInterface;
use Ramsey\Uuid\Converter\NumberConverterInterface;
use Ramsey\Uuid\Converter\TimeConverterInterface;
use Ramsey\Uuid\Fields\FieldsInterface;
use Ramsey\Uuid\Lazy\LazyUuidFromString;
use Ramsey\Uuid\Rfc4122\FieldsInterface as Rfc4122FieldsInterface;
use Ramsey\Uuid\Rfc4122\UuidInterface as Rfc4122UuidInterface;
use Ramsey\Uuid\Type\Hexadecimal;
use Ramsey\Uuid\Type\Integer as IntegerObject;
use ValueError;
@@ -40,7 +40,7 @@ use function substr;
*
* @psalm-immutable
*/
class Uuid implements UuidInterface
class Uuid implements Rfc4122UuidInterface
{
use DeprecatedUuidMethodsTrait;
@@ -369,7 +369,7 @@ class Uuid implements UuidInterface
return $this->codec->encodeBinary($this);
}
public function getFields(): FieldsInterface
public function getFields(): Rfc4122FieldsInterface
{
return $this->fields;
}
+17 -13
View File
@@ -8,6 +8,7 @@ use Ramsey\Uuid\Converter\TimeConverterInterface;
use Ramsey\Uuid\Generator\CombGenerator;
use Ramsey\Uuid\Generator\DefaultTimeGenerator;
use Ramsey\Uuid\Math\BrickMathCalculator;
use Ramsey\Uuid\Rfc4122\UuidInterface;
use Ramsey\Uuid\Type\Hexadecimal;
use Ramsey\Uuid\Type\Time;
use Ramsey\Uuid\Uuid;
@@ -33,9 +34,9 @@ class ExpectedBehaviorTest extends TestCase
*/
public function testStaticCreationMethodsAndStandardBehavior($method, $args)
{
/** @var UuidInterface $uuid */
$uuid = call_user_func_array(['Ramsey\Uuid\Uuid', $method], $args);
$this->assertInstanceOf('Ramsey\Uuid\UuidInterface', $uuid);
$this->assertIsInt($uuid->compareTo(Uuid::uuid1()));
$this->assertNotSame(0, $uuid->compareTo(Uuid::uuid4()));
$this->assertSame(0, $uuid->compareTo(clone $uuid));
@@ -54,13 +55,13 @@ class ExpectedBehaviorTest extends TestCase
$this->assertIsString($uuid->getTimeLowHex());
$this->assertIsString($uuid->getTimeMidHex());
$this->assertIsString($uuid->getTimeHiAndVersionHex());
$this->assertIsString($uuid->getClockSeqHiAndReservedHex());
$this->assertIsString($uuid->getFields()->getClockSeqHiAndReserved()->toString());
$this->assertIsString($uuid->getClockSeqLowHex());
$this->assertIsString($uuid->getNodeHex());
$this->assertSame($uuid->getFieldsHex()['time_low'], $uuid->getTimeLowHex());
$this->assertSame($uuid->getFieldsHex()['time_mid'], $uuid->getTimeMidHex());
$this->assertSame($uuid->getFieldsHex()['time_hi_and_version'], $uuid->getTimeHiAndVersionHex());
$this->assertSame($uuid->getFieldsHex()['clock_seq_hi_and_reserved'], $uuid->getClockSeqHiAndReservedHex());
$this->assertSame($uuid->getFieldsHex()['clock_seq_hi_and_reserved'], $uuid->getFields()->getClockSeqHiAndReserved()->toString());
$this->assertSame($uuid->getFieldsHex()['clock_seq_low'], $uuid->getClockSeqLowHex());
$this->assertSame($uuid->getFieldsHex()['node'], $uuid->getNodeHex());
$this->assertSame(substr((string) $uuid->getHex(), 16), $uuid->getLeastSignificantBitsHex());
@@ -71,7 +72,7 @@ class ExpectedBehaviorTest extends TestCase
$uuid->getTimeLowHex()
. $uuid->getTimeMidHex()
. $uuid->getTimeHiAndVersionHex()
. $uuid->getClockSeqHiAndReservedHex()
. $uuid->getFields()->getClockSeqHiAndReserved()->toString()
. $uuid->getClockSeqLowHex()
. $uuid->getNodeHex()
);
@@ -97,7 +98,7 @@ class ExpectedBehaviorTest extends TestCase
$uuid->getTimeLowHex() . '-'
. $uuid->getTimeMidHex() . '-'
. $uuid->getTimeHiAndVersionHex() . '-'
. $uuid->getClockSeqHiAndReservedHex()
. $uuid->getFields()->getClockSeqHiAndReserved()->toString()
. $uuid->getClockSeqLowHex() . '-'
. $uuid->getNodeHex()
);
@@ -107,7 +108,7 @@ class ExpectedBehaviorTest extends TestCase
$uuid->getTimeLowHex() . '-'
. $uuid->getTimeMidHex() . '-'
. $uuid->getTimeHiAndVersionHex() . '-'
. $uuid->getClockSeqHiAndReservedHex()
. $uuid->getFields()->getClockSeqHiAndReserved()->toString()
. $uuid->getClockSeqLowHex() . '-'
. $uuid->getNodeHex()
);
@@ -237,11 +238,12 @@ class ExpectedBehaviorTest extends TestCase
/**
* @dataProvider provideFromStringInteger
*/
public function testFromBytes($string, $version, $variant, $integer)
public function testFromBytes(string $string, ?int $version, int $variant, string $integer): void
{
$bytes = hex2bin(str_replace('-', '', $string));
$uuid = Uuid::fromBytes($bytes);
/** @var UuidInterface $uuid */
$uuid = Uuid::fromBytes((string) $bytes);
$this->assertInstanceOf('Ramsey\Uuid\UuidInterface', $uuid);
$this->assertSame($string, $uuid->toString());
@@ -253,7 +255,7 @@ class ExpectedBehaviorTest extends TestCase
$this->assertSame($components[0], $uuid->getTimeLowHex());
$this->assertSame($components[1], $uuid->getTimeMidHex());
$this->assertSame($components[2], $uuid->getTimeHiAndVersionHex());
$this->assertSame($components[3], $uuid->getClockSeqHiAndReservedHex() . $uuid->getClockSeqLowHex());
$this->assertSame($components[3], $uuid->getFields()->getClockSeqHiAndReserved()->toString() . $uuid->getClockSeqLowHex());
$this->assertSame($components[4], $uuid->getNodeHex());
$this->assertSame($integer, (string) $uuid->getInteger());
$this->assertSame($bytes, $uuid->getBytes());
@@ -262,10 +264,11 @@ class ExpectedBehaviorTest extends TestCase
/**
* @dataProvider provideFromStringInteger
*/
public function testFromInteger($string, $version, $variant, $integer)
public function testFromInteger(string $string, ?int $version, int $variant, string $integer): void
{
$bytes = hex2bin(str_replace('-', '', $string));
/** @var UuidInterface $uuid */
$uuid = Uuid::fromInteger($integer);
$this->assertInstanceOf('Ramsey\Uuid\UuidInterface', $uuid);
@@ -278,7 +281,7 @@ class ExpectedBehaviorTest extends TestCase
$this->assertSame($components[0], $uuid->getTimeLowHex());
$this->assertSame($components[1], $uuid->getTimeMidHex());
$this->assertSame($components[2], $uuid->getTimeHiAndVersionHex());
$this->assertSame($components[3], $uuid->getClockSeqHiAndReservedHex() . $uuid->getClockSeqLowHex());
$this->assertSame($components[3], $uuid->getFields()->getClockSeqHiAndReserved()->toString() . $uuid->getClockSeqLowHex());
$this->assertSame($components[4], $uuid->getNodeHex());
$this->assertSame($integer, (string) $uuid->getInteger());
$this->assertSame($bytes, $uuid->getBytes());
@@ -287,10 +290,11 @@ class ExpectedBehaviorTest extends TestCase
/**
* @dataProvider provideFromStringInteger
*/
public function testFromString($string, $version, $variant, $integer)
public function testFromString(string $string, ?int $version, int $variant, string $integer): void
{
$bytes = hex2bin(str_replace('-', '', $string));
/** @var UuidInterface $uuid */
$uuid = Uuid::fromString($string);
$this->assertInstanceOf('Ramsey\Uuid\UuidInterface', $uuid);
@@ -303,7 +307,7 @@ class ExpectedBehaviorTest extends TestCase
$this->assertSame($components[0], $uuid->getTimeLowHex());
$this->assertSame($components[1], $uuid->getTimeMidHex());
$this->assertSame($components[2], $uuid->getTimeHiAndVersionHex());
$this->assertSame($components[3], $uuid->getClockSeqHiAndReservedHex() . $uuid->getClockSeqLowHex());
$this->assertSame($components[3], $uuid->getFields()->getClockSeqHiAndReserved()->toString() . $uuid->getClockSeqLowHex());
$this->assertSame($components[4], $uuid->getNodeHex());
$this->assertSame($integer, (string) $uuid->getInteger());
$this->assertSame($bytes, $uuid->getBytes());
+8 -5
View File
@@ -153,9 +153,9 @@ class UuidTest extends TestCase
public function testGetClockSeqHiAndReservedHex(): void
{
/** @var Uuid $uuid */
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
$uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
$this->assertSame('9b', $uuid->getClockSeqHiAndReservedHex());
$this->assertSame('9b', $uuid->getFields()->getClockSeqHiAndReserved()->toString());
}
public function testGetClockSeqLow(): void
@@ -1203,7 +1203,7 @@ class UuidTest extends TestCase
Uuid::fromInteger($int),
];
/** @var UuidInterface $uuid */
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
foreach ($uuids as $uuid) {
$this->assertSame($string, $uuid->toString());
$this->assertSame($hex, $uuid->getHex()->toString());
@@ -1213,7 +1213,10 @@ class UuidTest extends TestCase
$this->assertSame($fields['time_low'], $uuid->getTimeLowHex());
$this->assertSame($fields['time_mid'], $uuid->getTimeMidHex());
$this->assertSame($fields['time_hi_and_version'], $uuid->getTimeHiAndVersionHex());
$this->assertSame($fields['clock_seq_hi_and_reserved'], $uuid->getClockSeqHiAndReservedHex());
$this->assertSame(
$fields['clock_seq_hi_and_reserved'],
$uuid->getFields()->getClockSeqHiAndReserved()->toString(),
);
$this->assertSame($fields['clock_seq_low'], $uuid->getClockSeqLowHex());
$this->assertSame($fields['node'], $uuid->getNodeHex());
$this->assertSame($urn, $uuid->getUrn());
@@ -1520,7 +1523,7 @@ class UuidTest extends TestCase
}
/**
* @covers Ramsey\Uuid\Uuid::jsonSerialize
* @covers \Ramsey\Uuid\Uuid::jsonSerialize
*/
public function testJsonSerialize(): void
{
+2 -2
View File
@@ -54,7 +54,6 @@ final class UuidIsImmutable
$a->getNumberConverter(),
$a->getHex(),
$a->getFieldsHex(),
$a->getClockSeqHiAndReservedHex(),
$a->getClockSeqLowHex(),
$a->getClockSequenceHex(),
$a->getDateTime(),
@@ -71,11 +70,12 @@ final class UuidIsImmutable
$a->getVersion(),
$a->toString(),
$a->__toString(),
$a->getFields(),
];
}
/**
* @return UuidInterface[]|bool[]
* @return array{UuidInterface, UuidInterface, bool}
*
* @psalm-pure
*/