This page covers 1.3.0 to 2.0.1. The repository has a CHANGELOG but no separate UPGRADE file.
Requirements
PHP ^8.5 is required (1.x: ^8.2). Update the constraint in composer.json:
{ "require": { "webpatser/uuid": "^2.0" }}
Removed
Uuid::isSqlServerFormat() is gone. It only checked the string format and gave the same answer as validate(). Replace calls with Uuid::validate(), or convert explicitly with importFromSqlServer().
Behaviour changes
compare()returnsfalsewhen either argument is not a valid UUID. In 1.x two unrelated invalid strings compared as equal. The comparison now useshash_equals().validate()is anchored with theDpattern modifier, so a trailing newline no longer passes.- The constructor, and so
import(), rejects any input that is not exactly 16 bytes. 1.x let an empty string through that check. - Name-based generation throws
Exception('Unsupported hash algorithm for name-based UUID.')instead of returning null on an unexpected hash algorithm.
Attributes
Factory and query methods now carry #[\NoDiscard]: generate(), v4(), v7(), import(), compare(), validate(), nil(), benchmark(), importFromSqlServer(), toSqlServer() and toSqlServerBinary(). PHP warns when you ignore their return value.
Additions
examples/benchmark.phpfor reproducible measurements.- The example scripts use the correct namespace and existing methods.
Development
The test suite moved from PHPUnit to Pest 4. This affects only contributors.
Unchanged
Method names and signatures, the property names, the namespace constants and the SQL Server conversion methods behave as in 1.3.0. Existing calls to v4(), v7(), generate(), import(), nil() and the properties need no change.
Checklist
- Upgrade PHP to 8.5 or newer.
- Run
composer require webpatser/uuid:^2.0. - Replace
isSqlServerFormat()calls. - Check code that relied on
compare()returningtruefor two invalid inputs. - Use the return value of every factory call to avoid
#[\NoDiscard]warnings.
See also the 2.x installation page and the API reference.