mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-14 15:56:48 +03:00
Re-add the @pure annotations
These were removed in 691c2c816e but
should remain in the code base.
This commit is contained in:
@@ -27,6 +27,8 @@ class BinaryUtils
|
||||
* @param int $clockSeq The 16-bit clock sequence value before the variant is applied
|
||||
*
|
||||
* @return int The 16-bit clock sequence multiplexed with the UUID variant
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public static function applyVariant(int $clockSeq): int
|
||||
{
|
||||
@@ -42,6 +44,8 @@ class BinaryUtils
|
||||
* @param int $version The version to apply to the `time_hi` field
|
||||
*
|
||||
* @return int The 16-bit time_hi field of the timestamp multiplexed with the UUID version number
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public static function applyVersion(int $timeHi, int $version): int
|
||||
{
|
||||
|
||||
@@ -50,6 +50,8 @@ class DegradedUuidBuilder implements UuidBuilderInterface
|
||||
* @param string $bytes The byte string from which to construct a UUID
|
||||
*
|
||||
* @return DegradedUuid The DegradedUuidBuild returns an instance of Ramsey\Uuid\DegradedUuid
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public function build(CodecInterface $codec, string $bytes): UuidInterface
|
||||
{
|
||||
|
||||
@@ -40,6 +40,8 @@ class FallbackBuilder implements UuidBuilderInterface
|
||||
* @param string $bytes The byte string from which to construct a UUID
|
||||
*
|
||||
* @return UuidInterface an instance of a UUID object
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public function build(CodecInterface $codec, string $bytes): UuidInterface
|
||||
{
|
||||
|
||||
@@ -31,6 +31,8 @@ interface UuidBuilderInterface
|
||||
* @param string $bytes The byte string from which to construct a UUID
|
||||
*
|
||||
* @return UuidInterface Implementations may choose to return more specific instances of UUIDs that implement UuidInterface
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public function build(CodecInterface $codec, string $bytes): UuidInterface;
|
||||
}
|
||||
|
||||
@@ -34,11 +34,17 @@ class BigNumberConverter implements NumberConverterInterface
|
||||
$this->converter = new GenericNumberConverter(new BrickMathCalculator());
|
||||
}
|
||||
|
||||
/**
|
||||
* @pure
|
||||
*/
|
||||
public function fromHex(string $hex): string
|
||||
{
|
||||
return $this->converter->fromHex($hex);
|
||||
}
|
||||
|
||||
/**
|
||||
* @pure
|
||||
*/
|
||||
public function toHex(string $number): string
|
||||
{
|
||||
return $this->converter->toHex($number);
|
||||
|
||||
@@ -29,14 +29,19 @@ class GenericNumberConverter implements NumberConverterInterface
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @pure
|
||||
*/
|
||||
public function fromHex(string $hex): string
|
||||
{
|
||||
return $this->calculator->fromBase($hex, 16)->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @pure
|
||||
*/
|
||||
public function toHex(string $number): string
|
||||
{
|
||||
/** @phpstan-ignore-next-line PHPStan complains that this is not a non-empty-string. */
|
||||
return $this->calculator->toBase(new IntegerObject($number), 16);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ interface NumberConverterInterface
|
||||
* @param string $hex The hexadecimal string representation to convert
|
||||
*
|
||||
* @return numeric-string String representation of an integer
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public function fromHex(string $hex): string;
|
||||
|
||||
@@ -40,6 +42,8 @@ interface NumberConverterInterface
|
||||
* unsigned integers that are greater than `PHP_INT_MAX`.
|
||||
*
|
||||
* @return non-empty-string Hexadecimal string
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public function toHex(string $number): string;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@ interface TimeConverterInterface
|
||||
* @param string $microseconds A string representation of the micro-seconds associated with the time to calculate
|
||||
*
|
||||
* @return Hexadecimal The full UUID timestamp as a Hexadecimal value
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public function calculateTime(string $seconds, string $microseconds): Hexadecimal;
|
||||
|
||||
@@ -44,6 +46,8 @@ interface TimeConverterInterface
|
||||
* of 100-nanosecond intervals since UTC 00:00:00.00, 15 October 1582.
|
||||
*
|
||||
* @return Time An instance of {@see Time}
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public function convertTime(Hexadecimal $uuidTimestamp): Time;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,9 @@ use function hash;
|
||||
*/
|
||||
class DefaultNameGenerator implements NameGeneratorInterface
|
||||
{
|
||||
/**
|
||||
* @pure
|
||||
*/
|
||||
public function generate(UuidInterface $ns, string $name, string $hashAlgorithm): string
|
||||
{
|
||||
try {
|
||||
|
||||
@@ -30,6 +30,8 @@ interface NameGeneratorInterface
|
||||
* @param string $hashAlgorithm The hashing algorithm to use
|
||||
*
|
||||
* @return string A binary string
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public function generate(UuidInterface $ns, string $name, string $hashAlgorithm): string;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@ use function uuid_parse;
|
||||
*/
|
||||
class PeclUuidNameGenerator implements NameGeneratorInterface
|
||||
{
|
||||
/**
|
||||
* @pure
|
||||
*/
|
||||
public function generate(UuidInterface $ns, string $name, string $hashAlgorithm): string
|
||||
{
|
||||
$uuid = match ($hashAlgorithm) {
|
||||
|
||||
@@ -49,6 +49,8 @@ class GuidBuilder implements UuidBuilderInterface
|
||||
* @param string $bytes The byte string from which to construct a UUID
|
||||
*
|
||||
* @return Guid The GuidBuilder returns an instance of Ramsey\Uuid\Guid\Guid
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public function build(CodecInterface $codec, string $bytes): UuidInterface
|
||||
{
|
||||
|
||||
@@ -61,6 +61,9 @@ final class LazyUuidFromString implements UuidInterface
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @pure
|
||||
*/
|
||||
public static function fromBytes(string $bytes): self
|
||||
{
|
||||
$base16Uuid = bin2hex($bytes);
|
||||
|
||||
@@ -47,6 +47,8 @@ class UuidBuilder implements UuidBuilderInterface
|
||||
* @param string $bytes The byte string from which to construct a UUID
|
||||
*
|
||||
* @return Uuid The Nonstandard\UuidBuilder returns an instance of Nonstandard\Uuid
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public function build(CodecInterface $codec, string $bytes): UuidInterface
|
||||
{
|
||||
|
||||
@@ -60,6 +60,8 @@ class UuidBuilder implements UuidBuilderInterface
|
||||
* @param string $bytes The byte string from which to construct a UUID
|
||||
*
|
||||
* @return Rfc4122UuidInterface UuidBuilder returns instances of Rfc4122UuidInterface
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public function build(CodecInterface $codec, string $bytes): UuidInterface
|
||||
{
|
||||
|
||||
@@ -448,6 +448,8 @@ class Uuid implements UuidInterface
|
||||
* @return UuidInterface A UuidInterface instance created from a binary string representation
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public static function fromBytes(string $bytes): UuidInterface
|
||||
{
|
||||
@@ -479,6 +481,8 @@ class Uuid implements UuidInterface
|
||||
* @return UuidInterface A UuidInterface instance created from a hexadecimal string representation
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public static function fromString(string $uuid): UuidInterface
|
||||
{
|
||||
@@ -518,6 +522,8 @@ class Uuid implements UuidInterface
|
||||
* @return UuidInterface A UuidInterface instance created from the Hexadecimal object representing a hexadecimal number
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public static function fromHexadecimal(Hexadecimal $hex): UuidInterface
|
||||
{
|
||||
@@ -541,6 +547,8 @@ class Uuid implements UuidInterface
|
||||
* @return UuidInterface A UuidInterface instance created from the string representation of a 128-bit integer
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public static function fromInteger(string $integer): UuidInterface
|
||||
{
|
||||
@@ -555,6 +563,8 @@ class Uuid implements UuidInterface
|
||||
* @return bool True if the string is a valid UUID, false otherwise
|
||||
*
|
||||
* @phpstan-assert-if-true =non-empty-string $uuid
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public static function isValid(string $uuid): bool
|
||||
{
|
||||
@@ -606,6 +616,8 @@ class Uuid implements UuidInterface
|
||||
* @param string $name The name to use for creating a UUID
|
||||
*
|
||||
* @return UuidInterface A UuidInterface instance that represents a version 3 UUID
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public static function uuid3($ns, string $name): UuidInterface
|
||||
{
|
||||
@@ -629,6 +641,8 @@ class Uuid implements UuidInterface
|
||||
* @param string $name The name to use for creating a UUID
|
||||
*
|
||||
* @return UuidInterface A UuidInterface instance that represents a version 5 UUID
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public static function uuid5($ns, string $name): UuidInterface
|
||||
{
|
||||
@@ -682,6 +696,8 @@ class Uuid implements UuidInterface
|
||||
* and 65 will be replaced with the UUID variant. You MUST NOT rely on these bits for your application needs.
|
||||
*
|
||||
* @return UuidInterface A UuidInterface instance that represents a version 8 UUID
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public static function uuid8(string $bytes): UuidInterface
|
||||
{
|
||||
|
||||
@@ -252,11 +252,17 @@ class UuidFactory implements UuidFactoryInterface
|
||||
$this->validator = $validator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @pure
|
||||
*/
|
||||
public function fromBytes(string $bytes): UuidInterface
|
||||
{
|
||||
return $this->codec->decodeBytes($bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @pure
|
||||
*/
|
||||
public function fromString(string $uuid): UuidInterface
|
||||
{
|
||||
$uuid = strtolower($uuid);
|
||||
@@ -264,6 +270,9 @@ class UuidFactory implements UuidFactoryInterface
|
||||
return $this->codec->decode($uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @pure
|
||||
*/
|
||||
public function fromInteger(string $integer): UuidInterface
|
||||
{
|
||||
$hex = $this->numberConverter->toHex($integer);
|
||||
@@ -284,6 +293,9 @@ class UuidFactory implements UuidFactoryInterface
|
||||
return $this->uuidFromBytesAndVersion($bytes, Uuid::UUID_TYPE_TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @pure
|
||||
*/
|
||||
public function fromHexadecimal(Hexadecimal $hex): UuidInterface
|
||||
{
|
||||
return $this->codec->decode($hex->__toString());
|
||||
@@ -312,6 +324,7 @@ class UuidFactory implements UuidFactoryInterface
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @pure
|
||||
*/
|
||||
public function uuid3($ns, string $name): UuidInterface
|
||||
{
|
||||
@@ -327,6 +340,7 @@ class UuidFactory implements UuidFactoryInterface
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @pure
|
||||
*/
|
||||
public function uuid5($ns, string $name): UuidInterface
|
||||
{
|
||||
@@ -377,6 +391,8 @@ class UuidFactory implements UuidFactoryInterface
|
||||
* and 65 will be replaced with the UUID variant. You MUST NOT rely on these bits for your application needs.
|
||||
*
|
||||
* @return UuidInterface A UuidInterface instance that represents a version 8 UUID
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public function uuid8(string $bytes): UuidInterface
|
||||
{
|
||||
@@ -391,6 +407,8 @@ class UuidFactory implements UuidFactoryInterface
|
||||
* @param string $bytes The byte string from which to construct a UUID
|
||||
*
|
||||
* @return UuidInterface An instance of UuidInterface, created from the provided bytes
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public function uuid(string $bytes): UuidInterface
|
||||
{
|
||||
@@ -406,6 +424,8 @@ class UuidFactory implements UuidFactoryInterface
|
||||
* @param string $hashAlgorithm The hashing algorithm to use when hashing together the namespace and name
|
||||
*
|
||||
* @return UuidInterface An instance of UuidInterface, created by hashing together the provided namespace and name
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
private function uuidFromNsAndName(
|
||||
UuidInterface | string $ns,
|
||||
|
||||
@@ -30,6 +30,8 @@ interface UuidFactoryInterface
|
||||
* @param string $bytes A binary string
|
||||
*
|
||||
* @return UuidInterface A UuidInterface instance created from a binary string representation
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public function fromBytes(string $bytes): UuidInterface;
|
||||
|
||||
@@ -55,6 +57,8 @@ interface UuidFactoryInterface
|
||||
* @param string $integer String representation of 128-bit integer
|
||||
*
|
||||
* @return UuidInterface A UuidInterface instance created from the string representation of a 128-bit integer
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public function fromInteger(string $integer): UuidInterface;
|
||||
|
||||
@@ -64,6 +68,8 @@ interface UuidFactoryInterface
|
||||
* @param string $uuid A hexadecimal string
|
||||
*
|
||||
* @return UuidInterface A UuidInterface instance created from a hexadecimal string representation
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public function fromString(string $uuid): UuidInterface;
|
||||
|
||||
@@ -112,6 +118,8 @@ interface UuidFactoryInterface
|
||||
* @param string $name The name to use for creating a UUID
|
||||
*
|
||||
* @return UuidInterface A UuidInterface instance that represents a version 3 UUID
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public function uuid3($ns, string $name): UuidInterface;
|
||||
|
||||
@@ -129,6 +137,8 @@ interface UuidFactoryInterface
|
||||
* @param string $name The name to use for creating a UUID
|
||||
*
|
||||
* @return UuidInterface A UuidInterface instance that represents a version 5 UUID
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
public function uuid5($ns, string $name): UuidInterface;
|
||||
|
||||
|
||||
@@ -62,6 +62,8 @@ function v2(
|
||||
* @param UuidInterface | string $ns The namespace (must be a valid UUID)
|
||||
*
|
||||
* @return non-empty-string Version 3 UUID as a string
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
function v3($ns, string $name): string
|
||||
{
|
||||
@@ -84,6 +86,8 @@ function v4(): string
|
||||
* @param UuidInterface | string $ns The namespace (must be a valid UUID)
|
||||
*
|
||||
* @return non-empty-string Version 5 UUID as a string
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
function v5($ns, string $name): string
|
||||
{
|
||||
@@ -128,6 +132,8 @@ function v7(?DateTimeInterface $dateTime = null): string
|
||||
* 65 will be replaced with the UUID variant. You MUST NOT rely on these bits for your application needs.
|
||||
*
|
||||
* @return non-empty-string Version 8 UUID as a string
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
function v8(string $bytes): string
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user