~/docs
Resonate
Resonate
4.x 4.0.0, current 3.x 3.0.1 2.x 2.0.1 1.x 1.3.0
UUID Library
Toggle sidebar
UUID Library
webpatser/uuid 3.0.1
You are reading the 3.x documentation
The current line is 4.x. Read this page for 4.x

UUID Library 3.x

Upgrade Guide

What changes when you move from webpatser/uuid 2.x to 3.0, including the PHP 8.6 requirement and removed methods.

Version 3.0.0 raises the PHP requirement. The public API is unchanged from 2.0.1.

PHP 8.6

composer.json now requires "php": "^8.6". PHP 8.5 is no longer supported. On PHP 8.5, stay on 2.x.

composer require webpatser/uuid:^3.0

The 3.0.0 changelog states that src/ was reviewed for PHP 8.6 features and needed no source changes, so behavior matches 2.0.1.

Changes since 2.0.1

Area Change
Requirement PHP ^8.6, was ^8.5
Dev dependency pestphp/pest ^5.0, was Pest 4 (Pest 4 does not install on PHP 8.6)
CI Runs on PHP 8.6; composer audit runs without --no-dev
Public API No change

Changes that arrived in 2.x

If you come from 1.x, these 2.0.0 and 2.0.1 changes also apply.

isSqlServerFormat() is removed

2.0.0 removed isSqlServerFormat(). It never worked as a format check and behaved like validate(). Replace calls with Uuid::validate():

// 1.x
$ok = Uuid::isSqlServerFormat($value);
 
// 2.x and 3.x
$ok = Uuid::validate($value);

importFromSqlServer(), toSqlServer() and toSqlServerBinary() remain, see SQL Server.

#[\NoDiscard]

All factory and query methods carry #[\NoDiscard]. A call whose result is ignored now raises a warning. Use the value, or cast the call to (void) when you mean to discard it:

Uuid::validate($input); // Warning: result ignored
$valid = Uuid::validate($input); // Fine

Stricter input handling

2.0.1 hardened validate(), compare() and the constructor against invalid input. compare() returns false when either value is not a UUID, including two identical invalid strings.

Other 2.0.0 changes

  • mintName() throws instead of returning null on an unexpected hash algorithm.
  • The test suite moved from PHPUnit to Pest.
  • examples/benchmark.php was added, see Performance.

Upgrade checklist

  1. Run PHP 8.6.
  2. Run composer require webpatser/uuid:^3.0.
  3. Replace any isSqlServerFormat() call with validate().
  4. Use the return value of every factory and query call, or cast to (void).
  5. Run your tests.