mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-13 15:46:53 +03:00
chore(deps-dev): remove Psalm
This commit is contained in:
@@ -19,8 +19,6 @@
|
|||||||
/phpstan-tests.neon export-ignore
|
/phpstan-tests.neon export-ignore
|
||||||
/phpstan.neon.dist export-ignore
|
/phpstan.neon.dist export-ignore
|
||||||
/phpunit.xml.dist export-ignore
|
/phpunit.xml.dist export-ignore
|
||||||
/psalm-baseline.xml export-ignore
|
|
||||||
/psalm.xml export-ignore
|
|
||||||
/resources/ export-ignore
|
/resources/ export-ignore
|
||||||
/SECURITY.md export-ignore
|
/SECURITY.md export-ignore
|
||||||
/tests/ export-ignore
|
/tests/ export-ignore
|
||||||
|
|||||||
@@ -63,9 +63,6 @@ jobs:
|
|||||||
- name: "Statically analyze code (PHPStan)"
|
- name: "Statically analyze code (PHPStan)"
|
||||||
run: "composer phpstan -- --ansi"
|
run: "composer phpstan -- --ansi"
|
||||||
|
|
||||||
- name: "Statically analyze code (Psalm)"
|
|
||||||
run: "composer psalm -- --shepherd"
|
|
||||||
|
|
||||||
benchmark:
|
benchmark:
|
||||||
name: "Benchmark"
|
name: "Benchmark"
|
||||||
needs: ["coding-standards", "static-analysis"]
|
needs: ["coding-standards", "static-analysis"]
|
||||||
|
|||||||
+2
-3
@@ -129,9 +129,8 @@ composer phpcbf
|
|||||||
|
|
||||||
### Static Analysis
|
### Static Analysis
|
||||||
|
|
||||||
This project uses a combination of [PHPStan](https://github.com/phpstan/phpstan)
|
This project uses [PHPStan](https://github.com/phpstan/phpstan) to provide
|
||||||
and [Psalm](https://github.com/vimeo/psalm) to provide static analysis of PHP
|
static analysis of PHP code.
|
||||||
code.
|
|
||||||
|
|
||||||
CaptainHook will run static analysis checks before committing.
|
CaptainHook will run static analysis checks before committing.
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
<a href="https://github.com/ramsey/uuid/blob/4.x/LICENSE"><img src="https://img.shields.io/packagist/l/ramsey/uuid.svg?style=flat-square&colorB=darkcyan" alt="Read License"></a>
|
<a href="https://github.com/ramsey/uuid/blob/4.x/LICENSE"><img src="https://img.shields.io/packagist/l/ramsey/uuid.svg?style=flat-square&colorB=darkcyan" alt="Read License"></a>
|
||||||
<a href="https://github.com/ramsey/uuid/actions/workflows/continuous-integration.yml"><img src="https://img.shields.io/github/actions/workflow/status/ramsey/uuid/continuous-integration.yml?branch=4.x&logo=github&style=flat-square" alt="Build Status"></a>
|
<a href="https://github.com/ramsey/uuid/actions/workflows/continuous-integration.yml"><img src="https://img.shields.io/github/actions/workflow/status/ramsey/uuid/continuous-integration.yml?branch=4.x&logo=github&style=flat-square" alt="Build Status"></a>
|
||||||
<a href="https://app.codecov.io/gh/ramsey/uuid/branch/4.x"><img src="https://img.shields.io/codecov/c/github/ramsey/uuid/4.x?label=codecov&logo=codecov&style=flat-square" alt="Codecov Code Coverage"></a>
|
<a href="https://app.codecov.io/gh/ramsey/uuid/branch/4.x"><img src="https://img.shields.io/codecov/c/github/ramsey/uuid/4.x?label=codecov&logo=codecov&style=flat-square" alt="Codecov Code Coverage"></a>
|
||||||
<a href="https://shepherd.dev/github/ramsey/uuid"><img src="https://img.shields.io/endpoint?style=flat-square&url=https%3A%2F%2Fshepherd.dev%2Fgithub%2Framsey%2Fuuid%2Fcoverage" alt="Psalm Type Coverage"></a>
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
ramsey/uuid is a PHP library for generating and working with universally unique
|
ramsey/uuid is a PHP library for generating and working with universally unique
|
||||||
|
|||||||
+2
-8
@@ -32,8 +32,7 @@
|
|||||||
"phpstan/phpstan-phpunit": "^1.1",
|
"phpstan/phpstan-phpunit": "^1.1",
|
||||||
"phpunit/phpunit": "^8.5 || ^9",
|
"phpunit/phpunit": "^8.5 || ^9",
|
||||||
"slevomat/coding-standard": "^8.4",
|
"slevomat/coding-standard": "^8.4",
|
||||||
"squizlabs/php_codesniffer": "^3.5",
|
"squizlabs/php_codesniffer": "^3.5"
|
||||||
"vimeo/psalm": "^4.9"
|
|
||||||
},
|
},
|
||||||
"replace": {
|
"replace": {
|
||||||
"rhumsaa/uuid": "self.version"
|
"rhumsaa/uuid": "self.version"
|
||||||
@@ -77,10 +76,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"analyze": [
|
"analyze": "@phpstan",
|
||||||
"@phpstan",
|
|
||||||
"@psalm"
|
|
||||||
],
|
|
||||||
"build:clean": "git clean -fX build/",
|
"build:clean": "git clean -fX build/",
|
||||||
"lint": "parallel-lint src tests",
|
"lint": "parallel-lint src tests",
|
||||||
"lint:paths": "parallel-lint",
|
"lint:paths": "parallel-lint",
|
||||||
@@ -93,13 +89,11 @@
|
|||||||
],
|
],
|
||||||
"phpunit": "phpunit --verbose --colors=always",
|
"phpunit": "phpunit --verbose --colors=always",
|
||||||
"phpunit-coverage": "phpunit --verbose --colors=always --coverage-html build/coverage",
|
"phpunit-coverage": "phpunit --verbose --colors=always --coverage-html build/coverage",
|
||||||
"psalm": "psalm --show-info=false --config=psalm.xml",
|
|
||||||
"test": [
|
"test": [
|
||||||
"@lint",
|
"@lint",
|
||||||
"@phpbench",
|
"@phpbench",
|
||||||
"@phpcs",
|
"@phpcs",
|
||||||
"@phpstan",
|
"@phpstan",
|
||||||
"@psalm",
|
|
||||||
"@phpunit"
|
"@phpunit"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+1
-1050
File diff suppressed because it is too large
Load Diff
@@ -1,175 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<files psalm-version="4.27.0@faf106e717c37b8c81721845dba9de3d8deed8ff">
|
|
||||||
<file src="src/Builder/DegradedUuidBuilder.php">
|
|
||||||
<DeprecatedClass occurrences="3">
|
|
||||||
<code>DegradedUuid</code>
|
|
||||||
<code>new DegradedTimeConverter()</code>
|
|
||||||
</DeprecatedClass>
|
|
||||||
<ImpureVariable occurrences="2">
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
</ImpureVariable>
|
|
||||||
</file>
|
|
||||||
<file src="src/Builder/FallbackBuilder.php">
|
|
||||||
<ImpureMethodCall occurrences="1"/>
|
|
||||||
<ImpureVariable occurrences="1">
|
|
||||||
<code>$this</code>
|
|
||||||
</ImpureVariable>
|
|
||||||
</file>
|
|
||||||
<file src="src/Converter/Number/BigNumberConverter.php">
|
|
||||||
<ImpureVariable occurrences="2">
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
</ImpureVariable>
|
|
||||||
</file>
|
|
||||||
<file src="src/Converter/Number/DegradedNumberConverter.php">
|
|
||||||
<DeprecatedClass occurrences="1">
|
|
||||||
<code>BigNumberConverter</code>
|
|
||||||
</DeprecatedClass>
|
|
||||||
</file>
|
|
||||||
<file src="src/Converter/Number/GenericNumberConverter.php">
|
|
||||||
<ImpureVariable occurrences="2">
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
</ImpureVariable>
|
|
||||||
</file>
|
|
||||||
<file src="src/Converter/Time/DegradedTimeConverter.php">
|
|
||||||
<DeprecatedClass occurrences="1">
|
|
||||||
<code>BigNumberTimeConverter</code>
|
|
||||||
</DeprecatedClass>
|
|
||||||
</file>
|
|
||||||
<file src="src/FeatureSet.php">
|
|
||||||
<PropertyNotSetInConstructor occurrences="5">
|
|
||||||
<code>$calculator</code>
|
|
||||||
<code>$dceSecurityGenerator</code>
|
|
||||||
<code>$numberConverter</code>
|
|
||||||
<code>$timeConverter</code>
|
|
||||||
<code>$timeGenerator</code>
|
|
||||||
</PropertyNotSetInConstructor>
|
|
||||||
</file>
|
|
||||||
<file src="src/Generator/PeclUuidNameGenerator.php">
|
|
||||||
<ImpureFunctionCall occurrences="3">
|
|
||||||
<code>uuid_generate_md5</code>
|
|
||||||
<code>uuid_generate_sha1</code>
|
|
||||||
<code>uuid_parse</code>
|
|
||||||
</ImpureFunctionCall>
|
|
||||||
</file>
|
|
||||||
<file src="src/Guid/GuidBuilder.php">
|
|
||||||
<ImpureVariable occurrences="3">
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
</ImpureVariable>
|
|
||||||
</file>
|
|
||||||
<file src="src/Nonstandard/UuidBuilder.php">
|
|
||||||
<ImpureVariable occurrences="3">
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
</ImpureVariable>
|
|
||||||
</file>
|
|
||||||
<file src="src/Provider/Dce/SystemDceSecurityProvider.php">
|
|
||||||
<ForbiddenCode occurrences="5">
|
|
||||||
<code>shell_exec('id -g')</code>
|
|
||||||
<code>shell_exec('id -u')</code>
|
|
||||||
<code>shell_exec('net user %username% | findstr /b /i "Local Group Memberships"')</code>
|
|
||||||
<code>shell_exec('whoami /user /fo csv /nh')</code>
|
|
||||||
<code>shell_exec('wmic group get name,sid | findstr /b /i ' . escapeshellarg($firstGroup))</code>
|
|
||||||
</ForbiddenCode>
|
|
||||||
</file>
|
|
||||||
<file src="src/Provider/Node/SystemNodeProvider.php">
|
|
||||||
<MixedArgument occurrences="1">
|
|
||||||
<code>$macs</code>
|
|
||||||
</MixedArgument>
|
|
||||||
<MixedArrayAssignment occurrences="1">
|
|
||||||
<code>$macs[]</code>
|
|
||||||
</MixedArrayAssignment>
|
|
||||||
</file>
|
|
||||||
<file src="src/Rfc4122/UuidBuilder.php">
|
|
||||||
<ImpureVariable occurrences="21">
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
</ImpureVariable>
|
|
||||||
</file>
|
|
||||||
<file src="src/Rfc4122/UuidV6.php">
|
|
||||||
<DeprecatedClass occurrences="1">
|
|
||||||
<code>NonstandardUuidV6</code>
|
|
||||||
</DeprecatedClass>
|
|
||||||
</file>
|
|
||||||
<file src="src/Type/Hexadecimal.php">
|
|
||||||
<UnusedMethodCall occurrences="1">
|
|
||||||
<code>unserialize</code>
|
|
||||||
</UnusedMethodCall>
|
|
||||||
</file>
|
|
||||||
<file src="src/Type/Integer.php">
|
|
||||||
<UnusedMethodCall occurrences="1">
|
|
||||||
<code>unserialize</code>
|
|
||||||
</UnusedMethodCall>
|
|
||||||
</file>
|
|
||||||
<file src="src/Type/Time.php">
|
|
||||||
<UnusedMethodCall occurrences="1">
|
|
||||||
<code>__construct</code>
|
|
||||||
</UnusedMethodCall>
|
|
||||||
</file>
|
|
||||||
<file src="src/Uuid.php">
|
|
||||||
<DeprecatedTrait occurrences="1">
|
|
||||||
<code>DeprecatedUuidMethodsTrait</code>
|
|
||||||
</DeprecatedTrait>
|
|
||||||
<ImpureMethodCall occurrences="6">
|
|
||||||
<code>getFactory</code>
|
|
||||||
<code>getFactory</code>
|
|
||||||
<code>getFactory</code>
|
|
||||||
<code>getFactory</code>
|
|
||||||
<code>getFactory</code>
|
|
||||||
<code>getFactory</code>
|
|
||||||
</ImpureMethodCall>
|
|
||||||
<UnusedMethodCall occurrences="1">
|
|
||||||
<code>unserialize</code>
|
|
||||||
</UnusedMethodCall>
|
|
||||||
</file>
|
|
||||||
<file src="src/UuidFactory.php">
|
|
||||||
<ImpurePropertyFetch occurrences="7">
|
|
||||||
<code>$this->codec</code>
|
|
||||||
<code>$this->codec</code>
|
|
||||||
<code>$this->codec</code>
|
|
||||||
<code>$this->isDefaultFeatureSet</code>
|
|
||||||
<code>$this->nameGenerator</code>
|
|
||||||
<code>$this->numberConverter</code>
|
|
||||||
<code>$this->uuidBuilder</code>
|
|
||||||
</ImpurePropertyFetch>
|
|
||||||
<ImpureVariable occurrences="13">
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
<code>$this</code>
|
|
||||||
</ImpureVariable>
|
|
||||||
</file>
|
|
||||||
</files>
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<psalm xmlns="https://getpsalm.org/schema/config"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
|
|
||||||
errorLevel="1"
|
|
||||||
cacheDirectory="./build/cache/psalm"
|
|
||||||
errorBaseline="psalm-baseline.xml"
|
|
||||||
phpVersion="8.1">
|
|
||||||
|
|
||||||
<projectFiles>
|
|
||||||
<directory name="./src" />
|
|
||||||
<directory name="./tests/static-analysis"/>
|
|
||||||
<ignoreFiles>
|
|
||||||
<file name="./tests/static-analysis/stubs.php"/>
|
|
||||||
</ignoreFiles>
|
|
||||||
</projectFiles>
|
|
||||||
|
|
||||||
<stubs>
|
|
||||||
<file name="./tests/static-analysis/stubs.php"/>
|
|
||||||
</stubs>
|
|
||||||
|
|
||||||
</psalm>
|
|
||||||
@@ -28,8 +28,6 @@ class BinaryUtils
|
|||||||
* variant is applied
|
* variant is applied
|
||||||
*
|
*
|
||||||
* @return int The 16-bit clock sequence multiplexed with the UUID variant
|
* @return int The 16-bit clock sequence multiplexed with the UUID variant
|
||||||
*
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
*/
|
||||||
public static function applyVariant(int $clockSeq): int
|
public static function applyVariant(int $clockSeq): int
|
||||||
{
|
{
|
||||||
@@ -50,8 +48,6 @@ class BinaryUtils
|
|||||||
*
|
*
|
||||||
* @return int The 16-bit time_hi field of the timestamp multiplexed with
|
* @return int The 16-bit time_hi field of the timestamp multiplexed with
|
||||||
* the UUID version number
|
* the UUID version number
|
||||||
*
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
*/
|
||||||
public static function applyVersion(int $timeHi, int $version): int
|
public static function applyVersion(int $timeHi, int $version): int
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ use Traversable;
|
|||||||
/**
|
/**
|
||||||
* A collection of UuidBuilderInterface objects
|
* A collection of UuidBuilderInterface objects
|
||||||
*
|
*
|
||||||
* @deprecated this class has been deprecated, and will be removed in 5.0.0. The use-case for this class comes from
|
* @deprecated this class has been deprecated and will be removed in 5.0.0. The use-case for this class comes from
|
||||||
* a pre-`phpstan/phpstan` and pre-`vimeo/psalm` ecosystem, in which type safety had to be mostly enforced
|
* a pre-`phpstan/phpstan` and pre-`vimeo/psalm` ecosystem, in which type safety had to be mostly enforced
|
||||||
* at runtime: that is no longer necessary, now that you can safely verify your code to be correct, and use
|
* at runtime: that is no longer necessary, now that you can safely verify your code to be correct, and use
|
||||||
* more generic types like `iterable<T>` instead.
|
* more generic types like `iterable<T>` instead.
|
||||||
@@ -41,11 +41,6 @@ class BuilderCollection extends AbstractCollection
|
|||||||
return UuidBuilderInterface::class;
|
return UuidBuilderInterface::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @psalm-mutation-free
|
|
||||||
* @psalm-suppress ImpureMethodCall
|
|
||||||
* @psalm-suppress InvalidTemplateParam
|
|
||||||
*/
|
|
||||||
public function getIterator(): Traversable
|
public function getIterator(): Traversable
|
||||||
{
|
{
|
||||||
return parent::getIterator();
|
return parent::getIterator();
|
||||||
@@ -56,9 +51,6 @@ class BuilderCollection extends AbstractCollection
|
|||||||
*
|
*
|
||||||
* @param string $serialized The serialized PHP string to unserialize into
|
* @param string $serialized The serialized PHP string to unserialize into
|
||||||
* a UuidInterface instance
|
* a UuidInterface instance
|
||||||
*
|
|
||||||
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
|
||||||
* @psalm-suppress RedundantConditionGivenDocblockType
|
|
||||||
*/
|
*/
|
||||||
public function unserialize($serialized): void
|
public function unserialize($serialized): void
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ use Ramsey\Uuid\Rfc4122\UuidBuilder as Rfc4122UuidBuilder;
|
|||||||
/**
|
/**
|
||||||
* @deprecated Transition to {@see Rfc4122UuidBuilder}.
|
* @deprecated Transition to {@see Rfc4122UuidBuilder}.
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
class DefaultUuidBuilder extends Rfc4122UuidBuilder
|
class DefaultUuidBuilder extends Rfc4122UuidBuilder
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ use Ramsey\Uuid\UuidInterface;
|
|||||||
* @deprecated DegradedUuid instances are no longer necessary to support 32-bit
|
* @deprecated DegradedUuid instances are no longer necessary to support 32-bit
|
||||||
* systems. Transition to {@see DefaultUuidBuilder}.
|
* systems. Transition to {@see DefaultUuidBuilder}.
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
class DegradedUuidBuilder implements UuidBuilderInterface
|
class DegradedUuidBuilder implements UuidBuilderInterface
|
||||||
{
|
{
|
||||||
@@ -52,8 +52,6 @@ class DegradedUuidBuilder implements UuidBuilderInterface
|
|||||||
* @param string $bytes The byte string from which to construct a UUID
|
* @param string $bytes The byte string from which to construct a UUID
|
||||||
*
|
*
|
||||||
* @return DegradedUuid The DegradedUuidBuild returns an instance of Ramsey\Uuid\DegradedUuid
|
* @return DegradedUuid The DegradedUuidBuild returns an instance of Ramsey\Uuid\DegradedUuid
|
||||||
*
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
*/
|
||||||
public function build(CodecInterface $codec, string $bytes): UuidInterface
|
public function build(CodecInterface $codec, string $bytes): UuidInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use Ramsey\Uuid\UuidInterface;
|
|||||||
* FallbackBuilder builds a UUID by stepping through a list of UUID builders
|
* FallbackBuilder builds a UUID by stepping through a list of UUID builders
|
||||||
* until a UUID can be constructed without exceptions
|
* until a UUID can be constructed without exceptions
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
class FallbackBuilder implements UuidBuilderInterface
|
class FallbackBuilder implements UuidBuilderInterface
|
||||||
{
|
{
|
||||||
@@ -42,8 +42,6 @@ class FallbackBuilder implements UuidBuilderInterface
|
|||||||
* @param string $bytes The byte string from which to construct a UUID
|
* @param string $bytes The byte string from which to construct a UUID
|
||||||
*
|
*
|
||||||
* @return UuidInterface an instance of a UUID object
|
* @return UuidInterface an instance of a UUID object
|
||||||
*
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
*/
|
||||||
public function build(CodecInterface $codec, string $bytes): UuidInterface
|
public function build(CodecInterface $codec, string $bytes): UuidInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ use Ramsey\Uuid\UuidInterface;
|
|||||||
/**
|
/**
|
||||||
* A UUID builder builds instances of UuidInterface
|
* A UUID builder builds instances of UuidInterface
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
interface UuidBuilderInterface
|
interface UuidBuilderInterface
|
||||||
{
|
{
|
||||||
@@ -32,8 +32,6 @@ interface UuidBuilderInterface
|
|||||||
*
|
*
|
||||||
* @return UuidInterface Implementations may choose to return more specific
|
* @return UuidInterface Implementations may choose to return more specific
|
||||||
* instances of UUIDs that implement UuidInterface
|
* instances of UUIDs that implement UuidInterface
|
||||||
*
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
*/
|
||||||
public function build(CodecInterface $codec, string $bytes): UuidInterface;
|
public function build(CodecInterface $codec, string $bytes): UuidInterface;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ use Ramsey\Uuid\UuidInterface;
|
|||||||
/**
|
/**
|
||||||
* A codec encodes and decodes a UUID according to defined rules
|
* A codec encodes and decodes a UUID according to defined rules
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
interface CodecInterface
|
interface CodecInterface
|
||||||
{
|
{
|
||||||
@@ -29,9 +29,7 @@ interface CodecInterface
|
|||||||
* @param UuidInterface $uuid The UUID for which to create a hexadecimal
|
* @param UuidInterface $uuid The UUID for which to create a hexadecimal
|
||||||
* string representation
|
* string representation
|
||||||
*
|
*
|
||||||
* @return string Hexadecimal string representation of a UUID
|
* @return non-empty-string Hexadecimal string representation of a UUID
|
||||||
*
|
|
||||||
* @psalm-return non-empty-string
|
|
||||||
*/
|
*/
|
||||||
public function encode(UuidInterface $uuid): string;
|
public function encode(UuidInterface $uuid): string;
|
||||||
|
|
||||||
@@ -41,9 +39,7 @@ interface CodecInterface
|
|||||||
* @param UuidInterface $uuid The UUID for which to create a binary string
|
* @param UuidInterface $uuid The UUID for which to create a binary string
|
||||||
* representation
|
* representation
|
||||||
*
|
*
|
||||||
* @return string Binary string representation of a UUID
|
* @return non-empty-string Binary string representation of a UUID
|
||||||
*
|
|
||||||
* @psalm-return non-empty-string
|
|
||||||
*/
|
*/
|
||||||
public function encodeBinary(UuidInterface $uuid): string;
|
public function encodeBinary(UuidInterface $uuid): string;
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ use function substr;
|
|||||||
*
|
*
|
||||||
* @see Guid
|
* @see Guid
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
class GuidStringCodec extends StringCodec
|
class GuidStringCodec extends StringCodec
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ use function substr;
|
|||||||
*
|
*
|
||||||
* @link https://www.percona.com/blog/2014/12/19/store-uuid-optimized-way/ Storing UUID Values in MySQL
|
* @link https://www.percona.com/blog/2014/12/19/store-uuid-optimized-way/ Storing UUID Values in MySQL
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
class OrderedTimeCodec extends StringCodec
|
class OrderedTimeCodec extends StringCodec
|
||||||
{
|
{
|
||||||
@@ -49,10 +49,7 @@ class OrderedTimeCodec extends StringCodec
|
|||||||
* Returns a binary string representation of a UUID, with the timestamp
|
* Returns a binary string representation of a UUID, with the timestamp
|
||||||
* fields rearranged for optimized storage
|
* fields rearranged for optimized storage
|
||||||
*
|
*
|
||||||
* @inheritDoc
|
* @return non-empty-string
|
||||||
* @psalm-return non-empty-string
|
|
||||||
* @psalm-suppress MoreSpecificReturnType we know that the retrieved `string` is never empty
|
|
||||||
* @psalm-suppress LessSpecificReturnStatement we know that the retrieved `string` is never empty
|
|
||||||
*/
|
*/
|
||||||
public function encodeBinary(UuidInterface $uuid): string
|
public function encodeBinary(UuidInterface $uuid): string
|
||||||
{
|
{
|
||||||
@@ -67,7 +64,7 @@ class OrderedTimeCodec extends StringCodec
|
|||||||
|
|
||||||
$bytes = $uuid->getFields()->getBytes();
|
$bytes = $uuid->getFields()->getBytes();
|
||||||
|
|
||||||
/** @phpstan-ignore-next-line PHPStan complains that this is not a non-empty-string. */
|
/** @var non-empty-string */
|
||||||
return $bytes[6] . $bytes[7]
|
return $bytes[6] . $bytes[7]
|
||||||
. $bytes[4] . $bytes[5]
|
. $bytes[4] . $bytes[5]
|
||||||
. $bytes[0] . $bytes[1] . $bytes[2] . $bytes[3]
|
. $bytes[0] . $bytes[1] . $bytes[2] . $bytes[3]
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ use function substr;
|
|||||||
*
|
*
|
||||||
* @link http://tools.ietf.org/html/rfc4122
|
* @link http://tools.ietf.org/html/rfc4122
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
class StringCodec implements CodecInterface
|
class StringCodec implements CodecInterface
|
||||||
{
|
{
|
||||||
@@ -62,9 +62,7 @@ class StringCodec implements CodecInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @psalm-return non-empty-string
|
* @return non-empty-string
|
||||||
* @psalm-suppress MoreSpecificReturnType we know that the retrieved `string` is never empty
|
|
||||||
* @psalm-suppress LessSpecificReturnStatement we know that the retrieved `string` is never empty
|
|
||||||
*/
|
*/
|
||||||
public function encodeBinary(UuidInterface $uuid): string
|
public function encodeBinary(UuidInterface $uuid): string
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -46,14 +46,12 @@ use function substr_replace;
|
|||||||
*
|
*
|
||||||
* @link https://www.informit.com/articles/printerfriendly/25862 The Cost of GUIDs as Primary Keys
|
* @link https://www.informit.com/articles/printerfriendly/25862 The Cost of GUIDs as Primary Keys
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
class TimestampFirstCombCodec extends StringCodec
|
class TimestampFirstCombCodec extends StringCodec
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @psalm-return non-empty-string
|
* @return non-empty-string
|
||||||
* @psalm-suppress MoreSpecificReturnType we know that the retrieved `string` is never empty
|
|
||||||
* @psalm-suppress LessSpecificReturnStatement we know that the retrieved `string` is never empty
|
|
||||||
*/
|
*/
|
||||||
public function encode(UuidInterface $uuid): string
|
public function encode(UuidInterface $uuid): string
|
||||||
{
|
{
|
||||||
@@ -70,9 +68,7 @@ class TimestampFirstCombCodec extends StringCodec
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @psalm-return non-empty-string
|
* @return non-empty-string
|
||||||
* @psalm-suppress MoreSpecificReturnType we know that the retrieved `string` is never empty
|
|
||||||
* @psalm-suppress LessSpecificReturnStatement we know that the retrieved `string` is never empty
|
|
||||||
*/
|
*/
|
||||||
public function encodeBinary(UuidInterface $uuid): string
|
public function encodeBinary(UuidInterface $uuid): string
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace Ramsey\Uuid\Codec;
|
|||||||
*
|
*
|
||||||
* @link https://www.informit.com/articles/printerfriendly/25862 The Cost of GUIDs as Primary Keys
|
* @link https://www.informit.com/articles/printerfriendly/25862 The Cost of GUIDs as Primary Keys
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
class TimestampLastCombCodec extends StringCodec
|
class TimestampLastCombCodec extends StringCodec
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use Ramsey\Uuid\Math\BrickMathCalculator;
|
|||||||
*
|
*
|
||||||
* @deprecated Transition to {@see GenericNumberConverter}.
|
* @deprecated Transition to {@see GenericNumberConverter}.
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
class BigNumberConverter implements NumberConverterInterface
|
class BigNumberConverter implements NumberConverterInterface
|
||||||
{
|
{
|
||||||
@@ -34,19 +34,11 @@ class BigNumberConverter implements NumberConverterInterface
|
|||||||
$this->converter = new GenericNumberConverter(new BrickMathCalculator());
|
$this->converter = new GenericNumberConverter(new BrickMathCalculator());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
|
||||||
public function fromHex(string $hex): string
|
public function fromHex(string $hex): string
|
||||||
{
|
{
|
||||||
return $this->converter->fromHex($hex);
|
return $this->converter->fromHex($hex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
|
||||||
public function toHex(string $number): string
|
public function toHex(string $number): string
|
||||||
{
|
{
|
||||||
return $this->converter->toHex($number);
|
return $this->converter->toHex($number);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace Ramsey\Uuid\Converter\Number;
|
|||||||
* @deprecated DegradedNumberConverter is no longer necessary for converting
|
* @deprecated DegradedNumberConverter is no longer necessary for converting
|
||||||
* numbers on 32-bit systems. Transition to {@see GenericNumberConverter}.
|
* numbers on 32-bit systems. Transition to {@see GenericNumberConverter}.
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
class DegradedNumberConverter extends BigNumberConverter
|
class DegradedNumberConverter extends BigNumberConverter
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ use Ramsey\Uuid\Type\Integer as IntegerObject;
|
|||||||
* GenericNumberConverter uses the provided calculator to convert decimal
|
* GenericNumberConverter uses the provided calculator to convert decimal
|
||||||
* numbers to and from hexadecimal values
|
* numbers to and from hexadecimal values
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
class GenericNumberConverter implements NumberConverterInterface
|
class GenericNumberConverter implements NumberConverterInterface
|
||||||
{
|
{
|
||||||
@@ -30,25 +30,11 @@ class GenericNumberConverter implements NumberConverterInterface
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
* @psalm-pure
|
|
||||||
* @psalm-return numeric-string
|
|
||||||
* @psalm-suppress MoreSpecificReturnType we know that the retrieved `string` is never empty
|
|
||||||
* @psalm-suppress LessSpecificReturnStatement we know that the retrieved `string` is never empty
|
|
||||||
*/
|
|
||||||
public function fromHex(string $hex): string
|
public function fromHex(string $hex): string
|
||||||
{
|
{
|
||||||
return $this->calculator->fromBase($hex, 16)->toString();
|
return $this->calculator->fromBase($hex, 16)->toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
* @psalm-pure
|
|
||||||
* @psalm-return non-empty-string
|
|
||||||
* @psalm-suppress MoreSpecificReturnType we know that the retrieved `string` is never empty
|
|
||||||
* @psalm-suppress LessSpecificReturnStatement we know that the retrieved `string` is never empty
|
|
||||||
*/
|
|
||||||
public function toHex(string $number): string
|
public function toHex(string $number): string
|
||||||
{
|
{
|
||||||
/** @phpstan-ignore-next-line PHPStan complains that this is not a non-empty-string. */
|
/** @phpstan-ignore-next-line PHPStan complains that this is not a non-empty-string. */
|
||||||
|
|||||||
@@ -18,24 +18,20 @@ namespace Ramsey\Uuid\Converter;
|
|||||||
* A number converter converts UUIDs from hexadecimal characters into
|
* A number converter converts UUIDs from hexadecimal characters into
|
||||||
* representations of integers and vice versa
|
* representations of integers and vice versa
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
interface NumberConverterInterface
|
interface NumberConverterInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Converts a hexadecimal number into an string integer representation of
|
* Converts a hexadecimal number into a string integer representation of
|
||||||
* the number
|
* the number
|
||||||
*
|
*
|
||||||
* The integer representation returned is a string representation of the
|
* The integer representation returned is a string representation of the
|
||||||
* integer, to accommodate unsigned integers greater than PHP_INT_MAX.
|
* integer to accommodate unsigned integers greater than PHP_INT_MAX.
|
||||||
*
|
*
|
||||||
* @param string $hex The hexadecimal string representation to convert
|
* @param string $hex The hexadecimal string representation to convert
|
||||||
*
|
*
|
||||||
* @return string String representation of an integer
|
* @return numeric-string String representation of an integer
|
||||||
*
|
|
||||||
* @psalm-return numeric-string
|
|
||||||
*
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
*/
|
||||||
public function fromHex(string $hex): string;
|
public function fromHex(string $hex): string;
|
||||||
|
|
||||||
@@ -47,11 +43,7 @@ interface NumberConverterInterface
|
|||||||
* must be a numeric string to accommodate unsigned integers greater
|
* must be a numeric string to accommodate unsigned integers greater
|
||||||
* than PHP_INT_MAX.
|
* than PHP_INT_MAX.
|
||||||
*
|
*
|
||||||
* @return string Hexadecimal string
|
* @return non-empty-string Hexadecimal string
|
||||||
*
|
|
||||||
* @psalm-return non-empty-string
|
|
||||||
*
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
*/
|
||||||
public function toHex(string $number): string;
|
public function toHex(string $number): string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ use Ramsey\Uuid\Type\Time;
|
|||||||
*
|
*
|
||||||
* @deprecated Transition to {@see GenericTimeConverter}.
|
* @deprecated Transition to {@see GenericTimeConverter}.
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
class BigNumberTimeConverter implements TimeConverterInterface
|
class BigNumberTimeConverter implements TimeConverterInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace Ramsey\Uuid\Converter\Time;
|
|||||||
* @deprecated DegradedTimeConverter is no longer necessary for converting
|
* @deprecated DegradedTimeConverter is no longer necessary for converting
|
||||||
* time on 32-bit systems. Transition to {@see GenericTimeConverter}.
|
* time on 32-bit systems. Transition to {@see GenericTimeConverter}.
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
class DegradedTimeConverter extends BigNumberTimeConverter
|
class DegradedTimeConverter extends BigNumberTimeConverter
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ use const STR_PAD_LEFT;
|
|||||||
* GenericTimeConverter uses the provided calculator to calculate and convert
|
* GenericTimeConverter uses the provided calculator to calculate and convert
|
||||||
* time values
|
* time values
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
class GenericTimeConverter implements TimeConverterInterface
|
class GenericTimeConverter implements TimeConverterInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ use const STR_PAD_RIGHT;
|
|||||||
* available to the PHP programming language to provide facilities for
|
* available to the PHP programming language to provide facilities for
|
||||||
* converting parts of time into representations that may be used in UUIDs
|
* converting parts of time into representations that may be used in UUIDs
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
class PhpTimeConverter implements TimeConverterInterface
|
class PhpTimeConverter implements TimeConverterInterface
|
||||||
{
|
{
|
||||||
@@ -92,7 +92,6 @@ class PhpTimeConverter implements TimeConverterInterface
|
|||||||
|
|
||||||
// Check to see whether we've overflowed the max/min integer size.
|
// Check to see whether we've overflowed the max/min integer size.
|
||||||
// If so, we will default to a different time converter.
|
// If so, we will default to a different time converter.
|
||||||
/** @psalm-suppress RedundantCondition */
|
|
||||||
if (!is_int($uuidTime)) {
|
if (!is_int($uuidTime)) {
|
||||||
return $this->fallbackConverter->calculateTime(
|
return $this->fallbackConverter->calculateTime(
|
||||||
$seconds->toString(),
|
$seconds->toString(),
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ use const STR_PAD_LEFT;
|
|||||||
* UnixTimeConverter converts Unix Epoch timestamps to/from hexadecimal values
|
* UnixTimeConverter converts Unix Epoch timestamps to/from hexadecimal values
|
||||||
* consisting of milliseconds elapsed since the Unix Epoch
|
* consisting of milliseconds elapsed since the Unix Epoch
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
class UnixTimeConverter implements TimeConverterInterface
|
class UnixTimeConverter implements TimeConverterInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ use Ramsey\Uuid\Type\Time;
|
|||||||
* A time converter converts timestamps into representations that may be used
|
* A time converter converts timestamps into representations that may be used
|
||||||
* in UUIDs
|
* in UUIDs
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
interface TimeConverterInterface
|
interface TimeConverterInterface
|
||||||
{
|
{
|
||||||
@@ -38,8 +38,6 @@ interface TimeConverterInterface
|
|||||||
* associated with the time to calculate
|
* associated with the time to calculate
|
||||||
*
|
*
|
||||||
* @return Hexadecimal The full UUID timestamp as a Hexadecimal value
|
* @return Hexadecimal The full UUID timestamp as a Hexadecimal value
|
||||||
*
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
*/
|
||||||
public function calculateTime(string $seconds, string $microseconds): Hexadecimal;
|
public function calculateTime(string $seconds, string $microseconds): Hexadecimal;
|
||||||
|
|
||||||
@@ -51,8 +49,6 @@ interface TimeConverterInterface
|
|||||||
* since UTC 00:00:00.00, 15 October 1582.
|
* since UTC 00:00:00.00, 15 October 1582.
|
||||||
*
|
*
|
||||||
* @return Time An instance of {@see Time}
|
* @return Time An instance of {@see Time}
|
||||||
*
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
*/
|
||||||
public function convertTime(Hexadecimal $uuidTimestamp): Time;
|
public function convertTime(Hexadecimal $uuidTimestamp): Time;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace Ramsey\Uuid;
|
|||||||
* @deprecated DegradedUuid is no longer necessary to represent UUIDs on 32-bit
|
* @deprecated DegradedUuid is no longer necessary to represent UUIDs on 32-bit
|
||||||
* systems. Transition typehints to {@see UuidInterface}.
|
* systems. Transition typehints to {@see UuidInterface}.
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
class DegradedUuid extends Uuid
|
class DegradedUuid extends Uuid
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ use Ramsey\Uuid\Converter\NumberConverterInterface;
|
|||||||
/**
|
/**
|
||||||
* This interface encapsulates deprecated methods for ramsey/uuid
|
* This interface encapsulates deprecated methods for ramsey/uuid
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
interface DeprecatedUuidInterface
|
interface DeprecatedUuidInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ use const STR_PAD_LEFT;
|
|||||||
*
|
*
|
||||||
* @deprecated This trait and its methods will be removed in ramsey/uuid 5.0.0.
|
* @deprecated This trait and its methods will be removed in ramsey/uuid 5.0.0.
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
trait DeprecatedUuidMethodsTrait
|
trait DeprecatedUuidMethodsTrait
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -212,7 +212,6 @@ class FeatureSet
|
|||||||
$this->numberConverter = $this->buildNumberConverter($calculator);
|
$this->numberConverter = $this->buildNumberConverter($calculator);
|
||||||
$this->timeConverter = $this->buildTimeConverter($calculator);
|
$this->timeConverter = $this->buildTimeConverter($calculator);
|
||||||
|
|
||||||
/** @psalm-suppress RedundantPropertyInitializationCheck */
|
|
||||||
if (isset($this->timeProvider)) {
|
if (isset($this->timeProvider)) {
|
||||||
$this->timeGenerator = $this->buildTimeGenerator($this->timeProvider);
|
$this->timeGenerator = $this->buildTimeGenerator($this->timeProvider);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ namespace Ramsey\Uuid\Fields;
|
|||||||
use Serializable;
|
use Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UUIDs are comprised of unsigned integers, the bytes of which are separated
|
* UUIDs consist of unsigned integers, the bytes of which are separated
|
||||||
* into fields and arranged in a particular layout defined by the specification
|
* into fields and arranged in a particular layout defined by the specification
|
||||||
* for the variant
|
* for the variant
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
interface FieldsInterface extends Serializable
|
interface FieldsInterface extends Serializable
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use function strlen;
|
|||||||
/**
|
/**
|
||||||
* Provides common serialization functionality to fields
|
* Provides common serialization functionality to fields
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
trait SerializableFieldsTrait
|
trait SerializableFieldsTrait
|
||||||
{
|
{
|
||||||
@@ -57,8 +57,6 @@ trait SerializableFieldsTrait
|
|||||||
* Constructs the object from a serialized string representation
|
* Constructs the object from a serialized string representation
|
||||||
*
|
*
|
||||||
* @param string $data The serialized string representation of the object
|
* @param string $data The serialized string representation of the object
|
||||||
*
|
|
||||||
* @psalm-suppress UnusedMethodCall
|
|
||||||
*/
|
*/
|
||||||
public function unserialize(string $data): void
|
public function unserialize(string $data): void
|
||||||
{
|
{
|
||||||
@@ -71,8 +69,6 @@ trait SerializableFieldsTrait
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array{bytes?: string} $data
|
* @param array{bytes?: string} $data
|
||||||
*
|
|
||||||
* @psalm-suppress UnusedMethodCall
|
|
||||||
*/
|
*/
|
||||||
public function __unserialize(array $data): void
|
public function __unserialize(array $data): void
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ use function hash;
|
|||||||
*/
|
*/
|
||||||
class DefaultNameGenerator implements NameGeneratorInterface
|
class DefaultNameGenerator implements NameGeneratorInterface
|
||||||
{
|
{
|
||||||
/** @psalm-pure */
|
|
||||||
public function generate(UuidInterface $ns, string $name, string $hashAlgorithm): string
|
public function generate(UuidInterface $ns, string $name, string $hashAlgorithm): string
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -31,8 +31,6 @@ interface NameGeneratorInterface
|
|||||||
* @param string $hashAlgorithm The hashing algorithm to use
|
* @param string $hashAlgorithm The hashing algorithm to use
|
||||||
*
|
*
|
||||||
* @return string A binary string
|
* @return string A binary string
|
||||||
*
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
*/
|
||||||
public function generate(UuidInterface $ns, string $name, string $hashAlgorithm): string;
|
public function generate(UuidInterface $ns, string $name, string $hashAlgorithm): string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ use function uuid_parse;
|
|||||||
*/
|
*/
|
||||||
class PeclUuidNameGenerator implements NameGeneratorInterface
|
class PeclUuidNameGenerator implements NameGeneratorInterface
|
||||||
{
|
{
|
||||||
/** @psalm-pure */
|
|
||||||
public function generate(UuidInterface $ns, string $name, string $hashAlgorithm): string
|
public function generate(UuidInterface $ns, string $name, string $hashAlgorithm): string
|
||||||
{
|
{
|
||||||
$uuid = match ($hashAlgorithm) {
|
$uuid = match ($hashAlgorithm) {
|
||||||
|
|||||||
+1
-1
@@ -41,7 +41,7 @@ use const STR_PAD_LEFT;
|
|||||||
*
|
*
|
||||||
* @see Guid
|
* @see Guid
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
final class Fields implements FieldsInterface
|
final class Fields implements FieldsInterface
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -46,7 +46,7 @@ use Ramsey\Uuid\Uuid;
|
|||||||
* @link https://docs.microsoft.com/en-us/dotnet/api/system.guid .NET Guid Struct
|
* @link https://docs.microsoft.com/en-us/dotnet/api/system.guid .NET Guid Struct
|
||||||
* @link https://docs.microsoft.com/en-us/dotnet/api/system.guid.tobytearray .NET Guid.ToByteArray Method
|
* @link https://docs.microsoft.com/en-us/dotnet/api/system.guid.tobytearray .NET Guid.ToByteArray Method
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
final class Guid extends Uuid
|
final class Guid extends Uuid
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ use Throwable;
|
|||||||
*
|
*
|
||||||
* @see Guid
|
* @see Guid
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
class GuidBuilder implements UuidBuilderInterface
|
class GuidBuilder implements UuidBuilderInterface
|
||||||
{
|
{
|
||||||
@@ -50,8 +50,6 @@ class GuidBuilder implements UuidBuilderInterface
|
|||||||
* @param string $bytes The byte string from which to construct a UUID
|
* @param string $bytes The byte string from which to construct a UUID
|
||||||
*
|
*
|
||||||
* @return Guid The GuidBuilder returns an instance of Ramsey\Uuid\Guid\Guid
|
* @return Guid The GuidBuilder returns an instance of Ramsey\Uuid\Guid\Guid
|
||||||
*
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
*/
|
||||||
public function build(CodecInterface $codec, string $bytes): UuidInterface
|
public function build(CodecInterface $codec, string $bytes): UuidInterface
|
||||||
{
|
{
|
||||||
|
|||||||
+39
-147
@@ -41,16 +41,13 @@ use function substr;
|
|||||||
* @internal this type is used internally for performance reasons, and is not supposed to be directly referenced
|
* @internal this type is used internally for performance reasons, and is not supposed to be directly referenced
|
||||||
* in consumer libraries.
|
* in consumer libraries.
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*
|
*
|
||||||
* Note: the {@see FieldsInterface} does not declare methods that deprecated API
|
* Note: the {@see FieldsInterface} does not declare methods that deprecated API
|
||||||
* relies upon: the API has been ported from the {@see \Ramsey\Uuid\Uuid} definition,
|
* relies upon: the API has been ported from the {@see \Ramsey\Uuid\Uuid} definition,
|
||||||
* and is deprecated anyway.
|
* and is deprecated anyway.
|
||||||
* Note: the deprecated API from {@see \Ramsey\Uuid\Uuid} is in use here (on purpose): it will be removed
|
* Note: the deprecated API from {@see \Ramsey\Uuid\Uuid} is in use here (on purpose): it will be removed
|
||||||
* once the deprecated API is gone from this class too.
|
* once the deprecated API is gone from this class too.
|
||||||
*
|
|
||||||
* @psalm-suppress UndefinedInterfaceMethod
|
|
||||||
* @psalm-suppress DeprecatedMethod
|
|
||||||
*/
|
*/
|
||||||
final class LazyUuidFromString implements UuidInterface
|
final class LazyUuidFromString implements UuidInterface
|
||||||
{
|
{
|
||||||
@@ -59,13 +56,12 @@ final class LazyUuidFromString implements UuidInterface
|
|||||||
private ?UuidInterface $unwrapped = null;
|
private ?UuidInterface $unwrapped = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @psalm-param non-empty-string $uuid
|
* @param non-empty-string $uuid
|
||||||
*/
|
*/
|
||||||
public function __construct(private string $uuid)
|
public function __construct(private string $uuid)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @psalm-pure */
|
|
||||||
public static function fromBytes(string $bytes): self
|
public static function fromBytes(string $bytes): self
|
||||||
{
|
{
|
||||||
$base16Uuid = bin2hex($bytes);
|
$base16Uuid = bin2hex($bytes);
|
||||||
@@ -89,9 +85,7 @@ final class LazyUuidFromString implements UuidInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array{string: string}
|
* @return array{string: non-empty-string}
|
||||||
*
|
|
||||||
* @psalm-return array{string: non-empty-string}
|
|
||||||
*/
|
*/
|
||||||
public function __serialize(): array
|
public function __serialize(): array
|
||||||
{
|
{
|
||||||
@@ -101,9 +95,7 @@ final class LazyUuidFromString implements UuidInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
* @param string $data
|
* @param non-empty-string $data
|
||||||
*
|
|
||||||
* @psalm-param non-empty-string $data
|
|
||||||
*/
|
*/
|
||||||
public function unserialize(string $data): void
|
public function unserialize(string $data): void
|
||||||
{
|
{
|
||||||
@@ -111,10 +103,7 @@ final class LazyUuidFromString implements UuidInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array{string?: string} $data
|
* @param array{string?: non-empty-string} $data
|
||||||
*
|
|
||||||
* @psalm-param array{string?: non-empty-string} $data
|
|
||||||
* @psalm-suppress UnusedMethodCall
|
|
||||||
*/
|
*/
|
||||||
public function __unserialize(array $data): void
|
public function __unserialize(array $data): void
|
||||||
{
|
{
|
||||||
@@ -127,7 +116,6 @@ final class LazyUuidFromString implements UuidInterface
|
|||||||
$this->unserialize($data['string']);
|
$this->unserialize($data['string']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @psalm-suppress DeprecatedMethod */
|
|
||||||
public function getNumberConverter(): NumberConverterInterface
|
public function getNumberConverter(): NumberConverterInterface
|
||||||
{
|
{
|
||||||
return ($this->unwrapped ?? $this->unwrap())
|
return ($this->unwrapped ?? $this->unwrap())
|
||||||
@@ -135,9 +123,7 @@ final class LazyUuidFromString implements UuidInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* @inheritDoc
|
||||||
*
|
|
||||||
* @psalm-suppress DeprecatedMethod
|
|
||||||
*/
|
*/
|
||||||
public function getFieldsHex(): array
|
public function getFieldsHex(): array
|
||||||
{
|
{
|
||||||
@@ -145,98 +131,84 @@ final class LazyUuidFromString implements UuidInterface
|
|||||||
->getFieldsHex();
|
->getFieldsHex();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @psalm-suppress DeprecatedMethod */
|
|
||||||
public function getClockSeqHiAndReservedHex(): string
|
public function getClockSeqHiAndReservedHex(): string
|
||||||
{
|
{
|
||||||
return ($this->unwrapped ?? $this->unwrap())
|
return ($this->unwrapped ?? $this->unwrap())
|
||||||
->getClockSeqHiAndReservedHex();
|
->getClockSeqHiAndReservedHex();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @psalm-suppress DeprecatedMethod */
|
|
||||||
public function getClockSeqLowHex(): string
|
public function getClockSeqLowHex(): string
|
||||||
{
|
{
|
||||||
return ($this->unwrapped ?? $this->unwrap())
|
return ($this->unwrapped ?? $this->unwrap())
|
||||||
->getClockSeqLowHex();
|
->getClockSeqLowHex();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @psalm-suppress DeprecatedMethod */
|
|
||||||
public function getClockSequenceHex(): string
|
public function getClockSequenceHex(): string
|
||||||
{
|
{
|
||||||
return ($this->unwrapped ?? $this->unwrap())
|
return ($this->unwrapped ?? $this->unwrap())
|
||||||
->getClockSequenceHex();
|
->getClockSequenceHex();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @psalm-suppress DeprecatedMethod */
|
|
||||||
public function getDateTime(): DateTimeInterface
|
public function getDateTime(): DateTimeInterface
|
||||||
{
|
{
|
||||||
return ($this->unwrapped ?? $this->unwrap())
|
return ($this->unwrapped ?? $this->unwrap())
|
||||||
->getDateTime();
|
->getDateTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @psalm-suppress DeprecatedMethod */
|
|
||||||
public function getLeastSignificantBitsHex(): string
|
public function getLeastSignificantBitsHex(): string
|
||||||
{
|
{
|
||||||
return ($this->unwrapped ?? $this->unwrap())
|
return ($this->unwrapped ?? $this->unwrap())
|
||||||
->getLeastSignificantBitsHex();
|
->getLeastSignificantBitsHex();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @psalm-suppress DeprecatedMethod */
|
|
||||||
public function getMostSignificantBitsHex(): string
|
public function getMostSignificantBitsHex(): string
|
||||||
{
|
{
|
||||||
return ($this->unwrapped ?? $this->unwrap())
|
return ($this->unwrapped ?? $this->unwrap())
|
||||||
->getMostSignificantBitsHex();
|
->getMostSignificantBitsHex();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @psalm-suppress DeprecatedMethod */
|
|
||||||
public function getNodeHex(): string
|
public function getNodeHex(): string
|
||||||
{
|
{
|
||||||
return ($this->unwrapped ?? $this->unwrap())
|
return ($this->unwrapped ?? $this->unwrap())
|
||||||
->getNodeHex();
|
->getNodeHex();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @psalm-suppress DeprecatedMethod */
|
|
||||||
public function getTimeHiAndVersionHex(): string
|
public function getTimeHiAndVersionHex(): string
|
||||||
{
|
{
|
||||||
return ($this->unwrapped ?? $this->unwrap())
|
return ($this->unwrapped ?? $this->unwrap())
|
||||||
->getTimeHiAndVersionHex();
|
->getTimeHiAndVersionHex();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @psalm-suppress DeprecatedMethod */
|
|
||||||
public function getTimeLowHex(): string
|
public function getTimeLowHex(): string
|
||||||
{
|
{
|
||||||
return ($this->unwrapped ?? $this->unwrap())
|
return ($this->unwrapped ?? $this->unwrap())
|
||||||
->getTimeLowHex();
|
->getTimeLowHex();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @psalm-suppress DeprecatedMethod */
|
|
||||||
public function getTimeMidHex(): string
|
public function getTimeMidHex(): string
|
||||||
{
|
{
|
||||||
return ($this->unwrapped ?? $this->unwrap())
|
return ($this->unwrapped ?? $this->unwrap())
|
||||||
->getTimeMidHex();
|
->getTimeMidHex();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @psalm-suppress DeprecatedMethod */
|
|
||||||
public function getTimestampHex(): string
|
public function getTimestampHex(): string
|
||||||
{
|
{
|
||||||
return ($this->unwrapped ?? $this->unwrap())
|
return ($this->unwrapped ?? $this->unwrap())
|
||||||
->getTimestampHex();
|
->getTimestampHex();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @psalm-suppress DeprecatedMethod */
|
|
||||||
public function getUrn(): string
|
public function getUrn(): string
|
||||||
{
|
{
|
||||||
return ($this->unwrapped ?? $this->unwrap())
|
return ($this->unwrapped ?? $this->unwrap())
|
||||||
->getUrn();
|
->getUrn();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @psalm-suppress DeprecatedMethod */
|
|
||||||
public function getVariant(): ?int
|
public function getVariant(): ?int
|
||||||
{
|
{
|
||||||
return ($this->unwrapped ?? $this->unwrap())
|
return ($this->unwrapped ?? $this->unwrap())
|
||||||
->getVariant();
|
->getVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @psalm-suppress DeprecatedMethod */
|
|
||||||
public function getVersion(): ?int
|
public function getVersion(): ?int
|
||||||
{
|
{
|
||||||
return ($this->unwrapped ?? $this->unwrap())
|
return ($this->unwrapped ?? $this->unwrap())
|
||||||
@@ -258,16 +230,9 @@ final class LazyUuidFromString implements UuidInterface
|
|||||||
return $this->uuid === $other->toString();
|
return $this->uuid === $other->toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* @psalm-suppress MoreSpecificReturnType
|
|
||||||
* @psalm-suppress LessSpecificReturnStatement we know that {@see self::$uuid} is a non-empty string, so
|
|
||||||
* we know that {@see hex2bin} will retrieve a non-empty string too.
|
|
||||||
*/
|
|
||||||
public function getBytes(): string
|
public function getBytes(): string
|
||||||
{
|
{
|
||||||
/** @phpstan-ignore-next-line PHPStan complains that this is not a non-empty-string. */
|
/** @var non-empty-string */
|
||||||
return (string) hex2bin(str_replace('-', '', $this->uuid));
|
return (string) hex2bin(str_replace('-', '', $this->uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,22 +275,15 @@ final class LazyUuidFromString implements UuidInterface
|
|||||||
* instance, you may call {@see Rfc4122FieldsInterface::getClockSeqHiAndReserved()}
|
* instance, you may call {@see Rfc4122FieldsInterface::getClockSeqHiAndReserved()}
|
||||||
* and use the arbitrary-precision math library of your choice to
|
* and use the arbitrary-precision math library of your choice to
|
||||||
* convert it to a string integer.
|
* convert it to a string integer.
|
||||||
*
|
|
||||||
* @psalm-suppress UndefinedInterfaceMethod
|
|
||||||
* @psalm-suppress DeprecatedMethod
|
|
||||||
* @psalm-suppress MixedArgument
|
|
||||||
* @psalm-suppress MixedMethodCall
|
|
||||||
*/
|
*/
|
||||||
public function getClockSeqHiAndReserved(): string
|
public function getClockSeqHiAndReserved(): string
|
||||||
{
|
{
|
||||||
$instance = ($this->unwrapped ?? $this->unwrap());
|
$instance = ($this->unwrapped ?? $this->unwrap());
|
||||||
|
|
||||||
return $instance->getNumberConverter()
|
$fields = $instance->getFields();
|
||||||
->fromHex(
|
assert($fields instanceof \Ramsey\Uuid\Rfc4122\FieldsInterface);
|
||||||
$instance->getFields()
|
|
||||||
->getClockSeqHiAndReserved()
|
return $instance->getNumberConverter()->fromHex($fields->getClockSeqHiAndReserved()->toString());
|
||||||
->toString()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -334,22 +292,15 @@ final class LazyUuidFromString implements UuidInterface
|
|||||||
* instance, you may call {@see Rfc4122FieldsInterface::getClockSeqLow()}
|
* instance, you may call {@see Rfc4122FieldsInterface::getClockSeqLow()}
|
||||||
* and use the arbitrary-precision math library of your choice to
|
* and use the arbitrary-precision math library of your choice to
|
||||||
* convert it to a string integer.
|
* convert it to a string integer.
|
||||||
*
|
|
||||||
* @psalm-suppress UndefinedInterfaceMethod
|
|
||||||
* @psalm-suppress DeprecatedMethod
|
|
||||||
* @psalm-suppress MixedArgument
|
|
||||||
* @psalm-suppress MixedMethodCall
|
|
||||||
*/
|
*/
|
||||||
public function getClockSeqLow(): string
|
public function getClockSeqLow(): string
|
||||||
{
|
{
|
||||||
$instance = ($this->unwrapped ?? $this->unwrap());
|
$instance = ($this->unwrapped ?? $this->unwrap());
|
||||||
|
|
||||||
return $instance->getNumberConverter()
|
$fields = $instance->getFields();
|
||||||
->fromHex(
|
assert($fields instanceof \Ramsey\Uuid\Rfc4122\FieldsInterface);
|
||||||
$instance->getFields()
|
|
||||||
->getClockSeqLow()
|
return $instance->getNumberConverter()->fromHex($fields->getClockSeqLow()->toString());
|
||||||
->toString()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -358,33 +309,21 @@ final class LazyUuidFromString implements UuidInterface
|
|||||||
* instance, you may call {@see Rfc4122FieldsInterface::getClockSeq()}
|
* instance, you may call {@see Rfc4122FieldsInterface::getClockSeq()}
|
||||||
* and use the arbitrary-precision math library of your choice to
|
* and use the arbitrary-precision math library of your choice to
|
||||||
* convert it to a string integer.
|
* convert it to a string integer.
|
||||||
*
|
|
||||||
* @psalm-suppress UndefinedInterfaceMethod
|
|
||||||
* @psalm-suppress DeprecatedMethod
|
|
||||||
* @psalm-suppress MixedArgument
|
|
||||||
* @psalm-suppress MixedMethodCall
|
|
||||||
*/
|
*/
|
||||||
public function getClockSequence(): string
|
public function getClockSequence(): string
|
||||||
{
|
{
|
||||||
$instance = ($this->unwrapped ?? $this->unwrap());
|
$instance = ($this->unwrapped ?? $this->unwrap());
|
||||||
|
|
||||||
return $instance->getNumberConverter()
|
$fields = $instance->getFields();
|
||||||
->fromHex(
|
assert($fields instanceof \Ramsey\Uuid\Rfc4122\FieldsInterface);
|
||||||
$instance->getFields()
|
|
||||||
->getClockSeq()
|
return $instance->getNumberConverter()->fromHex($fields->getClockSeq()->toString());
|
||||||
->toString()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated This method will be removed in 5.0.0. There is no direct
|
* @deprecated This method will be removed in 5.0.0. There is no direct
|
||||||
* alternative, but the same information may be obtained by splitting
|
* alternative, but the same information may be obtained by splitting
|
||||||
* in half the value returned by {@see UuidInterface::getHex()}.
|
* in half the value returned by {@see UuidInterface::getHex()}.
|
||||||
*
|
|
||||||
* @psalm-suppress UndefinedInterfaceMethod
|
|
||||||
* @psalm-suppress DeprecatedMethod
|
|
||||||
* @psalm-suppress MixedArgument
|
|
||||||
* @psalm-suppress MixedMethodCall
|
|
||||||
*/
|
*/
|
||||||
public function getLeastSignificantBits(): string
|
public function getLeastSignificantBits(): string
|
||||||
{
|
{
|
||||||
@@ -398,11 +337,6 @@ final class LazyUuidFromString implements UuidInterface
|
|||||||
* @deprecated This method will be removed in 5.0.0. There is no direct
|
* @deprecated This method will be removed in 5.0.0. There is no direct
|
||||||
* alternative, but the same information may be obtained by splitting
|
* alternative, but the same information may be obtained by splitting
|
||||||
* in half the value returned by {@see UuidInterface::getHex()}.
|
* in half the value returned by {@see UuidInterface::getHex()}.
|
||||||
*
|
|
||||||
* @psalm-suppress UndefinedInterfaceMethod
|
|
||||||
* @psalm-suppress DeprecatedMethod
|
|
||||||
* @psalm-suppress MixedArgument
|
|
||||||
* @psalm-suppress MixedMethodCall
|
|
||||||
*/
|
*/
|
||||||
public function getMostSignificantBits(): string
|
public function getMostSignificantBits(): string
|
||||||
{
|
{
|
||||||
@@ -418,22 +352,15 @@ final class LazyUuidFromString implements UuidInterface
|
|||||||
* instance, you may call {@see Rfc4122FieldsInterface::getNode()}
|
* instance, you may call {@see Rfc4122FieldsInterface::getNode()}
|
||||||
* and use the arbitrary-precision math library of your choice to
|
* and use the arbitrary-precision math library of your choice to
|
||||||
* convert it to a string integer.
|
* convert it to a string integer.
|
||||||
*
|
|
||||||
* @psalm-suppress UndefinedInterfaceMethod
|
|
||||||
* @psalm-suppress DeprecatedMethod
|
|
||||||
* @psalm-suppress MixedArgument
|
|
||||||
* @psalm-suppress MixedMethodCall
|
|
||||||
*/
|
*/
|
||||||
public function getNode(): string
|
public function getNode(): string
|
||||||
{
|
{
|
||||||
$instance = ($this->unwrapped ?? $this->unwrap());
|
$instance = ($this->unwrapped ?? $this->unwrap());
|
||||||
|
|
||||||
return $instance->getNumberConverter()
|
$fields = $instance->getFields();
|
||||||
->fromHex(
|
assert($fields instanceof \Ramsey\Uuid\Rfc4122\FieldsInterface);
|
||||||
$instance->getFields()
|
|
||||||
->getNode()
|
return $instance->getNumberConverter()->fromHex($fields->getNode()->toString());
|
||||||
->toString()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -442,22 +369,15 @@ final class LazyUuidFromString implements UuidInterface
|
|||||||
* instance, you may call {@see Rfc4122FieldsInterface::getTimeHiAndVersion()}
|
* instance, you may call {@see Rfc4122FieldsInterface::getTimeHiAndVersion()}
|
||||||
* and use the arbitrary-precision math library of your choice to
|
* and use the arbitrary-precision math library of your choice to
|
||||||
* convert it to a string integer.
|
* convert it to a string integer.
|
||||||
*
|
|
||||||
* @psalm-suppress UndefinedInterfaceMethod
|
|
||||||
* @psalm-suppress DeprecatedMethod
|
|
||||||
* @psalm-suppress MixedArgument
|
|
||||||
* @psalm-suppress MixedMethodCall
|
|
||||||
*/
|
*/
|
||||||
public function getTimeHiAndVersion(): string
|
public function getTimeHiAndVersion(): string
|
||||||
{
|
{
|
||||||
$instance = ($this->unwrapped ?? $this->unwrap());
|
$instance = ($this->unwrapped ?? $this->unwrap());
|
||||||
|
|
||||||
return $instance->getNumberConverter()
|
$fields = $instance->getFields();
|
||||||
->fromHex(
|
assert($fields instanceof \Ramsey\Uuid\Rfc4122\FieldsInterface);
|
||||||
$instance->getFields()
|
|
||||||
->getTimeHiAndVersion()
|
return $instance->getNumberConverter()->fromHex($fields->getTimeHiAndVersion()->toString());
|
||||||
->toString()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -466,22 +386,15 @@ final class LazyUuidFromString implements UuidInterface
|
|||||||
* instance, you may call {@see Rfc4122FieldsInterface::getTimeLow()}
|
* instance, you may call {@see Rfc4122FieldsInterface::getTimeLow()}
|
||||||
* and use the arbitrary-precision math library of your choice to
|
* and use the arbitrary-precision math library of your choice to
|
||||||
* convert it to a string integer.
|
* convert it to a string integer.
|
||||||
*
|
|
||||||
* @psalm-suppress UndefinedInterfaceMethod
|
|
||||||
* @psalm-suppress DeprecatedMethod
|
|
||||||
* @psalm-suppress MixedArgument
|
|
||||||
* @psalm-suppress MixedMethodCall
|
|
||||||
*/
|
*/
|
||||||
public function getTimeLow(): string
|
public function getTimeLow(): string
|
||||||
{
|
{
|
||||||
$instance = ($this->unwrapped ?? $this->unwrap());
|
$instance = ($this->unwrapped ?? $this->unwrap());
|
||||||
|
|
||||||
return $instance->getNumberConverter()
|
$fields = $instance->getFields();
|
||||||
->fromHex(
|
assert($fields instanceof \Ramsey\Uuid\Rfc4122\FieldsInterface);
|
||||||
$instance->getFields()
|
|
||||||
->getTimeLow()
|
return $instance->getNumberConverter()->fromHex($fields->getTimeLow()->toString());
|
||||||
->toString()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -490,22 +403,15 @@ final class LazyUuidFromString implements UuidInterface
|
|||||||
* instance, you may call {@see Rfc4122FieldsInterface::getTimeMid()}
|
* instance, you may call {@see Rfc4122FieldsInterface::getTimeMid()}
|
||||||
* and use the arbitrary-precision math library of your choice to
|
* and use the arbitrary-precision math library of your choice to
|
||||||
* convert it to a string integer.
|
* convert it to a string integer.
|
||||||
*
|
|
||||||
* @psalm-suppress UndefinedInterfaceMethod
|
|
||||||
* @psalm-suppress DeprecatedMethod
|
|
||||||
* @psalm-suppress MixedArgument
|
|
||||||
* @psalm-suppress MixedMethodCall
|
|
||||||
*/
|
*/
|
||||||
public function getTimeMid(): string
|
public function getTimeMid(): string
|
||||||
{
|
{
|
||||||
$instance = ($this->unwrapped ?? $this->unwrap());
|
$instance = ($this->unwrapped ?? $this->unwrap());
|
||||||
|
|
||||||
return $instance->getNumberConverter()
|
$fields = $instance->getFields();
|
||||||
->fromHex(
|
assert($fields instanceof \Ramsey\Uuid\Rfc4122\FieldsInterface);
|
||||||
$instance->getFields()
|
|
||||||
->getTimeMid()
|
return $instance->getNumberConverter()->fromHex($fields->getTimeMid()->toString());
|
||||||
->toString()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -514,23 +420,19 @@ final class LazyUuidFromString implements UuidInterface
|
|||||||
* instance, you may call {@see Rfc4122FieldsInterface::getTimestamp()}
|
* instance, you may call {@see Rfc4122FieldsInterface::getTimestamp()}
|
||||||
* and use the arbitrary-precision math library of your choice to
|
* and use the arbitrary-precision math library of your choice to
|
||||||
* convert it to a string integer.
|
* convert it to a string integer.
|
||||||
*
|
|
||||||
* @psalm-suppress UndefinedInterfaceMethod
|
|
||||||
* @psalm-suppress DeprecatedMethod
|
|
||||||
* @psalm-suppress MixedArgument
|
|
||||||
* @psalm-suppress MixedMethodCall
|
|
||||||
*/
|
*/
|
||||||
public function getTimestamp(): string
|
public function getTimestamp(): string
|
||||||
{
|
{
|
||||||
$instance = ($this->unwrapped ?? $this->unwrap());
|
$instance = ($this->unwrapped ?? $this->unwrap());
|
||||||
|
|
||||||
$fields = $instance->getFields();
|
$fields = $instance->getFields();
|
||||||
|
assert($fields instanceof \Ramsey\Uuid\Rfc4122\FieldsInterface);
|
||||||
|
|
||||||
if ($fields->getVersion() !== 1) {
|
if ($fields->getVersion() !== 1) {
|
||||||
throw new UnsupportedOperationException('Not a time-based UUID');
|
throw new UnsupportedOperationException('Not a time-based UUID');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $instance->getNumberConverter()
|
return $instance->getNumberConverter()->fromHex($fields->getTimestamp()->toString());
|
||||||
->fromHex($fields->getTimestamp()->toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toUuidV1(): UuidV1
|
public function toUuidV1(): UuidV1
|
||||||
@@ -555,18 +457,8 @@ final class LazyUuidFromString implements UuidInterface
|
|||||||
return $instance;
|
return $instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @psalm-suppress ImpureMethodCall the retrieval of the factory is a clear violation of purity here: this is a
|
|
||||||
* known pitfall of the design of this library, where a value object contains
|
|
||||||
* a mutable reference to a factory. We use a fixed factory here, so the violation
|
|
||||||
* will not have real-world effects, as this object is only instantiated with the
|
|
||||||
* default factory settings/features.
|
|
||||||
* @psalm-suppress InaccessibleProperty property {@see $unwrapped} is used as a cache: we don't expose it to the
|
|
||||||
* outside world, so we should be fine here.
|
|
||||||
*/
|
|
||||||
private function unwrap(): UuidInterface
|
private function unwrap(): UuidInterface
|
||||||
{
|
{
|
||||||
return $this->unwrapped = (new UuidFactory())
|
return $this->unwrapped = (new UuidFactory())->fromString($this->uuid);
|
||||||
->fromString($this->uuid);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ use Ramsey\Uuid\Type\NumberInterface;
|
|||||||
/**
|
/**
|
||||||
* A calculator using the brick/math library for arbitrary-precision arithmetic
|
* A calculator using the brick/math library for arbitrary-precision arithmetic
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
final class BrickMathCalculator implements CalculatorInterface
|
final class BrickMathCalculator implements CalculatorInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ use Ramsey\Uuid\Type\NumberInterface;
|
|||||||
/**
|
/**
|
||||||
* A calculator performs arithmetic operations on numbers
|
* A calculator performs arithmetic operations on numbers
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
interface CalculatorInterface
|
interface CalculatorInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ use const STR_PAD_LEFT;
|
|||||||
* Internally, this class represents the fields together as a 16-byte binary
|
* Internally, this class represents the fields together as a 16-byte binary
|
||||||
* string.
|
* string.
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
final class Fields implements FieldsInterface
|
final class Fields implements FieldsInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ use Ramsey\Uuid\Uuid as BaseUuid;
|
|||||||
/**
|
/**
|
||||||
* Nonstandard\Uuid is a UUID that doesn't conform to RFC 4122
|
* Nonstandard\Uuid is a UUID that doesn't conform to RFC 4122
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
final class Uuid extends BaseUuid
|
final class Uuid extends BaseUuid
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ use Throwable;
|
|||||||
/**
|
/**
|
||||||
* Nonstandard\UuidBuilder builds instances of Nonstandard\Uuid
|
* Nonstandard\UuidBuilder builds instances of Nonstandard\Uuid
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
class UuidBuilder implements UuidBuilderInterface
|
class UuidBuilder implements UuidBuilderInterface
|
||||||
{
|
{
|
||||||
@@ -49,8 +49,6 @@ class UuidBuilder implements UuidBuilderInterface
|
|||||||
*
|
*
|
||||||
* @return Uuid The Nonstandard\UuidBuilder returns an instance of
|
* @return Uuid The Nonstandard\UuidBuilder returns an instance of
|
||||||
* Nonstandard\Uuid
|
* Nonstandard\Uuid
|
||||||
*
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
*/
|
||||||
public function build(CodecInterface $codec, string $bytes): UuidInterface
|
public function build(CodecInterface $codec, string $bytes): UuidInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ use Ramsey\Uuid\Uuid as BaseUuid;
|
|||||||
* @link https://github.com/uuid6/uuid6-ietf-draft UUID version 6 IETF draft
|
* @link https://github.com/uuid6/uuid6-ietf-draft UUID version 6 IETF draft
|
||||||
* @link http://gh.peabody.io/uuidv6/ "Version 6" UUIDs
|
* @link http://gh.peabody.io/uuidv6/ "Version 6" UUIDs
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
class UuidV6 extends BaseUuid implements UuidInterface
|
class UuidV6 extends BaseUuid implements UuidInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -141,10 +141,7 @@ class SystemDceSecurityProvider implements DceSecurityProviderInterface
|
|||||||
*/
|
*/
|
||||||
private function getOs(): string
|
private function getOs(): string
|
||||||
{
|
{
|
||||||
/**
|
/** @var string $phpOs */
|
||||||
* @psalm-suppress UnnecessaryVarAnnotation
|
|
||||||
* @var string $phpOs
|
|
||||||
*/
|
|
||||||
$phpOs = constant('PHP_OS');
|
$phpOs = constant('PHP_OS');
|
||||||
|
|
||||||
return strtoupper(substr($phpOs, 0, 3));
|
return strtoupper(substr($phpOs, 0, 3));
|
||||||
|
|||||||
@@ -40,9 +40,6 @@ class NodeProviderCollection extends AbstractCollection
|
|||||||
*
|
*
|
||||||
* @param string $serialized The serialized PHP string to unserialize into
|
* @param string $serialized The serialized PHP string to unserialize into
|
||||||
* a UuidInterface instance
|
* a UuidInterface instance
|
||||||
*
|
|
||||||
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
|
||||||
* @psalm-suppress RedundantConditionGivenDocblockType
|
|
||||||
*/
|
*/
|
||||||
public function unserialize($serialized): void
|
public function unserialize($serialized): void
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -104,10 +104,7 @@ class SystemNodeProvider implements NodeProviderInterface
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** @var string $phpOs */
|
||||||
* @psalm-suppress UnnecessaryVarAnnotation
|
|
||||||
* @var string $phpOs
|
|
||||||
*/
|
|
||||||
$phpOs = constant('PHP_OS');
|
$phpOs = constant('PHP_OS');
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
@@ -151,10 +148,7 @@ class SystemNodeProvider implements NodeProviderInterface
|
|||||||
{
|
{
|
||||||
$mac = '';
|
$mac = '';
|
||||||
|
|
||||||
/**
|
/** @var string $phpOs */
|
||||||
* @psalm-suppress UnnecessaryVarAnnotation
|
|
||||||
* @var string $phpOs
|
|
||||||
*/
|
|
||||||
$phpOs = constant('PHP_OS');
|
$phpOs = constant('PHP_OS');
|
||||||
|
|
||||||
if (strtoupper($phpOs) === 'LINUX') {
|
if (strtoupper($phpOs) === 'LINUX') {
|
||||||
|
|||||||
@@ -31,12 +31,12 @@ use function unpack;
|
|||||||
use const STR_PAD_LEFT;
|
use const STR_PAD_LEFT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RFC 4122 variant UUIDs are comprised of a set of named fields
|
* RFC 4122 variant UUIDs consist of a set of named fields
|
||||||
*
|
*
|
||||||
* Internally, this class represents the fields together as a 16-byte binary
|
* Internally, this class represents the fields together as a 16-byte binary
|
||||||
* string.
|
* string.
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
final class Fields implements FieldsInterface
|
final class Fields implements FieldsInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ use Ramsey\Uuid\Type\Hexadecimal;
|
|||||||
*
|
*
|
||||||
* @link http://tools.ietf.org/html/rfc4122#section-4.1 RFC 4122, § 4.1: Format
|
* @link http://tools.ietf.org/html/rfc4122#section-4.1 RFC 4122, § 4.1: Format
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
interface FieldsInterface extends BaseFieldsInterface
|
interface FieldsInterface extends BaseFieldsInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace Ramsey\Uuid\Rfc4122;
|
|||||||
*
|
*
|
||||||
* @link https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis-00#section-5.10 Max UUID
|
* @link https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis-00#section-5.10 Max UUID
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
trait MaxTrait
|
trait MaxTrait
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ use Ramsey\Uuid\Uuid;
|
|||||||
* The max UUID is special form of UUID that is specified to have all 128 bits
|
* The max UUID is special form of UUID that is specified to have all 128 bits
|
||||||
* set to one
|
* set to one
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
final class MaxUuid extends Uuid implements UuidInterface
|
final class MaxUuid extends Uuid implements UuidInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace Ramsey\Uuid\Rfc4122;
|
|||||||
*
|
*
|
||||||
* @link https://tools.ietf.org/html/rfc4122#section-4.1.7 RFC 4122, § 4.1.7: Nil UUID
|
* @link https://tools.ietf.org/html/rfc4122#section-4.1.7 RFC 4122, § 4.1.7: Nil UUID
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
trait NilTrait
|
trait NilTrait
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ use Ramsey\Uuid\Uuid;
|
|||||||
* The nil UUID is special form of UUID that is specified to have all 128 bits
|
* The nil UUID is special form of UUID that is specified to have all 128 bits
|
||||||
* set to zero
|
* set to zero
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
final class NilUuid extends Uuid implements UuidInterface
|
final class NilUuid extends Uuid implements UuidInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ use const STR_PAD_LEFT;
|
|||||||
/**
|
/**
|
||||||
* Provides common functionality for getting the time from a time-based UUID
|
* Provides common functionality for getting the time from a time-based UUID
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
trait TimeTrait
|
trait TimeTrait
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ use Throwable;
|
|||||||
/**
|
/**
|
||||||
* UuidBuilder builds instances of RFC 4122 UUIDs
|
* UuidBuilder builds instances of RFC 4122 UUIDs
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
class UuidBuilder implements UuidBuilderInterface
|
class UuidBuilder implements UuidBuilderInterface
|
||||||
{
|
{
|
||||||
@@ -63,8 +63,6 @@ class UuidBuilder implements UuidBuilderInterface
|
|||||||
* @param string $bytes The byte string from which to construct a UUID
|
* @param string $bytes The byte string from which to construct a UUID
|
||||||
*
|
*
|
||||||
* @return Rfc4122UuidInterface UuidBuilder returns instances of Rfc4122UuidInterface
|
* @return Rfc4122UuidInterface UuidBuilder returns instances of Rfc4122UuidInterface
|
||||||
*
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
*/
|
||||||
public function build(CodecInterface $codec, string $bytes): UuidInterface
|
public function build(CodecInterface $codec, string $bytes): UuidInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ use Ramsey\Uuid\UuidInterface as BaseUuidInterface;
|
|||||||
*
|
*
|
||||||
* @link https://tools.ietf.org/html/rfc4122 RFC 4122
|
* @link https://tools.ietf.org/html/rfc4122 RFC 4122
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
interface UuidInterface extends BaseUuidInterface
|
interface UuidInterface extends BaseUuidInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ use Ramsey\Uuid\Uuid;
|
|||||||
* Gregorian time, or version 1, UUIDs include timestamp, clock sequence, and node
|
* Gregorian time, or version 1, UUIDs include timestamp, clock sequence, and node
|
||||||
* values that are combined into a 128-bit unsigned integer
|
* values that are combined into a 128-bit unsigned integer
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
final class UuidV1 extends Uuid implements UuidInterface
|
final class UuidV1 extends Uuid implements UuidInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ use function hexdec;
|
|||||||
* @link https://pubs.opengroup.org/onlinepubs/9629399/apdxa.htm DCE 1.1: RPC, Appendix A
|
* @link https://pubs.opengroup.org/onlinepubs/9629399/apdxa.htm DCE 1.1: RPC, Appendix A
|
||||||
* @link https://github.com/google/uuid Go package for UUIDs (includes DCE implementation)
|
* @link https://github.com/google/uuid Go package for UUIDs (includes DCE implementation)
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
final class UuidV2 extends Uuid implements UuidInterface
|
final class UuidV2 extends Uuid implements UuidInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ use Ramsey\Uuid\Rfc4122\FieldsInterface as Rfc4122FieldsInterface;
|
|||||||
use Ramsey\Uuid\Uuid;
|
use Ramsey\Uuid\Uuid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Version 3 UUIDs are named-based, using combination of a namespace and name
|
* Version 3 UUIDs are named-based, using a combination of a namespace and name
|
||||||
* that are hashed into a 128-bit unsigned integer using MD5
|
* that are hashed into a 128-bit unsigned integer using MD5
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
final class UuidV3 extends Uuid implements UuidInterface
|
final class UuidV3 extends Uuid implements UuidInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ use Ramsey\Uuid\Uuid;
|
|||||||
* Random, or version 4, UUIDs are randomly or pseudo-randomly generated 128-bit
|
* Random, or version 4, UUIDs are randomly or pseudo-randomly generated 128-bit
|
||||||
* integers
|
* integers
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
final class UuidV4 extends Uuid implements UuidInterface
|
final class UuidV4 extends Uuid implements UuidInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ use Ramsey\Uuid\Rfc4122\FieldsInterface as Rfc4122FieldsInterface;
|
|||||||
use Ramsey\Uuid\Uuid;
|
use Ramsey\Uuid\Uuid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Version 5 UUIDs are named-based, using combination of a namespace and name
|
* Version 5 UUIDs are named-based, using a combination of a namespace and name
|
||||||
* that are hashed into a 128-bit unsigned integer using SHA1
|
* that are hashed into a 128-bit unsigned integer using SHA1
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
final class UuidV5 extends Uuid implements UuidInterface
|
final class UuidV5 extends Uuid implements UuidInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ use Ramsey\Uuid\Nonstandard\UuidV6 as NonstandardUuidV6;
|
|||||||
*
|
*
|
||||||
* @link https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis-00#section-5.6 UUID Version 6
|
* @link https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis-00#section-5.6 UUID Version 6
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
final class UuidV6 extends NonstandardUuidV6 implements UuidInterface
|
final class UuidV6 extends NonstandardUuidV6 implements UuidInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ use Ramsey\Uuid\Uuid;
|
|||||||
*
|
*
|
||||||
* @link https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis-00#section-5.7 UUID Version 7
|
* @link https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis-00#section-5.7 UUID Version 7
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
final class UuidV7 extends Uuid implements UuidInterface
|
final class UuidV7 extends Uuid implements UuidInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ use Ramsey\Uuid\Uuid;
|
|||||||
*
|
*
|
||||||
* @link https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis-00#section-5.8 UUID Version 8
|
* @link https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis-00#section-5.8 UUID Version 8
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
final class UuidV8 extends Uuid implements UuidInterface
|
final class UuidV8 extends Uuid implements UuidInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use function str_replace;
|
|||||||
/**
|
/**
|
||||||
* Rfc4122\Validator validates strings as UUIDs of the RFC 4122 variant
|
* Rfc4122\Validator validates strings as UUIDs of the RFC 4122 variant
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
final class Validator implements ValidatorInterface
|
final class Validator implements ValidatorInterface
|
||||||
{
|
{
|
||||||
@@ -31,9 +31,7 @@ final class Validator implements ValidatorInterface
|
|||||||
. '[1-8][0-9A-Fa-f]{3}-[ABab89][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}\z';
|
. '[1-8][0-9A-Fa-f]{3}-[ABab89][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}\z';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @psalm-return non-empty-string
|
* @return non-empty-string
|
||||||
* @psalm-suppress MoreSpecificReturnType we know that the retrieved `string` is never empty
|
|
||||||
* @psalm-suppress LessSpecificReturnStatement we know that the retrieved `string` is never empty
|
|
||||||
*/
|
*/
|
||||||
public function getPattern(): string
|
public function getPattern(): string
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ use const STR_PAD_LEFT;
|
|||||||
/**
|
/**
|
||||||
* Provides common functionality for handling the variant, as defined by RFC 4122
|
* Provides common functionality for handling the variant, as defined by RFC 4122
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
trait VariantTrait
|
trait VariantTrait
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ use Ramsey\Uuid\Uuid;
|
|||||||
/**
|
/**
|
||||||
* Provides common functionality for handling the version, as defined by RFC 4122
|
* Provides common functionality for handling the version, as defined by RFC 4122
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
trait VersionTrait
|
trait VersionTrait
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ use function str_starts_with;
|
|||||||
* To support values as true decimals and not as floats or doubles, we store the
|
* To support values as true decimals and not as floats or doubles, we store the
|
||||||
* decimals as strings.
|
* decimals as strings.
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
final class Decimal implements NumberInterface
|
final class Decimal implements NumberInterface
|
||||||
{
|
{
|
||||||
@@ -103,8 +103,6 @@ final class Decimal implements NumberInterface
|
|||||||
* Constructs the object from a serialized string representation
|
* Constructs the object from a serialized string representation
|
||||||
*
|
*
|
||||||
* @param string $data The serialized string representation of the object
|
* @param string $data The serialized string representation of the object
|
||||||
*
|
|
||||||
* @psalm-suppress UnusedMethodCall
|
|
||||||
*/
|
*/
|
||||||
public function unserialize(string $data): void
|
public function unserialize(string $data): void
|
||||||
{
|
{
|
||||||
@@ -113,8 +111,6 @@ final class Decimal implements NumberInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array{string?: string} $data
|
* @param array{string?: string} $data
|
||||||
*
|
|
||||||
* @psalm-suppress UnusedMethodCall
|
|
||||||
*/
|
*/
|
||||||
public function __unserialize(array $data): void
|
public function __unserialize(array $data): void
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ use function substr;
|
|||||||
* returned from ramsey/uuid methods as strings are truly hexadecimal and not some
|
* returned from ramsey/uuid methods as strings are truly hexadecimal and not some
|
||||||
* other kind of string.
|
* other kind of string.
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
final class Hexadecimal implements TypeInterface
|
final class Hexadecimal implements TypeInterface
|
||||||
{
|
{
|
||||||
@@ -74,8 +74,6 @@ final class Hexadecimal implements TypeInterface
|
|||||||
* Constructs the object from a serialized string representation
|
* Constructs the object from a serialized string representation
|
||||||
*
|
*
|
||||||
* @param string $data The serialized string representation of the object
|
* @param string $data The serialized string representation of the object
|
||||||
*
|
|
||||||
* @psalm-suppress UnusedMethodCall
|
|
||||||
*/
|
*/
|
||||||
public function unserialize(string $data): void
|
public function unserialize(string $data): void
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,12 +33,12 @@ use function substr;
|
|||||||
* To support large integers beyond PHP_INT_MAX and PHP_INT_MIN on both 64-bit
|
* To support large integers beyond PHP_INT_MAX and PHP_INT_MIN on both 64-bit
|
||||||
* and 32-bit systems, we store the integers as strings.
|
* and 32-bit systems, we store the integers as strings.
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
final class Integer implements NumberInterface
|
final class Integer implements NumberInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @psalm-var numeric-string
|
* @var numeric-string
|
||||||
*/
|
*/
|
||||||
private string $value;
|
private string $value;
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ final class Integer implements NumberInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @psalm-return numeric-string
|
* @return numeric-string
|
||||||
*/
|
*/
|
||||||
public function toString(): string
|
public function toString(): string
|
||||||
{
|
{
|
||||||
@@ -63,7 +63,7 @@ final class Integer implements NumberInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @psalm-return numeric-string
|
* @return numeric-string
|
||||||
*/
|
*/
|
||||||
public function __toString(): string
|
public function __toString(): string
|
||||||
{
|
{
|
||||||
@@ -92,8 +92,6 @@ final class Integer implements NumberInterface
|
|||||||
* Constructs the object from a serialized string representation
|
* Constructs the object from a serialized string representation
|
||||||
*
|
*
|
||||||
* @param string $data The serialized string representation of the object
|
* @param string $data The serialized string representation of the object
|
||||||
*
|
|
||||||
* @psalm-suppress UnusedMethodCall
|
|
||||||
*/
|
*/
|
||||||
public function unserialize(string $data): void
|
public function unserialize(string $data): void
|
||||||
{
|
{
|
||||||
@@ -147,7 +145,6 @@ final class Integer implements NumberInterface
|
|||||||
if ($sign === '-' && $value !== '0') {
|
if ($sign === '-' && $value !== '0') {
|
||||||
$value = $sign . $value;
|
$value = $sign . $value;
|
||||||
|
|
||||||
/** @psalm-suppress InaccessibleProperty */
|
|
||||||
$this->isNegative = true;
|
$this->isNegative = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace Ramsey\Uuid\Type;
|
|||||||
/**
|
/**
|
||||||
* NumberInterface ensures consistency in numeric values returned by ramsey/uuid
|
* NumberInterface ensures consistency in numeric values returned by ramsey/uuid
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
interface NumberInterface extends TypeInterface
|
interface NumberInterface extends TypeInterface
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-3
@@ -29,7 +29,7 @@ use function sprintf;
|
|||||||
* by ramsey/uuid are truly timestamp integers and not some other kind of string
|
* by ramsey/uuid are truly timestamp integers and not some other kind of string
|
||||||
* or integer.
|
* or integer.
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
final class Time implements TypeInterface
|
final class Time implements TypeInterface
|
||||||
{
|
{
|
||||||
@@ -95,8 +95,6 @@ final class Time implements TypeInterface
|
|||||||
* Constructs the object from a serialized string representation
|
* Constructs the object from a serialized string representation
|
||||||
*
|
*
|
||||||
* @param string $data The serialized string representation of the object
|
* @param string $data The serialized string representation of the object
|
||||||
*
|
|
||||||
* @psalm-suppress UnusedMethodCall
|
|
||||||
*/
|
*/
|
||||||
public function unserialize(string $data): void
|
public function unserialize(string $data): void
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ use Serializable;
|
|||||||
/**
|
/**
|
||||||
* TypeInterface ensures consistency in typed values returned by ramsey/uuid
|
* TypeInterface ensures consistency in typed values returned by ramsey/uuid
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
interface TypeInterface extends JsonSerializable, Serializable
|
interface TypeInterface extends JsonSerializable, Serializable
|
||||||
{
|
{
|
||||||
|
|||||||
+7
-55
@@ -42,14 +42,14 @@ use function substr;
|
|||||||
/**
|
/**
|
||||||
* Uuid provides constants and static methods for working with and generating UUIDs
|
* Uuid provides constants and static methods for working with and generating UUIDs
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
class Uuid implements UuidInterface
|
class Uuid implements UuidInterface
|
||||||
{
|
{
|
||||||
use DeprecatedUuidMethodsTrait;
|
use DeprecatedUuidMethodsTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When this namespace is specified, the name string is a fully-qualified
|
* When this namespace is specified, the name string is a fully qualified
|
||||||
* domain name
|
* domain name
|
||||||
*
|
*
|
||||||
* @link http://tools.ietf.org/html/rfc4122#appendix-C RFC 4122, Appendix C: Some Name Space IDs
|
* @link http://tools.ietf.org/html/rfc4122#appendix-C RFC 4122, Appendix C: Some Name Space IDs
|
||||||
@@ -274,7 +274,7 @@ class Uuid implements UuidInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @psalm-return non-empty-string
|
* @return non-empty-string
|
||||||
*/
|
*/
|
||||||
public function __toString(): string
|
public function __toString(): string
|
||||||
{
|
{
|
||||||
@@ -366,7 +366,7 @@ class Uuid implements UuidInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @psalm-return non-empty-string
|
* @return non-empty-string
|
||||||
*/
|
*/
|
||||||
public function getBytes(): string
|
public function getBytes(): string
|
||||||
{
|
{
|
||||||
@@ -394,7 +394,7 @@ class Uuid implements UuidInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @psalm-return non-empty-string
|
* @return non-empty-string
|
||||||
*/
|
*/
|
||||||
public function toString(): string
|
public function toString(): string
|
||||||
{
|
{
|
||||||
@@ -438,13 +438,6 @@ class Uuid implements UuidInterface
|
|||||||
* string representation
|
* string representation
|
||||||
*
|
*
|
||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
*
|
|
||||||
* @psalm-pure note: changing the internal factory is an edge case not covered by purity invariants,
|
|
||||||
* but under constant factory setups, this method operates in functionally pure manners
|
|
||||||
* @psalm-suppress ImpureStaticProperty we know that the factory being replaced can lead to massive
|
|
||||||
* havoc across all consumers: that should never happen, and
|
|
||||||
* is generally to be discouraged. Until the factory is kept
|
|
||||||
* un-replaced, this method is effectively pure.
|
|
||||||
*/
|
*/
|
||||||
public static function fromBytes(string $bytes): UuidInterface
|
public static function fromBytes(string $bytes): UuidInterface
|
||||||
{
|
{
|
||||||
@@ -477,13 +470,6 @@ class Uuid implements UuidInterface
|
|||||||
* string representation
|
* string representation
|
||||||
*
|
*
|
||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
*
|
|
||||||
* @psalm-pure note: changing the internal factory is an edge case not covered by purity invariants,
|
|
||||||
* but under constant factory setups, this method operates in functionally pure manners
|
|
||||||
* @psalm-suppress ImpureStaticProperty we know that the factory being replaced can lead to massive
|
|
||||||
* havoc across all consumers: that should never happen, and
|
|
||||||
* is generally to be discouraged. Until the factory is kept
|
|
||||||
* un-replaced, this method is effectively pure.
|
|
||||||
*/
|
*/
|
||||||
public static function fromString(string $uuid): UuidInterface
|
public static function fromString(string $uuid): UuidInterface
|
||||||
{
|
{
|
||||||
@@ -524,24 +510,16 @@ class Uuid implements UuidInterface
|
|||||||
* @param Hexadecimal $hex Hexadecimal object representing a hexadecimal number
|
* @param Hexadecimal $hex Hexadecimal object representing a hexadecimal number
|
||||||
*
|
*
|
||||||
* @return UuidInterface A UuidInterface instance created from the Hexadecimal
|
* @return UuidInterface A UuidInterface instance created from the Hexadecimal
|
||||||
* object representing a hexadecimal number
|
* object representing a hexadecimal number
|
||||||
*
|
*
|
||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
*
|
|
||||||
* @psalm-pure note: changing the internal factory is an edge case not covered by purity invariants,
|
|
||||||
* but under constant factory setups, this method operates in functionally pure manners
|
|
||||||
* @psalm-suppress MixedInferredReturnType,MixedReturnStatement
|
|
||||||
*/
|
*/
|
||||||
public static function fromHexadecimal(Hexadecimal $hex): UuidInterface
|
public static function fromHexadecimal(Hexadecimal $hex): UuidInterface
|
||||||
{
|
{
|
||||||
$factory = self::getFactory();
|
$factory = self::getFactory();
|
||||||
|
|
||||||
if (method_exists($factory, 'fromHexadecimal')) {
|
if (method_exists($factory, 'fromHexadecimal')) {
|
||||||
/**
|
return $factory->fromHexadecimal($hex);
|
||||||
* @phpstan-ignore-next-line
|
|
||||||
* @psalm-suppress UndefinedInterfaceMethod
|
|
||||||
*/
|
|
||||||
return self::getFactory()->fromHexadecimal($hex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new BadMethodCallException('The method fromHexadecimal() does not exist on the provided factory');
|
throw new BadMethodCallException('The method fromHexadecimal() does not exist on the provided factory');
|
||||||
@@ -556,13 +534,9 @@ class Uuid implements UuidInterface
|
|||||||
* representation of a 128-bit integer
|
* representation of a 128-bit integer
|
||||||
*
|
*
|
||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
*
|
|
||||||
* @psalm-pure note: changing the internal factory is an edge case not covered by purity invariants,
|
|
||||||
* but under constant factory setups, this method operates in functionally pure manners
|
|
||||||
*/
|
*/
|
||||||
public static function fromInteger(string $integer): UuidInterface
|
public static function fromInteger(string $integer): UuidInterface
|
||||||
{
|
{
|
||||||
/** @psalm-suppress ImpureMethodCall */
|
|
||||||
return self::getFactory()->fromInteger($integer);
|
return self::getFactory()->fromInteger($integer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -572,15 +546,9 @@ class Uuid implements UuidInterface
|
|||||||
* @param string $uuid A string to validate as a UUID
|
* @param string $uuid A string to validate as a UUID
|
||||||
*
|
*
|
||||||
* @return bool True if the string is a valid UUID, false otherwise
|
* @return bool True if the string is a valid UUID, false otherwise
|
||||||
*
|
|
||||||
* @psalm-pure note: changing the internal factory is an edge case not covered by purity invariants,
|
|
||||||
* but under constant factory setups, this method operates in functionally pure manners
|
|
||||||
*
|
|
||||||
* @psalm-assert-if-true =non-empty-string $uuid
|
|
||||||
*/
|
*/
|
||||||
public static function isValid(string $uuid): bool
|
public static function isValid(string $uuid): bool
|
||||||
{
|
{
|
||||||
/** @psalm-suppress ImpureMethodCall */
|
|
||||||
return self::getFactory()->getValidator()->validate($uuid);
|
return self::getFactory()->getValidator()->validate($uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -641,14 +609,6 @@ class Uuid implements UuidInterface
|
|||||||
*
|
*
|
||||||
* @return UuidInterface A UuidInterface instance that represents a
|
* @return UuidInterface A UuidInterface instance that represents a
|
||||||
* version 3 UUID
|
* version 3 UUID
|
||||||
*
|
|
||||||
* @psalm-suppress ImpureMethodCall we know that the factory being replaced can lead to massive
|
|
||||||
* havoc across all consumers: that should never happen, and
|
|
||||||
* is generally to be discouraged. Until the factory is kept
|
|
||||||
* un-replaced, this method is effectively pure.
|
|
||||||
*
|
|
||||||
* @psalm-pure note: changing the internal factory is an edge case not covered by purity invariants,
|
|
||||||
* but under constant factory setups, this method operates in functionally pure manners
|
|
||||||
*/
|
*/
|
||||||
public static function uuid3($ns, string $name): UuidInterface
|
public static function uuid3($ns, string $name): UuidInterface
|
||||||
{
|
{
|
||||||
@@ -675,14 +635,6 @@ class Uuid implements UuidInterface
|
|||||||
*
|
*
|
||||||
* @return UuidInterface A UuidInterface instance that represents a
|
* @return UuidInterface A UuidInterface instance that represents a
|
||||||
* version 5 UUID
|
* version 5 UUID
|
||||||
*
|
|
||||||
* @psalm-pure note: changing the internal factory is an edge case not covered by purity invariants,
|
|
||||||
* but under constant factory setups, this method operates in functionally pure manners
|
|
||||||
*
|
|
||||||
* @psalm-suppress ImpureMethodCall we know that the factory being replaced can lead to massive
|
|
||||||
* havoc across all consumers: that should never happen, and
|
|
||||||
* is generally to be discouraged. Until the factory is kept
|
|
||||||
* un-replaced, this method is effectively pure.
|
|
||||||
*/
|
*/
|
||||||
public static function uuid5($ns, string $name): UuidInterface
|
public static function uuid5($ns, string $name): UuidInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -240,9 +240,6 @@ class UuidFactory implements UuidFactoryInterface
|
|||||||
$this->uuidBuilder = $builder;
|
$this->uuidBuilder = $builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @psalm-mutation-free
|
|
||||||
*/
|
|
||||||
public function getValidator(): ValidatorInterface
|
public function getValidator(): ValidatorInterface
|
||||||
{
|
{
|
||||||
return $this->validator;
|
return $this->validator;
|
||||||
@@ -261,17 +258,11 @@ class UuidFactory implements UuidFactoryInterface
|
|||||||
$this->validator = $validator;
|
$this->validator = $validator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
|
||||||
public function fromBytes(string $bytes): UuidInterface
|
public function fromBytes(string $bytes): UuidInterface
|
||||||
{
|
{
|
||||||
return $this->codec->decodeBytes($bytes);
|
return $this->codec->decodeBytes($bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
|
||||||
public function fromString(string $uuid): UuidInterface
|
public function fromString(string $uuid): UuidInterface
|
||||||
{
|
{
|
||||||
$uuid = strtolower($uuid);
|
$uuid = strtolower($uuid);
|
||||||
@@ -279,9 +270,6 @@ class UuidFactory implements UuidFactoryInterface
|
|||||||
return $this->codec->decode($uuid);
|
return $this->codec->decode($uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
|
||||||
public function fromInteger(string $integer): UuidInterface
|
public function fromInteger(string $integer): UuidInterface
|
||||||
{
|
{
|
||||||
$hex = $this->numberConverter->toHex($integer);
|
$hex = $this->numberConverter->toHex($integer);
|
||||||
@@ -312,9 +300,6 @@ class UuidFactory implements UuidFactoryInterface
|
|||||||
return $this->uuidFromBytesAndVersion($bytes, Uuid::UUID_TYPE_TIME);
|
return $this->uuidFromBytesAndVersion($bytes, Uuid::UUID_TYPE_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
|
||||||
public function fromHexadecimal(Hexadecimal $hex): UuidInterface
|
public function fromHexadecimal(Hexadecimal $hex): UuidInterface
|
||||||
{
|
{
|
||||||
return $this->codec->decode($hex->__toString());
|
return $this->codec->decode($hex->__toString());
|
||||||
@@ -348,7 +333,6 @@ class UuidFactory implements UuidFactoryInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
* @psalm-pure
|
|
||||||
*/
|
*/
|
||||||
public function uuid3($ns, string $name): UuidInterface
|
public function uuid3($ns, string $name): UuidInterface
|
||||||
{
|
{
|
||||||
@@ -364,7 +348,6 @@ class UuidFactory implements UuidFactoryInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
* @psalm-pure
|
|
||||||
*/
|
*/
|
||||||
public function uuid5($ns, string $name): UuidInterface
|
public function uuid5($ns, string $name): UuidInterface
|
||||||
{
|
{
|
||||||
@@ -439,12 +422,9 @@ class UuidFactory implements UuidFactoryInterface
|
|||||||
*
|
*
|
||||||
* @return UuidInterface An instance of UuidInterface, created from the
|
* @return UuidInterface An instance of UuidInterface, created from the
|
||||||
* provided bytes
|
* provided bytes
|
||||||
*
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
*/
|
||||||
public function uuid(string $bytes): UuidInterface
|
public function uuid(string $bytes): UuidInterface
|
||||||
{
|
{
|
||||||
/** @psalm-suppress ImpurePropertyFetch */
|
|
||||||
return $this->uuidBuilder->build($this->codec, $bytes);
|
return $this->uuidBuilder->build($this->codec, $bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -459,8 +439,6 @@ class UuidFactory implements UuidFactoryInterface
|
|||||||
*
|
*
|
||||||
* @return UuidInterface An instance of UuidInterface, created by hashing
|
* @return UuidInterface An instance of UuidInterface, created by hashing
|
||||||
* together the provided namespace and name
|
* together the provided namespace and name
|
||||||
*
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
*/
|
||||||
private function uuidFromNsAndName(
|
private function uuidFromNsAndName(
|
||||||
UuidInterface | string $ns,
|
UuidInterface | string $ns,
|
||||||
@@ -485,8 +463,6 @@ class UuidFactory implements UuidFactoryInterface
|
|||||||
*
|
*
|
||||||
* @return UuidInterface An instance of UuidInterface, created from the
|
* @return UuidInterface An instance of UuidInterface, created from the
|
||||||
* byte string and version
|
* byte string and version
|
||||||
*
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
*/
|
||||||
private function uuidFromBytesAndVersion(string $bytes, int $version): UuidInterface
|
private function uuidFromBytesAndVersion(string $bytes, int $version): UuidInterface
|
||||||
{
|
{
|
||||||
@@ -507,7 +483,6 @@ class UuidFactory implements UuidFactoryInterface
|
|||||||
return LazyUuidFromString::fromBytes($bytes);
|
return LazyUuidFromString::fromBytes($bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @psalm-suppress ImpureVariable */
|
|
||||||
return $this->uuid($bytes);
|
return $this->uuid($bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ use Ramsey\Uuid\Type\Integer as IntegerObject;
|
|||||||
use Ramsey\Uuid\Validator\ValidatorInterface;
|
use Ramsey\Uuid\Validator\ValidatorInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UuidFactoryInterface defines common functionality all `UuidFactory` instances
|
* UuidFactoryInterface defines the common functionality all `UuidFactory` instances
|
||||||
* must implement
|
* must implement
|
||||||
*/
|
*/
|
||||||
interface UuidFactoryInterface
|
interface UuidFactoryInterface
|
||||||
@@ -32,8 +32,6 @@ interface UuidFactoryInterface
|
|||||||
*
|
*
|
||||||
* @return UuidInterface A UuidInterface instance created from a binary
|
* @return UuidInterface A UuidInterface instance created from a binary
|
||||||
* string representation
|
* string representation
|
||||||
*
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
*/
|
||||||
public function fromBytes(string $bytes): UuidInterface;
|
public function fromBytes(string $bytes): UuidInterface;
|
||||||
|
|
||||||
@@ -63,8 +61,6 @@ interface UuidFactoryInterface
|
|||||||
*
|
*
|
||||||
* @return UuidInterface A UuidInterface instance created from the string
|
* @return UuidInterface A UuidInterface instance created from the string
|
||||||
* representation of a 128-bit integer
|
* representation of a 128-bit integer
|
||||||
*
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
*/
|
||||||
public function fromInteger(string $integer): UuidInterface;
|
public function fromInteger(string $integer): UuidInterface;
|
||||||
|
|
||||||
@@ -75,15 +71,11 @@ interface UuidFactoryInterface
|
|||||||
*
|
*
|
||||||
* @return UuidInterface A UuidInterface instance created from a hexadecimal
|
* @return UuidInterface A UuidInterface instance created from a hexadecimal
|
||||||
* string representation
|
* string representation
|
||||||
*
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
*/
|
||||||
public function fromString(string $uuid): UuidInterface;
|
public function fromString(string $uuid): UuidInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the validator to use for the factory
|
* Returns the validator used by the factory
|
||||||
*
|
|
||||||
* @psalm-mutation-free
|
|
||||||
*/
|
*/
|
||||||
public function getValidator(): ValidatorInterface;
|
public function getValidator(): ValidatorInterface;
|
||||||
|
|
||||||
@@ -138,8 +130,6 @@ interface UuidFactoryInterface
|
|||||||
*
|
*
|
||||||
* @return UuidInterface A UuidInterface instance that represents a
|
* @return UuidInterface A UuidInterface instance that represents a
|
||||||
* version 3 UUID
|
* version 3 UUID
|
||||||
*
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
*/
|
||||||
public function uuid3($ns, string $name): UuidInterface;
|
public function uuid3($ns, string $name): UuidInterface;
|
||||||
|
|
||||||
@@ -160,8 +150,6 @@ interface UuidFactoryInterface
|
|||||||
*
|
*
|
||||||
* @return UuidInterface A UuidInterface instance that represents a
|
* @return UuidInterface A UuidInterface instance that represents a
|
||||||
* version 5 UUID
|
* version 5 UUID
|
||||||
*
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
*/
|
||||||
public function uuid5($ns, string $name): UuidInterface;
|
public function uuid5($ns, string $name): UuidInterface;
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ use Stringable;
|
|||||||
* A UUID is a universally unique identifier adhering to an agreed-upon
|
* A UUID is a universally unique identifier adhering to an agreed-upon
|
||||||
* representation format and standard for generation
|
* representation format and standard for generation
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
interface UuidInterface extends
|
interface UuidInterface extends
|
||||||
DeprecatedUuidInterface,
|
DeprecatedUuidInterface,
|
||||||
@@ -66,7 +66,7 @@ interface UuidInterface extends
|
|||||||
/**
|
/**
|
||||||
* Returns the binary string representation of the UUID
|
* Returns the binary string representation of the UUID
|
||||||
*
|
*
|
||||||
* @psalm-return non-empty-string
|
* @return non-empty-string
|
||||||
*/
|
*/
|
||||||
public function getBytes(): string;
|
public function getBytes(): string;
|
||||||
|
|
||||||
@@ -96,14 +96,14 @@ interface UuidInterface extends
|
|||||||
/**
|
/**
|
||||||
* Returns the string standard representation of the UUID
|
* Returns the string standard representation of the UUID
|
||||||
*
|
*
|
||||||
* @psalm-return non-empty-string
|
* @return non-empty-string
|
||||||
*/
|
*/
|
||||||
public function toString(): string;
|
public function toString(): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Casts the UUID to the string standard representation
|
* Casts the UUID to the string standard representation
|
||||||
*
|
*
|
||||||
* @psalm-return non-empty-string
|
* @return non-empty-string
|
||||||
*/
|
*/
|
||||||
public function __toString(): string;
|
public function __toString(): string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ use function str_replace;
|
|||||||
/**
|
/**
|
||||||
* GenericValidator validates strings as UUIDs of any variant
|
* GenericValidator validates strings as UUIDs of any variant
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
final class GenericValidator implements ValidatorInterface
|
final class GenericValidator implements ValidatorInterface
|
||||||
{
|
{
|
||||||
@@ -32,9 +32,7 @@ final class GenericValidator implements ValidatorInterface
|
|||||||
private const VALID_PATTERN = '\A[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}\z';
|
private const VALID_PATTERN = '\A[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}\z';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @psalm-return non-empty-string
|
* @return non-empty-string
|
||||||
* @psalm-suppress MoreSpecificReturnType we know that the retrieved `string` is never empty
|
|
||||||
* @psalm-suppress LessSpecificReturnStatement we know that the retrieved `string` is never empty
|
|
||||||
*/
|
*/
|
||||||
public function getPattern(): string
|
public function getPattern(): string
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,16 +17,14 @@ namespace Ramsey\Uuid\Validator;
|
|||||||
/**
|
/**
|
||||||
* A validator validates a string as a proper UUID
|
* A validator validates a string as a proper UUID
|
||||||
*
|
*
|
||||||
* @psalm-immutable
|
* @immutable
|
||||||
*/
|
*/
|
||||||
interface ValidatorInterface
|
interface ValidatorInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Returns the regular expression pattern used by this validator
|
* Returns the regular expression pattern used by this validator
|
||||||
*
|
*
|
||||||
* @return string The regular expression pattern this validator uses
|
* @return non-empty-string The regular expression pattern this validator uses
|
||||||
*
|
|
||||||
* @psalm-return non-empty-string
|
|
||||||
*/
|
*/
|
||||||
public function getPattern(): string;
|
public function getPattern(): string;
|
||||||
|
|
||||||
|
|||||||
@@ -71,9 +71,6 @@ function v2(
|
|||||||
* @param string|UuidInterface $ns The namespace (must be a valid UUID)
|
* @param string|UuidInterface $ns The namespace (must be a valid UUID)
|
||||||
*
|
*
|
||||||
* @return non-empty-string Version 3 UUID as a string
|
* @return non-empty-string Version 3 UUID as a string
|
||||||
*
|
|
||||||
* @psalm-pure note: changing the internal factory is an edge case not covered by purity invariants,
|
|
||||||
* but under constant factory setups, this method operates in functionally pure manners
|
|
||||||
*/
|
*/
|
||||||
function v3($ns, string $name): string
|
function v3($ns, string $name): string
|
||||||
{
|
{
|
||||||
@@ -97,9 +94,6 @@ function v4(): string
|
|||||||
* @param string|UuidInterface $ns The namespace (must be a valid UUID)
|
* @param string|UuidInterface $ns The namespace (must be a valid UUID)
|
||||||
*
|
*
|
||||||
* @return non-empty-string Version 5 UUID as a string
|
* @return non-empty-string Version 5 UUID as a string
|
||||||
*
|
|
||||||
* @psalm-pure note: changing the internal factory is an edge case not covered by purity invariants,
|
|
||||||
* but under constant factory setups, this method operates in functionally pure manners
|
|
||||||
*/
|
*/
|
||||||
function v5($ns, string $name): string
|
function v5($ns, string $name): string
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -133,8 +133,7 @@ final class UuidSerializationBench
|
|||||||
/** @var UuidInterface */
|
/** @var UuidInterface */
|
||||||
private $uuid;
|
private $uuid;
|
||||||
/**
|
/**
|
||||||
* @var UuidInterface[]
|
* @var non-empty-list<UuidInterface>
|
||||||
* @psalm-var non-empty-list<UuidInterface>
|
|
||||||
*/
|
*/
|
||||||
private $promiscuousUuids;
|
private $promiscuousUuids;
|
||||||
/** @var string */
|
/** @var string */
|
||||||
@@ -144,8 +143,7 @@ final class UuidSerializationBench
|
|||||||
/** @var string */
|
/** @var string */
|
||||||
private $serializedUuid;
|
private $serializedUuid;
|
||||||
/**
|
/**
|
||||||
* @var string[]
|
* @var non-empty-list<string>
|
||||||
* @psalm-var non-empty-list<string>
|
|
||||||
*/
|
*/
|
||||||
private $serializedPromiscuousUuids;
|
private $serializedPromiscuousUuids;
|
||||||
|
|
||||||
|
|||||||
@@ -132,28 +132,23 @@ final class UuidStringConversionBench
|
|||||||
/** @var UuidInterface */
|
/** @var UuidInterface */
|
||||||
private $uuid;
|
private $uuid;
|
||||||
/**
|
/**
|
||||||
* @var UuidInterface[]
|
* @var non-empty-list<UuidInterface>
|
||||||
* @psalm-var non-empty-list<UuidInterface>
|
|
||||||
*/
|
*/
|
||||||
private $promiscuousUuids;
|
private $promiscuousUuids;
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var non-empty-string
|
||||||
* @psalm-var non-empty-string
|
|
||||||
*/
|
*/
|
||||||
private $tinyUuidBytes;
|
private $tinyUuidBytes;
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var non-empty-string
|
||||||
* @psalm-var non-empty-string
|
|
||||||
*/
|
*/
|
||||||
private $hugeUuidBytes;
|
private $hugeUuidBytes;
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var non-empty-string
|
||||||
* @psalm-var non-empty-string
|
|
||||||
*/
|
*/
|
||||||
private $uuidBytes;
|
private $uuidBytes;
|
||||||
/**
|
/**
|
||||||
* @var string[]
|
* @var non-empty-list<non-empty-string>
|
||||||
* @psalm-var non-empty-list<non-empty-string>
|
|
||||||
*/
|
*/
|
||||||
private $promiscuousUuidsBytes;
|
private $promiscuousUuidsBytes;
|
||||||
|
|
||||||
|
|||||||
@@ -29,13 +29,11 @@ use Ramsey\Uuid\UuidInterface;
|
|||||||
*/
|
*/
|
||||||
final class UuidIsImmutable
|
final class UuidIsImmutable
|
||||||
{
|
{
|
||||||
/** @psalm-pure */
|
|
||||||
public static function pureCompareTo(UuidInterface $a, UuidInterface $b): int
|
public static function pureCompareTo(UuidInterface $a, UuidInterface $b): int
|
||||||
{
|
{
|
||||||
return $a->compareTo($b);
|
return $a->compareTo($b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @psalm-pure */
|
|
||||||
public static function pureEquals(UuidInterface $a, ?object $b): bool
|
public static function pureEquals(UuidInterface $a, ?object $b): bool
|
||||||
{
|
{
|
||||||
return $a->equals($b);
|
return $a->equals($b);
|
||||||
@@ -43,9 +41,6 @@ final class UuidIsImmutable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed[]
|
* @return mixed[]
|
||||||
*
|
|
||||||
* @psalm-pure
|
|
||||||
* @psalm-suppress DeprecatedMethod
|
|
||||||
*/
|
*/
|
||||||
public static function pureGetters(UuidInterface $a): array
|
public static function pureGetters(UuidInterface $a): array
|
||||||
{
|
{
|
||||||
@@ -76,8 +71,6 @@ final class UuidIsImmutable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return UuidInterface[]|bool[]
|
* @return UuidInterface[]|bool[]
|
||||||
*
|
|
||||||
* @psalm-pure
|
|
||||||
*/
|
*/
|
||||||
public static function pureStaticUuidApi(): array
|
public static function pureStaticUuidApi(): array
|
||||||
{
|
{
|
||||||
@@ -90,7 +83,6 @@ final class UuidIsImmutable
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @psalm-pure */
|
|
||||||
public static function uuid3IsPure(): UuidInterface
|
public static function uuid3IsPure(): UuidInterface
|
||||||
{
|
{
|
||||||
return Uuid::uuid3(
|
return Uuid::uuid3(
|
||||||
@@ -99,7 +91,6 @@ final class UuidIsImmutable
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @psalm-pure */
|
|
||||||
public static function uuid5IsPure(): UuidInterface
|
public static function uuid5IsPure(): UuidInterface
|
||||||
{
|
{
|
||||||
return Uuid::uuid5(
|
return Uuid::uuid5(
|
||||||
|
|||||||
@@ -22,13 +22,13 @@ use Ramsey\Uuid\UuidInterface;
|
|||||||
*/
|
*/
|
||||||
final class UuidIsNeverEmpty
|
final class UuidIsNeverEmpty
|
||||||
{
|
{
|
||||||
/** @psalm-return non-empty-string */
|
/** @return non-empty-string */
|
||||||
public function bytesAreNeverEmpty(UuidInterface $uuid): string
|
public function bytesAreNeverEmpty(UuidInterface $uuid): string
|
||||||
{
|
{
|
||||||
return $uuid->getBytes();
|
return $uuid->getBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @psalm-return non-empty-string */
|
/** @return non-empty-string */
|
||||||
public function stringIsNeverEmpty(UuidInterface $uuid): string
|
public function stringIsNeverEmpty(UuidInterface $uuid): string
|
||||||
{
|
{
|
||||||
return $uuid->toString();
|
return $uuid->toString();
|
||||||
|
|||||||
@@ -16,18 +16,14 @@ if (!defined('UUID_TYPE_RANDOM')) {
|
|||||||
define('UUID_TYPE_RANDOM', 4);
|
define('UUID_TYPE_RANDOM', 4);
|
||||||
}
|
}
|
||||||
if (!function_exists('uuid_create')) {
|
if (!function_exists('uuid_create')) {
|
||||||
/** @psalm-suppress all */
|
|
||||||
function uuid_create(int $uuid_type=UUID_TYPE_DEFAULT): string {} // @phpstan-ignore-line
|
function uuid_create(int $uuid_type=UUID_TYPE_DEFAULT): string {} // @phpstan-ignore-line
|
||||||
}
|
}
|
||||||
if (!function_exists('uuid_generate_md5')) {
|
if (!function_exists('uuid_generate_md5')) {
|
||||||
/** @psalm-suppress all */
|
|
||||||
function uuid_generate_md5(string $uuid_ns, string $name): string {} // @phpstan-ignore-line
|
function uuid_generate_md5(string $uuid_ns, string $name): string {} // @phpstan-ignore-line
|
||||||
}
|
}
|
||||||
if (!function_exists('uuid_generate_sha1')) {
|
if (!function_exists('uuid_generate_sha1')) {
|
||||||
/** @psalm-suppress all */
|
|
||||||
function uuid_generate_sha1(string $uuid_ns, string $name): string {} // @phpstan-ignore-line
|
function uuid_generate_sha1(string $uuid_ns, string $name): string {} // @phpstan-ignore-line
|
||||||
}
|
}
|
||||||
if (!function_exists('uuid_parse')) {
|
if (!function_exists('uuid_parse')) {
|
||||||
/** @psalm-suppress all */
|
|
||||||
function uuid_parse(string $uuid): string {} // @phpstan-ignore-line
|
function uuid_parse(string $uuid): string {} // @phpstan-ignore-line
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user