Commit Graph

412 Commits

Author SHA1 Message Date
Ben Ramsey b21cb6d655 fix: max UUID should be variant 7, nil UUID should be variant 0 2025-05-31 20:12:03 -05:00
Ben Ramsey 6bd7221484 Clean up docblocks, code, and note new deprecations
The following are deprecated:

* `Ramsey\Uuid\Codec\OrderedTimeCodec`
* `Ramsey\Uuid\Codec\TimestampFirstCombCodec`
* `Ramsey\Uuid\Codec\TimestampLastCombCodec`
* `Ramsey\Uuid\Generator\CombGenerator`
2025-05-31 17:20:12 -05:00
Ben Ramsey bdd1b2f71f chore(deps-dev): upgrade remaining development dependencies 2025-05-25 19:37:26 -05:00
Ben Ramsey 76cbc566e2 chore(deps-dev): upgrade PHPStan 2025-05-25 16:52:53 -05:00
Ben Ramsey 691c2c816e chore(deps-dev): remove Psalm 2025-05-25 14:53:53 -05:00
Viktor Szépe 00945e11a4 Fix typo in SystemDceSecurityProviderTest (#510) 2023-11-07 23:25:47 -06:00
Wermeille Bastien 628d3dfc55 Fix Unserialize error with OrderedTimeCodec #494 (#496) 2023-04-15 17:59:43 -05:00
Maximilian Bösing bf2bee216a Add explicit Stringable interface to UuidInterface (#491)
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>
2023-02-07 10:14:23 -06:00
George Steel 4a14ce0c62 fix: Amends psalm assertion syntax on Uuid::isValid() to prevent incorrect type inference (#486)
* fix: Amends psalm assertion syntax on `Uuid::isValid()` to prevent incorrect type inference
* Add static analysis test case for invalid input
2023-01-10 16:09:08 -06:00
zedar187 77e33bc7be feat(SystemNodeProvider): dismiss zero'd mac address (#468)
Co-authored-by: Ben Ramsey <ben@benramsey.com>
2022-12-19 15:30:41 -06:00
Marcel Berteler 5e24bfd390 feat: add Uuid:fromHexadecimal() (#309)
Co-authored-by: mberteler <marcel.berteler@capetown.gov.za>
Co-authored-by: Ben Ramsey <ben@benramsey.com>
2022-12-19 15:18:32 -06:00
Ben Ramsey 55d8833b06 feat: support version 8, custom UUIDs 2022-11-05 17:57:29 -05:00
Ben Ramsey 0ba1ffb029 fix: ensure monotonicity for version 7 UUIDs 2022-11-05 16:29:26 -05:00
Ben Ramsey 283468905a refactor: improve string encoding performance of non-lazy UUIDs 2022-09-16 11:45:41 -05:00
Ben Ramsey 4000e896f9 refactor: remove dependency on ext-ctype 2022-09-16 09:43:44 -05:00
Ben Ramsey a180174b0e fix: update validation to support versions 6 & 7 2022-09-15 22:14:34 -05:00
Ben Ramsey ae247f1dcd chore: clean up types and PHP 8-ify the code 2022-09-15 22:14:04 -05:00
Ben Ramsey 685c2f3f23 feat: support max UUIDs 2022-09-14 20:44:24 -05:00
Ben Ramsey 4f4deb1dd6 feat: add UUIDv7 documentation and customization 2022-09-14 18:21:10 -05:00
Ben Ramsey aa1e488afa feat: support version 7 (Unix Epoch time) UUIDs 2022-09-13 22:13:33 -05:00
Ben Ramsey 078feed166 chore: update nomenclature 2022-09-12 20:56:42 -05:00
Ben Ramsey b78bcda2d1 feat: move UuidV6 to the Rfc4122 namespace 2022-09-12 19:41:46 -05:00
George Steel b4dff559ab Assert non-empty-string when UUID is valid (#410)
* Assert, for psalm, the string is non-empty if validation passes
* Adds a test for SA asserting that valid string are also non-empty
* Suppress PHPStan error for unsupported conditional type assertion
* Check SA tools don't complain about non-empty-string as input parameter to `Uuid::isValid()`
2022-08-09 10:04:36 -05:00
Ben Ramsey f1891183f9 Upgrade PHPStan 2022-08-05 14:46:56 -05:00
Alexander Schranz a800c468aa Remove dependency to moontoast/math (#426) 2022-08-05 11:50:28 -05:00
Simon Podlipsky 9a8ea11ad3 fix: adapt tests to reflect GH-7758 (#435) 2022-08-05 11:31:53 -05:00
Marco Pivetta f0ada112c5 Allow iterable<T> where ramsey/collection would be used, deprecate collection classes
This patch is based on https://github.com/ramsey/uuid/pull/405

As discussed in https://github.com/ramsey/uuid/pull/405#discussion_r832095457, the `ramsey/collection`
dependency can be phased out.

Doing so via direct removal is not feasible without a clear BC break, so this change only deprecates:

 * `Ramsey\Uuid\Builder\BuilderCollection`
 * `Ramsey\Uuid\Provider\Node\NodeProviderCollection`

These classes will then be removed in `5.0.0`, along with the `ramsey/collection` dependency.
2022-03-22 17:30:42 +01:00
Marco Pivetta 5f9cd80b1b Migrated from PHPUnit_Framework_TestCase#assertRegExp() (deprecated) to #assertMatchesRegularExpression() 2022-03-22 12:43:22 +01:00
hubipe e3e9179f27 LazyUuidFromString for valid UUIDs in uppercase (#401) 2022-01-29 13:05:59 -06:00
Ben Ramsey 852850b7da Remove mocks for ext-uuid functions 2021-09-23 18:49:10 -05:00
Ben Ramsey aa6535442e Show deprecations in tests 2021-09-23 17:04:10 -05:00
Chris Smith ef1eb74c82 Add test covering Uuid::fromString() being called with empty string 2021-08-09 12:55:31 +01:00
Ben Ramsey 06f8e67792 Merge pull request #361 from slevomat/patch-1
Serialization should not use internal codec
2021-08-06 16:25:27 -05:00
Ben Ramsey d7379b67af test: update exception message for PHP 8.1 2021-08-06 14:35:42 -05:00
Ben Ramsey c005f69d6e chore: update package files 2021-08-06 14:05:57 -05:00
Jan Langer ef25479d05 Serialization should not use internal codec 2021-02-05 17:36:26 +01:00
Ben Ramsey b941aa1a9a Prepare test suite for PHP 8 2020-10-29 18:24:14 -05:00
Remi Collet e20165e9dd use expectError instead of expectException (#351) 2020-10-29 10:07:00 -05:00
Ben Ramsey 954cb23d5e Allow builds to fail on PHP 8.0 2020-10-28 22:22:54 -05:00
Ben Ramsey 0a25f73ae0 Fix static analysis issues 2020-10-28 21:19:26 -05:00
Bilge 7947413a76 Use assertSame instead of assertEquals. 2020-08-23 13:53:19 +01:00
Marco Pivetta fa14d04231 Added benchmark about extracting UUID field details 2020-07-09 14:23:49 +02:00
Marco Pivetta 6339cd9fbc Added UUID serialization benchmark 2020-07-09 14:15:05 +02:00
Marco Pivetta b805572537 Ensure that Uuid::uuidX() generators produce instances equivalent to Uuid::fromString() and Uuid::fromBytes()
With this change, `Uuid::uuid1()`, `Uuid::uuid2()` and so forth now produce a `LazyUuidFromString` instance, which
is both more memory efficient and comparable to `Uuid::fromString()` instances in other tools, such as within
PHPUnit's `Assertion::assertEqual()`, which would reject any two objects not matching each other's types.

Before this patch, `Assertion::assertEquals(Uuid::uuid5(...), Uuid::fromString(...))` would always fail due to
different subtypes produced by the two factory methods.
2020-07-09 13:57:30 +02:00
Marco Pivetta 2421b79841 Added benchmark for UUID generation logic 2020-07-09 13:57:30 +02:00
Marco Pivetta 1f0cd71d93 Applied fixes and suppressions (sadly) to match psalm/phpstan code quality guidelines
We have a lot of deprecated API in here which shouldn't exist in first place, but that
will luckily disappear with v5.0.0 :-)
2020-07-09 13:57:30 +02:00
Marco Pivetta 1ce3f55673 Applied automated CS fixes according to project CS settings 2020-07-09 13:57:30 +02:00
Marco Pivetta 569e93ac4e Re-implemented Uuid::fromString() so it produces a LazyUuidFromString when possible
This should speed up `Uuid::fromString()` massively, leading to much shallower execution
paths when `toString()` and similar simplistic API is required.
2020-07-09 13:57:30 +02:00
Marco Pivetta 8d42044a99 Minimal benchmarks around Uuid::fromString(), Uuid::fromBytes(), Uuid#toString(), Uuid#getBytes()
This is mostly to store an initial state, before we go on and start manipulating the UUID library internals.
2020-07-09 13:56:04 +02:00
Ben Ramsey 22ee596348 Make serialize(UuidInterface) more compact
Resolves #318
2020-07-08 15:27:19 -05:00