diff --git a/src/DeprecatedUuidFactoryInterface.php b/src/DeprecatedUuidFactoryInterface.php deleted file mode 100644 index 2ea38f8..0000000 --- a/src/DeprecatedUuidFactoryInterface.php +++ /dev/null @@ -1,180 +0,0 @@ - - * @license http://opensource.org/licenses/MIT MIT - */ - -declare(strict_types=1); - -namespace Ramsey\Uuid; - -use DateTimeInterface; -use Ramsey\Uuid\Type\Hexadecimal; -use Ramsey\Uuid\Type\Integer as IntegerObject; -use Ramsey\Uuid\Validator\ValidatorInterface; - -/** - * This interface encapsulates deprecated methods for ramsey/uuid; this - * interface and its methods will be removed in ramsey/uuid 5.0.0. - * - * @deprecated This interface and its methods will be removed in ramsey/uuid 5.0.0. - */ -interface DeprecatedUuidFactoryInterface -{ - /** - * Creates a UUID from a DateTimeInterface instance - * - * @deprecated In ramsey/uuid version 5, UUID factories will no longer have - * dedicated methods for creating datetime-based UUIDs. Use a dedicated - * factory to generate UUIDs from a DateTime instance. - * - * @param DateTimeInterface $dateTime The date and time - * @param Hexadecimal|null $node A 48-bit number representing the hardware - * address - * @param int|null $clockSeq A 14-bit number used to help avoid duplicates - * that could arise when the clock is set backwards in time or if the - * node ID changes - * - * @return UuidInterface A UuidInterface instance that represents a - * version 1 UUID created from a DateTimeInterface instance - */ - public function fromDateTime( - DateTimeInterface $dateTime, - ?Hexadecimal $node = null, - ?int $clockSeq = null - ): UuidInterface; - - /** - * Returns the validator to use for the factory - * - * @deprecated In ramsey/uuid version 5, UUID factories will no longer have - * dedicated methods for getting validators. Use a dedicated validator - * class to validate UUIDs. - * - * @psalm-mutation-free - */ - public function getValidator(): ValidatorInterface; - - /** - * Returns a version 1 (time-based) UUID from a host ID, sequence number, - * and the current time - * - * @deprecated In ramsey/uuid version 5, UUID factories will no longer have - * methods specific to creating subtypes. Instead, version 5 will use - * dedicated factories for each subtype. - * - * @param Hexadecimal|int|string|null $node A 48-bit number representing the - * hardware address; this number may be represented as an integer or a - * hexadecimal string - * @param int|null $clockSeq A 14-bit number used to help avoid duplicates - * that could arise when the clock is set backwards in time or if the - * node ID changes - * - * @return UuidInterface A UuidInterface instance that represents a - * version 1 UUID - */ - public function uuid1($node = null, ?int $clockSeq = null): UuidInterface; - - /** - * Returns a version 2 (DCE Security) UUID from a local domain, local - * identifier, host ID, clock sequence, and the current time - * - * @deprecated In ramsey/uuid version 5, UUID factories will no longer have - * methods specific to creating subtypes. Instead, version 5 will use - * dedicated factories for each subtype. - * - * @param int $localDomain The local domain to use when generating bytes, - * according to DCE Security - * @param IntegerObject|null $localIdentifier The local identifier for the - * given domain; this may be a UID or GID on POSIX systems, if the local - * domain is person or group, or it may be a site-defined identifier - * if the local domain is org - * @param Hexadecimal|null $node A 48-bit number representing the hardware - * address - * @param int|null $clockSeq A 14-bit number used to help avoid duplicates - * that could arise when the clock is set backwards in time or if the - * node ID changes - * - * @return UuidInterface A UuidInterface instance that represents a - * version 2 UUID - */ - public function uuid2( - int $localDomain, - ?IntegerObject $localIdentifier = null, - ?Hexadecimal $node = null, - ?int $clockSeq = null - ): UuidInterface; - - /** - * Returns a version 3 (name-based) UUID based on the MD5 hash of a - * namespace ID and a name - * - * @deprecated In ramsey/uuid version 5, UUID factories will no longer have - * methods specific to creating subtypes. Instead, version 5 will use - * dedicated factories for each subtype. - * - * @param string|UuidInterface $ns The namespace (must be a valid UUID) - * @param string $name The name to use for creating a UUID - * - * @return UuidInterface A UuidInterface instance that represents a - * version 3 UUID - * - * @psalm-pure - */ - public function uuid3($ns, string $name): UuidInterface; - - /** - * Returns a version 4 (random) UUID - * - * @deprecated In ramsey/uuid version 5, UUID factories will no longer have - * methods specific to creating subtypes. Instead, version 5 will use - * dedicated factories for each subtype. - * - * @return UuidInterface A UuidInterface instance that represents a - * version 4 UUID - */ - public function uuid4(): UuidInterface; - - /** - * Returns a version 5 (name-based) UUID based on the SHA-1 hash of a - * namespace ID and a name - * - * @deprecated In ramsey/uuid version 5, UUID factories will no longer have - * methods specific to creating subtypes. Instead, version 5 will use - * dedicated factories for each subtype. - * - * @param string|UuidInterface $ns The namespace (must be a valid UUID) - * @param string $name The name to use for creating a UUID - * - * @return UuidInterface A UuidInterface instance that represents a - * version 5 UUID - * - * @psalm-pure - */ - public function uuid5($ns, string $name): UuidInterface; - - /** - * Returns a version 6 (ordered-time) UUID from a host ID, sequence number, - * and the current time - * - * @deprecated In ramsey/uuid version 5, UUID factories will no longer have - * methods specific to creating subtypes. Instead, version 5 will use - * dedicated factories for each subtype. - * - * @param Hexadecimal|null $node A 48-bit number representing the hardware - * address - * @param int|null $clockSeq A 14-bit number used to help avoid duplicates - * that could arise when the clock is set backwards in time or if the - * node ID changes - * - * @return UuidInterface A UuidInterface instance that represents a - * version 6 UUID - */ - public function uuid6(?Hexadecimal $node = null, ?int $clockSeq = null): UuidInterface; -} diff --git a/src/DeprecatedUuidInterface.php b/src/DeprecatedUuidInterface.php index 017d16d..ac01a79 100644 --- a/src/DeprecatedUuidInterface.php +++ b/src/DeprecatedUuidInterface.php @@ -18,10 +18,7 @@ use DateTimeInterface; use Ramsey\Uuid\Converter\NumberConverterInterface; /** - * This interface encapsulates deprecated methods for ramsey/uuid; this - * interface and its methods will be removed in ramsey/uuid 5.0.0. - * - * @deprecated This interface and its methods will be removed in ramsey/uuid 5.0.0. + * This interface encapsulates deprecated methods for ramsey/uuid * * @psalm-immutable */ diff --git a/src/FeatureSet.php b/src/FeatureSet.php index 0a71436..819f99a 100644 --- a/src/FeatureSet.php +++ b/src/FeatureSet.php @@ -58,8 +58,6 @@ use const PHP_INT_SIZE; * * A feature set is used by UuidFactory to determine the available features and * capabilities of the environment. - * - * @deprecated This class will go away in ramsey/uuid version 5. */ class FeatureSet { diff --git a/src/Uuid.php b/src/Uuid.php index 7d0317f..019cec8 100644 --- a/src/Uuid.php +++ b/src/Uuid.php @@ -85,9 +85,6 @@ class Uuid implements UuidInterface /** * Variant: reserved, NCS backward compatibility * - * @deprecated The Ramsey\Uuid\Variant enum will replace this constant in - * ramsey/uuid version 5. - * * @link http://tools.ietf.org/html/rfc4122#section-4.1.1 RFC 4122, § 4.1.1: Variant */ public const RESERVED_NCS = 0; @@ -95,9 +92,6 @@ class Uuid implements UuidInterface /** * Variant: the UUID layout specified in RFC 4122 * - * @deprecated The Ramsey\Uuid\Variant enum will replace this constant in - * ramsey/uuid version 5. - * * @link http://tools.ietf.org/html/rfc4122#section-4.1.1 RFC 4122, § 4.1.1: Variant */ public const RFC_4122 = 2; @@ -105,9 +99,6 @@ class Uuid implements UuidInterface /** * Variant: reserved, Microsoft Corporation backward compatibility * - * @deprecated The Ramsey\Uuid\Variant enum will replace this constant in - * ramsey/uuid version 5. - * * @link http://tools.ietf.org/html/rfc4122#section-4.1.1 RFC 4122, § 4.1.1: Variant */ public const RESERVED_MICROSOFT = 6; @@ -115,9 +106,6 @@ class Uuid implements UuidInterface /** * Variant: reserved for future definition * - * @deprecated The Ramsey\Uuid\Variant enum will replace this constant in - * ramsey/uuid version 5. - * * @link http://tools.ietf.org/html/rfc4122#section-4.1.1 RFC 4122, § 4.1.1: Variant */ public const RESERVED_FUTURE = 7; @@ -130,9 +118,6 @@ class Uuid implements UuidInterface /** * Version 1 (time-based) UUID * - * @deprecated The Ramsey\Uuid\Version enum will replace this constant in - * ramsey/uuid version 5. - * * @link https://tools.ietf.org/html/rfc4122#section-4.1.3 RFC 4122, § 4.1.3: Version */ public const UUID_TYPE_TIME = 1; @@ -140,9 +125,6 @@ class Uuid implements UuidInterface /** * Version 2 (DCE Security) UUID * - * @deprecated The Ramsey\Uuid\Version enum will replace this constant in - * ramsey/uuid version 5. - * * @link https://tools.ietf.org/html/rfc4122#section-4.1.3 RFC 4122, § 4.1.3: Version */ public const UUID_TYPE_DCE_SECURITY = 2; @@ -155,9 +137,6 @@ class Uuid implements UuidInterface /** * Version 3 (name-based and hashed with MD5) UUID * - * @deprecated The Ramsey\Uuid\Version enum will replace this constant in - * ramsey/uuid version 5. - * * @link https://tools.ietf.org/html/rfc4122#section-4.1.3 RFC 4122, § 4.1.3: Version */ public const UUID_TYPE_HASH_MD5 = 3; @@ -165,9 +144,6 @@ class Uuid implements UuidInterface /** * Version 4 (random) UUID * - * @deprecated The Ramsey\Uuid\Version enum will replace this constant in - * ramsey/uuid version 5. - * * @link https://tools.ietf.org/html/rfc4122#section-4.1.3 RFC 4122, § 4.1.3: Version */ public const UUID_TYPE_RANDOM = 4; @@ -175,9 +151,6 @@ class Uuid implements UuidInterface /** * Version 5 (name-based and hashed with SHA1) UUID * - * @deprecated The Ramsey\Uuid\Version enum will replace this constant in - * ramsey/uuid version 5. - * * @link https://tools.ietf.org/html/rfc4122#section-4.1.3 RFC 4122, § 4.1.3: Version */ public const UUID_TYPE_HASH_SHA1 = 5; @@ -277,10 +250,6 @@ class Uuid implements UuidInterface * $namespaceSha1Uuid = Uuid::uuid5(Uuid::NAMESPACE_URL, 'http://php.net/'); * ``` * - * @deprecated ramsey/uuid version 5 will no longer allow direct - * instantiation of the base Ramsey\Uuid\Uuid class. Instead, you must - * use factories to create UUID objects. - * * @param Rfc4122FieldsInterface $fields The fields from which to construct a UUID * @param NumberConverterInterface $numberConverter The number converter to use * for converting hex values to/from integers @@ -433,9 +402,6 @@ class Uuid implements UuidInterface /** * Returns the factory used to create UUIDs - * - * @deprecated ramsey/uuid version 5 will no longer support getting a - * factory instance from the base Ramsey\Uuid\Uuid class. */ public static function getFactory(): UuidFactoryInterface { @@ -449,11 +415,6 @@ class Uuid implements UuidInterface /** * Sets the factory used to create UUIDs * - * @deprecated ramsey/uuid version 5 will no longer support setting a - * factory instance on the base Ramsey\Uuid\Uuid class. If you need to - * customize the properties used to build a UUID, use one of the - * dedicated factories that version 5 will introduce. - * * @param UuidFactoryInterface $factory A factory that will be used by this * class to create UUIDs */ diff --git a/src/UuidFactory.php b/src/UuidFactory.php index 67ed8ee..6f2cea0 100644 --- a/src/UuidFactory.php +++ b/src/UuidFactory.php @@ -43,10 +43,6 @@ use function unpack; use const STR_PAD_LEFT; -/** - * @deprecated UuidFactory will go away in ramsey/uuid version 5. Use dedicated - * factories for subtypes instead. - */ class UuidFactory implements UuidFactoryInterface { /** diff --git a/src/UuidFactoryInterface.php b/src/UuidFactoryInterface.php index e2a1236..bc0e615 100644 --- a/src/UuidFactoryInterface.php +++ b/src/UuidFactoryInterface.php @@ -14,11 +14,16 @@ declare(strict_types=1); namespace Ramsey\Uuid; +use DateTimeInterface; +use Ramsey\Uuid\Type\Hexadecimal; +use Ramsey\Uuid\Type\Integer as IntegerObject; +use Ramsey\Uuid\Validator\ValidatorInterface; + /** * UuidFactoryInterface defines common functionality all `UuidFactory` instances * must implement */ -interface UuidFactoryInterface extends DeprecatedUuidFactoryInterface +interface UuidFactoryInterface { /** * Creates a UUID from a byte string @@ -32,6 +37,25 @@ interface UuidFactoryInterface extends DeprecatedUuidFactoryInterface */ public function fromBytes(string $bytes): UuidInterface; + /** + * Creates a UUID from a DateTimeInterface instance + * + * @param DateTimeInterface $dateTime The date and time + * @param Hexadecimal|null $node A 48-bit number representing the hardware + * address + * @param int|null $clockSeq A 14-bit number used to help avoid duplicates + * that could arise when the clock is set backwards in time or if the + * node ID changes + * + * @return UuidInterface A UuidInterface instance that represents a + * version 1 UUID created from a DateTimeInterface instance + */ + public function fromDateTime( + DateTimeInterface $dateTime, + ?Hexadecimal $node = null, + ?int $clockSeq = null + ): UuidInterface; + /** * Creates a UUID from a 128-bit integer string * @@ -55,4 +79,104 @@ interface UuidFactoryInterface extends DeprecatedUuidFactoryInterface * @psalm-pure */ public function fromString(string $uuid): UuidInterface; + + /** + * Returns the validator to use for the factory + * + * @psalm-mutation-free + */ + public function getValidator(): ValidatorInterface; + + /** + * Returns a version 1 (time-based) UUID from a host ID, sequence number, + * and the current time + * + * @param Hexadecimal|int|string|null $node A 48-bit number representing the + * hardware address; this number may be represented as an integer or a + * hexadecimal string + * @param int|null $clockSeq A 14-bit number used to help avoid duplicates + * that could arise when the clock is set backwards in time or if the + * node ID changes + * + * @return UuidInterface A UuidInterface instance that represents a + * version 1 UUID + */ + public function uuid1($node = null, ?int $clockSeq = null): UuidInterface; + + /** + * Returns a version 2 (DCE Security) UUID from a local domain, local + * identifier, host ID, clock sequence, and the current time + * + * @param int $localDomain The local domain to use when generating bytes, + * according to DCE Security + * @param IntegerObject|null $localIdentifier The local identifier for the + * given domain; this may be a UID or GID on POSIX systems, if the local + * domain is person or group, or it may be a site-defined identifier + * if the local domain is org + * @param Hexadecimal|null $node A 48-bit number representing the hardware + * address + * @param int|null $clockSeq A 14-bit number used to help avoid duplicates + * that could arise when the clock is set backwards in time or if the + * node ID changes + * + * @return UuidInterface A UuidInterface instance that represents a + * version 2 UUID + */ + public function uuid2( + int $localDomain, + ?IntegerObject $localIdentifier = null, + ?Hexadecimal $node = null, + ?int $clockSeq = null + ): UuidInterface; + + /** + * Returns a version 3 (name-based) UUID based on the MD5 hash of a + * namespace ID and a name + * + * @param string|UuidInterface $ns The namespace (must be a valid UUID) + * @param string $name The name to use for creating a UUID + * + * @return UuidInterface A UuidInterface instance that represents a + * version 3 UUID + * + * @psalm-pure + */ + public function uuid3($ns, string $name): UuidInterface; + + /** + * Returns a version 4 (random) UUID + * + * @return UuidInterface A UuidInterface instance that represents a + * version 4 UUID + */ + public function uuid4(): UuidInterface; + + /** + * Returns a version 5 (name-based) UUID based on the SHA-1 hash of a + * namespace ID and a name + * + * @param string|UuidInterface $ns The namespace (must be a valid UUID) + * @param string $name The name to use for creating a UUID + * + * @return UuidInterface A UuidInterface instance that represents a + * version 5 UUID + * + * @psalm-pure + */ + public function uuid5($ns, string $name): UuidInterface; + + /** + * Returns a version 6 (ordered-time) UUID from a host ID, sequence number, + * and the current time + * + * @param Hexadecimal|null $node A 48-bit number representing the hardware + * address + * @param int|null $clockSeq A 14-bit number used to help avoid duplicates + * that could arise when the clock is set backwards in time or if the + * node ID changes + * + * @return UuidInterface A UuidInterface instance that represents a + * version 6 UUID + */ + public function uuid6(?Hexadecimal $node = null, ?int $clockSeq = null): UuidInterface; }