Commit Graph

43 Commits

Author SHA1 Message Date
Ben Ramsey c005f69d6e chore: update package files 2021-08-06 14:05:57 -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 d98764ac16 Enhance the Guid documentation 2020-02-21 13:09:00 -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
Marco Pivetta 598b47d07f Refining type of producing a string that can be declared as non-empty-string 2020-02-03 11:05:36 -06:00
Ben Ramsey 4963f2320a Optimize codec algorithms 2020-01-21 22:17:32 -06:00
Ben Ramsey bf237a1962 Change UuidBuilderInterface::build() to accept bytes instead of fields 2020-01-21 15:49:18 -06:00
Ben Ramsey 0b64d6d995 Optimize how OrderedTimeCodec rearranges bytes and validates instances 2020-01-18 12:14:01 -06:00
Ben Ramsey 360261d617 Deprecate all the fields methods on UuidInterface and Uuid 2020-01-18 12:14:00 -06:00
Ben Ramsey 668b6ab9a2 Use the codec to encode to binary when using Uuid::getBytes() 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 8e79ff851a Address Psalm errors 2020-01-18 12:13:56 -06:00
Ben Ramsey b7f9dc5010 Check for RFC 4122, version 1 UUIDs with OrderedTimeCodec 2020-01-18 12:13:56 -06:00
Barney Laurance bdc9170edc Run Psalm on src as well as Static Analysis Fixture (#282)
* Run Psalm on src as well as Static Analysis Fixture

Psalm baselining feature is used to prevent immediate build failures -
psalm will just cause failures for errors caused by future changes to
the code.

See https://psalm.dev/docs/running_psalm/dealing_with_code_issues/#using-a-baseline-file

* Fix MixedArgument issues in OrderedTimeCodec

Potentially unpack should be documented as returning string[] instead of
array to make this unecassary.

* Fix Psalm PossiblyNullPropertyAssignmentValue issues

* Add psalm-immutable annotation to Uuid class

* Fix Psalm MixedArgument issues

* Fix MissingImmutableAnnotation psalm issue

* Fix Psalm MixedAssignment issue

* Fix Psalm InvalidReturnStatement / InvalidReturnType issue

* Add ImpureMethodCall issues to baseline.

Fixing these in one place just moves them somewhere else.

* Exclude psalm-baseline.xml from exported git archives
2020-01-18 12:13:56 -06:00
Ben Ramsey 12896f06db Use internal exceptions
Fixes #254
2020-01-18 12:13:55 -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
SignpostMarv 0030399564 Increase PHPStan levels and update code to resolve issues found 2020-01-18 12:13:08 -06:00
Mathieu TUDISCO e535e89708 Fix typo 2020-01-17 10:16:13 -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
Ben Ramsey 64ba9a2767 Clean up code according to PhpStorm inspections report 2019-11-30 13:14:52 -08:00
Alessandro Minoccheri c4cc058f3d change array declarations 2019-11-30 09:10:09 -08:00
Marco Perone 4b7374129c add annotations for thrown exceptions 2018-07-09 09:04:12 +02:00
Martin Hujer 4eefce356d Optimize UUID string decoding
I realized, that 30% of the request time in our app is spent by
hydrating the uuid (We are using Doctrine and in this specific request
I was accidentally hydrating few thousands entities). Luckily, I
remembered the #160 and tried to do similar optimization for uuid
decoding. It resulted in 10-20% performance improvement.
2017-03-26 19:02:20 +02:00
Massimiliano Arione a2647abc14 add a specific exception for invalid UUID string 2017-03-11 10:52:53 +01:00
Barry vd. Heuvel ca0cc642aa Add OrderedTimeCodec + test 2016-04-27 21:38:55 +02:00
Alex Farcas ad6f0747bd Implemented timestamp first and timestamp last comb generators 2016-03-18 16:49:19 +02: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 4e548705c0 Point to Ramsey\Uuid\UuidInterface::getFieldsHex instead 2015-09-27 18:59:32 -05:00
Ben Ramsey 77a34348d5 Add docblocks for classes and interface in Ramsey\Uuid\Codec namespace 2015-09-03 23:28:07 -04:00
Aztech d3535feb50 Use host dependant endianness in GUID string codec 2015-08-14 21:57:59 +02: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
Ben Ramsey db27dc1680 Rename UuidBuilder to Builder\UuidBuilderInterface 2015-07-16 10:06:16 -05:00
Ben Ramsey 3f0ba1ed00 Move CodecInterface to the Codec namespace 2015-07-16 10:01:24 -05:00
Ben Ramsey e006f669ad Adding common docblock file header 2015-07-15 13:59:52 -05:00
Ben Ramsey d67c3490a8 Change namespace to "Ramsey"; closes #48 2015-04-25 12:11:37 -05:00
Ben Ramsey 680fd794cb Interfaces should have the suffix "Interface" in their names 2014-11-08 16:27:20 -05:00
Thibaud Fabre cce58a0b8a Fix doc comments and remove unneeded usings 2014-11-08 15:57:30 +01:00
Thibaud Fabre c07988fe31 Refactor codecs to remove duplication 2014-11-08 15:00:58 +01:00
Thibaud Fabre 84123b2060 Remove all env related logic from factory
Defers all environment related decisions to factory initialization
All behavior is customizable through DI, but all deps are initialized to proper default instances
Removes static factory configuration
2014-11-08 12:41:40 +01:00
Thibaud Fabre fead6f3223 Refactor in the spirit of #1 & #34 2014-10-30 15:16:59 +01:00
Thibaud Fabre 723ef345bf Refactor factory functions
Remove $littleEndian parameter
Add fromGuidString/Bytes factory methods for GUIDs
No longer possible to output GUIDs as UUIDs and vice-versa
Pass tests
2014-10-30 15:15:16 +01:00
Thibaud Fabre 13b3bf7ed9 Refactor from/toString methods to codecs 2014-10-30 15:15:16 +01:00