Commit Graph

56 Commits

Author SHA1 Message Date
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 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
Ben Ramsey 0ba1ffb029 fix: ensure monotonicity for version 7 UUIDs 2022-11-05 16:29:26 -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 aa1e488afa feat: support version 7 (Unix Epoch time) UUIDs 2022-09-13 22:13:33 -05:00
Ben Ramsey 89905d1948 chore: remove deprecation notices 2022-09-12 19:41:45 -05:00
Ben Ramsey bc6cd7d888 Deprecate factory methods; improve deprecation docblocks 2022-08-09 09:24:01 -05:00
Ben Ramsey f1891183f9 Upgrade PHPStan 2022-08-05 14:46:56 -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
Ben Ramsey 0b4be8392a fix: check whether property is set 2021-08-06 14:29:01 -05:00
Ben Ramsey 4511ccd7e6 chore(deps): upgrade vimeo/psalm 2021-08-06 14:25:16 -05:00
Ben Ramsey 67665bf107 Build the time generator when setting the calculator 2020-03-09 17:08:23 -05:00
Ben Ramsey 57e3ce9dd7 Fix Psalm errors resulting from changes introduced in 3.9.4 2020-03-07 15:22:00 -06:00
Ben Ramsey 836de4ece5 Allow setting the node provider on the FeatureSet 2020-02-29 23:51:00 -06:00
Ben Ramsey aaccc850a1 Use strict argument validation for collections
This resolves #106
2020-02-23 00:50:00 -06:00
Ben Ramsey 0bff9e8660 Add NameGeneratorInterface and generators for v3 and v5 UUIDs 2020-02-08 13:12:20 -06:00
Marco Pivetta a252f29847 Import used functions and constants via use statement to disallow ambiguity for compiler/static-analysis
As documented in https://wiki.php.net/rfc/use_global_elements, the engine (by default) does a local namespace
lookup, then falls back to global namespace when first calling a global function referenced in namespaced code,
unless that function is referenced via fully qualified name (FQN).

By using the FQN, the actual symbol can be looked up at compile-time, both by the PHP engine and by static analysis
tooling, allowing for compiler (in particular) optimizations to replace known hot-path functions with specialized opcodes.

Sadly, no actual benchmark at hand: the improvements can be minimal or massive, depending on where this library is
used (tight loops being most relevant).
2020-02-03 13:15:35 -06:00
Ben Ramsey 5fa4eb4f17 Add fromDateTime() to create version 1 UUIDs from DateTime instances
Fixes #28
2020-02-03 00:48:41 -06:00
Ben Ramsey a8d52100de Support microtime in returned DateTimeInterface instances
Fixes #90 and supersedes #93.
2020-01-19 23:21:48 -06:00
Ben Ramsey 72a2312f62 Support generation of version 2 (DCE Security) UUIDs 2020-01-18 12:14:01 -06:00
Ben Ramsey b52fff6b52 Build number and time converters when setting calculator 2020-01-18 12:14:01 -06:00
Ben Ramsey 12a2b0680d Add individual concrete classes for each version of RFC 4122 UUID 2020-01-18 12:14:01 -06:00
Ben Ramsey 5d1f106882 Rename Validator\Validator to Validator\GenericValidator 2020-01-18 12:14:00 -06:00
Ben Ramsey 2ad77d9ca7 Remove CalculatorInterface as a Uuid constructor parameter 2020-01-18 12:14:00 -06:00
Ben Ramsey 360261d617 Deprecate all the fields methods on UuidInterface and Uuid 2020-01-18 12:14:00 -06:00
Ben Ramsey c80ad2606f Deprecate degraded UUIDs; they are no longer necessary 2020-01-18 12:13:59 -06:00
Ben Ramsey 63942c393d Remove Gmp converters; the generic converters are preferred 2020-01-18 12:13:58 -06:00
Ben Ramsey 3546a86f7d Deprecate BigNumberConverter and BigNumberTimeConverter 2020-01-18 12:13:58 -06:00
Ben Ramsey 4d1db4d090 Clean up class naming conventions 2020-01-18 12:13:57 -06:00
Ben Ramsey 70eace9086 Introduce separate classes to handle nonstandard UUIDs 2020-01-18 12:13:57 -06:00
Ben Ramsey d6ed9b3832 Introduce separate class support for GUIDs 2020-01-18 12:13:57 -06:00
Ben Ramsey 0d7b8c2b7a Update coding style to include PSR-12, among other options
This also includes heavy use of slevomat/coding-standard to apply
various checks to the code, based on maintainer (me) preference.
2020-01-18 12:13:55 -06:00
Massimiliano Arione 5459113b81 add typehints and return types 2020-01-18 12:13:10 -06:00
André Filipe bdfbf64a10 Removed some else/elseif and added some early returns to make the code a little easier to read, nothing changes on the big picture 2020-01-18 12:13:09 -06:00
Julian Ecknig 4de1348099 Add GmpConverter and GmpTimeConverter 2020-01-18 12:13:09 -06:00
Bradyn Poulsen 3cf759ad05 Migrate isValid() to Validator and ValidatorInterface
* Maintain backwards compatibility with the former Uuid::isValid() and
  Uuid::VALID_PATTERN
* Remove the assert statements in favor of str_replace and preg_match
* Make the validator a featureset of the factory
* Remove old suggestion about locations of constants
* Remove argument count assertions
* Remove VALID_PATTERN from Uuid
2020-01-18 12:13:08 -06:00
SignpostMarv 0030399564 Increase PHPStan levels and update code to resolve issues found 2020-01-18 12:13:08 -06:00
Martin Hujer ca2629767d Require phpstan and correct issues found up to level 2
* issues found by phpstan L0
* issues found by phpstan L1
* issues found by phpstan L2 in src/
* issues found by phpstan L2 in tests/
2020-01-18 12:13:08 -06:00
André Filipe 84fe6cf755 Removed some else/elseif and added some early returns to make the code a little easier to read, nothing changes on the big picture 2019-11-30 15:10:48 -08:00
Emir Beganovic fb1cd7a944 Cleanup: Update and add missing docblocks, remove unused imports
Just a bit of house keeping for the sake of code cleanliness.
2015-10-05 10:18:21 +02:00
Ben Ramsey e6f97dc8ab Add docblocks for classes and interfaces in top-level Ramsey\Uuid namespace 2015-09-27 18:58:50 -05:00
Scrutinizer Auto-Fixer f59b447603 Scrutinizer Auto-Fixes
This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
2015-08-13 15:32:44 +00:00
Aztech bbce46dabe Add option to enable PeclUuidTimeGenerator via FeatureSet 2015-07-28 22:20:04 +02:00
Aztech 0cd74639cf Enable use of custom TimeGenerator implementations
- Removes now unnecessary `timeConverter` and `timeProvider`
  properties, setters, and getters in both FeatureSet and
  UuidFactory as those are now exclusively used by the default
  TimeGenerator
- Adds a `setTimeGenerator` method on UuidFactory to override the
  default time generator
2015-07-28 22:16:29 +02:00
Aztech e2047199cd Remove redundant method call 2015-07-27 11:14:20 -05:00
Aztech 8974c76bf6 Refactor TimeGeneratorInterface
- Remove UuidFactory from signature
- Remove setters on UuidFactory to prevent inconsistencies (a new feature set and factory should be used instead)
- Update tests to reflect those changes
2015-07-27 11:14:20 -05:00
Ben Ramsey dfbf8b8098 Abstract time generation into family of TimeGeneratorInterface classes 2015-07-27 11:14:20 -05:00
Ben Ramsey b3ef99a2e9 Move RandomGeneratorInterface and RandomGeneratorFactory to Generator NS 2015-07-16 09:54:04 -05:00
Ben Ramsey e006f669ad Adding common docblock file header 2015-07-15 13:59:52 -05:00