aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/ramsey/uuid/src/Provider
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ramsey/uuid/src/Provider')
-rw-r--r--vendor/ramsey/uuid/src/Provider/Node/FallbackNodeProvider.php3
-rw-r--r--vendor/ramsey/uuid/src/Provider/Node/RandomNodeProvider.php23
-rw-r--r--vendor/ramsey/uuid/src/Provider/Node/SystemNodeProvider.php11
-rw-r--r--vendor/ramsey/uuid/src/Provider/NodeProviderInterface.php4
-rw-r--r--vendor/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php5
5 files changed, 34 insertions, 12 deletions
diff --git a/vendor/ramsey/uuid/src/Provider/Node/FallbackNodeProvider.php b/vendor/ramsey/uuid/src/Provider/Node/FallbackNodeProvider.php
index 289fddeae..83488ab96 100644
--- a/vendor/ramsey/uuid/src/Provider/Node/FallbackNodeProvider.php
+++ b/vendor/ramsey/uuid/src/Provider/Node/FallbackNodeProvider.php
@@ -14,6 +14,7 @@
namespace Ramsey\Uuid\Provider\Node;
+use Exception;
use Ramsey\Uuid\Provider\NodeProviderInterface;
/**
@@ -43,7 +44,7 @@ class FallbackNodeProvider implements NodeProviderInterface
* and returning the first non-empty value found
*
* @return string System node ID as a hexadecimal string
- * @throws \Exception
+ * @throws Exception
*/
public function getNode()
{
diff --git a/vendor/ramsey/uuid/src/Provider/Node/RandomNodeProvider.php b/vendor/ramsey/uuid/src/Provider/Node/RandomNodeProvider.php
index 76c570d7f..79ec63cb8 100644
--- a/vendor/ramsey/uuid/src/Provider/Node/RandomNodeProvider.php
+++ b/vendor/ramsey/uuid/src/Provider/Node/RandomNodeProvider.php
@@ -14,6 +14,7 @@
namespace Ramsey\Uuid\Provider\Node;
+use Exception;
use Ramsey\Uuid\Provider\NodeProviderInterface;
/**
@@ -28,15 +29,29 @@ class RandomNodeProvider implements NodeProviderInterface
* Returns the system node ID
*
* @return string System node ID as a hexadecimal string
- * @throws \Exception if it was not possible to gather sufficient entropy
+ * @throws Exception if it was not possible to gather sufficient entropy
*/
public function getNode()
{
- $node = hexdec(bin2hex(random_bytes(6)));
+ $nodeBytes = random_bytes(6);
+
+ // Split the node bytes for math on 32-bit systems.
+ $nodeMsb = substr($nodeBytes, 0, 3);
+ $nodeLsb = substr($nodeBytes, 3);
// Set the multicast bit; see RFC 4122, section 4.5.
- $node = $node | 0x010000000000;
+ $nodeMsb = hex2bin(
+ str_pad(
+ dechex(hexdec(bin2hex($nodeMsb)) | 0x010000),
+ 6,
+ '0',
+ STR_PAD_LEFT
+ )
+ );
+
+ // Recombine the node bytes.
+ $node = $nodeMsb . $nodeLsb;
- return str_pad(dechex($node), 12, '0', STR_PAD_LEFT);
+ return str_pad(bin2hex($node), 12, '0', STR_PAD_LEFT);
}
}
diff --git a/vendor/ramsey/uuid/src/Provider/Node/SystemNodeProvider.php b/vendor/ramsey/uuid/src/Provider/Node/SystemNodeProvider.php
index ae6a09eaa..57015133a 100644
--- a/vendor/ramsey/uuid/src/Provider/Node/SystemNodeProvider.php
+++ b/vendor/ramsey/uuid/src/Provider/Node/SystemNodeProvider.php
@@ -36,7 +36,7 @@ class SystemNodeProvider implements NodeProviderInterface
}
$pattern = '/[^:]([0-9A-Fa-f]{2}([:-])[0-9A-Fa-f]{2}(\2[0-9A-Fa-f]{2}){4})[^:]/';
- $matches = array();
+ $matches = [];
// first try a linux specific way
$node = $this->getSysfs();
@@ -67,7 +67,7 @@ class SystemNodeProvider implements NodeProviderInterface
}
ob_start();
- switch (strtoupper(substr(php_uname('a'), 0, 3))) {
+ switch (strtoupper(substr(constant('PHP_OS'), 0, 3))) {
case 'WIN':
passthru('ipconfig /all 2>&1');
break;
@@ -95,15 +95,18 @@ class SystemNodeProvider implements NodeProviderInterface
{
$mac = false;
- if (strtoupper(php_uname('s')) === 'LINUX') {
+ if (strtoupper(constant('PHP_OS')) === 'LINUX') {
$addressPaths = glob('/sys/class/net/*/address', GLOB_NOSORT);
if (empty($addressPaths)) {
return false;
}
+ $macs = [];
array_walk($addressPaths, function ($addressPath) use (&$macs) {
- $macs[] = file_get_contents($addressPath);
+ if (is_readable($addressPath)) {
+ $macs[] = file_get_contents($addressPath);
+ }
});
$macs = array_map('trim', $macs);
diff --git a/vendor/ramsey/uuid/src/Provider/NodeProviderInterface.php b/vendor/ramsey/uuid/src/Provider/NodeProviderInterface.php
index 14f747bea..b6f721feb 100644
--- a/vendor/ramsey/uuid/src/Provider/NodeProviderInterface.php
+++ b/vendor/ramsey/uuid/src/Provider/NodeProviderInterface.php
@@ -14,6 +14,8 @@
namespace Ramsey\Uuid\Provider;
+use Exception;
+
/**
* NodeProviderInterface provides functionality to get the node ID (or host ID
* in the form of the system's MAC address) from a specific type of node provider
@@ -24,7 +26,7 @@ interface NodeProviderInterface
* Returns the system node ID
*
* @return string System node ID as a hexadecimal string
- * @throws \Exception if it was not possible to gather sufficient entropy
+ * @throws Exception if it was not possible to gather sufficient entropy
*/
public function getNode();
}
diff --git a/vendor/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php b/vendor/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php
index a62d39c62..79a9d04e0 100644
--- a/vendor/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php
+++ b/vendor/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php
@@ -14,6 +14,7 @@
namespace Ramsey\Uuid\Provider\Time;
+use InvalidArgumentException;
use Ramsey\Uuid\Provider\TimeProviderInterface;
/**
@@ -33,12 +34,12 @@ class FixedTimeProvider implements TimeProviderInterface
* Constructs a `FixedTimeProvider` using the provided `$timestamp`
*
* @param int[] Array containing `sec` and `usec` components of a timestamp
- * @throws \InvalidArgumentException if the `$timestamp` does not contain `sec` or `usec` components
+ * @throws InvalidArgumentException if the `$timestamp` does not contain `sec` or `usec` components
*/
public function __construct(array $timestamp)
{
if (!array_key_exists('sec', $timestamp) || !array_key_exists('usec', $timestamp)) {
- throw new \InvalidArgumentException('Array must contain sec and usec keys.');
+ throw new InvalidArgumentException('Array must contain sec and usec keys.');
}
$this->fixedTime = $timestamp;