Changed
- For times before the Unix epoch,
GenericTimeConverter::convertTime()andPhpTimeConverter::convertTime()now return the seconds rounded down, with microseconds that count forward from them. For example, 1.5 seconds before the epoch is now -2 seconds and 500000 microseconds, where it was -1 seconds and 500000 microseconds. The microseconds are added to the seconds, so -2 seconds plus 0.5 seconds is -1.5 seconds.Time::toString()returns-1.500000for this time. ThegetDateTime()methods read the time from anyTimeConverterInterfaceimplementation in the same way. Uuid::fromString(), the string codecs, and the validators now accept only the standard forms of a UUID string: 32 hexadecimal digits with hyphens in all four standard positions or with no hyphens, optionally in one pair of braces, optionally after oneurn:prefix, oneuuid:prefix, or both in that order. Before, they removed these prefixes, braces, and (in the codecs) hyphens from anywhere in the string, so strings such as{{6ba7b8109dad-11d180b400c04fd430c8uuid:were read as UUIDs.Uuid::uuid7()now throwsInvalidArgumentExceptionfor a date before 1970-01-01 00:00:00 UTC or after 10889-08-02 05:31:50.655 UTC. Before, it returned a UUID with a wrong timestamp.Uuid::fromDateTime(),GenericTimeConverter::calculateTime(), andPhpTimeConverter::calculateTime()now throwInvalidArgumentExceptionfor a time before the Gregorian calendar epoch, 1582-10-15 00:00:00 UTC. Before,PhpTimeConverterreturned a wrong timestamp.Uuid::fromDateTime(),GenericTimeConverter::calculateTime(), andPhpTimeConverter::calculateTime()now throwInvalidArgumentExceptionfor a time after 5236-03-31 21:21:00.684697 UTC, the last time that fits in the 60-bit timestamp of a version 1, 2, or 6 UUID. Before, the timestamp lost its highest bits, so the UUID's date started again from 1582.Uuid::uuid7()now stores the fraction of the millisecond in the 12 bits after the version, using method 3 of RFC 9562 section 6.2. Version 7 UUIDs now sort by creation time to about a microsecond, even when different processes created them. They have 62 random bits, where they had 74, and the UUID for a given date and time has different bits after the timestamp than before.UnixTimeGeneratornow asks its random generator for 8 bytes for each new counter and 16 bytes for a seed, where it asked for 16 bytes at first and 10 bytes after that.Uuid::uuid7()now throwsTimeSourceExceptionwhen the system clock is before 1970-01-01 00:00:00 UTC or after 10889-08-02 05:31:50.655 UTC, the first and last times a version 7 UUID can have. Before, it returned a UUID with a wrong timestamp. It throws the same exception when calls for the last of those times have used every timestamp that is left.Uuid::uuid7()now throwsRandomSourceExceptionwhen a custom random generator returns a different number of bytes thanUnixTimeGeneratorasked it for. Before, PHP raised a warning or the UUID had wrong bits.Uuid::uuid8()now throwsInvalidArgumentExceptionunless it receives exactly 16 bytes. Before, shorter input raised aTypeError, and the default factory used the first 16 bytes of longer input. The other factory methods throw the same exception when a custom generator returns the wrong number of bytes.
Deprecated
BinaryUtils::applyVariant()andBinaryUtils::applyVersion()are deprecated. ramsey/uuid no longer uses them.
Fixed
- A date passed to
Uuid::uuid7()no longer changes the UUIDs that later calls without a date return. Before, after a call with a future date, every later call returned a UUID with that date until the clock passed it. - After a process forks, the parent and the child no longer continue the same version 7 counter with the same numbers, which could produce equal UUIDs in the millisecond of the fork.
PhpTimeConverter::convertTime()no longer returns wrong microseconds, such as dropping a leading zero, depending on theprecisionini setting. It now uses integer math; fixed in #653.getDateTime()no longer throwsInvalidArgumentExceptionfor version 1 and version 6 UUIDs whose time is just before the Unix epoch, such as1969-12-31 23:59:59.999999; fixed in #645.getDateTime()no longer returns a time after the Unix epoch for UUIDs whose time is less than one second before it.GenericTimeConverter::convertTime()andPhpTimeConverter::convertTime()no longer return a wrong time for times before the Unix epoch. For times less than one second before the epoch, the minus sign was lost. For earlier times,calculateTime()read the returned seconds and microseconds as a different time, so a timestamp 1.5 seconds before the epoch converted back as 0.5 seconds before it.- Factories built with
new FeatureSet(useGuids: true)now generate valid GUIDs. Before,uuid1()always threwUnableToBuildUuidException, other methods threw for some values, and the GUIDs they returned had the wrong version. Because of this fix,uuid3()anduuid5()on such a factory now return different GUIDs than before for the same namespace and name, so GUIDs stored from earlier versions will not match; fixed in #651. FeatureSet::setTimeProvider()andFeatureSet::setNodeProvider()now also apply to version 2 (DCE Security) UUIDs, andFeatureSet::setCalculator()now also rebuilds the builder and codec so they use the new calculator. As a result,FeatureSet::getBuilder()andFeatureSet::getCodec()return new objects aftersetCalculator()is called; fixed in #652.Hexadecimal,Integer, and the$nodeparameter ofUuid::uuid1()no longer accept a value that ends with a newline character. Before,Uuid::uuid1()returned a malformed UUID for such a node.BuilderCollection::unserialize()andNodeProviderCollection::unserialize()now throwUnsupportedOperationExceptionfor a value that is not a serialized array, instead of raising aTypeError.- Unserializing a lazy UUID now throws
InvalidUuidStringExceptionwhen the serialized value is not a UUID string. Before, a changed serialized value produced aUuidInterfaceobject whosetoString()method returned that value as it was. UuidV2::getLocalDomainName()now throwsDceSecurityExceptionfor a version 2 UUID whose local domain is not the person, group, or org domain. Before, it raised aTypeError.BrickMathCalculator::divide()now throwsInvalidArgumentExceptionfor a divisor of zero. Before, it let the brick/math exception through.- Calling
toUuidV1()ortoUuidV6()on a UUID of another version, such as one returned byUuid::uuid4(), now throwsUnsupportedOperationException. Before, it raised aTypeError, anError, or anAssertionError, depending on the method and thezend.assertionssetting. Decimalnow removes the whitespace around a numeric string. Before, it kept the whitespace,isNegative()returnedfalsefor a negative number with whitespace before it, andBrickMathCalculatorcould not read the value.Decimalno longer changes a number too small for a float, such as1e-400, to0.- Unserializing a
Decimal,Hexadecimal,Integer, orTimewhose serialized value has the wrong type, such as an array, now throwsValueError, andTime::unserialize()throwsUnsupportedOperationException. Before, these raised aTypeError.
New Contributors
- @kevin9327 made their first contribution in #653
- @IonBazan made their first contribution in #651
- @dualfroz made their first contribution in #645
Full Changelog: 4.9.4...4.10.0