From 25c4faac19549ebfcd3a6a73732dddeb188eaf5a Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Sat, 28 Jan 2023 18:00:47 +0100 Subject: [PATCH 1/8] chore(deps): allow brick/math v0.11 (#488) --- composer.json | 2 +- composer.lock | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index 86bccac1..9ea4e06b 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "require": { "php": "^8.0", "ext-json": "*", - "brick/math": "^0.8.8 || ^0.9 || ^0.10", + "brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11", "ramsey/collection": "^1.2 || ^2.0" }, "require-dev": { diff --git a/composer.lock b/composer.lock index fd22cad2..d23eb53b 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": "0199024b1259b59c0544623603e0f2cf", + "content-hash": "1a0cfb78275fbdcb1744fc79f1d5fb66", "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" }, { "name": "ramsey/collection", From d33a8f1023af74aae4071dc98b5955d0b185ab6f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Feb 2023 15:10:27 -0600 Subject: [PATCH 2/8] chore(deps): bump ridedott/merge-me-action from 2.10.42 to 2.10.43 --- .github/workflows/merge-dependabot-upgrades.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/merge-dependabot-upgrades.yml b/.github/workflows/merge-dependabot-upgrades.yml index ee57e4b3..6d72ce1c 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.43 with: # This must be used as GitHub Actions token does not support pushing # to protected branches. From 29bb73b69bfc977d7c745f08b663663e8073a611 Mon Sep 17 00:00:00 2001 From: Valentin Udaltsov Date: Tue, 7 Feb 2023 19:06:53 +0300 Subject: [PATCH 3/8] Fixed v8() phpDoc (#493) --- src/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/functions.php b/src/functions.php index 2adf214c..1b3ce00f 100644 --- a/src/functions.php +++ b/src/functions.php @@ -150,7 +150,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 { From bf2bee216a4379eaf62162307d62bb7850405fec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Tue, 7 Feb 2023 17:14:23 +0100 Subject: [PATCH 4/8] Add explicit `Stringable` interface to `UuidInterface` (#491) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Even tho, the `Stringable` interface is implicit on all objects containing the method `__toString`, it is recommended by PHP to explicitly setting that interface. From php.net documentation: > [...] Unlike most interfaces, **Stringable** is implicitly present on any class that has the magic `__toString()` method defined, although it can and should be declared explicitly. Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- src/UuidInterface.php | 4 +++- tests/UuidTest.php | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/UuidInterface.php b/src/UuidInterface.php index 5f41675b..0a978080 100644 --- a/src/UuidInterface.php +++ b/src/UuidInterface.php @@ -19,6 +19,7 @@ use Ramsey\Uuid\Type\Hexadecimal; use Ramsey\Uuid\Type\Integer as IntegerObject; use Serializable; +use Stringable; /** * A UUID is a universally unique identifier adhering to an agreed-upon @@ -29,7 +30,8 @@ interface UuidInterface extends DeprecatedUuidInterface, JsonSerializable, - Serializable + Serializable, + Stringable { /** * Returns -1, 0, or 1 if the UUID is less than, equal to, or greater than diff --git a/tests/UuidTest.php b/tests/UuidTest.php index 17b62a9a..feea5a04 100644 --- a/tests/UuidTest.php +++ b/tests/UuidTest.php @@ -41,6 +41,7 @@ use Ramsey\Uuid\UuidInterface; use Ramsey\Uuid\Validator\GenericValidator; use Ramsey\Uuid\Validator\ValidatorInterface; +use Stringable; use stdClass; use function base64_decode; @@ -575,11 +576,19 @@ public function testToString(): void $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 From 8e955307d32dc9b6992440ff81321d3cb09db75a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Mar 2023 17:05:11 -0500 Subject: [PATCH 5/8] chore(deps): bump ridedott/merge-me-action from 2.10.43 to 2.10.44 --- .github/workflows/merge-dependabot-upgrades.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/merge-dependabot-upgrades.yml b/.github/workflows/merge-dependabot-upgrades.yml index 6d72ce1c..cddb9376 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.43 + uses: ridedott/merge-me-action@v2.10.44 with: # This must be used as GitHub Actions token does not support pushing # to protected branches. From abe81c15a99cf521fd5a5bd997fa816ac96f7905 Mon Sep 17 00:00:00 2001 From: Wermeille Bastien Date: Sun, 16 Apr 2023 00:47:42 +0200 Subject: [PATCH 6/8] Fix namepsace conflict #490 (#495) --- src/Nonstandard/UuidV6.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nonstandard/UuidV6.php b/src/Nonstandard/UuidV6.php index 1a7bbaf7..7497dd10 100644 --- a/src/Nonstandard/UuidV6.php +++ b/src/Nonstandard/UuidV6.php @@ -23,7 +23,7 @@ use Ramsey\Uuid\Rfc4122\TimeTrait; use Ramsey\Uuid\Rfc4122\UuidInterface; use Ramsey\Uuid\Rfc4122\UuidV1; -use Ramsey\Uuid\Uuid; +use Ramsey\Uuid\Uuid as BaseUuid; /** * Reordered time, or version 6, UUIDs include timestamp, clock sequence, and @@ -36,7 +36,7 @@ * * @psalm-immutable */ -class UuidV6 extends Uuid implements UuidInterface +class UuidV6 extends BaseUuid implements UuidInterface { use TimeTrait; From 628d3dfc55fef83d91e1cfdd57fea2eea097b64f Mon Sep 17 00:00:00 2001 From: Wermeille Bastien Date: Sun, 16 Apr 2023 00:59:43 +0200 Subject: [PATCH 7/8] Fix Unserialize error with OrderedTimeCodec #494 (#496) --- src/Uuid.php | 22 ++++++------ tests/ExpectedBehaviorTest.php | 65 +++++++++++++++++++++++----------- 2 files changed, 56 insertions(+), 31 deletions(-) diff --git a/src/Uuid.php b/src/Uuid.php index 6fb1e5b7..e0384a50 100644 --- a/src/Uuid.php +++ b/src/Uuid.php @@ -293,7 +293,7 @@ public function jsonSerialize(): string */ public function serialize(): string { - return $this->getFields()->getBytes(); + return $this->codec->encode($this); } /** @@ -446,20 +446,20 @@ public static function setFactory(UuidFactoryInterface $factory): void */ 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) ); } @@ -485,7 +485,7 @@ public static function fromBytes(string $bytes): UuidInterface 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) { assert($uuid !== ''); return new LazyUuidFromString($uuid); diff --git a/tests/ExpectedBehaviorTest.php b/tests/ExpectedBehaviorTest.php index 289a5adf..804239c2 100644 --- a/tests/ExpectedBehaviorTest.php +++ b/tests/ExpectedBehaviorTest.php @@ -5,6 +5,7 @@ use Brick\Math\BigInteger; use Ramsey\Uuid\Builder\DegradedUuidBuilder; use Ramsey\Uuid\Codec\CodecInterface; +use Ramsey\Uuid\Codec\OrderedTimeCodec; use Ramsey\Uuid\Codec\TimestampFirstCombCodec; use Ramsey\Uuid\Converter\Number\DegradedNumberConverter; use Ramsey\Uuid\Converter\Time\DegradedTimeConverter; @@ -74,21 +75,21 @@ public function testStaticCreationMethodsAndStandardBehavior($method, $args) $this->assertSame( (string) $uuid->getHex(), $uuid->getTimeLowHex() - . $uuid->getTimeMidHex() - . $uuid->getTimeHiAndVersionHex() - . $uuid->getClockSeqHiAndReservedHex() - . $uuid->getClockSeqLowHex() - . $uuid->getNodeHex() + . $uuid->getTimeMidHex() + . $uuid->getTimeHiAndVersionHex() + . $uuid->getClockSeqHiAndReservedHex() + . $uuid->getClockSeqLowHex() + . $uuid->getNodeHex() ); $this->assertSame( (string) $uuid->getHex(), $uuid->getFieldsHex()['time_low'] - . $uuid->getFieldsHex()['time_mid'] - . $uuid->getFieldsHex()['time_hi_and_version'] - . $uuid->getFieldsHex()['clock_seq_hi_and_reserved'] - . $uuid->getFieldsHex()['clock_seq_low'] - . $uuid->getFieldsHex()['node'] + . $uuid->getFieldsHex()['time_mid'] + . $uuid->getFieldsHex()['time_hi_and_version'] + . $uuid->getFieldsHex()['clock_seq_hi_and_reserved'] + . $uuid->getFieldsHex()['clock_seq_low'] + . $uuid->getFieldsHex()['node'] ); $this->assertIsString($uuid->getUrn()); @@ -100,21 +101,21 @@ public function testStaticCreationMethodsAndStandardBehavior($method, $args) $this->assertSame( $uuid->toString(), $uuid->getTimeLowHex() . '-' - . $uuid->getTimeMidHex() . '-' - . $uuid->getTimeHiAndVersionHex() . '-' - . $uuid->getClockSeqHiAndReservedHex() - . $uuid->getClockSeqLowHex() . '-' - . $uuid->getNodeHex() + . $uuid->getTimeMidHex() . '-' + . $uuid->getTimeHiAndVersionHex() . '-' + . $uuid->getClockSeqHiAndReservedHex() + . $uuid->getClockSeqLowHex() . '-' + . $uuid->getNodeHex() ); $this->assertSame( (string) $uuid, $uuid->getTimeLowHex() . '-' - . $uuid->getTimeMidHex() . '-' - . $uuid->getTimeHiAndVersionHex() . '-' - . $uuid->getClockSeqHiAndReservedHex() - . $uuid->getClockSeqLowHex() . '-' - . $uuid->getNodeHex() + . $uuid->getTimeMidHex() . '-' + . $uuid->getTimeHiAndVersionHex() . '-' + . $uuid->getClockSeqHiAndReservedHex() + . $uuid->getClockSeqLowHex() . '-' + . $uuid->getNodeHex() ); $this->assertSame(2, $uuid->getVariant()); @@ -240,6 +241,30 @@ public function testSerialization($string) $this->assertSame("\"{$string}\"", json_encode($uuid)); } + /** + * @dataProvider provideFromStringInteger + */ + public function testSerializationWithOrderedTimeCodec($string) + { + $factory = new UuidFactory(); + $factory->setCodec(new OrderedTimeCodec( + $factory->getUuidBuilder() + )); + + $previousFactory = Uuid::getFactory(); + Uuid::setFactory($factory); + $uuid = Uuid::fromString($string); + + $serialized = serialize($uuid); + $unserialized = unserialize($serialized); + + Uuid::setFactory($previousFactory); + + $this->assertSame(0, $uuid->compareTo($unserialized)); + $this->assertTrue($uuid->equals($unserialized)); + $this->assertSame("\"{$string}\"", json_encode($uuid)); + } + /** * @dataProvider provideFromStringInteger */ From 60a4c63ab724854332900504274f6150ff26d286 Mon Sep 17 00:00:00 2001 From: Ben Ramsey Date: Sat, 15 Apr 2023 18:01:58 -0500 Subject: [PATCH 8/8] chore: prepare for release 4.7.4 --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5a5b03d..c65322c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,17 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## 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