aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/ramsey/uuid/src/Type
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ramsey/uuid/src/Type')
-rw-r--r--vendor/ramsey/uuid/src/Type/Decimal.php32
-rw-r--r--vendor/ramsey/uuid/src/Type/Hexadecimal.php18
-rw-r--r--vendor/ramsey/uuid/src/Type/Integer.php25
-rw-r--r--vendor/ramsey/uuid/src/Type/Time.php37
4 files changed, 41 insertions, 71 deletions
diff --git a/vendor/ramsey/uuid/src/Type/Decimal.php b/vendor/ramsey/uuid/src/Type/Decimal.php
index 10f93845b..acc5e754b 100644
--- a/vendor/ramsey/uuid/src/Type/Decimal.php
+++ b/vendor/ramsey/uuid/src/Type/Decimal.php
@@ -19,6 +19,7 @@ use ValueError;
use function is_numeric;
use function sprintf;
+use function str_starts_with;
/**
* A value object representing a decimal
@@ -34,20 +35,10 @@ use function sprintf;
*/
final class Decimal implements NumberInterface
{
- /**
- * @var string
- */
- private $value;
-
- /**
- * @var bool
- */
- private $isNegative = false;
+ private string $value;
+ private bool $isNegative = false;
- /**
- * @param mixed $value The decimal value to store
- */
- public function __construct($value)
+ public function __construct(float | int | string | self $value)
{
$value = (string) $value;
@@ -59,7 +50,7 @@ final class Decimal implements NumberInterface
}
// Remove the leading +-symbol.
- if (strpos($value, '+') === 0) {
+ if (str_starts_with($value, '+')) {
$value = substr($value, 1);
}
@@ -68,7 +59,7 @@ final class Decimal implements NumberInterface
$value = '0';
}
- if (strpos($value, '-') === 0) {
+ if (str_starts_with($value, '-')) {
$this->isNegative = true;
}
@@ -111,18 +102,19 @@ final class Decimal implements NumberInterface
/**
* Constructs the object from a serialized string representation
*
- * @param string $serialized The serialized string representation of the object
+ * @param string $data The serialized string representation of the object
*
- * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
* @psalm-suppress UnusedMethodCall
*/
- public function unserialize($serialized): void
+ public function unserialize(string $data): void
{
- $this->__construct($serialized);
+ $this->__construct($data);
}
/**
- * @param array{string: string} $data
+ * @param array{string?: string} $data
+ *
+ * @psalm-suppress UnusedMethodCall
*/
public function __unserialize(array $data): void
{
diff --git a/vendor/ramsey/uuid/src/Type/Hexadecimal.php b/vendor/ramsey/uuid/src/Type/Hexadecimal.php
index 88adc2e7e..3c8f30adf 100644
--- a/vendor/ramsey/uuid/src/Type/Hexadecimal.php
+++ b/vendor/ramsey/uuid/src/Type/Hexadecimal.php
@@ -19,7 +19,7 @@ use ValueError;
use function ctype_xdigit;
use function sprintf;
-use function strpos;
+use function str_starts_with;
use function strtolower;
use function substr;
@@ -34,10 +34,7 @@ use function substr;
*/
final class Hexadecimal implements TypeInterface
{
- /**
- * @var string
- */
- private $value;
+ private string $value;
/**
* @param string $value The hexadecimal value to store
@@ -46,7 +43,7 @@ final class Hexadecimal implements TypeInterface
{
$value = strtolower($value);
- if (strpos($value, '0x') === 0) {
+ if (str_starts_with($value, '0x')) {
$value = substr($value, 2);
}
@@ -90,18 +87,17 @@ final class Hexadecimal implements TypeInterface
/**
* Constructs the object from a serialized string representation
*
- * @param string $serialized The serialized string representation of the object
+ * @param string $data The serialized string representation of the object
*
- * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
* @psalm-suppress UnusedMethodCall
*/
- public function unserialize($serialized): void
+ public function unserialize(string $data): void
{
- $this->__construct($serialized);
+ $this->__construct($data);
}
/**
- * @param array{string: string} $data
+ * @param array{string?: string} $data
*/
public function __unserialize(array $data): void
{
diff --git a/vendor/ramsey/uuid/src/Type/Integer.php b/vendor/ramsey/uuid/src/Type/Integer.php
index 7690f6cd8..e41b3cad5 100644
--- a/vendor/ramsey/uuid/src/Type/Integer.php
+++ b/vendor/ramsey/uuid/src/Type/Integer.php
@@ -20,7 +20,7 @@ use ValueError;
use function ctype_digit;
use function ltrim;
use function sprintf;
-use function strpos;
+use function str_starts_with;
use function substr;
/**
@@ -40,23 +40,17 @@ final class Integer implements NumberInterface
/**
* @psalm-var numeric-string
*/
- private $value;
+ private string $value;
- /**
- * @var bool
- */
- private $isNegative = false;
+ private bool $isNegative = false;
- /**
- * @param mixed $value The integer value to store
- */
- public function __construct($value)
+ public function __construct(float | int | string | self $value)
{
$value = (string) $value;
$sign = '+';
// If the value contains a sign, remove it for ctype_digit() check.
- if (strpos($value, '-') === 0 || strpos($value, '+') === 0) {
+ if (str_starts_with($value, '-') || str_starts_with($value, '+')) {
$sign = substr($value, 0, 1);
$value = substr($value, 1);
}
@@ -127,18 +121,17 @@ final class Integer implements NumberInterface
/**
* Constructs the object from a serialized string representation
*
- * @param string $serialized The serialized string representation of the object
+ * @param string $data The serialized string representation of the object
*
- * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
* @psalm-suppress UnusedMethodCall
*/
- public function unserialize($serialized): void
+ public function unserialize(string $data): void
{
- $this->__construct($serialized);
+ $this->__construct($data);
}
/**
- * @param array{string: string} $data
+ * @param array{string?: string} $data
*/
public function __unserialize(array $data): void
{
diff --git a/vendor/ramsey/uuid/src/Type/Time.php b/vendor/ramsey/uuid/src/Type/Time.php
index dd1b8bc28..745b5ccab 100644
--- a/vendor/ramsey/uuid/src/Type/Time.php
+++ b/vendor/ramsey/uuid/src/Type/Time.php
@@ -17,7 +17,6 @@ namespace Ramsey\Uuid\Type;
use Ramsey\Uuid\Exception\UnsupportedOperationException;
use Ramsey\Uuid\Type\Integer as IntegerObject;
use ValueError;
-use stdClass;
use function json_decode;
use function json_encode;
@@ -34,22 +33,13 @@ use function sprintf;
*/
final class Time implements TypeInterface
{
- /**
- * @var IntegerObject
- */
- private $seconds;
-
- /**
- * @var IntegerObject
- */
- private $microseconds;
+ private IntegerObject $seconds;
+ private IntegerObject $microseconds;
- /**
- * @param mixed $seconds
- * @param mixed $microseconds
- */
- public function __construct($seconds, $microseconds = 0)
- {
+ public function __construct(
+ float | int | string | IntegerObject $seconds,
+ float | int | string | IntegerObject $microseconds = 0,
+ ) {
$this->seconds = new IntegerObject($seconds);
$this->microseconds = new IntegerObject($microseconds);
}
@@ -104,27 +94,26 @@ final class Time implements TypeInterface
/**
* Constructs the object from a serialized string representation
*
- * @param string $serialized The serialized string representation of the object
+ * @param string $data The serialized string representation of the object
*
- * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
* @psalm-suppress UnusedMethodCall
*/
- public function unserialize($serialized): void
+ public function unserialize(string $data): void
{
- /** @var stdClass $time */
- $time = json_decode($serialized);
+ /** @var array{seconds?: int|float|string, microseconds?: int|float|string} $time */
+ $time = json_decode($data, true);
- if (!isset($time->seconds) || !isset($time->microseconds)) {
+ if (!isset($time['seconds']) || !isset($time['microseconds'])) {
throw new UnsupportedOperationException(
'Attempted to unserialize an invalid value'
);
}
- $this->__construct($time->seconds, $time->microseconds);
+ $this->__construct($time['seconds'], $time['microseconds']);
}
/**
- * @param array{seconds: string, microseconds: string} $data
+ * @param array{seconds?: string, microseconds?: string} $data
*/
public function __unserialize(array $data): void
{