diff --git a/.github/workflows/merge-dependabot-upgrades.yml b/.github/workflows/merge-dependabot-upgrades.yml index ee57e4b..cddb937 100644 --- a/.github/workflows/merge-dependabot-upgrades.yml +++ b/.github/workflows/merge-dependabot-upgrades.yml @@ -17,7 +17,7 @@ jobs: steps: - name: Auto-Merge if: ${{ github.event.workflow_run.conclusion == 'success' }} - uses: ridedott/merge-me-action@v2.10.42 + uses: ridedott/merge-me-action@v2.10.44 with: # This must be used as GitHub Actions token does not support pushing # to protected branches. diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d5d6ac..1b3abc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,6 +72,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. * Remove dependency on ramsey/collection package. +## 4.7.4 - 2023-04-15 + +### Fixed + +* Allow brick/math version `^0.11`. +* Add explicit `Stringable` interface to `UuidInterface`. +* Fix namespace conflict reported in [#490](https://github.com/ramsey/uuid/issues/490). +* Fix unserialize error with `OrderedTimeCodec` reported in + [#494](https://github.com/ramsey/uuid/issues/494). + + ## 4.7.3 - 2023-01-12 ### Fixed diff --git a/composer.json b/composer.json index 632c1d2..3ffc6f8 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "require": { "php": "^8.1", "ext-json": "*", - "brick/math": "^0.8.8 || ^0.9 || ^0.10" + "brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11" }, "require-dev": { "captainhook/captainhook": "^5.10", diff --git a/composer.lock b/composer.lock index b344512..f9bccf0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,30 +4,29 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9835fa7593485115e03f0ef91f0f2145", + "content-hash": "a37c400c7a3410be8aab78fc569c2a59", "packages": [ { "name": "brick/math", - "version": "0.10.2", + "version": "0.11.0", "source": { "type": "git", "url": "https://github.com/brick/math.git", - "reference": "459f2781e1a08d52ee56b0b1444086e038561e3f" + "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/brick/math/zipball/459f2781e1a08d52ee56b0b1444086e038561e3f", - "reference": "459f2781e1a08d52ee56b0b1444086e038561e3f", + "url": "https://api.github.com/repos/brick/math/zipball/0ad82ce168c82ba30d1c01ec86116ab52f589478", + "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478", "shasum": "" }, "require": { - "ext-json": "*", - "php": "^7.4 || ^8.0" + "php": "^8.0" }, "require-dev": { "php-coveralls/php-coveralls": "^2.2", "phpunit/phpunit": "^9.0", - "vimeo/psalm": "4.25.0" + "vimeo/psalm": "5.0.0" }, "type": "library", "autoload": { @@ -52,7 +51,7 @@ ], "support": { "issues": "https://github.com/brick/math/issues", - "source": "https://github.com/brick/math/tree/0.10.2" + "source": "https://github.com/brick/math/tree/0.11.0" }, "funding": [ { @@ -60,7 +59,7 @@ "type": "github" } ], - "time": "2022-08-10T22:54:19+00:00" + "time": "2023-01-15T23:15:59+00:00" } ], "packages-dev": [ diff --git a/src/Nonstandard/UuidV6.php b/src/Nonstandard/UuidV6.php index e014a8c..f90bab0 100644 --- a/src/Nonstandard/UuidV6.php +++ b/src/Nonstandard/UuidV6.php @@ -25,7 +25,7 @@ use Ramsey\Uuid\Rfc4122\UuidInterface; use Ramsey\Uuid\Rfc4122\UuidV1; use Ramsey\Uuid\Rfc4122\Version; use Ramsey\Uuid\TimeBasedUuidInterface; -use Ramsey\Uuid\Uuid; +use Ramsey\Uuid\Uuid as BaseUuid; /** * Reordered time, or version 6, UUIDs include timestamp, clock sequence, and @@ -38,7 +38,7 @@ use Ramsey\Uuid\Uuid; * * @psalm-immutable */ -class UuidV6 extends Uuid implements UuidInterface, TimeBasedUuidInterface +class UuidV6 extends BaseUuid implements UuidInterface, TimeBasedUuidInterface { use TimeTrait; diff --git a/src/Uuid.php b/src/Uuid.php index b42850b..ef5140a 100644 --- a/src/Uuid.php +++ b/src/Uuid.php @@ -332,20 +332,20 @@ class Uuid implements Rfc4122UuidInterface */ public static function fromBytes(string $bytes): UuidInterface { - if (! self::$factoryReplaced && strlen($bytes) === 16) { + if (!self::$factoryReplaced && strlen($bytes) === 16) { $base16Uuid = bin2hex($bytes); // Note: we are calling `fromString` internally because we don't know if the given `$bytes` is a valid UUID return self::fromString( substr($base16Uuid, 0, 8) - . '-' - . substr($base16Uuid, 8, 4) - . '-' - . substr($base16Uuid, 12, 4) - . '-' - . substr($base16Uuid, 16, 4) - . '-' - . substr($base16Uuid, 20, 12) + . '-' + . substr($base16Uuid, 8, 4) + . '-' + . substr($base16Uuid, 12, 4) + . '-' + . substr($base16Uuid, 16, 4) + . '-' + . substr($base16Uuid, 20, 12) ); } @@ -371,7 +371,7 @@ class Uuid implements Rfc4122UuidInterface public static function fromString(string $uuid): UuidInterface { $uuid = strtolower($uuid); - if (! self::$factoryReplaced && preg_match(LazyUuidFromString::VALID_REGEX, $uuid) === 1) { + if (!self::$factoryReplaced && preg_match(LazyUuidFromString::VALID_REGEX, $uuid) === 1) { /** @psalm-suppress DocblockTypeContradiction */ assert($uuid !== ''); diff --git a/src/UuidInterface.php b/src/UuidInterface.php index 8fb1b6b..9f3035b 100644 --- a/src/UuidInterface.php +++ b/src/UuidInterface.php @@ -18,6 +18,7 @@ use JsonSerializable; use Ramsey\Uuid\Fields\FieldsInterface; use Ramsey\Uuid\Type\Hexadecimal; use Ramsey\Uuid\Type\Integer as IntegerObject; +use Stringable; /** * A UUID is a universally unique identifier adhering to an agreed-upon @@ -25,7 +26,7 @@ use Ramsey\Uuid\Type\Integer as IntegerObject; * * @psalm-immutable */ -interface UuidInterface extends JsonSerializable +interface UuidInterface extends JsonSerializable, Stringable { /** * @return mixed[] diff --git a/src/functions.php b/src/functions.php index 4d5a04a..d35821f 100644 --- a/src/functions.php +++ b/src/functions.php @@ -152,7 +152,7 @@ function v7(?DateTimeInterface $dateTime = null): string * field, and bits 64 and 65 will be replaced with the UUID variant. You * MUST NOT rely on these bits for your application needs. * - * @return non-empty-string Version 7 UUID as a string + * @return non-empty-string Version 8 UUID as a string */ function v8(string $bytes): string { diff --git a/tests/ExpectedBehaviorTest.php b/tests/ExpectedBehaviorTest.php index 30fbbe2..58518fe 100644 --- a/tests/ExpectedBehaviorTest.php +++ b/tests/ExpectedBehaviorTest.php @@ -48,11 +48,11 @@ class ExpectedBehaviorTest extends TestCase $this->assertSame( (string) $uuid->getHex(), $uuid->getFields()->getTimeLow()->toString() - . $uuid->getFields()->getTimeMid()->toString() - . $uuid->getFields()->getTimeHiAndVersion()->toString() - . $uuid->getFields()->getClockSeqHiAndReserved()->toString() - . $uuid->getFields()->getClockSeqLow()->toString() - . $uuid->getFields()->getNode()->toString() + . $uuid->getFields()->getTimeMid()->toString() + . $uuid->getFields()->getTimeHiAndVersion()->toString() + . $uuid->getFields()->getClockSeqHiAndReserved()->toString() + . $uuid->getFields()->getClockSeqLow()->toString() + . $uuid->getFields()->getNode()->toString() ); $this->assertStringStartsWith('urn:uuid:', $uuid->getUrn()); @@ -63,21 +63,21 @@ class ExpectedBehaviorTest extends TestCase $this->assertSame( $uuid->toString(), $uuid->getFields()->getTimeLow()->toString() . '-' - . $uuid->getFields()->getTimeMid()->toString() . '-' - . $uuid->getFields()->getTimeHiAndVersion()->toString() . '-' - . $uuid->getFields()->getClockSeqHiAndReserved()->toString() - . $uuid->getFields()->getClockSeqLow()->toString() . '-' - . $uuid->getFields()->getNode()->toString() + . $uuid->getFields()->getTimeMid()->toString() . '-' + . $uuid->getFields()->getTimeHiAndVersion()->toString() . '-' + . $uuid->getFields()->getClockSeqHiAndReserved()->toString() + . $uuid->getFields()->getClockSeqLow()->toString() . '-' + . $uuid->getFields()->getNode()->toString() ); $this->assertSame( (string) $uuid, $uuid->getFields()->getTimeLow()->toString() . '-' - . $uuid->getFields()->getTimeMid()->toString() . '-' - . $uuid->getFields()->getTimeHiAndVersion()->toString() . '-' - . $uuid->getFields()->getClockSeqHiAndReserved()->toString() - . $uuid->getFields()->getClockSeqLow()->toString() . '-' - . $uuid->getFields()->getNode()->toString() + . $uuid->getFields()->getTimeMid()->toString() . '-' + . $uuid->getFields()->getTimeHiAndVersion()->toString() . '-' + . $uuid->getFields()->getClockSeqHiAndReserved()->toString() + . $uuid->getFields()->getClockSeqLow()->toString() . '-' + . $uuid->getFields()->getNode()->toString() ); $this->assertSame(Variant::Rfc4122, $uuid->getFields()->getVariant()); diff --git a/tests/UuidTest.php b/tests/UuidTest.php index 9f53248..643f243 100644 --- a/tests/UuidTest.php +++ b/tests/UuidTest.php @@ -47,6 +47,7 @@ use Ramsey\Uuid\UuidInterface; use Ramsey\Uuid\Validator\GenericValidator; use Ramsey\Uuid\Validator\ValidatorInterface; use Ramsey\Uuid\Variant; +use Stringable; use stdClass; use function base64_decode; @@ -489,11 +490,19 @@ class UuidTest extends TestCase $uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66'); $this->assertSame('ff6f8cb0-c57d-11e1-9b21-0800200c9a66', $uuid->toString()); $this->assertSame('ff6f8cb0-c57d-11e1-9b21-0800200c9a66', (string) $uuid); + $this->assertSame( + 'ff6f8cb0-c57d-11e1-9b21-0800200c9a66', + (static fn (Stringable $uuid) => (string) $uuid)($uuid) + ); // Check with an old date $uuid = Uuid::fromString('0901e600-0154-1000-9b21-0800200c9a66'); $this->assertSame('0901e600-0154-1000-9b21-0800200c9a66', $uuid->toString()); $this->assertSame('0901e600-0154-1000-9b21-0800200c9a66', (string) $uuid); + $this->assertSame( + '0901e600-0154-1000-9b21-0800200c9a66', + (static fn (Stringable $uuid) => (string) $uuid)($uuid) + ); } public function testUuid1(): void