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.
escapeshellargs() uses different quotation mark characters between Linux
and Windows, so tests were failing on Windows. This change uses a
regular expression instead.
Rename `Type\IntegerValue` to `Type\Integer`. It was originally named
`IntegerValue` because static analysis sees `Integer` in docblock
annotations and treats it as the native `int` type. `Integer` is not a
reserved word in PHP, so it should be named `Integer` for consistency
with other types in this library. When using it, a class alias prevents
static analysis from complaining.
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).
The 6 bytes obtained from `random_bytes()` is a 48-bit integer, which
cannot be converted to decimal on a 32-bit system, without being
implicitly cast to a float by PHP. This was causing problems with
setting the multicast bit, and it led to non-random node values.
This new approach splits the 6 bytes up into two 3-byte values, each a
24-bit integer, and applies the multicast bit to the most significant
bits before re-combining the bytes as a string.
If passthru() is disabled in php.ini, this will force the
SystemNodeProvider to return `false` for the node. Using the default
FallbackNodeProvider, ramsey/uuid will default to the
RandomNodeProvider, in these cases.
Closes#114
* Changes location of providers in the SystemNodeProviderTest
They are now grouped at the bottom of the class.
* Adds logic to SystemNodeProviderTest.
* Changes call to `file_get_contents` SystemNodeProvider so it can be
mocked.
* Changes SystemNodeProviderTest so native PHP functions are mocked
instead of the class under test.
* Changes SystemNodeProviderTest so "\n" is used instead of PHP_EOL
As the (input or output) of the tests is not system dependant it does
not make sense to use PHP_EOL. All of these instance have been
replaced for the sake of readability and stating intent more clearly.
* Adds dataprovider to SystemNodeProvider main test for input
variations.
* Adds OS to SystemNodeProviderTest dataprovider for Linux fail
scenario.
* Adds test for SystemNodeProvider to ensure invalid values are not
accepted.
* Changes names of dataproviders in SystemNodeProviderTest for
consistency.
* Changes SystemNodeProviderTest by grouping dataproviders together.
* Changes method in SystemNodeProviderTest to use the provided mock
functions.
* Fixes PSR-2 coding conventions in SystemNodeProviderTest.
* Minor change to SystemNodeProviderTest based on review.