Merge branch '4.x' into 5.x

This commit is contained in:
Ben Ramsey
2025-05-25 18:34:47 -05:00
117 changed files with 613 additions and 1306 deletions
-2
View File
@@ -19,8 +19,6 @@
/phpstan-tests.neon export-ignore
/phpstan.neon.dist export-ignore
/phpunit.xml.dist export-ignore
/psalm-baseline.xml export-ignore
/psalm.xml export-ignore
/resources/ export-ignore
/SECURITY.md export-ignore
/tests/ export-ignore
@@ -63,9 +63,6 @@ jobs:
- name: "Statically analyze code (PHPStan)"
run: "composer phpstan -- --ansi"
- name: "Statically analyze code (Psalm)"
run: "composer psalm -- --shepherd"
benchmark:
name: "Benchmark"
needs: ["coding-standards", "static-analysis"]
+2 -3
View File
@@ -129,9 +129,8 @@ composer phpcbf
### Static Analysis
This project uses a combination of [PHPStan](https://github.com/phpstan/phpstan)
and [Psalm](https://github.com/vimeo/psalm) to provide static analysis of PHP
code.
This project uses [PHPStan](https://github.com/phpstan/phpstan) to provide
static analysis of PHP code.
CaptainHook will run static analysis checks before committing.
-1
View File
@@ -11,7 +11,6 @@
<a href="https://github.com/ramsey/uuid/blob/5.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=5.x&logo=github&style=flat-square" alt="Build Status"></a>
<a href="https://app.codecov.io/gh/ramsey/uuid/branch/5.x"><img src="https://img.shields.io/codecov/c/github/ramsey/uuid/5.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>
ramsey/uuid is a PHP library for generating and working with universally unique
+8 -20
View File
@@ -24,16 +24,13 @@
"php-mock/php-mock-mockery": "^1.3",
"php-parallel-lint/php-parallel-lint": "^1.4.0",
"phpbench/phpbench": "^1.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.8",
"phpstan/phpstan-mockery": "^1.1",
"phpstan/phpstan-phpunit": "^1.1",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-mockery": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpunit/phpunit": "^9.5",
"psalm/plugin-phpunit": "^0.16.1",
"ramsey/composer-repl": "^1.4",
"slevomat/coding-standard": "^8.4",
"squizlabs/php_codesniffer": "^3.5",
"vimeo/psalm": "^4.22"
"squizlabs/php_codesniffer": "^3.5"
},
"replace": {
"rhumsaa/uuid": "self.version"
@@ -66,8 +63,7 @@
"captainhook/plugin-composer": true,
"ergebnis/composer-normalize": true,
"phpstan/extension-installer": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"ramsey/composer-repl": true
"dealerdirect/phpcodesniffer-composer-installer": true
},
"sort-packages": true
},
@@ -77,29 +73,21 @@
}
},
"scripts": {
"analyze": [
"@phpstan",
"@psalm"
],
"analyze": "@phpstan",
"build:clean": "git clean -fX build/",
"lint": "parallel-lint src tests",
"lint:paths": "parallel-lint",
"phpbench": "phpbench run",
"phpcbf": "phpcbf -vpw --cache=build/cache/phpcs.cache",
"phpcs": "phpcs --cache=build/cache/phpcs.cache",
"phpstan": [
"phpstan analyse --no-progress --memory-limit=1G",
"phpstan analyse -c phpstan-tests.neon --no-progress --memory-limit=1G"
],
"phpstan": "phpstan analyse --memory-limit=1G",
"phpunit": "phpunit --verbose --colors=always",
"phpunit-coverage": "phpunit --verbose --colors=always --coverage-html build/coverage",
"psalm": "psalm --show-info=false --config=psalm.xml",
"test": [
"@lint",
"@phpbench",
"@phpcs",
"@phpstan",
"@psalm",
"@phpunit"
]
}
Generated
+130 -471
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "e17d280f45e686b94dad8bca568a2a98",
"content-hash": "fc6577f454e08f13e218ac9add695c90",
"packages": [
{
"name": "brick/math",
@@ -70,16 +70,16 @@
"packages-dev": [
{
"name": "amphp/amp",
"version": "v2.6.2",
"version": "v2.6.4",
"source": {
"type": "git",
"url": "https://github.com/amphp/amp.git",
"reference": "9d5100cebffa729aaffecd3ad25dc5aeea4f13bb"
"reference": "ded3d9be08f526089eb7ee8d9f16a9768f9dec2d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/amphp/amp/zipball/9d5100cebffa729aaffecd3ad25dc5aeea4f13bb",
"reference": "9d5100cebffa729aaffecd3ad25dc5aeea4f13bb",
"url": "https://api.github.com/repos/amphp/amp/zipball/ded3d9be08f526089eb7ee8d9f16a9768f9dec2d",
"reference": "ded3d9be08f526089eb7ee8d9f16a9768f9dec2d",
"shasum": ""
},
"require": {
@@ -91,8 +91,8 @@
"ext-json": "*",
"jetbrains/phpstorm-stubs": "^2019.3",
"phpunit/phpunit": "^7 | ^8 | ^9",
"psalm/phar": "^3.11@dev",
"react/promise": "^2"
"react/promise": "^2",
"vimeo/psalm": "^3.12"
},
"type": "library",
"extra": {
@@ -147,7 +147,7 @@
"support": {
"irc": "irc://irc.freenode.org/amphp",
"issues": "https://github.com/amphp/amp/issues",
"source": "https://github.com/amphp/amp/tree/v2.6.2"
"source": "https://github.com/amphp/amp/tree/v2.6.4"
},
"funding": [
{
@@ -155,20 +155,20 @@
"type": "github"
}
],
"time": "2022-02-20T17:52:18+00:00"
"time": "2024-03-21T18:52:26+00:00"
},
{
"name": "amphp/byte-stream",
"version": "v1.8.1",
"version": "v1.8.2",
"source": {
"type": "git",
"url": "https://github.com/amphp/byte-stream.git",
"reference": "acbd8002b3536485c997c4e019206b3f10ca15bd"
"reference": "4f0e968ba3798a423730f567b1b50d3441c16ddc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/amphp/byte-stream/zipball/acbd8002b3536485c997c4e019206b3f10ca15bd",
"reference": "acbd8002b3536485c997c4e019206b3f10ca15bd",
"url": "https://api.github.com/repos/amphp/byte-stream/zipball/4f0e968ba3798a423730f567b1b50d3441c16ddc",
"reference": "4f0e968ba3798a423730f567b1b50d3441c16ddc",
"shasum": ""
},
"require": {
@@ -184,11 +184,6 @@
"psalm/phar": "^3.11.4"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"autoload": {
"files": [
"lib/functions.php"
@@ -212,7 +207,7 @@
}
],
"description": "A stream abstraction to make working with non-blocking I/O simple.",
"homepage": "http://amphp.org/byte-stream",
"homepage": "https://amphp.org/byte-stream",
"keywords": [
"amp",
"amphp",
@@ -222,9 +217,8 @@
"stream"
],
"support": {
"irc": "irc://irc.freenode.org/amphp",
"issues": "https://github.com/amphp/byte-stream/issues",
"source": "https://github.com/amphp/byte-stream/tree/v1.8.1"
"source": "https://github.com/amphp/byte-stream/tree/v1.8.2"
},
"funding": [
{
@@ -232,7 +226,7 @@
"type": "github"
}
],
"time": "2021-03-30T17:13:30+00:00"
"time": "2024-04-13T18:00:56+00:00"
},
{
"name": "captainhook/captainhook",
@@ -1762,16 +1756,16 @@
},
{
"name": "felixfbecker/language-server-protocol",
"version": "v1.5.2",
"version": "v1.5.3",
"source": {
"type": "git",
"url": "https://github.com/felixfbecker/php-language-server-protocol.git",
"reference": "6e82196ffd7c62f7794d778ca52b69feec9f2842"
"reference": "a9e113dbc7d849e35b8776da39edaf4313b7b6c9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/felixfbecker/php-language-server-protocol/zipball/6e82196ffd7c62f7794d778ca52b69feec9f2842",
"reference": "6e82196ffd7c62f7794d778ca52b69feec9f2842",
"url": "https://api.github.com/repos/felixfbecker/php-language-server-protocol/zipball/a9e113dbc7d849e35b8776da39edaf4313b7b6c9",
"reference": "a9e113dbc7d849e35b8776da39edaf4313b7b6c9",
"shasum": ""
},
"require": {
@@ -1812,9 +1806,9 @@
],
"support": {
"issues": "https://github.com/felixfbecker/php-language-server-protocol/issues",
"source": "https://github.com/felixfbecker/php-language-server-protocol/tree/v1.5.2"
"source": "https://github.com/felixfbecker/php-language-server-protocol/tree/v1.5.3"
},
"time": "2022-03-02T22:36:06+00:00"
"time": "2024-04-30T00:40:11+00:00"
},
{
"name": "hamcrest/hamcrest-php",
@@ -2130,16 +2124,16 @@
},
{
"name": "netresearch/jsonmapper",
"version": "v4.1.0",
"version": "v4.5.0",
"source": {
"type": "git",
"url": "https://github.com/cweiske/jsonmapper.git",
"reference": "cfa81ea1d35294d64adb9c68aa4cb9e92400e53f"
"reference": "8e76efb98ee8b6afc54687045e1b8dba55ac76e5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/cfa81ea1d35294d64adb9c68aa4cb9e92400e53f",
"reference": "cfa81ea1d35294d64adb9c68aa4cb9e92400e53f",
"url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/8e76efb98ee8b6afc54687045e1b8dba55ac76e5",
"reference": "8e76efb98ee8b6afc54687045e1b8dba55ac76e5",
"shasum": ""
},
"require": {
@@ -2150,7 +2144,7 @@
"php": ">=7.1"
},
"require-dev": {
"phpunit/phpunit": "~7.5 || ~8.0 || ~9.0",
"phpunit/phpunit": "~7.5 || ~8.0 || ~9.0 || ~10.0",
"squizlabs/php_codesniffer": "~3.5"
},
"type": "library",
@@ -2175,9 +2169,9 @@
"support": {
"email": "cweiske@cweiske.de",
"issues": "https://github.com/cweiske/jsonmapper/issues",
"source": "https://github.com/cweiske/jsonmapper/tree/v4.1.0"
"source": "https://github.com/cweiske/jsonmapper/tree/v4.5.0"
},
"time": "2022-12-08T20:46:14+00:00"
"time": "2024-09-08T10:13:13+00:00"
},
{
"name": "nikic/php-parser",
@@ -2954,24 +2948,27 @@
},
{
"name": "phpdocumentor/type-resolver",
"version": "1.6.2",
"version": "1.8.2",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/TypeResolver.git",
"reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d"
"reference": "153ae662783729388a584b4361f2545e4d841e3c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/48f445a408c131e38cab1c235aa6d2bb7a0bb20d",
"reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/153ae662783729388a584b4361f2545e4d841e3c",
"reference": "153ae662783729388a584b4361f2545e4d841e3c",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0",
"phpdocumentor/reflection-common": "^2.0"
"doctrine/deprecations": "^1.0",
"php": "^7.3 || ^8.0",
"phpdocumentor/reflection-common": "^2.0",
"phpstan/phpdoc-parser": "^1.13"
},
"require-dev": {
"ext-tokenizer": "*",
"phpbench/phpbench": "^1.2",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.8",
"phpstan/phpstan-phpunit": "^1.1",
@@ -3003,28 +3000,28 @@
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
"support": {
"issues": "https://github.com/phpDocumentor/TypeResolver/issues",
"source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.2"
"source": "https://github.com/phpDocumentor/TypeResolver/tree/1.8.2"
},
"time": "2022-10-14T12:47:21+00:00"
"time": "2024-02-23T11:10:43+00:00"
},
{
"name": "phpstan/extension-installer",
"version": "1.2.0",
"version": "1.4.3",
"source": {
"type": "git",
"url": "https://github.com/phpstan/extension-installer.git",
"reference": "f06dbb052ddc394e7896fcd1cfcd533f9f6ace40"
"reference": "85e90b3942d06b2326fba0403ec24fe912372936"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/extension-installer/zipball/f06dbb052ddc394e7896fcd1cfcd533f9f6ace40",
"reference": "f06dbb052ddc394e7896fcd1cfcd533f9f6ace40",
"url": "https://api.github.com/repos/phpstan/extension-installer/zipball/85e90b3942d06b2326fba0403ec24fe912372936",
"reference": "85e90b3942d06b2326fba0403ec24fe912372936",
"shasum": ""
},
"require": {
"composer-plugin-api": "^2.0",
"php": "^7.2 || ^8.0",
"phpstan/phpstan": "^1.8.0"
"phpstan/phpstan": "^1.9.0 || ^2.0"
},
"require-dev": {
"composer/composer": "^2.0",
@@ -3045,11 +3042,15 @@
"MIT"
],
"description": "Composer plugin for automatic installation of PHPStan extensions",
"keywords": [
"dev",
"static analysis"
],
"support": {
"issues": "https://github.com/phpstan/extension-installer/issues",
"source": "https://github.com/phpstan/extension-installer/tree/1.2.0"
"source": "https://github.com/phpstan/extension-installer/tree/1.4.3"
},
"time": "2022-10-17T12:59:16+00:00"
"time": "2024-09-04T20:21:43+00:00"
},
{
"name": "phpstan/phpdoc-parser",
@@ -3098,20 +3099,20 @@
},
{
"name": "phpstan/phpstan",
"version": "1.9.4",
"version": "2.1.17",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "d03bccee595e2146b7c9d174486b84f4dc61b0f2"
"reference": "89b5ef665716fa2a52ecd2633f21007a6a349053"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/d03bccee595e2146b7c9d174486b84f4dc61b0f2",
"reference": "d03bccee595e2146b7c9d174486b84f4dc61b0f2",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/89b5ef665716fa2a52ecd2633f21007a6a349053",
"reference": "89b5ef665716fa2a52ecd2633f21007a6a349053",
"shasum": ""
},
"require": {
"php": "^7.2|^8.0"
"php": "^7.4|^8.0"
},
"conflict": {
"phpstan/phpstan-shim": "*"
@@ -3136,8 +3137,11 @@
"static analysis"
],
"support": {
"docs": "https://phpstan.org/user-guide/getting-started",
"forum": "https://github.com/phpstan/phpstan/discussions",
"issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/1.9.4"
"security": "https://github.com/phpstan/phpstan/security/policy",
"source": "https://github.com/phpstan/phpstan-src"
},
"funding": [
{
@@ -3147,39 +3151,34 @@
{
"url": "https://github.com/phpstan",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan",
"type": "tidelift"
}
],
"time": "2022-12-17T13:33:52+00:00"
"time": "2025-05-21T20:55:28+00:00"
},
{
"name": "phpstan/phpstan-mockery",
"version": "1.1.0",
"version": "2.0.0",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-mockery.git",
"reference": "245b17ccd00f04be3c6b9fc6645f63793b37b2ea"
"reference": "89a949d0ac64298e88b7c7fa00caee565c198394"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-mockery/zipball/245b17ccd00f04be3c6b9fc6645f63793b37b2ea",
"reference": "245b17ccd00f04be3c6b9fc6645f63793b37b2ea",
"url": "https://api.github.com/repos/phpstan/phpstan-mockery/zipball/89a949d0ac64298e88b7c7fa00caee565c198394",
"reference": "89a949d0ac64298e88b7c7fa00caee565c198394",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0",
"phpstan/phpstan": "^1.5.0"
"php": "^7.4 || ^8.0",
"phpstan/phpstan": "^2.0"
},
"require-dev": {
"mockery/mockery": "^1.2.4",
"nikic/php-parser": "^4.13.0",
"mockery/mockery": "^1.6.11",
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0",
"phpunit/phpunit": "^9.5"
"phpstan/phpstan-phpunit": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^9.6"
},
"type": "phpstan-extension",
"extra": {
@@ -3201,36 +3200,37 @@
"description": "PHPStan Mockery extension",
"support": {
"issues": "https://github.com/phpstan/phpstan-mockery/issues",
"source": "https://github.com/phpstan/phpstan-mockery/tree/1.1.0"
"source": "https://github.com/phpstan/phpstan-mockery/tree/2.0.0"
},
"time": "2022-05-09T13:12:35+00:00"
"time": "2024-10-14T03:18:12+00:00"
},
{
"name": "phpstan/phpstan-phpunit",
"version": "1.3.3",
"version": "2.0.6",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-phpunit.git",
"reference": "54a24bd23e9e80ee918cdc24f909d376c2e273f7"
"reference": "6b92469f8a7995e626da3aa487099617b8dfa260"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/54a24bd23e9e80ee918cdc24f909d376c2e273f7",
"reference": "54a24bd23e9e80ee918cdc24f909d376c2e273f7",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/6b92469f8a7995e626da3aa487099617b8dfa260",
"reference": "6b92469f8a7995e626da3aa487099617b8dfa260",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0",
"phpstan/phpstan": "^1.9.3"
"php": "^7.4 || ^8.0",
"phpstan/phpstan": "^2.0.4"
},
"conflict": {
"phpunit/phpunit": "<7.0"
},
"require-dev": {
"nikic/php-parser": "^4.13.0",
"nikic/php-parser": "^5",
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/phpstan-strict-rules": "^1.0",
"phpunit/phpunit": "^9.5"
"phpstan/phpstan-deprecation-rules": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^9.6"
},
"type": "phpstan-extension",
"extra": {
@@ -3253,9 +3253,9 @@
"description": "PHPUnit extensions and rules for PHPStan",
"support": {
"issues": "https://github.com/phpstan/phpstan-phpunit/issues",
"source": "https://github.com/phpstan/phpstan-phpunit/tree/1.3.3"
"source": "https://github.com/phpstan/phpstan-phpunit/tree/2.0.6"
},
"time": "2022-12-21T15:25:00+00:00"
"time": "2025-03-26T12:47:06+00:00"
},
{
"name": "phpunit/php-code-coverage",
@@ -3889,265 +3889,25 @@
},
"time": "2021-07-14T16:46:02+00:00"
},
{
"name": "psy/psysh",
"version": "v0.11.10",
"source": {
"type": "git",
"url": "https://github.com/bobthecow/psysh.git",
"reference": "e9eadffbed9c9deb5426fd107faae0452bf20a36"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/bobthecow/psysh/zipball/e9eadffbed9c9deb5426fd107faae0452bf20a36",
"reference": "e9eadffbed9c9deb5426fd107faae0452bf20a36",
"shasum": ""
},
"require": {
"ext-json": "*",
"ext-tokenizer": "*",
"nikic/php-parser": "^4.0 || ^3.1",
"php": "^8.0 || ^7.0.8",
"symfony/console": "^6.0 || ^5.0 || ^4.0 || ^3.4",
"symfony/var-dumper": "^6.0 || ^5.0 || ^4.0 || ^3.4"
},
"conflict": {
"symfony/console": "4.4.37 || 5.3.14 || 5.3.15 || 5.4.3 || 5.4.4 || 6.0.3 || 6.0.4"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.2"
},
"suggest": {
"ext-pcntl": "Enabling the PCNTL extension makes PsySH a lot happier :)",
"ext-pdo-sqlite": "The doc command requires SQLite to work.",
"ext-posix": "If you have PCNTL, you'll want the POSIX extension as well.",
"ext-readline": "Enables support for arrow-key history navigation, and showing and manipulating command history."
},
"bin": [
"bin/psysh"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "0.11.x-dev"
}
},
"autoload": {
"files": [
"src/functions.php"
],
"psr-4": {
"Psy\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Justin Hileman",
"email": "justin@justinhileman.info",
"homepage": "http://justinhileman.com"
}
],
"description": "An interactive shell for modern PHP.",
"homepage": "http://psysh.org",
"keywords": [
"REPL",
"console",
"interactive",
"shell"
],
"support": {
"issues": "https://github.com/bobthecow/psysh/issues",
"source": "https://github.com/bobthecow/psysh/tree/v0.11.10"
},
"time": "2022-12-23T17:47:18+00:00"
},
{
"name": "ramsey/composer-repl",
"version": "1.4.1",
"source": {
"type": "git",
"url": "https://github.com/ramsey/composer-repl.git",
"reference": "24553610c07df626c7dfd44ef328b7ae3349366f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ramsey/composer-repl/zipball/24553610c07df626c7dfd44ef328b7ae3349366f",
"reference": "24553610c07df626c7dfd44ef328b7ae3349366f",
"shasum": ""
},
"require": {
"composer-plugin-api": "^2",
"php": "^7.4 || ^8",
"ramsey/composer-repl-lib": "^1.1"
},
"require-dev": {
"captainhook/captainhook": "^5.10",
"captainhook/plugin-composer": "^5.3",
"ergebnis/composer-normalize": "^2.25",
"roave/security-advisories": "dev-latest"
},
"type": "composer-plugin",
"extra": {
"branch-alias": {
"dev-main": "1.x-dev"
},
"captainhook": {
"force-install": true
},
"class": "Ramsey\\Dev\\Repl\\Composer\\ReplPlugin",
"ramsey/conventional-commits": {
"configFile": "conventional-commits.json"
},
"ramsey/devtools": {
"command-prefix": "dev"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ben Ramsey",
"email": "ben@benramsey.com",
"homepage": "https://benramsey.com"
}
],
"description": "A REPL for PHP built into Composer.",
"keywords": [
"REPL",
"psysh",
"shell"
],
"support": {
"issues": "https://github.com/ramsey/composer-repl/issues",
"source": "https://github.com/ramsey/composer-repl/tree/1.4.1"
},
"funding": [
{
"url": "https://github.com/ramsey",
"type": "github"
}
],
"time": "2022-04-17T02:07:54+00:00"
},
{
"name": "ramsey/composer-repl-lib",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/ramsey/composer-repl-lib.git",
"reference": "53f7666f1f4b49711741ad22b633671a312a6fdc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ramsey/composer-repl-lib/zipball/53f7666f1f4b49711741ad22b633671a312a6fdc",
"reference": "53f7666f1f4b49711741ad22b633671a312a6fdc",
"shasum": ""
},
"require": {
"composer/composer": "^2.1.9",
"php": "^7.4 || ^8",
"phpunit/phpunit": "^6 || ^7 || ^8 || ^9",
"psy/psysh": "^0.11.0",
"symfony/console": "^4.4.30 || ^5.3.7 || ^6",
"symfony/process": "^4.4.30 || ^5.3.7 || ^6"
},
"require-dev": {
"captainhook/captainhook": "^5.10",
"captainhook/plugin-composer": "^5.3",
"ergebnis/composer-normalize": "^2.25",
"hamcrest/hamcrest-php": "^2.0",
"mockery/mockery": "^1.5",
"php-parallel-lint/php-console-highlighter": "^1.0",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.5",
"phpstan/phpstan-mockery": "^1.0",
"phpstan/phpstan-phpunit": "^1.1",
"psalm/plugin-mockery": "^0.9.1",
"psalm/plugin-phpunit": "^0.16.1",
"ramsey/coding-standard": "^2.0.3",
"roave/security-advisories": "dev-latest",
"vimeo/psalm": "^4.22"
},
"bin": [
"bin/repl"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.x-dev"
},
"captainhook": {
"force-install": true
},
"ramsey/composer-repl": {
"includes": [
"repl.php"
]
},
"ramsey/conventional-commits": {
"configFile": "conventional-commits.json"
}
},
"autoload": {
"psr-4": {
"Ramsey\\Dev\\Repl\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ben Ramsey",
"email": "ben@benramsey.com",
"homepage": "https://benramsey.com"
}
],
"description": "The library behind ramsey/composer-repl, allowing for extension of the ramsey/composer-repl Composer plugin and non-plugin use of the repl command.",
"keywords": [
"REPL",
"psysh",
"shell"
],
"support": {
"issues": "https://github.com/ramsey/composer-repl-lib/issues",
"source": "https://github.com/ramsey/composer-repl-lib/tree/1.1.0"
},
"funding": [
{
"url": "https://github.com/ramsey",
"type": "github"
}
],
"time": "2022-04-17T01:54:57+00:00"
},
{
"name": "react/promise",
"version": "v2.9.0",
"version": "v2.11.0",
"source": {
"type": "git",
"url": "https://github.com/reactphp/promise.git",
"reference": "234f8fd1023c9158e2314fa9d7d0e6a83db42910"
"reference": "1a8460931ea36dc5c76838fec5734d55c88c6831"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/reactphp/promise/zipball/234f8fd1023c9158e2314fa9d7d0e6a83db42910",
"reference": "234f8fd1023c9158e2314fa9d7d0e6a83db42910",
"url": "https://api.github.com/repos/reactphp/promise/zipball/1a8460931ea36dc5c76838fec5734d55c88c6831",
"reference": "1a8460931ea36dc5c76838fec5734d55c88c6831",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
},
"require-dev": {
"phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.36"
"phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36"
},
"type": "library",
"autoload": {
@@ -4191,19 +3951,15 @@
],
"support": {
"issues": "https://github.com/reactphp/promise/issues",
"source": "https://github.com/reactphp/promise/tree/v2.9.0"
"source": "https://github.com/reactphp/promise/tree/v2.11.0"
},
"funding": [
{
"url": "https://github.com/WyriHaximus",
"type": "github"
},
{
"url": "https://github.com/clue",
"type": "github"
"url": "https://opencollective.com/reactphp",
"type": "open_collective"
}
],
"time": "2022-02-11T10:27:51+00:00"
"time": "2023-11-16T16:16:50+00:00"
},
{
"name": "sebastian/cli-parser",
@@ -5458,16 +5214,16 @@
},
{
"name": "seld/signal-handler",
"version": "2.0.1",
"version": "2.0.2",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/signal-handler.git",
"reference": "f69d119511dc0360440cdbdaa71829c149b7be75"
"reference": "04a6112e883ad76c0ada8e4a9f7520bbfdb6bb98"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/signal-handler/zipball/f69d119511dc0360440cdbdaa71829c149b7be75",
"reference": "f69d119511dc0360440cdbdaa71829c149b7be75",
"url": "https://api.github.com/repos/Seldaek/signal-handler/zipball/04a6112e883ad76c0ada8e4a9f7520bbfdb6bb98",
"reference": "04a6112e883ad76c0ada8e4a9f7520bbfdb6bb98",
"shasum": ""
},
"require": {
@@ -5513,9 +5269,9 @@
],
"support": {
"issues": "https://github.com/Seldaek/signal-handler/issues",
"source": "https://github.com/Seldaek/signal-handler/tree/2.0.1"
"source": "https://github.com/Seldaek/signal-handler/tree/2.0.2"
},
"time": "2022-07-20T18:31:45+00:00"
"time": "2023-09-03T09:24:00+00:00"
},
{
"name": "slevomat/coding-standard",
@@ -6327,29 +6083,26 @@
},
{
"name": "symfony/polyfill-php73",
"version": "v1.27.0",
"version": "v1.32.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php73.git",
"reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9"
"reference": "0f68c03565dcaaf25a890667542e8bd75fe7e5bb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/9e8ecb5f92152187c4799efd3c96b78ccab18ff9",
"reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9",
"url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/0f68c03565dcaaf25a890667542e8bd75fe7e5bb",
"reference": "0f68c03565dcaaf25a890667542e8bd75fe7e5bb",
"shasum": ""
},
"require": {
"php": ">=7.1"
"php": ">=7.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.27-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
"url": "https://github.com/symfony/polyfill",
"name": "symfony/polyfill"
}
},
"autoload": {
@@ -6386,7 +6139,7 @@
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php73/tree/v1.27.0"
"source": "https://github.com/symfony/polyfill-php73/tree/v1.32.0"
},
"funding": [
{
@@ -6402,33 +6155,30 @@
"type": "tidelift"
}
],
"time": "2022-11-03T14:55:06+00:00"
"time": "2024-09-09T11:45:10+00:00"
},
{
"name": "symfony/polyfill-php80",
"version": "v1.27.0",
"version": "v1.32.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php80.git",
"reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936"
"reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936",
"reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/0cc9dd0f17f61d8131e7df6b84bd344899fe2608",
"reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608",
"shasum": ""
},
"require": {
"php": ">=7.1"
"php": ">=7.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.27-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
"url": "https://github.com/symfony/polyfill",
"name": "symfony/polyfill"
}
},
"autoload": {
@@ -6469,7 +6219,7 @@
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php80/tree/v1.27.0"
"source": "https://github.com/symfony/polyfill-php80/tree/v1.32.0"
},
"funding": [
{
@@ -6485,33 +6235,30 @@
"type": "tidelift"
}
],
"time": "2022-11-03T14:55:06+00:00"
"time": "2025-01-02T08:10:11+00:00"
},
{
"name": "symfony/polyfill-php81",
"version": "v1.27.0",
"version": "v1.32.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php81.git",
"reference": "707403074c8ea6e2edaf8794b0157a0bfa52157a"
"reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/707403074c8ea6e2edaf8794b0157a0bfa52157a",
"reference": "707403074c8ea6e2edaf8794b0157a0bfa52157a",
"url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c",
"reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c",
"shasum": ""
},
"require": {
"php": ">=7.1"
"php": ">=7.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.27-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
"url": "https://github.com/symfony/polyfill",
"name": "symfony/polyfill"
}
},
"autoload": {
@@ -6548,7 +6295,7 @@
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php81/tree/v1.27.0"
"source": "https://github.com/symfony/polyfill-php81/tree/v1.32.0"
},
"funding": [
{
@@ -6564,7 +6311,7 @@
"type": "tidelift"
}
],
"time": "2022-11-03T14:55:06+00:00"
"time": "2024-09-09T11:45:10+00:00"
},
{
"name": "symfony/process",
@@ -6798,94 +6545,6 @@
],
"time": "2022-12-14T16:11:27+00:00"
},
{
"name": "symfony/var-dumper",
"version": "v6.2.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-dumper.git",
"reference": "fdbadd4803bc3c96ef89238c9c9e2ebe424ec2e0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/fdbadd4803bc3c96ef89238c9c9e2ebe424ec2e0",
"reference": "fdbadd4803bc3c96ef89238c9c9e2ebe424ec2e0",
"shasum": ""
},
"require": {
"php": ">=8.1",
"symfony/polyfill-mbstring": "~1.0"
},
"conflict": {
"phpunit/phpunit": "<5.4.3",
"symfony/console": "<5.4"
},
"require-dev": {
"ext-iconv": "*",
"symfony/console": "^5.4|^6.0",
"symfony/process": "^5.4|^6.0",
"symfony/uid": "^5.4|^6.0",
"twig/twig": "^2.13|^3.0.4"
},
"suggest": {
"ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).",
"ext-intl": "To show region name in time zone dump",
"symfony/console": "To use the ServerDumpCommand and/or the bin/var-dump-server script"
},
"bin": [
"Resources/bin/var-dump-server"
],
"type": "library",
"autoload": {
"files": [
"Resources/functions/dump.php"
],
"psr-4": {
"Symfony\\Component\\VarDumper\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Provides mechanisms for walking through any arbitrary PHP variable",
"homepage": "https://symfony.com",
"keywords": [
"debug",
"dump"
],
"support": {
"source": "https://github.com/symfony/var-dumper/tree/v6.2.3"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2022-12-22T17:55:15+00:00"
},
{
"name": "theseer/tokenizer",
"version": "1.2.1",
@@ -7008,10 +6667,10 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.x-dev",
"dev-3.x": "3.x-dev",
"dev-1.x": "1.x-dev",
"dev-2.x": "2.x-dev",
"dev-1.x": "1.x-dev"
"dev-3.x": "3.x-dev",
"dev-master": "4.x-dev"
}
},
"autoload": {
-32
View File
@@ -1,32 +0,0 @@
parameters:
tmpDir: ./build/cache/phpstan
level: max
paths:
- ./tests
bootstrapFiles:
- ./tests/static-analysis/stubs.php
checkMissingIterableValueType: false
reportUnmatchedIgnoredErrors: false
excludePaths:
analyse:
- ./tests/ExpectedBehaviorTest.php
- ./tests/static-analysis/stubs.php
ignoreErrors:
-
message: "#^Call to static method Ramsey\\\\Uuid\\\\.+ on a separate line has no effect\\.$#"
paths:
- ./tests/*Test.php
- ./tests/benchmark/*Bench.php
-
message: "#^Call to method Ramsey\\\\Uuid\\\\.+ on a separate line has no effect\\.$#"
paths:
- ./tests/Builder/*Test.php
- ./tests/Converter/*Test.php
- ./tests/Generator/*Test.php
- ./tests/Guid/*Test.php
- ./tests/Nonstandard/*Test.php
- ./tests/Rfc4122/*Test.php
-
message: "#^Method Ramsey\\\\Uuid\\\\.+ should return non-empty-string but returns string\\.$#"
paths:
- ./tests/static-analysis/ValidUuidIsNonEmpty.php
+6 -18
View File
@@ -1,25 +1,13 @@
parameters:
tmpDir: ./build/cache/phpstan
level: max
treatPhpDocTypesAsCertain: false
paths:
- ./src
checkMissingIterableValueType: false
- ./tests
bootstrapFiles:
- ./tests/static-analysis/stubs.php
ignoreErrors:
-
message: '#^Comparison operation ">" between 6 and 0 is always true\.$#'
count: 1
path: ./src/Generator/CombGenerator.php
-
message: '#^Result of \|\| is always false\.$#'
count: 1
path: ./src/Generator/DceSecurityGenerator.php
-
message: '#^Comparison operation ">" between int<0, 63>\|null and 63 is always false\.$#'
count: 1
path: ./src/Generator/DceSecurityGenerator.php
-
message: '#^Comparison operation "<" between int<0, 63>\|null and 0 is always false\.$#'
count: 1
path: ./src/Generator/DceSecurityGenerator.php
excludePaths:
analyse:
- ./tests/ExpectedBehaviorTest.php
- ./tests/static-analysis/stubs.php
-133
View File
@@ -1,133 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.30.0@d0bc6e25d89f649e4f36a534f330f8bb4643dd69">
<file src="src/Builder/FallbackBuilder.php">
<ImpureMethodCall occurrences="1"/>
<ImpureVariable occurrences="1">
<code>$this</code>
</ImpureVariable>
</file>
<file src="src/Converter/Number/GenericNumberConverter.php">
<ImpureVariable occurrences="2">
<code>$this</code>
<code>$this</code>
</ImpureVariable>
</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/Decimal.php">
<InaccessibleProperty occurrences="1">
<code>$this-&gt;isNegative</code>
</InaccessibleProperty>
</file>
<file src="src/Uuid.php">
<ImpureMethodCall occurrences="6">
<code>getFactory</code>
<code>getFactory</code>
<code>getFactory</code>
<code>getFactory</code>
<code>getFactory</code>
<code>getFactory</code>
</ImpureMethodCall>
</file>
<file src="src/UuidFactory.php">
<ImpurePropertyFetch occurrences="6">
<code>$this-&gt;codec</code>
<code>$this-&gt;codec</code>
<code>$this-&gt;codec</code>
<code>$this-&gt;isDefaultFeatureSet</code>
<code>$this-&gt;nameGenerator</code>
<code>$this-&gt;numberConverter</code>
</ImpurePropertyFetch>
<ImpureVariable occurrences="14">
<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>
</files>
-26
View File
@@ -1,26 +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>
<plugins>
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
</plugins>
</psalm>
+4 -10
View File
@@ -35,8 +35,6 @@ class BinaryUtils
* variant is applied
*
* @return int The 16-bit clock sequence multiplexed with the UUID variant
*
* @psalm-pure
*/
public static function applyVariant(int $clockSeq, Variant $variant = Variant::Rfc4122): int
{
@@ -59,8 +57,6 @@ class BinaryUtils
*
* @return int The 16-bit time_hi field of the timestamp multiplexed with
* the UUID version number
*
* @psalm-pure
*/
public static function applyVersion(int $timeHi, Version $version): int
{
@@ -80,22 +76,20 @@ class BinaryUtils
* @param Version $version The RFC 4122 version to apply
*
* @return non-empty-string A 16-byte string with the UUID version and variant applied
*
* @psalm-pure
*/
public static function applyVersionAndVariant(
string $bytes,
Version $version,
Variant $variant = Variant::Rfc4122
): string {
/** @var array $unpackedTime */
/** @var int[] $unpackedTime */
$unpackedTime = unpack('n*', substr($bytes, 6, 2));
$timeHi = (int) $unpackedTime[1];
$timeHi = $unpackedTime[1];
$timeHiAndVersion = pack('n*', self::applyVersion($timeHi, $version));
/** @var array $unpackedClockSeq */
/** @var int[] $unpackedClockSeq */
$unpackedClockSeq = unpack('n*', substr($bytes, 8, 2));
$clockSeqHi = (int) $unpackedClockSeq[1];
$clockSeqHi = $unpackedClockSeq[1];
$clockSeqHiAndReserved = pack('n*', self::applyVariant($clockSeqHi, $variant));
$bytes = substr_replace($bytes, $timeHiAndVersion, 6, 2);
+1 -3
View File
@@ -23,7 +23,7 @@ use Ramsey\Uuid\UuidInterface;
* FallbackBuilder builds a UUID by stepping through a list of UUID builders
* until a UUID can be constructed without exceptions
*
* @psalm-immutable
* @immutable
*/
class FallbackBuilder implements UuidBuilderInterface
{
@@ -42,8 +42,6 @@ class FallbackBuilder implements UuidBuilderInterface
* @param non-empty-string $bytes The byte string from which to construct a UUID
*
* @return UuidInterface an instance of a UUID object
*
* @psalm-pure
*/
public function build(CodecInterface $codec, string $bytes): UuidInterface
{
+1 -3
View File
@@ -20,7 +20,7 @@ use Ramsey\Uuid\UuidInterface;
/**
* A UUID builder builds instances of UuidInterface
*
* @psalm-immutable
* @immutable
*/
interface UuidBuilderInterface
{
@@ -32,8 +32,6 @@ interface UuidBuilderInterface
*
* @return UuidInterface Implementations may choose to return more specific
* instances of UUIDs that implement UuidInterface
*
* @psalm-pure
*/
public function build(CodecInterface $codec, string $bytes): UuidInterface;
}
+1 -1
View File
@@ -19,7 +19,7 @@ use Ramsey\Uuid\UuidInterface;
/**
* A codec encodes and decodes a UUID according to defined rules
*
* @psalm-immutable
* @immutable
*/
interface CodecInterface
{
+1 -1
View File
@@ -26,7 +26,7 @@ use function substr;
*
* @see Guid
*
* @psalm-immutable
* @immutable
*/
class GuidStringCodec extends StringCodec
{
+3 -8
View File
@@ -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
*
* @psalm-immutable
* @immutable
*/
class OrderedTimeCodec extends StringCodec
{
@@ -49,7 +49,7 @@ class OrderedTimeCodec extends StringCodec
* Returns a binary string representation of a UUID, with the timestamp
* fields rearranged for optimized storage
*
* @inheritDoc
* @return non-empty-string
*/
public function encodeBinary(UuidInterface $uuid): string
{
@@ -86,12 +86,7 @@ class OrderedTimeCodec extends StringCodec
);
}
/**
* Rearrange the bytes to their original order.
*
* @psalm-suppress UnnecessaryVarAnnotation
* @phpstan-var non-empty-string $rearrangedBytes
*/
// Rearrange the bytes to their original order.
$rearrangedBytes = $bytes[4] . $bytes[5] . $bytes[6] . $bytes[7]
. $bytes[2] . $bytes[3]
. $bytes[0] . $bytes[1]
+4 -1
View File
@@ -33,7 +33,7 @@ use function substr;
*
* @link http://tools.ietf.org/html/rfc4122
*
* @psalm-immutable
* @immutable
*/
class StringCodec implements CodecInterface
{
@@ -61,6 +61,9 @@ class StringCodec implements CodecInterface
);
}
/**
* @return non-empty-string
*/
public function encodeBinary(UuidInterface $uuid): string
{
return $uuid->getFields()->getBytes();
+7 -1
View File
@@ -46,10 +46,13 @@ use function substr_replace;
*
* @link https://www.informit.com/articles/printerfriendly/25862 The Cost of GUIDs as Primary Keys
*
* @psalm-immutable
* @immutable
*/
class TimestampFirstCombCodec extends StringCodec
{
/**
* @return non-empty-string
*/
public function encode(UuidInterface $uuid): string
{
$bytes = $this->swapBytes($uuid->getFields()->getBytes());
@@ -65,6 +68,9 @@ class TimestampFirstCombCodec extends StringCodec
);
}
/**
* @return non-empty-string
*/
public function encodeBinary(UuidInterface $uuid): string
{
return $this->swapBytes($uuid->getFields()->getBytes());
+1 -1
View File
@@ -44,7 +44,7 @@ namespace Ramsey\Uuid\Codec;
*
* @link https://www.informit.com/articles/printerfriendly/25862 The Cost of GUIDs as Primary Keys
*
* @psalm-immutable
* @immutable
*/
class TimestampLastCombCodec extends StringCodec
{
@@ -22,7 +22,7 @@ use Ramsey\Uuid\Type\Integer as IntegerObject;
* GenericNumberConverter uses the provided calculator to convert decimal
* numbers to and from hexadecimal values
*
* @psalm-immutable
* @immutable
*/
class GenericNumberConverter implements NumberConverterInterface
{
@@ -30,17 +30,11 @@ class GenericNumberConverter implements NumberConverterInterface
{
}
/**
* @psalm-pure
*/
public function fromHex(string $hex): string
{
return $this->calculator->fromBase($hex, 16)->toString();
}
/**
* @psalm-pure
*/
public function toHex(string $number): string
{
return $this->calculator->toBase(new IntegerObject($number), 16);
+2 -6
View File
@@ -18,7 +18,7 @@ namespace Ramsey\Uuid\Converter;
* A number converter converts UUIDs from hexadecimal characters into
* representations of integers and vice versa
*
* @psalm-immutable
* @immutable
*/
interface NumberConverterInterface
{
@@ -27,13 +27,11 @@ interface NumberConverterInterface
* the number
*
* 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 non-empty-string $hex The hexadecimal string representation to convert
*
* @return numeric-string String representation of an integer
*
* @psalm-pure
*/
public function fromHex(string $hex): string;
@@ -46,8 +44,6 @@ interface NumberConverterInterface
* greater than PHP_INT_MAX.
*
* @return non-empty-string Hexadecimal string
*
* @psalm-pure
*/
public function toHex(string $number): string;
}
+1 -1
View File
@@ -30,7 +30,7 @@ use const STR_PAD_LEFT;
* GenericTimeConverter uses the provided calculator to calculate and convert
* time values
*
* @psalm-immutable
* @immutable
*/
class GenericTimeConverter implements TimeConverterInterface
{
+2 -2
View File
@@ -37,7 +37,7 @@ use const STR_PAD_LEFT;
* available to the PHP programming language to provide facilities for
* converting parts of time into representations that may be used in UUIDs
*
* @psalm-immutable
* @immutable
*/
class PhpTimeConverter implements TimeConverterInterface
{
@@ -79,7 +79,7 @@ class PhpTimeConverter implements TimeConverterInterface
// Check to see whether we've overflowed the max/min integer size.
// If so, we will default to a different time converter.
/** @psalm-suppress RedundantCondition */
// @phpstan-ignore function.alreadyNarrowedType (the integer value might have overflowed)
if (!is_int($uuidTime)) {
return $this->fallbackConverter->calculateTime(
$seconds->toString(),
+1 -1
View File
@@ -30,7 +30,7 @@ use const STR_PAD_LEFT;
* UnixTimeConverter converts Unix Epoch timestamps to/from hexadecimal values
* consisting of milliseconds elapsed since the Unix Epoch
*
* @psalm-immutable
* @immutable
*/
class UnixTimeConverter implements TimeConverterInterface
{
+1 -5
View File
@@ -21,7 +21,7 @@ use Ramsey\Uuid\Type\Time;
* A time converter converts timestamps into representations that may be used
* in UUIDs
*
* @psalm-immutable
* @immutable
*/
interface TimeConverterInterface
{
@@ -38,8 +38,6 @@ interface TimeConverterInterface
* micro-seconds associated with the time to calculate
*
* @return Hexadecimal The full UUID timestamp as a Hexadecimal value
*
* @psalm-pure
*/
public function calculateTime(string $seconds, string $microseconds): Hexadecimal;
@@ -51,8 +49,6 @@ interface TimeConverterInterface
* since UTC 00:00:00.00, 15 October 1582.
*
* @return Time An instance of {@see Time}
*
* @psalm-pure
*/
public function convertTime(Hexadecimal $uuidTimestamp): Time;
}
-1
View File
@@ -210,7 +210,6 @@ class FeatureSet
$this->numberConverter = $this->buildNumberConverter($calculator);
$this->timeConverter = $this->buildTimeConverter($calculator);
/** @psalm-suppress RedundantPropertyInitializationCheck */
if (isset($this->timeProvider)) {
$this->timeGenerator = $this->buildTimeGenerator($this->timeProvider);
}
+2 -2
View File
@@ -15,11 +15,11 @@ declare(strict_types=1);
namespace Ramsey\Uuid\Fields;
/**
* 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
* for the variant
*
* @psalm-immutable
* @immutable
*/
interface FieldsInterface
{
+1 -2
View File
@@ -23,7 +23,7 @@ use function strlen;
/**
* Provides common serialization functionality to fields
*
* @psalm-immutable
* @immutable
*/
trait SerializableFieldsTrait
{
@@ -49,7 +49,6 @@ trait SerializableFieldsTrait
/**
* @inheritDoc
* @psalm-suppress UnusedMethodCall
*/
public function __unserialize(array $data): void
{
+2
View File
@@ -87,6 +87,8 @@ class CombGenerator implements RandomGeneratorInterface
}
$hash = '';
/** @phpstan-ignore greater.alwaysTrue (TIMESTAMP_BYTES constant could change in child classes) */
if (self::TIMESTAMP_BYTES > 0 && $length > self::TIMESTAMP_BYTES) {
$hash = $this->generator->generate($length - self::TIMESTAMP_BYTES);
}
+1 -1
View File
@@ -124,7 +124,7 @@ class DceSecurityGenerator implements DceSecurityGeneratorInterface
// Shift the clock sequence 8 bits to the left, so it matches 0x3f00.
if ($clockSeq !== null) {
/** @var int<0, 16383> $clockSeq */
/** @var int<0, 16128> $clockSeq */
$clockSeq = $clockSeq << 8;
}
+5 -16
View File
@@ -26,26 +26,15 @@ use function hash;
*/
class DefaultNameGenerator implements NameGeneratorInterface
{
/**
* @inheritDoc
* @psalm-pure
*/
public function generate(UuidInterface $ns, string $name, string $hashAlgorithm): string
{
try {
/** @var non-empty-string|false $bytes */
$bytes = @hash($hashAlgorithm, $ns->getBytes() . $name, true);
return hash($hashAlgorithm, $ns->getBytes() . $name, true);
} catch (ValueError $e) {
$bytes = false; // keep same behavior than PHP 7
throw new NameException(
message: sprintf('Unable to hash namespace and name with algorithm \'%s\'', $hashAlgorithm),
previous: $e,
);
}
if ($bytes === false) {
throw new NameException(sprintf(
'Unable to hash namespace and name with algorithm \'%s\'',
$hashAlgorithm
));
}
return $bytes;
}
}
-2
View File
@@ -31,8 +31,6 @@ interface NameGeneratorInterface
* @param non-empty-string $hashAlgorithm The hashing algorithm to use
*
* @return non-empty-string A binary string
*
* @psalm-pure
*/
public function generate(UuidInterface $ns, string $name, string $hashAlgorithm): string;
}
-4
View File
@@ -30,10 +30,6 @@ use function uuid_parse;
*/
class PeclUuidNameGenerator implements NameGeneratorInterface
{
/**
* @inheritDoc
* @psalm-pure
*/
public function generate(UuidInterface $ns, string $name, string $hashAlgorithm): string
{
$uuid = match ($hashAlgorithm) {
+7 -7
View File
@@ -38,11 +38,11 @@ use function unpack;
use const STR_PAD_LEFT;
/**
* GUIDs are comprised of a set of named fields, according to RFC 4122
* GUIDs consist of a set of named fields, according to RFC 4122
*
* @see Guid
*
* @psalm-immutable
* @immutable
*/
final class Fields implements FieldsInterface
{
@@ -90,7 +90,7 @@ final class Fields implements FieldsInterface
public function getTimeLow(): Hexadecimal
{
// Swap the bytes from little endian to network byte order.
/** @var array{mixed, non-empty-string} $hex */
/** @var non-empty-string[] $hex */
$hex = unpack(
'H*',
pack(
@@ -106,7 +106,7 @@ final class Fields implements FieldsInterface
public function getTimeMid(): Hexadecimal
{
// Swap the bytes from little endian to network byte order.
/** @var array{mixed, non-empty-string} $hex */
/** @var non-empty-string[] $hex */
$hex = unpack(
'H*',
pack(
@@ -121,7 +121,7 @@ final class Fields implements FieldsInterface
public function getTimeHiAndVersion(): Hexadecimal
{
// Swap the bytes from little endian to network byte order.
/** @var array{mixed, non-empty-string} $hex */
/** @var non-empty-string[] $hex */
$hex = unpack(
'H*',
pack(
@@ -189,10 +189,10 @@ final class Fields implements FieldsInterface
return null;
}
/** @var array $parts */
/** @var int[] $parts */
$parts = unpack('n*', $this->bytes);
return Version::tryFrom(((int) $parts[4] >> 4) & 0x00f);
return Version::tryFrom(($parts[4] >> 4) & 0x00f);
}
private function isCorrectVariant(): bool
+1 -1
View File
@@ -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.tobytearray .NET Guid.ToByteArray Method
*
* @psalm-immutable
* @immutable
*/
final class Guid extends Uuid
{
+1 -3
View File
@@ -27,7 +27,7 @@ use Throwable;
*
* @see Guid
*
* @psalm-immutable
* @immutable
*/
class GuidBuilder implements UuidBuilderInterface
{
@@ -50,8 +50,6 @@ class GuidBuilder implements UuidBuilderInterface
* @param non-empty-string $bytes The byte string from which to construct a UUID
*
* @return Guid The GuidBuilder returns an instance of Ramsey\Uuid\Guid\Guid
*
* @psalm-pure
*/
public function build(CodecInterface $codec, string $bytes): UuidInterface
{
+4 -31
View File
@@ -38,19 +38,14 @@ use function substr;
* conversion. This object optimizes instantiation, serialization and string conversion time, at the cost of
* increased overhead for more advanced UUID operations.
*
* @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.
*
* @psalm-immutable
*
* 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,
* and is deprecated anyway.
* 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.
*
* @psalm-suppress UndefinedInterfaceMethod
* @psalm-suppress DeprecatedMethod
*/
final class LazyUuidFromString implements TimeBasedUuidInterface
{
@@ -59,15 +54,12 @@ final class LazyUuidFromString implements TimeBasedUuidInterface
private ?UuidInterface $unwrapped = null;
/**
* @psalm-param non-empty-string $uuid
* @param non-empty-string $uuid
*/
public function __construct(private readonly string $uuid)
{
}
/**
* @psalm-pure
*/
public static function fromBytes(string $bytes): self
{
$base16Uuid = bin2hex($bytes);
@@ -95,7 +87,6 @@ final class LazyUuidFromString implements TimeBasedUuidInterface
/**
* @inheritDoc
* @psalm-suppress UnusedMethodCall
*/
public function __unserialize(array $data): void
{
@@ -119,7 +110,6 @@ final class LazyUuidFromString implements TimeBasedUuidInterface
throw new UnsupportedOperationException('Not a time-based UUID');
}
/** @psalm-suppress DeprecatedMethod */
public function getUrn(): string
{
return ($this->unwrapped ?? $this->unwrap())
@@ -141,16 +131,9 @@ final class LazyUuidFromString implements TimeBasedUuidInterface
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
{
/** @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));
}
@@ -209,18 +192,8 @@ final class LazyUuidFromString implements TimeBasedUuidInterface
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
{
return $this->unwrapped = (new UuidFactory())
->fromString($this->uuid);
return $this->unwrapped = (new UuidFactory())->fromString($this->uuid);
}
}
+1 -1
View File
@@ -27,7 +27,7 @@ use Ramsey\Uuid\Type\NumberInterface;
/**
* A calculator using the brick/math library for arbitrary-precision arithmetic
*
* @psalm-immutable
* @immutable
*/
final class BrickMathCalculator implements CalculatorInterface
{
+1 -1
View File
@@ -21,7 +21,7 @@ use Ramsey\Uuid\Type\NumberInterface;
/**
* A calculator performs arithmetic operations on numbers
*
* @psalm-immutable
* @immutable
*/
interface CalculatorInterface
{
+1 -1
View File
@@ -41,7 +41,7 @@ use const STR_PAD_LEFT;
* Internally, this class represents the fields together as a 16-byte binary
* string.
*
* @psalm-immutable
* @immutable
*/
final class Fields implements FieldsInterface
{
+1 -1
View File
@@ -22,7 +22,7 @@ use Ramsey\Uuid\Uuid as BaseUuid;
/**
* Nonstandard\Uuid is a UUID that doesn't conform to RFC 4122
*
* @psalm-immutable
* @immutable
*/
final class Uuid extends BaseUuid
{
+1 -3
View File
@@ -25,7 +25,7 @@ use Throwable;
/**
* Nonstandard\UuidBuilder builds instances of Nonstandard\Uuid
*
* @psalm-immutable
* @immutable
*/
class UuidBuilder implements UuidBuilderInterface
{
@@ -49,8 +49,6 @@ class UuidBuilder implements UuidBuilderInterface
*
* @return Uuid The Nonstandard\UuidBuilder returns an instance of
* Nonstandard\Uuid
*
* @psalm-pure
*/
public function build(CodecInterface $codec, string $bytes): UuidInterface
{
+1 -1
View File
@@ -36,7 +36,7 @@ use Ramsey\Uuid\Uuid as BaseUuid;
* @link https://github.com/uuid6/uuid6-ietf-draft UUID version 6 IETF draft
* @link http://gh.peabody.io/uuidv6/ "Version 6" UUIDs
*
* @psalm-immutable
* @immutable
*/
class UuidV6 extends BaseUuid implements UuidInterface, TimeBasedUuidInterface
{
@@ -146,10 +146,7 @@ class SystemDceSecurityProvider implements DceSecurityProviderInterface
*/
private function getOs(): string
{
/**
* @psalm-suppress UnnecessaryVarAnnotation
* @var string $os
*/
/** @var string $os */
$os = constant('PHP_OS');
return strtoupper(substr($os, 0, 3));
@@ -207,9 +204,7 @@ class SystemDceSecurityProvider implements DceSecurityProviderInterface
return '';
}
/** @var string[] $userGroups */
$userGroups = preg_split('/\s{2,}/', (string) $response, -1, PREG_SPLIT_NO_EMPTY);
$firstGroup = trim($userGroups[1] ?? '', "* \t\n\r\0\x0B");
if ($firstGroup === '') {
@@ -222,9 +217,7 @@ class SystemDceSecurityProvider implements DceSecurityProviderInterface
return '';
}
/** @var string[] $userGroup */
$userGroup = preg_split('/\s{2,}/', (string) $response, -1, PREG_SPLIT_NO_EMPTY);
$sid = $userGroup[1] ?? '';
if (($lastHyphen = strrpos($sid, '-')) === false) {
+6 -12
View File
@@ -72,10 +72,11 @@ class SystemNodeProvider implements NodeProviderInterface
*/
protected function getNodeFromSystem(): string
{
/** @var string | null $node */
static $node = null;
if ($node !== null) {
return (string) $node;
return $node;
}
// First, try a Linux-specific approach.
@@ -104,10 +105,7 @@ class SystemNodeProvider implements NodeProviderInterface
return '';
}
/**
* @psalm-suppress UnnecessaryVarAnnotation
* @var string $os
*/
/** @var string $os */
$os = constant('PHP_OS');
ob_start();
@@ -151,10 +149,7 @@ class SystemNodeProvider implements NodeProviderInterface
{
$mac = '';
/**
* @psalm-suppress UnnecessaryVarAnnotation
* @var string $os
*/
/** @var string $os */
$os = constant('PHP_OS');
if (strtoupper($os) === 'LINUX') {
@@ -176,9 +171,8 @@ class SystemNodeProvider implements NodeProviderInterface
$macs = array_map(trim(...), $macs);
// Remove invalid entries.
$macs = array_filter($macs, function (string $address) {
return $address !== '00:00:00:00:00:00'
&& preg_match(self::SYSFS_PATTERN, $address);
$macs = array_filter($macs, function (mixed $address): bool {
return $address !== '00:00:00:00:00:00' && preg_match(self::SYSFS_PATTERN, $address);
});
/** @var string|bool $mac */
+2 -2
View File
@@ -31,12 +31,12 @@ use function unpack;
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
* string.
*
* @psalm-immutable
* @immutable
*/
final class Fields implements FieldsInterface
{
+1 -1
View File
@@ -36,7 +36,7 @@ use Ramsey\Uuid\Variant;
*
* @link http://tools.ietf.org/html/rfc4122#section-4.1 RFC 4122, § 4.1: Format
*
* @psalm-immutable
* @immutable
*/
interface FieldsInterface extends BaseFieldsInterface
{
+1 -1
View File
@@ -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
*
* @psalm-immutable
* @immutable
*/
trait MaxTrait
{
+1 -1
View File
@@ -20,7 +20,7 @@ use Ramsey\Uuid\Uuid;
* The max UUID is special form of UUID that is specified to have all 128 bits
* set to one
*
* @psalm-immutable
* @immutable
*/
final class MaxUuid extends Uuid implements UuidInterface
{
+1 -1
View File
@@ -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
*
* @psalm-immutable
* @immutable
*/
trait NilTrait
{
+1 -1
View File
@@ -20,7 +20,7 @@ use Ramsey\Uuid\Uuid;
* The nil UUID is special form of UUID that is specified to have all 128 bits
* set to zero
*
* @psalm-immutable
* @immutable
*/
final class NilUuid extends Uuid implements UuidInterface
{
+1 -1
View File
@@ -26,7 +26,7 @@ use const STR_PAD_LEFT;
/**
* Provides common functionality for getting the time from a time-based UUID
*
* @psalm-immutable
* @immutable
*/
trait TimeTrait
{
+1 -3
View File
@@ -29,7 +29,7 @@ use Throwable;
/**
* UuidBuilder builds instances of RFC 4122 UUIDs
*
* @psalm-immutable
* @immutable
*/
class UuidBuilder implements UuidBuilderInterface
{
@@ -59,8 +59,6 @@ class UuidBuilder implements UuidBuilderInterface
* @param non-empty-string $bytes The byte string from which to construct a UUID
*
* @return Rfc4122UuidInterface UuidBuilder returns instances of Rfc4122UuidInterface
*
* @psalm-pure
*/
public function build(CodecInterface $codec, string $bytes): UuidInterface
{
+1 -1
View File
@@ -22,7 +22,7 @@ use Ramsey\Uuid\UuidInterface as BaseUuidInterface;
*
* @link https://tools.ietf.org/html/rfc4122 RFC 4122
*
* @psalm-immutable
* @immutable
*/
interface UuidInterface extends BaseUuidInterface
{
+1 -1
View File
@@ -26,7 +26,7 @@ use Ramsey\Uuid\Uuid;
* Gregorian time, or version 1, UUIDs include timestamp, clock sequence, and node
* values that are combined into a 128-bit unsigned integer
*
* @psalm-immutable
* @immutable
*/
final class UuidV1 extends Uuid implements UuidInterface, TimeBasedUuidInterface
{
+1 -1
View File
@@ -49,7 +49,7 @@ use function hexdec;
* @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)
*
* @psalm-immutable
* @immutable
*/
final class UuidV2 extends Uuid implements UuidInterface, TimeBasedUuidInterface
{
+2 -2
View File
@@ -22,10 +22,10 @@ use Ramsey\Uuid\Rfc4122\FieldsInterface as Rfc4122FieldsInterface;
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
*
* @psalm-immutable
* @immutable
*/
final class UuidV3 extends Uuid implements UuidInterface
{
+1 -1
View File
@@ -25,7 +25,7 @@ use Ramsey\Uuid\Uuid;
* Random, or version 4, UUIDs are randomly or pseudo-randomly generated 128-bit
* integers
*
* @psalm-immutable
* @immutable
*/
final class UuidV4 extends Uuid implements UuidInterface
{
+2 -2
View File
@@ -22,10 +22,10 @@ use Ramsey\Uuid\Rfc4122\FieldsInterface as Rfc4122FieldsInterface;
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
*
* @psalm-immutable
* @immutable
*/
final class UuidV5 extends Uuid implements UuidInterface
{
+1 -1
View File
@@ -23,7 +23,7 @@ use Ramsey\Uuid\TimeBasedUuidInterface;
*
* @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, TimeBasedUuidInterface
{
+1 -1
View File
@@ -28,7 +28,7 @@ use Ramsey\Uuid\Uuid;
*
* @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, TimeBasedUuidInterface
{
+1 -1
View File
@@ -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
*
* @psalm-immutable
* @immutable
*/
final class UuidV8 extends Uuid implements UuidInterface
{
+4 -1
View File
@@ -23,13 +23,16 @@ use function str_replace;
/**
* Rfc4122\Validator validates strings as UUIDs of the RFC 4122 variant
*
* @psalm-immutable
* @immutable
*/
final class Validator implements ValidatorInterface
{
private const VALID_PATTERN = '\A[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-'
. '[1-8][0-9A-Fa-f]{3}-[ABab89][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}\z';
/**
* @return non-empty-string
*/
public function getPattern(): string
{
return self::VALID_PATTERN;
+1 -1
View File
@@ -29,7 +29,7 @@ use const STR_PAD_LEFT;
/**
* Provides common functionality for handling the variant, as defined by RFC 4122
*
* @psalm-immutable
* @immutable
*/
trait VariantTrait
{
+1 -1
View File
@@ -17,7 +17,7 @@ namespace Ramsey\Uuid\Rfc4122;
/**
* Provides common functionality for handling the version, as defined by RFC 4122
*
* @psalm-immutable
* @immutable
*/
trait VersionTrait
{
+1 -3
View File
@@ -21,7 +21,7 @@ use Ramsey\Uuid\Type\Hexadecimal;
* TimeBasedUuidFactoryInterface defines common functionality all factories for
* time-based UUIDs must implement
*
* @psalm-immutable
* @immutable
*/
interface TimeBasedUuidFactoryInterface extends UuidFactoryInterface
{
@@ -37,8 +37,6 @@ interface TimeBasedUuidFactoryInterface extends UuidFactoryInterface
*
* @return UuidInterface A UuidInterface instance that represents a
* UUID created from a DateTimeInterface instance
*
* @psalm-pure
*/
public function fromDateTime(
DateTimeInterface $dateTime,
+1 -1
View File
@@ -19,7 +19,7 @@ use DateTimeInterface;
/**
* Time-based UUIDs are derived from a date/time value
*
* @psalm-immutable
* @immutable
*/
interface TimeBasedUuidInterface extends UuidInterface
{
-2
View File
@@ -32,8 +32,6 @@ use function str_starts_with;
*
* To support values as true decimals and not as floats or doubles, we store the
* decimals as strings.
*
* @psalm-immutable
*/
final class Decimal implements NumberInterface
{
+1 -1
View File
@@ -30,7 +30,7 @@ use function substr;
* returned from ramsey/uuid methods as strings are truly hexadecimal and not some
* other kind of string.
*
* @psalm-immutable
* @immutable
*/
final class Hexadecimal implements TypeInterface
{
+8 -5
View File
@@ -34,7 +34,7 @@ use function substr;
* 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.
*
* @psalm-immutable
* @immutable
*/
final class Integer implements NumberInterface
{
@@ -43,6 +43,9 @@ final class Integer implements NumberInterface
*/
private readonly string $value;
/**
* @phpstan-ignore property.readOnlyByPhpDocDefaultValue
*/
private bool $isNegative = false;
public function __construct(float | int | self | string $value)
@@ -56,7 +59,7 @@ final class Integer implements NumberInterface
}
/**
* @psalm-return numeric-string
* @return numeric-string
*/
public function toString(): string
{
@@ -64,7 +67,7 @@ final class Integer implements NumberInterface
}
/**
* @psalm-return numeric-string
* @return numeric-string
*/
public function __toString(): string
{
@@ -72,7 +75,7 @@ final class Integer implements NumberInterface
}
/**
* @psalm-return numeric-string
* @return numeric-string
*/
public function jsonSerialize(): string
{
@@ -134,7 +137,7 @@ final class Integer implements NumberInterface
if ($sign === '-' && $value !== '0') {
$value = $sign . $value;
/** @psalm-suppress InaccessibleProperty */
/** @phpstan-ignore property.readOnlyByPhpDocAssignNotInConstructor */
$this->isNegative = true;
}
+1 -1
View File
@@ -17,7 +17,7 @@ namespace Ramsey\Uuid\Type;
/**
* NumberInterface ensures consistency in numeric values returned by ramsey/uuid
*
* @psalm-immutable
* @immutable
*/
interface NumberInterface extends TypeInterface
{
+5 -2
View File
@@ -26,7 +26,7 @@ use function sprintf;
* by ramsey/uuid are truly timestamp integers and not some other kind of string
* or integer.
*
* @psalm-immutable
* @immutable
*/
final class Time implements TypeInterface
{
@@ -56,8 +56,11 @@ final class Time implements TypeInterface
*/
public function toString(): string
{
/** @var numeric-string $microseconds */
$microseconds = sprintf('%06s', $this->microseconds->toString());
/** @var numeric-string */
return $this->seconds->toString() . '.' . sprintf('%06s', $this->microseconds->toString());
return "{$this->seconds->toString()}.$microseconds";
}
/**
+1 -1
View File
@@ -19,7 +19,7 @@ use JsonSerializable;
/**
* TypeInterface ensures consistency in typed values returned by ramsey/uuid
*
* @psalm-immutable
* @immutable
*/
interface TypeInterface extends JsonSerializable
{
+19 -53
View File
@@ -42,12 +42,12 @@ use function substr;
/**
* Uuid provides constants and static methods for working with and generating UUIDs
*
* @psalm-immutable
* @immutable
*/
class Uuid implements Rfc4122UuidInterface
{
/**
* 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
*
* @link http://tools.ietf.org/html/rfc4122#appendix-C RFC 4122, Appendix C: Some Name Space IDs
@@ -124,12 +124,16 @@ class Uuid implements Rfc4122UuidInterface
self::DCE_DOMAIN_ORG => 'org',
];
/**
* @phpstan-ignore property.readOnlyByPhpDocDefaultValue
*/
private static ?UuidFactoryInterface $factory = null;
/**
* @var bool flag to detect if the UUID factory was replaced internally,
* which disables all optimizations for the default/happy path internal
* scenarios
* @phpstan-ignore property.readOnlyByPhpDocDefaultValue
*/
private static bool $factoryReplaced = false;
@@ -166,7 +170,7 @@ class Uuid implements Rfc4122UuidInterface
}
/**
* @psalm-return non-empty-string
* @return non-empty-string
*/
public function __toString(): string
{
@@ -238,6 +242,9 @@ class Uuid implements Rfc4122UuidInterface
return $this->compareTo($other) === 0;
}
/**
* @return non-empty-string
*/
public function getBytes(): string
{
return $this->codec->encodeBinary($this);
@@ -266,6 +273,9 @@ class Uuid implements Rfc4122UuidInterface
return 'urn:uuid:' . $this->toString();
}
/**
* @return non-empty-string
*/
public function toString(): string
{
return $this->codec->encode($this);
@@ -324,13 +334,6 @@ class Uuid implements Rfc4122UuidInterface
* string representation
*
* @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
{
@@ -363,19 +366,11 @@ class Uuid implements Rfc4122UuidInterface
* string representation
*
* @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
{
$uuid = strtolower($uuid);
if (!self::$factoryReplaced && preg_match(LazyUuidFromString::VALID_REGEX, $uuid) === 1) {
/** @psalm-suppress DocblockTypeContradiction */
assert($uuid !== '');
return new LazyUuidFromString($uuid);
@@ -411,24 +406,19 @@ class Uuid implements Rfc4122UuidInterface
* @param Hexadecimal $hex Hexadecimal object representing a hexadecimal number
*
* @return UuidInterface A UuidInterface instance created from the Hexadecimal
* object representing a hexadecimal number
* object representing a hexadecimal number
*
* @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
{
$factory = self::getFactory();
if (method_exists($factory, 'fromHexadecimal')) {
/**
* @phpstan-ignore-next-line
* @psalm-suppress UndefinedInterfaceMethod
*/
return self::getFactory()->fromHexadecimal($hex);
$uuid = $factory->fromHexadecimal($hex);
assert($uuid instanceof UuidInterface);
return $uuid;
}
throw new BadMethodCallException('The method fromHexadecimal() does not exist on the provided factory');
@@ -443,13 +433,9 @@ class Uuid implements Rfc4122UuidInterface
* representation of a 128-bit integer
*
* @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
{
/** @psalm-suppress ImpureMethodCall */
return self::getFactory()->fromInteger($integer);
}
@@ -460,14 +446,10 @@ class Uuid implements Rfc4122UuidInterface
*
* @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
* @phpstan-assert-if-true =non-empty-string $uuid
*/
public static function isValid(string $uuid): bool
{
/** @psalm-suppress ImpureMethodCall */
return self::getFactory()->getValidator()->validate($uuid);
}
@@ -528,14 +510,6 @@ class Uuid implements Rfc4122UuidInterface
*
* @return UuidInterface A UuidInterface instance that represents a
* 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(UuidInterface | string $ns, string $name): UuidInterface
{
@@ -562,14 +536,6 @@ class Uuid implements Rfc4122UuidInterface
*
* @return UuidInterface A UuidInterface instance that represents a
* 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(UuidInterface | string $ns, string $name): UuidInterface
{
-33
View File
@@ -42,9 +42,6 @@ use function substr;
use const STR_PAD_LEFT;
/**
* @psalm-suppress MissingImmutableAnnotation
*/
class UuidFactory implements UuidFactoryInterface
{
private CodecInterface $codec;
@@ -241,9 +238,6 @@ class UuidFactory implements UuidFactoryInterface
$this->uuidBuilder = $builder;
}
/**
* @psalm-mutation-free
*/
public function getValidator(): ValidatorInterface
{
return $this->validator;
@@ -262,17 +256,11 @@ class UuidFactory implements UuidFactoryInterface
$this->validator = $validator;
}
/**
* @psalm-pure
*/
public function fromBytes(string $bytes): UuidInterface
{
return $this->codec->decodeBytes($bytes);
}
/**
* @psalm-pure
*/
public function fromString(string $uuid): UuidInterface
{
$uuid = strtolower($uuid);
@@ -280,9 +268,6 @@ class UuidFactory implements UuidFactoryInterface
return $this->codec->decode($uuid);
}
/**
* @psalm-pure
*/
public function fromInteger(string $integer): UuidInterface
{
$hex = $this->numberConverter->toHex($integer);
@@ -313,9 +298,6 @@ class UuidFactory implements UuidFactoryInterface
return $this->uuidFromBytesAndVersion($bytes, Version::Time);
}
/**
* @psalm-pure
*/
public function fromHexadecimal(Hexadecimal $hex): UuidInterface
{
return $this->codec->decode($hex->__toString());
@@ -344,10 +326,6 @@ class UuidFactory implements UuidFactoryInterface
return $this->uuidFromBytesAndVersion($bytes, Version::DceSecurity);
}
/**
* @inheritDoc
* @psalm-pure
*/
public function uuid3(UuidInterface | string $ns, string $name): UuidInterface
{
return $this->uuidFromNsAndName($ns, $name, Version::HashMd5, 'md5');
@@ -360,10 +338,6 @@ class UuidFactory implements UuidFactoryInterface
return $this->uuidFromBytesAndVersion($bytes, Version::Random);
}
/**
* @inheritDoc
* @psalm-pure
*/
public function uuid5(UuidInterface | string $ns, string $name): UuidInterface
{
return $this->uuidFromNsAndName($ns, $name, Version::HashSha1, 'sha1');
@@ -438,12 +412,9 @@ class UuidFactory implements UuidFactoryInterface
*
* @return UuidInterface An instance of UuidInterface, created from the
* provided bytes
*
* @psalm-pure
*/
public function uuid(string $bytes): UuidInterface
{
/** @psalm-suppress ImpurePropertyFetch */
return $this->uuidBuilder->build($this->codec, $bytes);
}
@@ -458,8 +429,6 @@ class UuidFactory implements UuidFactoryInterface
*
* @return UuidInterface An instance of UuidInterface, created by hashing
* together the provided namespace and name
*
* @psalm-pure
*/
private function uuidFromNsAndName(
UuidInterface | string $ns,
@@ -487,8 +456,6 @@ class UuidFactory implements UuidFactoryInterface
*
* @return UuidInterface An instance of UuidInterface, created from the
* byte string and version
*
* @psalm-pure
*/
private function uuidFromBytesAndVersion(string $bytes, Version $version): UuidInterface
{
+3 -15
View File
@@ -20,10 +20,10 @@ use Ramsey\Uuid\Type\Integer as IntegerObject;
use Ramsey\Uuid\Validator\ValidatorInterface;
/**
* UuidFactoryInterface defines common functionality all `UuidFactory` instances
* UuidFactoryInterface defines the common functionality all `UuidFactory` instances
* must implement
*
* @psalm-immutable
* @immutable
*/
interface UuidFactoryInterface
{
@@ -34,8 +34,6 @@ interface UuidFactoryInterface
*
* @return UuidInterface A UuidInterface instance created from a binary
* string representation
*
* @psalm-pure
*/
public function fromBytes(string $bytes): UuidInterface;
@@ -65,8 +63,6 @@ interface UuidFactoryInterface
*
* @return UuidInterface A UuidInterface instance created from the string
* representation of a 128-bit integer
*
* @psalm-pure
*/
public function fromInteger(string $integer): UuidInterface;
@@ -77,15 +73,11 @@ interface UuidFactoryInterface
*
* @return UuidInterface A UuidInterface instance created from a hexadecimal
* string representation
*
* @psalm-pure
*/
public function fromString(string $uuid): UuidInterface;
/**
* Returns the validator to use for the factory
*
* @psalm-mutation-free
* Returns the validator used by the factory
*/
public function getValidator(): ValidatorInterface;
@@ -140,8 +132,6 @@ interface UuidFactoryInterface
*
* @return UuidInterface A UuidInterface instance that represents a
* version 3 UUID
*
* @psalm-pure
*/
public function uuid3(UuidInterface | string $ns, string $name): UuidInterface;
@@ -162,8 +152,6 @@ interface UuidFactoryInterface
*
* @return UuidInterface A UuidInterface instance that represents a
* version 5 UUID
*
* @psalm-pure
*/
public function uuid5(UuidInterface | string $ns, string $name): UuidInterface;
+4 -4
View File
@@ -24,7 +24,7 @@ use Stringable;
* A UUID is a universally unique identifier adhering to an agreed-upon
* representation format and standard for generation
*
* @psalm-immutable
* @immutable
*/
interface UuidInterface extends JsonSerializable, Stringable
{
@@ -36,7 +36,7 @@ interface UuidInterface extends JsonSerializable, Stringable
/**
* Casts the UUID to the string standard representation
*
* @psalm-return non-empty-string
* @return non-empty-string
*/
public function __toString(): string;
@@ -78,7 +78,7 @@ interface UuidInterface extends JsonSerializable, Stringable
/**
* Returns the binary string representation of the UUID
*
* @psalm-return non-empty-string
* @return non-empty-string
*/
public function getBytes(): string;
@@ -108,7 +108,7 @@ interface UuidInterface extends JsonSerializable, Stringable
/**
* Returns the string standard representation of the UUID
*
* @psalm-return non-empty-string
* @return non-empty-string
*/
public function toString(): string;
}
+4 -1
View File
@@ -22,7 +22,7 @@ use function str_replace;
/**
* GenericValidator validates strings as UUIDs of any variant
*
* @psalm-immutable
* @immutable
*/
final class GenericValidator implements ValidatorInterface
{
@@ -31,6 +31,9 @@ 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';
/**
* @return non-empty-string
*/
public function getPattern(): string
{
return self::VALID_PATTERN;
+1 -1
View File
@@ -17,7 +17,7 @@ namespace Ramsey\Uuid\Validator;
/**
* A validator validates a string as a proper UUID
*
* @psalm-immutable
* @immutable
*/
interface ValidatorInterface
{
-6
View File
@@ -72,9 +72,6 @@ function v2(
* @param non-empty-string $name The name to use for creating a UUID
*
* @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(UuidInterface | string $ns, string $name): string
{
@@ -99,9 +96,6 @@ function v4(): string
* @param non-empty-string $name The name to use for creating a UUID
*
* @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(UuidInterface | string $ns, string $name): string
{
+2 -2
View File
@@ -46,7 +46,7 @@ class BinaryUtilsTest extends TestCase
}
/**
* @return array<array{timeHi: int, version: Version, expectedInt: int, expectedHex: string}>
* @return array<array{timeHi: int, version: Version, expectedInt: int, expectedHex: non-empty-string}>
*/
public function provideVersionTestValues(): array
{
@@ -199,7 +199,7 @@ class BinaryUtilsTest extends TestCase
}
/**
* @return array<array{clockSeq: int, variant: Variant, expectedInt: int, expectedHex: string}>
* @return array<array{clockSeq: int, variant: Variant, expectedInt: int, expectedHex: non-empty-string}>
*/
public function provideVariantTestValues(): array
{
+19 -20
View File
@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace Ramsey\Uuid\Test\Builder;
use DateTimeInterface;
use Mockery;
use Ramsey\Uuid\Builder\FallbackBuilder;
use Ramsey\Uuid\Builder\UuidBuilderInterface;
@@ -103,7 +102,7 @@ class FallbackBuilderTest extends TestCase
$uuid = $builder->build($codec, $bytes);
if (($uuid instanceof UuidV1) || ($uuid instanceof UuidV2) || ($uuid instanceof UuidV6)) {
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertNotEmpty($uuid->getDateTime()->format('r'));
}
} catch (UnableToBuildUuidException $exception) {
switch ($exception->getMessage()) {
@@ -120,78 +119,78 @@ class FallbackBuilderTest extends TestCase
}
/**
* @return array<array{bytes: string|false}>
* @return array<array{bytes: string}>
*/
public function provideBytes(): array
{
return [
[
// GUID bytes
'bytes' => hex2bin('b08c6fff7dc5e1110b210800200c9a66'),
'bytes' => (string) hex2bin('b08c6fff7dc5e1110b210800200c9a66'),
],
[
// GUID bytes
'bytes' => hex2bin('b08c6fff7dc5e1111b210800200c9a66'),
'bytes' => (string) hex2bin('b08c6fff7dc5e1111b210800200c9a66'),
],
[
// GUID bytes
'bytes' => hex2bin('b08c6fff7dc5e1112b210800200c9a66'),
'bytes' => (string) hex2bin('b08c6fff7dc5e1112b210800200c9a66'),
],
[
// GUID bytes
'bytes' => hex2bin('b08c6fff7dc5e1113b210800200c9a66'),
'bytes' => (string) hex2bin('b08c6fff7dc5e1113b210800200c9a66'),
],
[
// GUID bytes
'bytes' => hex2bin('b08c6fff7dc5e1114b210800200c9a66'),
'bytes' => (string) hex2bin('b08c6fff7dc5e1114b210800200c9a66'),
],
[
// GUID bytes
'bytes' => hex2bin('b08c6fff7dc5e1115b210800200c9a66'),
'bytes' => (string) hex2bin('b08c6fff7dc5e1115b210800200c9a66'),
],
[
// GUID bytes
'bytes' => hex2bin('b08c6fff7dc5e1116b210800200c9a66'),
'bytes' => (string) hex2bin('b08c6fff7dc5e1116b210800200c9a66'),
],
[
// GUID bytes
'bytes' => hex2bin('b08c6fff7dc5e1117b210800200c9a66'),
'bytes' => (string) hex2bin('b08c6fff7dc5e1117b210800200c9a66'),
],
[
// GUID bytes
'bytes' => hex2bin('b08c6fff7dc5e111eb210800200c9a66'),
'bytes' => (string) hex2bin('b08c6fff7dc5e111eb210800200c9a66'),
],
[
// GUID bytes
'bytes' => hex2bin('b08c6fff7dc5e111fb210800200c9a66'),
'bytes' => (string) hex2bin('b08c6fff7dc5e111fb210800200c9a66'),
],
[
// Version 1 bytes
'bytes' => hex2bin('ff6f8cb0c57d11e19b210800200c9a66'),
'bytes' => (string) hex2bin('ff6f8cb0c57d11e19b210800200c9a66'),
],
[
// Version 2 bytes
'bytes' => hex2bin('000001f55cde21ea84000242ac130003'),
'bytes' => (string) hex2bin('000001f55cde21ea84000242ac130003'),
],
[
// Version 3 bytes
'bytes' => hex2bin('ff6f8cb0c57d31e1bb210800200c9a66'),
'bytes' => (string) hex2bin('ff6f8cb0c57d31e1bb210800200c9a66'),
],
[
// Version 4 bytes
'bytes' => hex2bin('ff6f8cb0c57d41e1ab210800200c9a66'),
'bytes' => (string) hex2bin('ff6f8cb0c57d41e1ab210800200c9a66'),
],
[
// Version 5 bytes
'bytes' => hex2bin('ff6f8cb0c57d51e18b210800200c9a66'),
'bytes' => (string) hex2bin('ff6f8cb0c57d51e18b210800200c9a66'),
],
[
// Version 6 bytes
'bytes' => hex2bin('ff6f8cb0c57d61e18b210800200c9a66'),
'bytes' => (string) hex2bin('ff6f8cb0c57d61e18b210800200c9a66'),
],
[
// NIL bytes
'bytes' => hex2bin('00000000000000000000000000000000'),
'bytes' => (string) hex2bin('00000000000000000000000000000000'),
],
];
}
@@ -14,6 +14,7 @@ class GenericTimeConverterTest extends TestCase
/**
* @param numeric-string $seconds
* @param numeric-string $microseconds
* @param non-empty-string $expected
*
* @dataProvider provideCalculateTime
*/
@@ -28,7 +29,7 @@ class GenericTimeConverterTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{seconds: numeric-string, microseconds: numeric-string, expected: non-empty-string}>
*/
public function provideCalculateTime(): array
{
@@ -83,6 +84,9 @@ class GenericTimeConverterTest extends TestCase
}
/**
* @param numeric-string $unixTimestamp
* @param numeric-string $microseconds
*
* @dataProvider provideConvertTime
*/
public function testConvertTime(Hexadecimal $uuidTimestamp, string $unixTimestamp, string $microseconds): void
@@ -97,7 +101,7 @@ class GenericTimeConverterTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{uuidTimestamp: Hexadecimal, unixTimestamp: numeric-string, microseconds: numeric-string}>
*/
public function provideConvertTime(): array
{
@@ -77,6 +77,9 @@ class PhpTimeConverterTest extends TestCase
}
/**
* @param numeric-string $unixTimestamp
* @param numeric-string $microseconds
*
* @dataProvider provideConvertTime
*/
public function testConvertTime(Hexadecimal $uuidTimestamp, string $unixTimestamp, string $microseconds): void
@@ -92,7 +95,7 @@ class PhpTimeConverterTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{uuidTimestamp: Hexadecimal, unixTimestamp: numeric-string, microseconds: numeric-string}>
*/
public function provideConvertTime(): array
{
@@ -143,6 +146,7 @@ class PhpTimeConverterTest extends TestCase
/**
* @param numeric-string $seconds
* @param numeric-string $microseconds
* @param non-empty-string $expected
*
* @dataProvider provideCalculateTime
*/
@@ -158,7 +162,7 @@ class PhpTimeConverterTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{seconds: numeric-string, microseconds: numeric-string, expected: non-empty-string}>
*/
public function provideCalculateTime(): array
{
+1
View File
@@ -46,6 +46,7 @@ class FeatureSetTest extends TestCase
{
$featureSet = new FeatureSet();
/** @phpstan-ignore method.alreadyNarrowedType */
$this->assertInstanceOf(TimeConverterInterface::class, $featureSet->getTimeConverter());
}
+2 -1
View File
@@ -15,6 +15,7 @@ class DefaultNameGeneratorTest extends TestCase
{
/**
* @param non-empty-string $ns
* @param non-empty-string $name
* @param non-empty-string $algorithm
*
* @dataProvider provideNamesForHashingTest
@@ -30,7 +31,7 @@ class DefaultNameGeneratorTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{ns: non-empty-string, name: non-empty-string, algorithm: non-empty-string}>
*/
public function provideNamesForHashingTest(): array
{
@@ -34,14 +34,14 @@ class PeclUuidNameGeneratorTest extends TestCase
// Need to add the version and variant, since ext-uuid already includes
// these in the values returned.
/** @var array $unpackedTime */
/** @var int[] $unpackedTime */
$unpackedTime = unpack('n*', substr($expectedBytes, 6, 2));
$timeHi = (int) $unpackedTime[1];
$timeHi = $unpackedTime[1];
$timeHiAndVersion = pack('n*', BinaryUtils::applyVersion($timeHi, $version));
/** @var array $unpackedClockSeq */
/** @var int[] $unpackedClockSeq */
$unpackedClockSeq = unpack('n*', substr($expectedBytes, 8, 2));
$clockSeqHi = (int) $unpackedClockSeq[1];
$clockSeqHi = $unpackedClockSeq[1];
$clockSeqHiAndReserved = pack('n*', BinaryUtils::applyVariant($clockSeqHi));
$expectedBytes = substr_replace($expectedBytes, $timeHiAndVersion, 6, 2);
@@ -101,7 +101,6 @@ class PeclUuidNameGeneratorTest extends TestCase
'Unable to hash namespace and name with algorithm \'aBadAlgorithm\''
);
/** @phpstan-ignore-next-line */
$generator->generate($namespace, 'a test name', 'aBadAlgorithm');
}
}
+3 -2
View File
@@ -15,7 +15,7 @@ use function hex2bin;
class RandomBytesGeneratorTest extends TestCase
{
/**
* @return array<array{positive-int, string}>
* @return array<array{0: positive-int, 1: non-empty-string}>
*/
public function lengthAndHexDataProvider(): array
{
@@ -28,6 +28,7 @@ class RandomBytesGeneratorTest extends TestCase
/**
* @param positive-int $length
* @param non-empty-string $hex
*
* @throws Exception
*
@@ -53,7 +54,7 @@ class RandomBytesGeneratorTest extends TestCase
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
public function testGenerateThrowsExceptionWhenExceptionThrownByRandombytes(): void
public function testGenerateThrowsExceptionWhenExceptionThrownByRandomBytes(): void
{
PHPMockery::mock('Ramsey\Uuid\Generator', 'random_bytes')
->once()
@@ -28,6 +28,7 @@ class TimeGeneratorFactoryTest extends TestCase
$factory = new TimeGeneratorFactory($nodeProvider, $timeConverter, $timeProvider);
$generator = $factory->getGenerator();
/** @phpstan-ignore method.alreadyNarrowedType */
$this->assertInstanceOf(TimeGeneratorInterface::class, $generator);
}
}
+16 -4
View File
@@ -28,6 +28,8 @@ class FieldsTest extends TestCase
}
/**
* @param non-empty-string $guid
*
* @dataProvider nonRfc4122GuidVariantProvider
*/
public function testConstructorThrowsExceptionIfNotRfc4122Variant(string $guid): void
@@ -47,7 +49,7 @@ class FieldsTest extends TestCase
/**
* These values are already in GUID byte order, for easy testing.
*
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{0: non-empty-string}>
*/
public function nonRfc4122GuidVariantProvider(): array
{
@@ -68,6 +70,8 @@ class FieldsTest extends TestCase
}
/**
* @param non-empty-string $guid
*
* @dataProvider invalidVersionProvider
*/
public function testConstructorThrowsExceptionIfInvalidVersion(string $guid): void
@@ -84,7 +88,7 @@ class FieldsTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{0: non-empty-string}>
*/
public function invalidVersionProvider(): array
{
@@ -104,12 +108,16 @@ class FieldsTest extends TestCase
}
/**
* @param non-empty-string $bytes
* @param non-empty-string $methodName
* @param Variant | Version | bool | non-empty-string | null $expectedValue
*
* @dataProvider fieldGetterMethodProvider
*/
public function testFieldGetterMethods(
string $bytes,
string $methodName,
bool | string | Variant | Version | null $expectedValue
Variant | Version | bool | string | null $expectedValue,
): void {
/** @var non-empty-string $bytes */
$bytes = (string) hex2bin($bytes);
@@ -125,7 +133,11 @@ class FieldsTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{
* 0: non-empty-string,
* 1: non-empty-string,
* 2: Variant | Version | bool | non-empty-string | null,
* }>
*/
public function fieldGetterMethodProvider(): array
{
-3
View File
@@ -8,7 +8,6 @@ use Ramsey\Uuid\Exception\InvalidArgumentException;
use Ramsey\Uuid\Math\BrickMathCalculator;
use Ramsey\Uuid\Math\RoundingMode;
use Ramsey\Uuid\Test\TestCase;
use Ramsey\Uuid\Type\Hexadecimal;
use Ramsey\Uuid\Type\Integer as IntegerObject;
class BrickMathCalculatorTest extends TestCase
@@ -71,7 +70,6 @@ class BrickMathCalculatorTest extends TestCase
$result = $calculator->fromBase('ffffffffffffffffffff', 16);
$this->assertInstanceOf(IntegerObject::class, $result);
$this->assertSame('1208925819614629174706175', $result->toString());
}
@@ -90,7 +88,6 @@ class BrickMathCalculatorTest extends TestCase
$result = $calculator->toHexadecimal($intValue);
$this->assertInstanceOf(Hexadecimal::class, $result);
$this->assertSame('ffffffffffffffffffff', $result->toString());
}
+9 -4
View File
@@ -28,12 +28,17 @@ class FieldsTest extends TestCase
}
/**
* @param string|int $expectedValue
* @param non-empty-string $uuid
* @param non-empty-string $methodName
* @param Variant | bool | non-empty-string | null $expectedValue
*
* @dataProvider fieldGetterMethodProvider
*/
public function testFieldGetterMethods(string $uuid, string $methodName, $expectedValue): void
{
public function testFieldGetterMethods(
string $uuid,
string $methodName,
Variant | bool | string | null $expectedValue,
): void {
/** @var non-empty-string $bytes */
$bytes = (string) hex2bin(str_replace('-', '', $uuid));
$fields = new Fields($bytes);
@@ -48,7 +53,7 @@ class FieldsTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{0: non-empty-string, 1: non-empty-string, 2: Variant | bool | non-empty-string | null}>
*/
public function fieldGetterMethodProvider(): array
{
+3 -3
View File
@@ -45,7 +45,7 @@ class UuidV6Test extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{version: Version}>
*/
public function provideTestVersions(): array
{
@@ -77,7 +77,7 @@ class UuidV6Test extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{uuid: non-empty-string, expected: non-empty-string}>
*/
public function provideUuidV6WithOddMicroseconds(): array
{
@@ -145,7 +145,7 @@ class UuidV6Test extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{uuidv6: non-empty-string, uuidv1: non-empty-string}>
*/
public function provideUuidV1UuidV6Equivalents(): array
{
@@ -8,7 +8,6 @@ use Mockery;
use Ramsey\Uuid\Exception\DceSecurityException;
use Ramsey\Uuid\Provider\Dce\SystemDceSecurityProvider;
use Ramsey\Uuid\Test\TestCase;
use Ramsey\Uuid\Type\Integer as IntegerObject;
use phpmock\mockery\PHPMockery;
use function array_merge;
@@ -147,13 +146,12 @@ class SystemDceSecurityProviderTest extends TestCase
$uid = $provider->getUid();
$this->assertInstanceOf(IntegerObject::class, $uid);
$this->assertSame($expectedId, $uid->toString());
$this->assertSame($uid, $provider->getUid());
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{value: non-empty-string, expectedId: non-empty-string}>
*/
public function provideWindowsGoodWhoAmIValues(): array
{
@@ -199,7 +197,6 @@ class SystemDceSecurityProviderTest extends TestCase
$uid = $provider->getUid();
$this->assertInstanceOf(IntegerObject::class, $uid);
$this->assertSame($id, $uid->toString());
$this->assertSame($uid, $provider->getUid());
}
@@ -298,7 +295,6 @@ class SystemDceSecurityProviderTest extends TestCase
$gid = $provider->getGid();
$this->assertInstanceOf(IntegerObject::class, $gid);
$this->assertSame($id, $gid->toString());
$this->assertSame($gid, $provider->getGid());
}
@@ -419,13 +415,17 @@ class SystemDceSecurityProviderTest extends TestCase
$gid = $provider->getGid();
$this->assertInstanceOf(IntegerObject::class, $gid);
$this->assertSame($expectedId, $gid->toString());
$this->assertSame($gid, $provider->getGid());
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{
* netUserResponse: non-empty-string,
* wmicGroupResponse: non-empty-string,
* expectedGroup: non-empty-string,
* expectedId: non-empty-string,
* }>
*/
public function provideWindowsGoodNetUserAndWmicGroupValues(): array
{
@@ -458,7 +458,7 @@ class SystemDceSecurityProviderTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{os: non-empty-string, id: non-empty-string}>
*/
public function providePosixTestValues(): array
{
@@ -474,7 +474,7 @@ class SystemDceSecurityProviderTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{value: string | null}>
*/
public function provideWindowsBadValues(): array
{
@@ -490,7 +490,7 @@ class SystemDceSecurityProviderTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{value: string | null}>
*/
public function provideWindowsBadGroupValues(): array
{
@@ -81,7 +81,6 @@ class FallbackNodeProviderTest extends TestCase
foreach ($unserializedNodeProviderCollection as $nodeProvider) {
$this->assertInstanceOf(NodeProviderInterface::class, $nodeProvider);
$this->assertInstanceOf(Hexadecimal::class, $nodeProvider->getNode());
}
}
}
@@ -12,6 +12,8 @@ use Ramsey\Uuid\Type\Hexadecimal;
class StaticNodeProviderTest extends TestCase
{
/**
* @param non-empty-string $expectedNode
*
* @dataProvider provideNodeForTest
*/
public function testStaticNode(Hexadecimal $node, string $expectedNode): void
@@ -22,7 +24,7 @@ class StaticNodeProviderTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{node: Hexadecimal, expectedNode: non-empty-string}>
*/
public function provideNodeForTest(): array
{
+156 -151
View File
@@ -401,6 +401,7 @@ class SystemNodeProviderTest extends TestCase
/* Arrange */
$this->arrangeMockFunctions(
function () {
/** @var non-empty-list<string> $macs */
static $macs = ["00:00:00:00:00:00\n", "01:02:03:04:05:06\n"];
return array_shift($macs);
@@ -654,11 +655,11 @@ class SystemNodeProviderTest extends TestCase
self::MOCK_IS_READABLE => $isReadableAssert,
];
array_walk($mockFunctionAsserts, function ($asserts, $key): void {
array_walk($mockFunctionAsserts, function (mixed $asserts, string $key): void {
if ($asserts === null) {
// Assert the function was never invoked.
$this->assertEmpty($this->functionProxies[$key]->getInvocations());
} elseif (is_array($asserts)) {
} elseif (is_array($asserts)) { /** @phpstan-ignore function.alreadyNarrowedType */
// Assert there was at least one invocation for this function.
$this->assertNotEmpty($this->functionProxies[$key]->getInvocations());
@@ -686,7 +687,7 @@ class SystemNodeProviderTest extends TestCase
/**
* Provides the command that should be executed per supported OS
*
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<string, array{0: non-empty-string, 1: non-empty-string}>
*/
public function provideCommandPerOs(): array
{
@@ -703,7 +704,7 @@ class SystemNodeProviderTest extends TestCase
/**
* Values that are NOT parsed to a mac address by the class under test
*
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<string, array{0: non-empty-string}>
*/
public function provideInvalidNetStatOutput(): array
{
@@ -729,7 +730,7 @@ class SystemNodeProviderTest extends TestCase
/**
* Provides notations that the class under test should NOT attempt to strip
*
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{0: non-empty-string}>
*/
public function provideInvalidNotationalFormats(): array
{
@@ -749,7 +750,7 @@ class SystemNodeProviderTest extends TestCase
/**
* Provides mac addresses that the class under test should strip notational format from
*
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{0: non-empty-string, 1: non-empty-string}>
*/
public function provideNotationalFormats(): array
{
@@ -762,168 +763,172 @@ class SystemNodeProviderTest extends TestCase
/**
* Values that are parsed to a mac address by the class under test
*
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<string, array{0: non-empty-string, 1: non-empty-string}>
*/
public function provideValidNetStatOutput(): array
{
return [
/* Full output of related command */
'Full output - Linux' => [<<<'TXT'
Kernel Interface table
docker0 Link encap:Ethernet HWaddr 01:23:45:67:89:ab
inet addr:172.17.0.1 Bcast:0.0.0.0 Mask:255.255.0.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
'Full output - Linux' => [
<<<'TXT'
Kernel Interface table
docker0 Link encap:Ethernet HWaddr 01:23:45:67:89:ab
inet addr:172.17.0.1 Bcast:0.0.0.0 Mask:255.255.0.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
enp3s0 Link encap:Ethernet HWaddr fe:dc:ba:98:76:54
inet addr:10.0.0.1 Bcast:10.0.0.255 Mask:255.255.255.0
inet6 addr: ffee::ddcc:bbaa:9988:7766/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:943077 errors:0 dropped:0 overruns:0 frame:0
TX packets:2168039 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:748596414 (748.5 MB) TX bytes:2930448282 (2.9 GB)
enp3s0 Link encap:Ethernet HWaddr fe:dc:ba:98:76:54
inet addr:10.0.0.1 Bcast:10.0.0.255 Mask:255.255.255.0
inet6 addr: ffee::ddcc:bbaa:9988:7766/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:943077 errors:0 dropped:0 overruns:0 frame:0
TX packets:2168039 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:748596414 (748.5 MB) TX bytes:2930448282 (2.9 GB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:8302 errors:0 dropped:0 overruns:0 frame:0
TX packets:8302 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1094983 (1.0 MB) TX bytes:1094983 (1.0 MB)
TXT
, '0123456789ab',
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:8302 errors:0 dropped:0 overruns:0 frame:0
TX packets:8302 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1094983 (1.0 MB) TX bytes:1094983 (1.0 MB)
TXT,
'0123456789ab',
],
'Full output - MacOS' => [<<<'TXT'
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP>
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
nd6 options=201<PERFORMNUD,DAD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
EHC29: flags=0<> mtu 0
XHC20: flags=0<> mtu 0
EHC26: flags=0<> mtu 0
aa0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=10b<RXCSUM,TXCSUM,VLAN_HWTAGGING,AV>
ether 00:00:00:00:00:00
status: active
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=10b<RXCSUM,TXCSUM,VLAN_HWTAGGING,AV>
ether 10:dd:b1:b4:e4:8e
inet6 fe80::c70:76f5:aa1:5db1%en0 prefixlen 64 secured scopeid 0x7
inet 10.53.8.112 netmask 0xfffffc00 broadcast 10.53.11.255
nd6 options=201<PERFORMNUD,DAD>
media: autoselect (1000baseT <full-duplex>)
status: active
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether ec:35:86:38:c8:c2
inet6 fe80::aa:d44f:5f5f:7fd4%en1 prefixlen 64 secured scopeid 0x8
inet 10.53.17.196 netmask 0xfffffc00 broadcast 10.53.19.255
nd6 options=201<PERFORMNUD,DAD>
media: autoselect
status: active
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
ether 0e:35:86:38:c8:c2
media: autoselect
status: inactive
awdl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1484
ether ea:ab:ae:25:f5:d0
inet6 fe80::e8ab:aeff:fe25:f5d0%awdl0 prefixlen 64 scopeid 0xa
nd6 options=201<PERFORMNUD,DAD>
media: autoselect
status: active
en2: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
options=60<TSO4,TSO6>
ether 32:00:18:9b:dc:60
media: autoselect <full-duplex>
status: inactive
en3: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
options=60<TSO4,TSO6>
ether 32:00:18:9b:dc:61
media: autoselect <full-duplex>
status: inactive
bridge0: flags=8822<BROADCAST,SMART,SIMPLEX,MULTICAST> mtu 1500
options=63<RXCSUM,TXCSUM,TSO4,TSO6>
ether 32:00:18:9b:dc:60
Configuration:
id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
ipfilter disabled flags 0x2
member: en2 flags=3<LEARNING,DISCOVER>
ifmaxaddr 0 port 11 priority 0 path cost 0
member: en3 flags=3<LEARNING,DISCOVER>
ifmaxaddr 0 port 12 priority 0 path cost 0
media: <unknown type>
status: inactive
utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000
options=6403<RXCSUM,TXCSUM,CHANNEL_IO,PARTIAL_CSUM,ZEROINVERT_CSUM>
inet6 fe80::57c6:d692:9d41:d28f%utun0 prefixlen 64 scopeid 0xe
nd6 options=201<PERFORMNUD,DAD>
TXT
, '10ddb1b4e48e',
'Full output - MacOS' => [
<<<'TXT'
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP>
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
nd6 options=201<PERFORMNUD,DAD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
EHC29: flags=0<> mtu 0
XHC20: flags=0<> mtu 0
EHC26: flags=0<> mtu 0
aa0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=10b<RXCSUM,TXCSUM,VLAN_HWTAGGING,AV>
ether 00:00:00:00:00:00
status: active
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=10b<RXCSUM,TXCSUM,VLAN_HWTAGGING,AV>
ether 10:dd:b1:b4:e4:8e
inet6 fe80::c70:76f5:aa1:5db1%en0 prefixlen 64 secured scopeid 0x7
inet 10.53.8.112 netmask 0xfffffc00 broadcast 10.53.11.255
nd6 options=201<PERFORMNUD,DAD>
media: autoselect (1000baseT <full-duplex>)
status: active
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether ec:35:86:38:c8:c2
inet6 fe80::aa:d44f:5f5f:7fd4%en1 prefixlen 64 secured scopeid 0x8
inet 10.53.17.196 netmask 0xfffffc00 broadcast 10.53.19.255
nd6 options=201<PERFORMNUD,DAD>
media: autoselect
status: active
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
ether 0e:35:86:38:c8:c2
media: autoselect
status: inactive
awdl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1484
ether ea:ab:ae:25:f5:d0
inet6 fe80::e8ab:aeff:fe25:f5d0%awdl0 prefixlen 64 scopeid 0xa
nd6 options=201<PERFORMNUD,DAD>
media: autoselect
status: active
en2: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
options=60<TSO4,TSO6>
ether 32:00:18:9b:dc:60
media: autoselect <full-duplex>
status: inactive
en3: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
options=60<TSO4,TSO6>
ether 32:00:18:9b:dc:61
media: autoselect <full-duplex>
status: inactive
bridge0: flags=8822<BROADCAST,SMART,SIMPLEX,MULTICAST> mtu 1500
options=63<RXCSUM,TXCSUM,TSO4,TSO6>
ether 32:00:18:9b:dc:60
Configuration:
id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
ipfilter disabled flags 0x2
member: en2 flags=3<LEARNING,DISCOVER>
ifmaxaddr 0 port 11 priority 0 path cost 0
member: en3 flags=3<LEARNING,DISCOVER>
ifmaxaddr 0 port 12 priority 0 path cost 0
media: <unknown type>
status: inactive
utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000
options=6403<RXCSUM,TXCSUM,CHANNEL_IO,PARTIAL_CSUM,ZEROINVERT_CSUM>
inet6 fe80::57c6:d692:9d41:d28f%utun0 prefixlen 64 scopeid 0xe
nd6 options=201<PERFORMNUD,DAD>
TXT,
'10ddb1b4e48e',
],
'Full output - Window' => [<<<'TXT'
Windows IP Configuration
'Full output - Window' => [
<<<'TXT'
Windows IP Configuration
Host Name . . . . . . . . . . . . : MSEDGEWIN10
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
DNS Suffix Search List. . . . . . : network.lan
Host Name . . . . . . . . . . . . : MSEDGEWIN10
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
DNS Suffix Search List. . . . . . : network.lan
Some kind of adapter:
Some kind of adapter:
Connection-specific DNS Suffix . : network.foo
Description . . . . . . . . . . . : Some Adapter
Physical Address. . . . . . . . . : 00-00-00-00-00-00
Connection-specific DNS Suffix . : network.foo
Description . . . . . . . . . . . : Some Adapter
Physical Address. . . . . . . . . : 00-00-00-00-00-00
Ethernet adapter Ethernet:
Ethernet adapter Ethernet:
Connection-specific DNS Suffix . : network.lan
Description . . . . . . . . . . . : Intel(R) PRO/1000 MT Desktop Adapter
Physical Address. . . . . . . . . : 08-00-27-B8-42-C6
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::606a:ae33:7ce1:b5e9%3(Preferred)
IPv4 Address. . . . . . . . . . . : 10.0.2.15(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : Tuesday, January 30, 2018 11:25:31 PM
Lease Expires . . . . . . . . . . : Wednesday, January 31, 2018 11:25:27 PM
Default Gateway . . . . . . . . . : 10.0.2.2
DHCP Server . . . . . . . . . . . : 10.0.2.2
DHCPv6 IAID . . . . . . . . . . . : 34078759
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-21-40-72-3F-08-00-27-B8-42-C6
DNS Servers . . . . . . . . . . . : 10.0.2.3
NetBIOS over Tcpip. . . . . . . . : Enabled
Connection-specific DNS Suffix . : network.lan
Description . . . . . . . . . . . : Intel(R) PRO/1000 MT Desktop Adapter
Physical Address. . . . . . . . . : 08-00-27-B8-42-C6
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::606a:ae33:7ce1:b5e9%3(Preferred)
IPv4 Address. . . . . . . . . . . : 10.0.2.15(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : Tuesday, January 30, 2018 11:25:31 PM
Lease Expires . . . . . . . . . . : Wednesday, January 31, 2018 11:25:27 PM
Default Gateway . . . . . . . . . : 10.0.2.2
DHCP Server . . . . . . . . . . . : 10.0.2.2
DHCPv6 IAID . . . . . . . . . . . : 34078759
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-21-40-72-3F-08-00-27-B8-42-C6
DNS Servers . . . . . . . . . . . : 10.0.2.3
NetBIOS over Tcpip. . . . . . . . : Enabled
Tunnel adapter isatap.network.lan:
Tunnel adapter isatap.network.lan:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . : network.lan
Description . . . . . . . . . . . : Microsoft ISATAP Adapter
Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
TXT
, '080027b842c6',
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . : network.lan
Description . . . . . . . . . . . : Microsoft ISATAP Adapter
Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
TXT,
'080027b842c6',
],
'Full output - FreeBSD' => [<<<'TXT'
Name Mtu Network Address Ipkts Ierrs Idrop Opkts Oerrs Coll
aa0 0 <Link#0> 00:00:00:00:00:00 0 0 0 0 0 0
em0 1500 <Link#1> 08:00:27:71:a1:00 65514 0 0 42918 0 0
em1 1500 <Link#2> 08:00:27:d0:60:a0 1199 0 0 535 0 0
lo0 16384 <Link#3> lo0 4 0 0 4 0 0
TXT
, '08002771a100',
'Full output - FreeBSD' => [
<<<'TXT'
Name Mtu Network Address Ipkts Ierrs Idrop Opkts Oerrs Coll
aa0 0 <Link#0> 00:00:00:00:00:00 0 0 0 0 0 0
em0 1500 <Link#1> 08:00:27:71:a1:00 65514 0 0 42918 0 0
em1 1500 <Link#2> 08:00:27:d0:60:a0 1199 0 0 535 0 0
lo0 16384 <Link#3> lo0 4 0 0 4 0 0
TXT,
'08002771a100',
],
/* The single line that is relevant */
@@ -15,6 +15,7 @@ class SystemTimeProviderTest extends TestCase
$provider = new SystemTimeProvider();
$time = $provider->getTime();
/** @phpstan-ignore method.alreadyNarrowedType */
$this->assertInstanceOf(Time::class, $time);
}
}
+16 -4
View File
@@ -29,6 +29,8 @@ class FieldsTest extends TestCase
}
/**
* @param non-empty-string $uuid
*
* @dataProvider nonRfc4122VariantProvider
*/
public function testConstructorThrowsExceptionIfNotRfc4122Variant(string $uuid): void
@@ -45,7 +47,7 @@ class FieldsTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{0: non-empty-string}>
*/
public function nonRfc4122VariantProvider(): array
{
@@ -66,6 +68,8 @@ class FieldsTest extends TestCase
}
/**
* @param non-empty-string $uuid
*
* @dataProvider invalidVersionProvider
*/
public function testConstructorThrowsExceptionIfInvalidVersion(string $uuid): void
@@ -82,7 +86,7 @@ class FieldsTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{0: non-empty-string}>
*/
public function invalidVersionProvider(): array
{
@@ -99,12 +103,16 @@ class FieldsTest extends TestCase
}
/**
* @param non-empty-string $uuid
* @param non-empty-string $methodName
* @param Variant | Version | bool | non-empty-string | null $expectedValue
*
* @dataProvider fieldGetterMethodProvider
*/
public function testFieldGetterMethods(
string $uuid,
string $methodName,
bool | string | Variant | Version | null $expectedValue
Variant | Version | bool | string | null $expectedValue,
): void {
/** @var non-empty-string $bytes */
$bytes = (string) hex2bin(str_replace('-', '', $uuid));
@@ -120,7 +128,11 @@ class FieldsTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{
* 0: non-empty-string,
* 1: non-empty-string,
* 2: Variant | Version | bool | non-empty-string | null,
* }>
*/
public function fieldGetterMethodProvider(): array
{
+2 -1
View File
@@ -31,6 +31,7 @@ use function str_replace;
class UuidBuilderTest extends TestCase
{
/**
* @param non-empty-string $uuid
* @param class-string $expectedClass
*
* @dataProvider provideBuildTestValues
@@ -56,7 +57,7 @@ class UuidBuilderTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{uuid: non-empty-string, expectedClass: class-string, expectedVersion: Version | null}>
*/
public function provideBuildTestValues(): array
{

Some files were not shown because too many files have changed in this diff Show More