Releases: ramsey/uuid
Releases · ramsey/uuid
Release list
3.9.4
4.1.1
4.1.0
4.0.1
Fixed
- Fix collection deserialization errors due to upstream
allowed_classesbeing
set tofalse. For details, see ramsey/uuid#303
and ramsey/collection#47.
4.0.0
Read the upgrade guide for details on how these changes may impact your code and what you can do to ease the upgrade process.
Added
- Add support for version 6 UUIDs, as defined by http://gh.peabody.io/uuidv6/,
including the static methodUuid::uuid6(), which returns a
Nonstandard\UuidV6instance. - Add ability to generate version 2 (DCE Security) UUIDs, including the static
methodUuid::uuid2(), which returns anRfc4122\UuidV2instance. - Add classes to represent each version of RFC 4122 UUID. When generating new
UUIDs or creating UUIDs from existing strings, bytes, or integers, if the UUID
is an RFC 4122 variant, one of these instances will be returned:Rfc4122\UuidV1Rfc4122\UuidV2Rfc4122\UuidV3Rfc4122\UuidV4Rfc4122\UuidV5Rfc4122\NilUuid
- Add classes to represent version 6 UUIDs, GUIDs, and nonstandard
(non-RFC 4122 variant) UUIDs:Nonstandard\UuidV6Guid\GuidNonstandard\Uuid
- Add
Uuid::fromDateTime()to create version 1 UUIDs from instances of
\DateTimeInterface. - The
\DateTimeInterfaceinstance returned byUuidInterface::getDateTime()
(and nowRfc4122\UuidV1::getDateTime()) now includes microseconds, as
specified by the version 1 UUID. - Add
Validator\ValidatorInterfaceandValidator\GenericValidatorto allow
flexibility in validating UUIDs/GUIDs.- The default validator continues to validate UUID strings using the same
relaxed validation pattern found in the 3.x series of ramsey/uuid. - Introduce
Rfc4122\Validatorthat may be used for strict validation of
RFC 4122 UUID strings. - Add ability to change the default validator used by
Uuidthrough
FeatureSet::setValidator(). - Add
getValidator()andsetValidator()toUuidFactory.
- The default validator continues to validate UUID strings using the same
- Add
Provider\Node\StaticNodeProviderto assist in setting a custom static
node value with the multicast bit set for version 1 UUIDs. - Add the following new exceptions:
Exception\BuilderNotFoundException-
Thrown to indicate that no suitable UUID builder could be found.Exception\DateTimeException-
Thrown to indicate that the PHP DateTime extension encountered an
exception/error.Exception\DceSecurityException-
Thrown to indicate an exception occurred while dealing with DCE Security
(version 2) UUIDs.Exception\InvalidArgumentException-
Thrown to indicate that the argument received is not valid. This extends the
built-in PHP\InvalidArgumentException, so there should be no BC breaks
with ramsey/uuid throwing this exception, if you are catching the PHP
exception.Exception\InvalidBytesException-
Thrown to indicate that the bytes being operated on are invalid in some way.Exception\NameException-
Thrown to indicate that an error occurred while attempting to hash a
namespace and name.Exception\NodeException-
Throw to indicate that attempting to fetch or create a node ID encountered
an error.Exception\RandomSourceException-
Thrown to indicate that the source of random data encountered an error.Exception\TimeSourceException-
Thrown to indicate that the source of time encountered an error.Exception\UnableToBuildUuidException-
Thrown to indicate a builder is unable to build a UUID.
- Introduce a
Builder\FallbackBuilder, used byFeatureSetto help decide
whether to return aUuidorNonstandard\Uuidwhen decoding a
UUID string or bytes. - Add
Rfc4122\UuidInterfaceto specifically represent RFC 4122 variant UUIDs. - Add
Rfc4122\UuidBuilderto build RFC 4122 variant UUIDs. This replaces the
existingBuilder\DefaultUuidBuilder, which is now deprecated. - Introduce
Math\CalculatorInterfacefor representing calculators to perform
arithmetic operations on integers. - Depend on brick/math for the
Math\BrickMathCalculator, which is the default calculator used by this
library when math cannot be performed in native PHP due to integer size
limitations. The calculator is configurable and may be changed, if desired. - Add
Converter\Number\GenericNumberConverterand
Converter\Time\GenericTimeConverterwhich will use the calculator provided
to convert numbers and time to values for UUIDs. - Introduce
Type\Hexadecimal,Type\Integer,Type\Decimal, andType\Time
for improved type-safety when dealing with arbitrary string values. - Add a
Type\TypeInterfacethat each of the ramsey/uuid types implements. - Add
Fields\FieldsInterfaceandRfc4122\FieldsInterfaceto define
field layouts for UUID variants. The implementationsRfc4122\Fields,
Guid\Fields, andNonstandard\Fieldsstore the 16-byte,
binary string representation of the UUID internally, and these manage
conversion of the binary string into the hexadecimal field values. - Introduce
Builder\BuilderCollectionandProvider\Node\NodeProviderCollection.
These are typed collections for providing builders and node providers to
Builder\FallbackBuilderandProvider\Node\FallbackNodeProvider, respectively. - Add
Generator\NameGeneratorInterfaceto support alternate methods of
generating bytes for version 3 and version 5 name-based UUID. By default,
ramsey/uuid uses theGenerator\DefaultNameGenerator, which uses the standard
algorithm this library has used since the beginning. You may choose to use the
newGenerator\PeclUuidNameGeneratorto make use of the new
uuid_generate_md5()anduuid_generate_sha1()functions in
ext-uuid version 1.1.0.
Changed
- Set minimum required PHP version to 7.2.
- This library now works on 32-bit and 64-bit systems, with no degradation in
functionality. - By default, the following static methods will now return specific instance
types. This should not cause any BC breaks if typehints targetUuidInterface:Uuid::uuid1returnsRfc4122\UuidV1Uuid::uuid3returnsRfc4122\UuidV3Uuid::uuid4returnsRfc4122\UuidV4Uuid::uuid5returnsRfc4122\UuidV5
- Accept
Type\Hexadecimalfor the$nodeparameter for
UuidFactoryInterface::uuid1(). This is in addition to theint|stringtypes
already accepted, so there are no BC breaks.Type\Hexadecimalis now the
recommended type to pass for$node. - Out of the box,
Uuid::fromString(),Uuid::fromBytes(), and
Uuid::fromInteger()will now return either anRfc4122\UuidInterface
instance or an instance ofNonstandard\Uuid, depending on whether the input
contains an RFC 4122 variant UUID with a valid version identifier. Both
implementUuidInterface, so BC breaks should not occur if typehints use the
interface. - Change
Uuid::getFields()to return an instance ofFields\FieldsInterface.
Previously, it returned an array of integer values (on 64-bit systems only). Uuid::getDateTime()now returns an instance of\DateTimeImmutableinstead
of\DateTime.- Make the following changes to
UuidInterface:getHex()now returns aType\Hexadecimalinstance.getInteger()now returns aType\Integerinstance. TheType\Integer
instance holds a string representation of a 128-bit integer. You may then
use a math library of your choice (bcmath, gmp, etc.) to operate on the
string integer.getDateTime()now returns\DateTimeInterfaceinstead of\DateTime.- Add
__toString()method. - Add
getFields()method. It returns an instance ofFields\FieldsInterface.
- Add the following new methods to
UuidFactoryInterface:uuid2()uuid6()fromDateTime()fromInteger()getValidator()
- This library no longer throws generic exceptions. However, this should not
result in BC breaks, since the new exceptions extend from built-in PHP
exceptions that this library previously threw.Exception\UnsupportedOperationExceptionis now descended from
\LogicException. Previously, it descended from\RuntimeException.
- Change required constructor parameters for
Uuid:- Change the first required constructor parameter for
Uuidfrom
array $fieldstoRfc4122\FieldsInterface $fields. - Add
Converter\TimeConverterInterface $timeConverteras the fourth
required constructor parameter forUuid.
- Change the first required constructor parameter for
- Change the second required parameter of
Builder\UuidBuilderInterface::build()
fromarray $fieldstostring $bytes. Rather than accepting an array of
hexadecimal strings as UUID fields, thebuild()method now expects a byte
string. - Add
Converter\TimeConverterInterface $timeConverteras the second required
constructor parameter forRfc4122\UuidBuilder. This also affects the
now-deprecatedBuilder\DefaultUuidBuilder, since this class now inherits
fromRfc4122\UuidBuilder. - Add
convertTime()method toConverter\TimeConverterInterface. - Add
getTime()method toProvider\TimeProviderInterface. It replaces the
currentTime()method. Provider\Node\FallbackNodeProvidernow accepts only a
Provider\Node\NodeProviderCollectionas its constructor parameter.Provider\Time\FixedTimeProviderno longer accepts an array but accepts only
Type\Timeinstances.Provider\NodeProviderInterface::getNode()now returnsType\Hexadecimal
instead ofstring|false|null.Converter/TimeConverterInterface::calculateTime()now returns
Type\Hexadecimalinstead ofarray. The value is the full UUID timestamp
value (count of 100-nanosecond intervals since the Gregorian calendar epoch)
in hexadecimal format.- Change methods in
NumberConverterInterfaceto accept and return string values
instead ofmixed; this simplifies ...
4.0.0-beta2
Added
- Add missing convenience methods for
Rfc4122\UuidV2. - Add
Provider\Node\StaticNodeProviderto assist in setting a custom static
node value with the multicast bit set for version 1 UUIDs.
Changed
Provider\NodeProviderInterface::getNode()now returnsType\Hexadecimal
instead ofstring|false|null.
4.0.0-beta1
Added
- Add
ValidatorInterface::getPattern()to return the regular expression
pattern used by the validator. - Add
v6()helper function for version 6 UUIDs.
Changed
- Set the pattern constants on validators as
private. Use thegetPattern()
method instead. - Change the
$nodeparameter forUuidFactoryInterface::uuid6()to accept
nullorType\Hexadecimal. - Accept
Type\Hexadecimalfor the$nodeparameter for
UuidFactoryInterface::uuid1(). This is in addition to theint|stringtypes
already accepted, so there are no BC breaks.Type\Hexadecimalis now the
recommended type to pass for$node.
Removed
- Remove
currentTime()method fromProvider\Time\FixedTimeProviderand
Provider\Time\SystemTimeProvider; it had previously been removed from
Provider\TimeProviderInterface.
4.0.0-alpha5
Added
- Introduce
Builder\BuilderCollectionandProvider\Node\NodeProviderCollection.
Changed
Builder\FallbackBuildernow accepts only aBuilder\BuilderCollectionas
its constructor parameter.Provider\Node\FallbackNodeProvidernow accepts only aProvider\Node\NodeProviderCollection
as its constructor parameter.Provider\Time\FixedTimeProviderno longer accepts an array but accepts only
Type\Timeinstances.
4.0.0-alpha4
Added
- Add a
Type\TypeInterfacethat each of the ramsey/uuid types implements. - Support version 6 UUIDs; see http://gh.peabody.io/uuidv6/.
Changed
- Rename
Type\IntegerValuetoType\Integer. It was originally named
IntegerValuebecause static analysis seesIntegerin docblock annotations
and treats it as the nativeinttype.Integeris not a reserved word in
PHP, so it should be namedIntegerfor consistency with other types in this
library. When using it, a class alias prevents static analysis from
complaining. - Mark
Guid\GuidandNonstandard\Uuidclasses asfinal. - Add
uuid6()method toUuidFactoryInterface.
Deprecated
Uuid::UUID_TYPE_IDENTIFIERis deprecated. UseUuid::UUID_TYPE_DCE_SECURITY
instead.Uuid::VALID_PATTERNis deprecated. UseValidator\GenericValidator::VALID_PATTERN
instead.
4.0.0-alpha3
Fixed
- Fix microsecond rounding error on 32-bit systems.