Version v0.17.0-dev

This commit is contained in:
github-actions[bot] 2025-06-30 18:07:11 +00:00
parent a991c884ab
commit a6213bc39d
72 changed files with 789 additions and 278 deletions

View File

@ -1 +1 @@
v0.16.1
v0.17.0-dev

175
composer.lock generated
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": "cf5ad91649510c1a7d389314192c90cd",
"content-hash": "7a1692c86b6fc70eaaf43c4bee3673aa",
"packages": [
{
"name": "brick/math",
@ -475,16 +475,16 @@
},
{
"name": "ipl/html",
"version": "v0.8.2",
"version": "dev-main",
"source": {
"type": "git",
"url": "https://github.com/Icinga/ipl-html.git",
"reference": "e18bdf11abca5e477100e2c7d190ef5f424d0d98"
"reference": "946f5c06265f64a90cd74d7df8833a353a90d9a5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Icinga/ipl-html/zipball/e18bdf11abca5e477100e2c7d190ef5f424d0d98",
"reference": "e18bdf11abca5e477100e2c7d190ef5f424d0d98",
"url": "https://api.github.com/repos/Icinga/ipl-html/zipball/946f5c06265f64a90cd74d7df8833a353a90d9a5",
"reference": "946f5c06265f64a90cd74d7df8833a353a90d9a5",
"shasum": ""
},
"require": {
@ -499,6 +499,7 @@
"ipl/stdlib": "dev-main",
"ipl/validator": "dev-main"
},
"default-branch": true,
"type": "library",
"autoload": {
"psr-4": {
@ -516,22 +517,22 @@
],
"support": {
"issues": "https://github.com/Icinga/ipl-html/issues",
"source": "https://github.com/Icinga/ipl-html/tree/v0.8.2"
"source": "https://github.com/Icinga/ipl-html/tree/main"
},
"time": "2025-05-21T09:00:03+00:00"
"time": "2025-06-12T11:57:29+00:00"
},
{
"name": "ipl/i18n",
"version": "v0.2.2",
"version": "dev-main",
"source": {
"type": "git",
"url": "https://github.com/Icinga/ipl-i18n.git",
"reference": "a2b6109c5a93f86ce46d5dc351dbe75e8502cf8c"
"reference": "692c33cf46fb8a4511da613dbf97c6216c345cc5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Icinga/ipl-i18n/zipball/a2b6109c5a93f86ce46d5dc351dbe75e8502cf8c",
"reference": "a2b6109c5a93f86ce46d5dc351dbe75e8502cf8c",
"url": "https://api.github.com/repos/Icinga/ipl-i18n/zipball/692c33cf46fb8a4511da613dbf97c6216c345cc5",
"reference": "692c33cf46fb8a4511da613dbf97c6216c345cc5",
"shasum": ""
},
"require": {
@ -543,6 +544,7 @@
"require-dev": {
"ipl/stdlib": "dev-main"
},
"default-branch": true,
"type": "library",
"autoload": {
"files": [
@ -567,13 +569,13 @@
],
"support": {
"issues": "https://github.com/Icinga/ipl-i18n/issues",
"source": "https://github.com/Icinga/ipl-i18n/tree/v0.2.2"
"source": "https://github.com/Icinga/ipl-i18n/tree/main"
},
"time": "2024-04-08T12:28:47+00:00"
"time": "2025-06-12T11:57:41+00:00"
},
{
"name": "ipl/orm",
"version": "v0.6.3",
"version": "dev-main",
"source": {
"type": "git",
"url": "https://github.com/Icinga/ipl-orm.git",
@ -596,6 +598,7 @@
"ipl/sql": "dev-main",
"ipl/stdlib": "dev-main"
},
"default-branch": true,
"type": "library",
"autoload": {
"psr-4": {
@ -621,16 +624,16 @@
},
{
"name": "ipl/scheduler",
"version": "v0.1.2",
"version": "dev-main",
"source": {
"type": "git",
"url": "https://github.com/Icinga/ipl-scheduler.git",
"reference": "6119afdea07b1390bd728e350e0d80b26ec8d6ba"
"reference": "3e4e8db870239d213b1dfd5d79d59fc7784b4c34"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Icinga/ipl-scheduler/zipball/6119afdea07b1390bd728e350e0d80b26ec8d6ba",
"reference": "6119afdea07b1390bd728e350e0d80b26ec8d6ba",
"url": "https://api.github.com/repos/Icinga/ipl-scheduler/zipball/3e4e8db870239d213b1dfd5d79d59fc7784b4c34",
"reference": "3e4e8db870239d213b1dfd5d79d59fc7784b4c34",
"shasum": ""
},
"require": {
@ -650,6 +653,7 @@
"suggest": {
"ext-ev": "Improves performance, efficiency and avoids system limitations. Highly recommended! (See https://www.php.net/manual/en/intro.ev.php for details)"
},
"default-branch": true,
"type": "library",
"autoload": {
"files": [
@ -673,22 +677,22 @@
],
"support": {
"issues": "https://github.com/Icinga/ipl-scheduler/issues",
"source": "https://github.com/Icinga/ipl-scheduler/tree/v0.1.2"
"source": "https://github.com/Icinga/ipl-scheduler/tree/main"
},
"time": "2023-08-30T14:14:23+00:00"
"time": "2025-06-12T11:58:09+00:00"
},
{
"name": "ipl/sql",
"version": "v0.7.1",
"version": "dev-main",
"source": {
"type": "git",
"url": "https://github.com/Icinga/ipl-sql.git",
"reference": "e80f1b712c4b96099b0bf9096e6efe317a165e3b"
"reference": "d668799c89fe25af974db8cb249d1f100002e615"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Icinga/ipl-sql/zipball/e80f1b712c4b96099b0bf9096e6efe317a165e3b",
"reference": "e80f1b712c4b96099b0bf9096e6efe317a165e3b",
"url": "https://api.github.com/repos/Icinga/ipl-sql/zipball/d668799c89fe25af974db8cb249d1f100002e615",
"reference": "d668799c89fe25af974db8cb249d1f100002e615",
"shasum": ""
},
"require": {
@ -699,6 +703,7 @@
"require-dev": {
"ipl/stdlib": "dev-main"
},
"default-branch": true,
"type": "library",
"autoload": {
"psr-4": {
@ -717,22 +722,22 @@
],
"support": {
"issues": "https://github.com/Icinga/ipl-sql/issues",
"source": "https://github.com/Icinga/ipl-sql/tree/v0.7.1"
"source": "https://github.com/Icinga/ipl-sql/tree/main"
},
"time": "2024-06-25T09:55:43+00:00"
"time": "2025-06-12T11:58:24+00:00"
},
{
"name": "ipl/stdlib",
"version": "v0.14.0",
"version": "dev-main",
"source": {
"type": "git",
"url": "https://github.com/Icinga/ipl-stdlib.git",
"reference": "bf5fc8f40b86bd90337db6f3be389be2a93fa64a"
"reference": "dca0319664db9b575254215b3f5dbbd87a3387bd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Icinga/ipl-stdlib/zipball/bf5fc8f40b86bd90337db6f3be389be2a93fa64a",
"reference": "bf5fc8f40b86bd90337db6f3be389be2a93fa64a",
"url": "https://api.github.com/repos/Icinga/ipl-stdlib/zipball/dca0319664db9b575254215b3f5dbbd87a3387bd",
"reference": "dca0319664db9b575254215b3f5dbbd87a3387bd",
"shasum": ""
},
"require": {
@ -740,6 +745,7 @@
"ext-openssl": "*",
"php": ">=7.2"
},
"default-branch": true,
"type": "library",
"autoload": {
"files": [
@ -756,22 +762,22 @@
"description": "ipl Standard Library",
"support": {
"issues": "https://github.com/Icinga/ipl-stdlib/issues",
"source": "https://github.com/Icinga/ipl-stdlib/tree/v0.14.0"
"source": "https://github.com/Icinga/ipl-stdlib/tree/main"
},
"time": "2024-04-22T08:47:08+00:00"
"time": "2025-06-12T11:59:06+00:00"
},
{
"name": "ipl/validator",
"version": "v0.5.0",
"version": "dev-main",
"source": {
"type": "git",
"url": "https://github.com/Icinga/ipl-validator.git",
"reference": "a601fae0ed330e63cea50e4a2a6659ca1ad97bde"
"reference": "eac5c6c114d8007db5c24ae159fe6f55e89a946b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Icinga/ipl-validator/zipball/a601fae0ed330e63cea50e4a2a6659ca1ad97bde",
"reference": "a601fae0ed330e63cea50e4a2a6659ca1ad97bde",
"url": "https://api.github.com/repos/Icinga/ipl-validator/zipball/eac5c6c114d8007db5c24ae159fe6f55e89a946b",
"reference": "eac5c6c114d8007db5c24ae159fe6f55e89a946b",
"shasum": ""
},
"require": {
@ -780,11 +786,14 @@
"ipl/i18n": ">=0.2.0",
"ipl/stdlib": ">=0.12.0",
"php": ">=7.2",
"psr/http-message": "~1.0"
"psr/http-message": "^1.1"
},
"require-dev": {
"guzzlehttp/psr7": "^1"
"guzzlehttp/psr7": "^1",
"ipl/i18n": "dev-main",
"ipl/stdlib": "dev-main"
},
"default-branch": true,
"type": "library",
"autoload": {
"psr-4": {
@ -799,13 +808,13 @@
"homepage": "https://github.com/Icinga/ipl-validator",
"support": {
"issues": "https://github.com/Icinga/ipl-validator/issues",
"source": "https://github.com/Icinga/ipl-validator/tree/v0.5.0"
"source": "https://github.com/Icinga/ipl-validator/tree/main"
},
"time": "2023-03-21T15:59:00+00:00"
"time": "2025-06-12T11:59:27+00:00"
},
{
"name": "ipl/web",
"version": "v0.11.1",
"version": "dev-main",
"source": {
"type": "git",
"url": "https://github.com/Icinga/ipl-web.git",
@ -837,6 +846,7 @@
"ipl/stdlib": "dev-main",
"shardj/zf1-future": "^1.22"
},
"default-branch": true,
"type": "library",
"autoload": {
"psr-4": {
@ -1138,21 +1148,20 @@
},
{
"name": "ramsey/uuid",
"version": "4.8.1",
"version": "4.9.0",
"source": {
"type": "git",
"url": "https://github.com/ramsey/uuid.git",
"reference": "fdf4dd4e2ff1813111bd0ad58d7a1ddbb5b56c28"
"reference": "4e0e23cc785f0724a0e838279a9eb03f28b092a0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ramsey/uuid/zipball/fdf4dd4e2ff1813111bd0ad58d7a1ddbb5b56c28",
"reference": "fdf4dd4e2ff1813111bd0ad58d7a1ddbb5b56c28",
"url": "https://api.github.com/repos/ramsey/uuid/zipball/4e0e23cc785f0724a0e838279a9eb03f28b092a0",
"reference": "4e0e23cc785f0724a0e838279a9eb03f28b092a0",
"shasum": ""
},
"require": {
"brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11 || ^0.12 || ^0.13",
"ext-json": "*",
"php": "^8.0",
"ramsey/collection": "^1.2 || ^2.0"
},
@ -1211,9 +1220,9 @@
],
"support": {
"issues": "https://github.com/ramsey/uuid/issues",
"source": "https://github.com/ramsey/uuid/tree/4.8.1"
"source": "https://github.com/ramsey/uuid/tree/4.9.0"
},
"time": "2025-06-01T06:28:46+00:00"
"time": "2025-06-25T14:20:11+00:00"
},
{
"name": "react/event-loop",
@ -1629,15 +1638,73 @@
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"aliases": [
{
"package": "ipl/html",
"version": "dev-main",
"alias": "99.x-dev",
"alias_normalized": "99.9999999.9999999.9999999-dev"
},
{
"package": "ipl/i18n",
"version": "dev-main",
"alias": "99.x-dev",
"alias_normalized": "99.9999999.9999999.9999999-dev"
},
{
"package": "ipl/orm",
"version": "dev-main",
"alias": "99.x-dev",
"alias_normalized": "99.9999999.9999999.9999999-dev"
},
{
"package": "ipl/scheduler",
"version": "dev-main",
"alias": "99.x-dev",
"alias_normalized": "99.9999999.9999999.9999999-dev"
},
{
"package": "ipl/sql",
"version": "dev-main",
"alias": "99.x-dev",
"alias_normalized": "99.9999999.9999999.9999999-dev"
},
{
"package": "ipl/stdlib",
"version": "dev-main",
"alias": "99.x-dev",
"alias_normalized": "99.9999999.9999999.9999999-dev"
},
{
"package": "ipl/validator",
"version": "dev-main",
"alias": "99.x-dev",
"alias_normalized": "99.9999999.9999999.9999999-dev"
},
{
"package": "ipl/web",
"version": "dev-main",
"alias": "99.x-dev",
"alias_normalized": "99.9999999.9999999.9999999-dev"
}
],
"minimum-stability": "dev",
"stability-flags": {
"ipl/html": 20,
"ipl/i18n": 20,
"ipl/orm": 20,
"ipl/scheduler": 20,
"ipl/sql": 20,
"ipl/stdlib": 20,
"ipl/validator": 20,
"ipl/web": 20
},
"prefer-stable": true,
"prefer-lowest": false,
"platform": {
"php": ">=8.2"
"php": ">=7.2"
},
"platform-dev": [],
"platform-dev": {},
"platform-overrides": {
"php": "8.2"
},

7
vendor/autoload.php vendored
View File

@ -14,12 +14,9 @@ if (PHP_VERSION_ID < 50600) {
echo $err;
}
}
trigger_error(
$err,
E_USER_ERROR
);
throw new RuntimeException($err);
}
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitcf5ad91649510c1a7d389314192c90cd::getLoader();
return ComposerAutoloaderInit7a1692c86b6fc70eaaf43c4bee3673aa::getLoader();

View File

@ -26,12 +26,23 @@ use Composer\Semver\VersionParser;
*/
class InstalledVersions
{
/**
* @var string|null if set (by reflection by Composer), this should be set to the path where this class is being copied to
* @internal
*/
private static $selfDir = null;
/**
* @var mixed[]|null
* @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
*/
private static $installed;
/**
* @var bool
*/
private static $installedIsLocalDir;
/**
* @var bool|null
*/
@ -309,6 +320,24 @@ class InstalledVersions
{
self::$installed = $data;
self::$installedByVendor = array();
// when using reload, we disable the duplicate protection to ensure that self::$installed data is
// always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not,
// so we have to assume it does not, and that may result in duplicate data being returned when listing
// all installed packages for example
self::$installedIsLocalDir = false;
}
/**
* @return string
*/
private static function getSelfDir()
{
if (self::$selfDir === null) {
self::$selfDir = strtr(__DIR__, '\\', '/');
}
return self::$selfDir;
}
/**
@ -322,19 +351,27 @@ class InstalledVersions
}
$installed = array();
$copiedLocalDir = false;
if (self::$canGetVendors) {
$selfDir = self::getSelfDir();
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
$vendorDir = strtr($vendorDir, '\\', '/');
if (isset(self::$installedByVendor[$vendorDir])) {
$installed[] = self::$installedByVendor[$vendorDir];
} elseif (is_file($vendorDir.'/composer/installed.php')) {
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
$required = require $vendorDir.'/composer/installed.php';
$installed[] = self::$installedByVendor[$vendorDir] = $required;
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
self::$installed = $installed[count($installed) - 1];
self::$installedByVendor[$vendorDir] = $required;
$installed[] = $required;
if (self::$installed === null && $vendorDir.'/composer' === $selfDir) {
self::$installed = $required;
self::$installedIsLocalDir = true;
}
}
if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) {
$copiedLocalDir = true;
}
}
}
@ -350,7 +387,7 @@ class InstalledVersions
}
}
if (self::$installed !== array()) {
if (self::$installed !== array() && !$copiedLocalDir) {
$installed[] = self::$installed;
}

View File

@ -22,7 +22,7 @@ return array(
'Ramsey\\Uuid\\' => array($vendorDir . '/ramsey/uuid/src'),
'Ramsey\\Collection\\' => array($vendorDir . '/ramsey/collection/src'),
'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src', $vendorDir . '/psr/http-factory/src'),
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-factory/src', $vendorDir . '/psr/http-message/src'),
'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'),
'Evenement\\' => array($vendorDir . '/evenement/evenement/src'),
'Doctrine\\Deprecations\\' => array($vendorDir . '/doctrine/deprecations/src'),

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitcf5ad91649510c1a7d389314192c90cd
class ComposerAutoloaderInit7a1692c86b6fc70eaaf43c4bee3673aa
{
private static $loader;
@ -24,16 +24,16 @@ class ComposerAutoloaderInitcf5ad91649510c1a7d389314192c90cd
require __DIR__ . '/platform_check.php';
spl_autoload_register(array('ComposerAutoloaderInitcf5ad91649510c1a7d389314192c90cd', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit7a1692c86b6fc70eaaf43c4bee3673aa', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitcf5ad91649510c1a7d389314192c90cd', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit7a1692c86b6fc70eaaf43c4bee3673aa', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitcf5ad91649510c1a7d389314192c90cd::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit7a1692c86b6fc70eaaf43c4bee3673aa::getInitializer($loader));
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInitcf5ad91649510c1a7d389314192c90cd::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit7a1692c86b6fc70eaaf43c4bee3673aa::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInitcf5ad91649510c1a7d389314192c90cd
class ComposerStaticInit7a1692c86b6fc70eaaf43c4bee3673aa
{
public static $files = array (
'a2c78434f64e5f5ed402f42eee19c025' => __DIR__ . '/..' . '/ipl/stdlib/src/functions_include.php',
@ -139,8 +139,8 @@ class ComposerStaticInitcf5ad91649510c1a7d389314192c90cd
),
'Psr\\Http\\Message\\' =>
array (
0 => __DIR__ . '/..' . '/psr/http-message/src',
1 => __DIR__ . '/..' . '/psr/http-factory/src',
0 => __DIR__ . '/..' . '/psr/http-factory/src',
1 => __DIR__ . '/..' . '/psr/http-message/src',
),
'GuzzleHttp\\Psr7\\' =>
array (
@ -194,10 +194,10 @@ class ComposerStaticInitcf5ad91649510c1a7d389314192c90cd
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitcf5ad91649510c1a7d389314192c90cd::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitcf5ad91649510c1a7d389314192c90cd::$prefixDirsPsr4;
$loader->prefixesPsr0 = ComposerStaticInitcf5ad91649510c1a7d389314192c90cd::$prefixesPsr0;
$loader->classMap = ComposerStaticInitcf5ad91649510c1a7d389314192c90cd::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit7a1692c86b6fc70eaaf43c4bee3673aa::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit7a1692c86b6fc70eaaf43c4bee3673aa::$prefixDirsPsr4;
$loader->prefixesPsr0 = ComposerStaticInit7a1692c86b6fc70eaaf43c4bee3673aa::$prefixesPsr0;
$loader->classMap = ComposerStaticInit7a1692c86b6fc70eaaf43c4bee3673aa::$classMap;
}, null, ClassLoader::class);
}

View File

@ -490,17 +490,17 @@
},
{
"name": "ipl/html",
"version": "v0.8.2",
"version_normalized": "0.8.2.0",
"version": "dev-main",
"version_normalized": "dev-main",
"source": {
"type": "git",
"url": "https://github.com/Icinga/ipl-html.git",
"reference": "e18bdf11abca5e477100e2c7d190ef5f424d0d98"
"reference": "946f5c06265f64a90cd74d7df8833a353a90d9a5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Icinga/ipl-html/zipball/e18bdf11abca5e477100e2c7d190ef5f424d0d98",
"reference": "e18bdf11abca5e477100e2c7d190ef5f424d0d98",
"url": "https://api.github.com/repos/Icinga/ipl-html/zipball/946f5c06265f64a90cd74d7df8833a353a90d9a5",
"reference": "946f5c06265f64a90cd74d7df8833a353a90d9a5",
"shasum": ""
},
"require": {
@ -515,7 +515,8 @@
"ipl/stdlib": "dev-main",
"ipl/validator": "dev-main"
},
"time": "2025-05-21T09:00:03+00:00",
"time": "2025-06-12T11:57:29+00:00",
"default-branch": true,
"type": "library",
"installation-source": "dist",
"autoload": {
@ -534,23 +535,23 @@
],
"support": {
"issues": "https://github.com/Icinga/ipl-html/issues",
"source": "https://github.com/Icinga/ipl-html/tree/v0.8.2"
"source": "https://github.com/Icinga/ipl-html/tree/main"
},
"install-path": "../ipl/html"
},
{
"name": "ipl/i18n",
"version": "v0.2.2",
"version_normalized": "0.2.2.0",
"version": "dev-main",
"version_normalized": "dev-main",
"source": {
"type": "git",
"url": "https://github.com/Icinga/ipl-i18n.git",
"reference": "a2b6109c5a93f86ce46d5dc351dbe75e8502cf8c"
"reference": "692c33cf46fb8a4511da613dbf97c6216c345cc5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Icinga/ipl-i18n/zipball/a2b6109c5a93f86ce46d5dc351dbe75e8502cf8c",
"reference": "a2b6109c5a93f86ce46d5dc351dbe75e8502cf8c",
"url": "https://api.github.com/repos/Icinga/ipl-i18n/zipball/692c33cf46fb8a4511da613dbf97c6216c345cc5",
"reference": "692c33cf46fb8a4511da613dbf97c6216c345cc5",
"shasum": ""
},
"require": {
@ -562,7 +563,8 @@
"require-dev": {
"ipl/stdlib": "dev-main"
},
"time": "2024-04-08T12:28:47+00:00",
"time": "2025-06-12T11:57:41+00:00",
"default-branch": true,
"type": "library",
"installation-source": "dist",
"autoload": {
@ -588,14 +590,14 @@
],
"support": {
"issues": "https://github.com/Icinga/ipl-i18n/issues",
"source": "https://github.com/Icinga/ipl-i18n/tree/v0.2.2"
"source": "https://github.com/Icinga/ipl-i18n/tree/main"
},
"install-path": "../ipl/i18n"
},
{
"name": "ipl/orm",
"version": "v0.6.3",
"version_normalized": "0.6.3.0",
"version": "dev-main",
"version_normalized": "dev-main",
"source": {
"type": "git",
"url": "https://github.com/Icinga/ipl-orm.git",
@ -619,6 +621,7 @@
"ipl/stdlib": "dev-main"
},
"time": "2025-06-12T11:57:55+00:00",
"default-branch": true,
"type": "library",
"installation-source": "dist",
"autoload": {
@ -645,17 +648,17 @@
},
{
"name": "ipl/scheduler",
"version": "v0.1.2",
"version_normalized": "0.1.2.0",
"version": "dev-main",
"version_normalized": "dev-main",
"source": {
"type": "git",
"url": "https://github.com/Icinga/ipl-scheduler.git",
"reference": "6119afdea07b1390bd728e350e0d80b26ec8d6ba"
"reference": "3e4e8db870239d213b1dfd5d79d59fc7784b4c34"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Icinga/ipl-scheduler/zipball/6119afdea07b1390bd728e350e0d80b26ec8d6ba",
"reference": "6119afdea07b1390bd728e350e0d80b26ec8d6ba",
"url": "https://api.github.com/repos/Icinga/ipl-scheduler/zipball/3e4e8db870239d213b1dfd5d79d59fc7784b4c34",
"reference": "3e4e8db870239d213b1dfd5d79d59fc7784b4c34",
"shasum": ""
},
"require": {
@ -675,7 +678,8 @@
"suggest": {
"ext-ev": "Improves performance, efficiency and avoids system limitations. Highly recommended! (See https://www.php.net/manual/en/intro.ev.php for details)"
},
"time": "2023-08-30T14:14:23+00:00",
"time": "2025-06-12T11:58:09+00:00",
"default-branch": true,
"type": "library",
"installation-source": "dist",
"autoload": {
@ -700,23 +704,23 @@
],
"support": {
"issues": "https://github.com/Icinga/ipl-scheduler/issues",
"source": "https://github.com/Icinga/ipl-scheduler/tree/v0.1.2"
"source": "https://github.com/Icinga/ipl-scheduler/tree/main"
},
"install-path": "../ipl/scheduler"
},
{
"name": "ipl/sql",
"version": "v0.7.1",
"version_normalized": "0.7.1.0",
"version": "dev-main",
"version_normalized": "dev-main",
"source": {
"type": "git",
"url": "https://github.com/Icinga/ipl-sql.git",
"reference": "e80f1b712c4b96099b0bf9096e6efe317a165e3b"
"reference": "d668799c89fe25af974db8cb249d1f100002e615"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Icinga/ipl-sql/zipball/e80f1b712c4b96099b0bf9096e6efe317a165e3b",
"reference": "e80f1b712c4b96099b0bf9096e6efe317a165e3b",
"url": "https://api.github.com/repos/Icinga/ipl-sql/zipball/d668799c89fe25af974db8cb249d1f100002e615",
"reference": "d668799c89fe25af974db8cb249d1f100002e615",
"shasum": ""
},
"require": {
@ -727,7 +731,8 @@
"require-dev": {
"ipl/stdlib": "dev-main"
},
"time": "2024-06-25T09:55:43+00:00",
"time": "2025-06-12T11:58:24+00:00",
"default-branch": true,
"type": "library",
"installation-source": "dist",
"autoload": {
@ -747,23 +752,23 @@
],
"support": {
"issues": "https://github.com/Icinga/ipl-sql/issues",
"source": "https://github.com/Icinga/ipl-sql/tree/v0.7.1"
"source": "https://github.com/Icinga/ipl-sql/tree/main"
},
"install-path": "../ipl/sql"
},
{
"name": "ipl/stdlib",
"version": "v0.14.0",
"version_normalized": "0.14.0.0",
"version": "dev-main",
"version_normalized": "dev-main",
"source": {
"type": "git",
"url": "https://github.com/Icinga/ipl-stdlib.git",
"reference": "bf5fc8f40b86bd90337db6f3be389be2a93fa64a"
"reference": "dca0319664db9b575254215b3f5dbbd87a3387bd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Icinga/ipl-stdlib/zipball/bf5fc8f40b86bd90337db6f3be389be2a93fa64a",
"reference": "bf5fc8f40b86bd90337db6f3be389be2a93fa64a",
"url": "https://api.github.com/repos/Icinga/ipl-stdlib/zipball/dca0319664db9b575254215b3f5dbbd87a3387bd",
"reference": "dca0319664db9b575254215b3f5dbbd87a3387bd",
"shasum": ""
},
"require": {
@ -771,7 +776,8 @@
"ext-openssl": "*",
"php": ">=7.2"
},
"time": "2024-04-22T08:47:08+00:00",
"time": "2025-06-12T11:59:06+00:00",
"default-branch": true,
"type": "library",
"installation-source": "dist",
"autoload": {
@ -789,23 +795,23 @@
"description": "ipl Standard Library",
"support": {
"issues": "https://github.com/Icinga/ipl-stdlib/issues",
"source": "https://github.com/Icinga/ipl-stdlib/tree/v0.14.0"
"source": "https://github.com/Icinga/ipl-stdlib/tree/main"
},
"install-path": "../ipl/stdlib"
},
{
"name": "ipl/validator",
"version": "v0.5.0",
"version_normalized": "0.5.0.0",
"version": "dev-main",
"version_normalized": "dev-main",
"source": {
"type": "git",
"url": "https://github.com/Icinga/ipl-validator.git",
"reference": "a601fae0ed330e63cea50e4a2a6659ca1ad97bde"
"reference": "eac5c6c114d8007db5c24ae159fe6f55e89a946b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Icinga/ipl-validator/zipball/a601fae0ed330e63cea50e4a2a6659ca1ad97bde",
"reference": "a601fae0ed330e63cea50e4a2a6659ca1ad97bde",
"url": "https://api.github.com/repos/Icinga/ipl-validator/zipball/eac5c6c114d8007db5c24ae159fe6f55e89a946b",
"reference": "eac5c6c114d8007db5c24ae159fe6f55e89a946b",
"shasum": ""
},
"require": {
@ -814,12 +820,15 @@
"ipl/i18n": ">=0.2.0",
"ipl/stdlib": ">=0.12.0",
"php": ">=7.2",
"psr/http-message": "~1.0"
"psr/http-message": "^1.1"
},
"require-dev": {
"guzzlehttp/psr7": "^1"
"guzzlehttp/psr7": "^1",
"ipl/i18n": "dev-main",
"ipl/stdlib": "dev-main"
},
"time": "2023-03-21T15:59:00+00:00",
"time": "2025-06-12T11:59:27+00:00",
"default-branch": true,
"type": "library",
"installation-source": "dist",
"autoload": {
@ -835,14 +844,14 @@
"homepage": "https://github.com/Icinga/ipl-validator",
"support": {
"issues": "https://github.com/Icinga/ipl-validator/issues",
"source": "https://github.com/Icinga/ipl-validator/tree/v0.5.0"
"source": "https://github.com/Icinga/ipl-validator/tree/main"
},
"install-path": "../ipl/validator"
},
{
"name": "ipl/web",
"version": "v0.11.1",
"version_normalized": "0.11.1.0",
"version": "dev-main",
"version_normalized": "dev-main",
"source": {
"type": "git",
"url": "https://github.com/Icinga/ipl-web.git",
@ -875,6 +884,7 @@
"shardj/zf1-future": "^1.22"
},
"time": "2025-06-12T11:58:42+00:00",
"default-branch": true,
"type": "library",
"installation-source": "dist",
"autoload": {
@ -1192,22 +1202,21 @@
},
{
"name": "ramsey/uuid",
"version": "4.8.1",
"version_normalized": "4.8.1.0",
"version": "4.9.0",
"version_normalized": "4.9.0.0",
"source": {
"type": "git",
"url": "https://github.com/ramsey/uuid.git",
"reference": "fdf4dd4e2ff1813111bd0ad58d7a1ddbb5b56c28"
"reference": "4e0e23cc785f0724a0e838279a9eb03f28b092a0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ramsey/uuid/zipball/fdf4dd4e2ff1813111bd0ad58d7a1ddbb5b56c28",
"reference": "fdf4dd4e2ff1813111bd0ad58d7a1ddbb5b56c28",
"url": "https://api.github.com/repos/ramsey/uuid/zipball/4e0e23cc785f0724a0e838279a9eb03f28b092a0",
"reference": "4e0e23cc785f0724a0e838279a9eb03f28b092a0",
"shasum": ""
},
"require": {
"brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11 || ^0.12 || ^0.13",
"ext-json": "*",
"php": "^8.0",
"ramsey/collection": "^1.2 || ^2.0"
},
@ -1240,7 +1249,7 @@
"paragonie/random-lib": "Provides RandomLib for use with the RandomLibAdapter",
"ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type."
},
"time": "2025-06-01T06:28:46+00:00",
"time": "2025-06-25T14:20:11+00:00",
"type": "library",
"extra": {
"captainhook": {
@ -1268,7 +1277,7 @@
],
"support": {
"issues": "https://github.com/ramsey/uuid/issues",
"source": "https://github.com/ramsey/uuid/tree/4.8.1"
"source": "https://github.com/ramsey/uuid/tree/4.9.0"
},
"install-path": "../ramsey/uuid"
},

View File

@ -3,7 +3,7 @@
'name' => 'icinga/icinga-php-library',
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => '2afd0f67eb878c401d4f61c5580fff023ddcc9a6',
'reference' => 'a991c884ab803fcba7fe3e59bb173839ce723a0c',
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@ -76,82 +76,106 @@
'icinga/icinga-php-library' => array(
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => '2afd0f67eb878c401d4f61c5580fff023ddcc9a6',
'reference' => 'a991c884ab803fcba7fe3e59bb173839ce723a0c',
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'dev_requirement' => false,
),
'ipl/html' => array(
'pretty_version' => 'v0.8.2',
'version' => '0.8.2.0',
'reference' => 'e18bdf11abca5e477100e2c7d190ef5f424d0d98',
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => '946f5c06265f64a90cd74d7df8833a353a90d9a5',
'type' => 'library',
'install_path' => __DIR__ . '/../ipl/html',
'aliases' => array(),
'aliases' => array(
0 => '99.x-dev',
1 => '9999999-dev',
),
'dev_requirement' => false,
),
'ipl/i18n' => array(
'pretty_version' => 'v0.2.2',
'version' => '0.2.2.0',
'reference' => 'a2b6109c5a93f86ce46d5dc351dbe75e8502cf8c',
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => '692c33cf46fb8a4511da613dbf97c6216c345cc5',
'type' => 'library',
'install_path' => __DIR__ . '/../ipl/i18n',
'aliases' => array(),
'aliases' => array(
0 => '99.x-dev',
1 => '9999999-dev',
),
'dev_requirement' => false,
),
'ipl/orm' => array(
'pretty_version' => 'v0.6.3',
'version' => '0.6.3.0',
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => 'a775a2745764a8dc7f28618cce69dcd7bbfd7915',
'type' => 'library',
'install_path' => __DIR__ . '/../ipl/orm',
'aliases' => array(),
'aliases' => array(
0 => '99.x-dev',
1 => '9999999-dev',
),
'dev_requirement' => false,
),
'ipl/scheduler' => array(
'pretty_version' => 'v0.1.2',
'version' => '0.1.2.0',
'reference' => '6119afdea07b1390bd728e350e0d80b26ec8d6ba',
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => '3e4e8db870239d213b1dfd5d79d59fc7784b4c34',
'type' => 'library',
'install_path' => __DIR__ . '/../ipl/scheduler',
'aliases' => array(),
'aliases' => array(
0 => '99.x-dev',
1 => '9999999-dev',
),
'dev_requirement' => false,
),
'ipl/sql' => array(
'pretty_version' => 'v0.7.1',
'version' => '0.7.1.0',
'reference' => 'e80f1b712c4b96099b0bf9096e6efe317a165e3b',
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => 'd668799c89fe25af974db8cb249d1f100002e615',
'type' => 'library',
'install_path' => __DIR__ . '/../ipl/sql',
'aliases' => array(),
'aliases' => array(
0 => '99.x-dev',
1 => '9999999-dev',
),
'dev_requirement' => false,
),
'ipl/stdlib' => array(
'pretty_version' => 'v0.14.0',
'version' => '0.14.0.0',
'reference' => 'bf5fc8f40b86bd90337db6f3be389be2a93fa64a',
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => 'dca0319664db9b575254215b3f5dbbd87a3387bd',
'type' => 'library',
'install_path' => __DIR__ . '/../ipl/stdlib',
'aliases' => array(),
'aliases' => array(
0 => '99.x-dev',
1 => '9999999-dev',
),
'dev_requirement' => false,
),
'ipl/validator' => array(
'pretty_version' => 'v0.5.0',
'version' => '0.5.0.0',
'reference' => 'a601fae0ed330e63cea50e4a2a6659ca1ad97bde',
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => 'eac5c6c114d8007db5c24ae159fe6f55e89a946b',
'type' => 'library',
'install_path' => __DIR__ . '/../ipl/validator',
'aliases' => array(),
'aliases' => array(
0 => '99.x-dev',
1 => '9999999-dev',
),
'dev_requirement' => false,
),
'ipl/web' => array(
'pretty_version' => 'v0.11.1',
'version' => '0.11.1.0',
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => 'af3a8a7be5e924f0ad841baf1471d296329aa1e7',
'type' => 'library',
'install_path' => __DIR__ . '/../ipl/web',
'aliases' => array(),
'aliases' => array(
0 => '99.x-dev',
1 => '9999999-dev',
),
'dev_requirement' => false,
),
'mtdowling/cron-expression' => array(
@ -218,9 +242,9 @@
'dev_requirement' => false,
),
'ramsey/uuid' => array(
'pretty_version' => '4.8.1',
'version' => '4.8.1.0',
'reference' => 'fdf4dd4e2ff1813111bd0ad58d7a1ddbb5b56c28',
'pretty_version' => '4.9.0',
'version' => '4.9.0.0',
'reference' => '4e0e23cc785f0724a0e838279a9eb03f28b092a0',
'type' => 'library',
'install_path' => __DIR__ . '/../ramsey/uuid',
'aliases' => array(),
@ -247,7 +271,7 @@
'rhumsaa/uuid' => array(
'dev_requirement' => false,
'replaced' => array(
0 => '4.8.1',
0 => '4.9.0',
),
),
'simshaun/recurr' => array(

View File

@ -13,4 +13,53 @@ class TestConnection extends Connection
{
$this->adapter = new TestAdapter();
}
public function connect()
{
return $this;
}
public function beginTransaction()
{
throw new \LogicException('Transactions are not supported by the test connection');
}
public function commitTransaction()
{
throw new \LogicException('Transactions are not supported by the test connection');
}
public function rollbackTransaction()
{
throw new \LogicException('Transactions are not supported by the test connection');
}
public function prepexec($stmt, $values = null)
{
if (PHP_MAJOR_VERSION >= 8) {
return new class extends \PDOStatement {
public function getIterator(): \Iterator
{
return new \ArrayIterator([]);
}
public function setFetchMode($mode, ...$args): bool
{
return true;
}
};
} else {
return new class extends \PDOStatement {
public function getIterator(): \Iterator
{
return new \ArrayIterator([]);
}
public function setFetchMode($mode, $params = null): bool
{
return true;
}
};
}
}
}

View File

@ -10,7 +10,7 @@
"ext-openssl": "*",
"ipl/stdlib": ">=0.12.0",
"ipl/i18n": ">=0.2.0",
"psr/http-message": "~1.0"
"psr/http-message": "^1.1"
},
"autoload": {
"psr-4": {
@ -23,6 +23,8 @@
}
},
"require-dev": {
"guzzlehttp/psr7": "^1"
"guzzlehttp/psr7": "^1",
"ipl/stdlib": "dev-main",
"ipl/i18n": "dev-main"
}
}

View File

@ -12,10 +12,10 @@ class BetweenValidator extends BaseValidator
{
use Translation;
/** @var mixed Min value */
/** @var int|float Min value */
protected $min;
/** @var mixed Max value */
/** @var int|float Max value */
protected $max;
/**
@ -33,14 +33,14 @@ class BetweenValidator extends BaseValidator
*
* Required options:
*
* - min: (scalar) Minimum border
* - max: (scalar) Maximum border
* - min: (int|float) Minimum border
* - max: (int|float) Maximum border
*
* Optional options:
*
* - inclusive: (bool) Whether inclusive border values, default true
*
* @param array $options
* @param array{min: int|float, max: int|float, inclusive?: bool} $options
*
* @throws Exception When required option is missing
*/
@ -58,7 +58,7 @@ class BetweenValidator extends BaseValidator
/**
* Return the min option
*
* @return mixed
* @return int|float
*/
public function getMin()
{
@ -68,7 +68,7 @@ class BetweenValidator extends BaseValidator
/**
* Set the min option
*
* @param mixed $min
* @param int|float $min
*
* @return $this
*/
@ -82,7 +82,7 @@ class BetweenValidator extends BaseValidator
/**
* Return the max option
*
* @return mixed
* @return int|float
*/
public function getMax()
{
@ -92,7 +92,7 @@ class BetweenValidator extends BaseValidator
/**
* Set the max option
*
* @param mixed $max
* @param int|float $max
*
* @return $this
*/
@ -120,14 +120,19 @@ class BetweenValidator extends BaseValidator
*
* @return $this
*/
public function setInclusive($inclusive = true): self
public function setInclusive(bool $inclusive = true): self
{
$this->inclusive = (bool) $inclusive;
$this->inclusive = $inclusive;
return $this;
}
public function isValid($value)
/**
* @param int|float $value
*
* @return bool
*/
public function isValid($value): bool
{
// Multiple isValid() calls must not stack validation messages
$this->clearMessages();

View File

@ -35,7 +35,7 @@ class CallbackValidator extends BaseValidator
$this->callback = $callback;
}
public function isValid($value)
public function isValid($value): bool
{
// Multiple isValid() calls must not stack validation messages
$this->clearMessages();

View File

@ -12,6 +12,10 @@ class CidrValidator extends BaseValidator
{
use Translation;
/**
* @param string $value
* @return bool
*/
public function isValid($value): bool
{
$this->clearMessages();

View File

@ -23,9 +23,9 @@ class DateTimeValidator extends BaseValidator
*
* @param bool $local
*/
public function __construct($local = true)
public function __construct(bool $local = true)
{
$this->local = (bool) $local;
$this->local = $local;
}
/**
@ -35,7 +35,7 @@ class DateTimeValidator extends BaseValidator
*
* @return bool
*/
public function isValid($value)
public function isValid($value): bool
{
// Multiple isValid() calls must not stack validation messages
$this->clearMessages();

View File

@ -15,7 +15,7 @@ class DeferredInArrayValidator extends InArrayValidator
*
* **Required parameter:**
*
* - `callback`: (`callable`) The callback to create haystack
* - `callback`: (`callable`) The callback to create the haystack
*
* **Optional parameter:**
*
@ -23,8 +23,8 @@ class DeferredInArrayValidator extends InArrayValidator
*
* * `strict`: (`bool`) Whether the types of the needle in the haystack should also match, default `false`
*
* @param callable $callback Validation callback
* @param array $options
* @param callable $callback The callback to create the haystack
* @param array{haystack?: mixed[], strict?: bool} $options
*/
public function __construct(callable $callback, array $options = [])
{

View File

@ -40,7 +40,7 @@ class EmailAddressValidator extends BaseValidator
* 'mx' => If an MX check should be enabled, boolean
* 'deep' => If a deep MX check should be enabled, boolean
*
* @param array $options
* @param array{max?: bool, deep?: bool} $options
*
* @throws Exception
*/
@ -266,7 +266,8 @@ class EmailAddressValidator extends BaseValidator
//decode IDN domain name
$decodedHostname = idn_to_ascii($hostname, 0, INTL_IDNA_VARIANT_UTS46);
$result = getmxrr($decodedHostname, $mxHosts);
$result = $decodedHostname && getmxrr($decodedHostname, $mxHosts);
if (! $result) {
$this->addMessage(sprintf(
$this->translate("'%s' does not appear to have a valid MX record for the email address '%s'"),

View File

@ -34,6 +34,8 @@ class FileValidator extends BaseValidator
* - maxSize: (int) Maximum allowed file size, by default no limit
* - maxFileNameLength: (int) Maximum allowed file name length, by default no limit
* - mimeType: (array) Allowed mime types, by default no restriction
*
* @param array{minSize?: int, maxSize?: int, maxFileNameLength?: int, mimeType?: string[]} $options
*/
public function __construct(array $options = [])
{
@ -160,7 +162,11 @@ class FileValidator extends BaseValidator
return $this;
}
public function isValid($value)
/**
* @param UploadedFileInterface|UploadedFileInterface[] $value
* @return bool
*/
public function isValid($value): bool
{
// Multiple isValid() calls must not stack validation messages
$this->clearMessages();
@ -185,7 +191,7 @@ class FileValidator extends BaseValidator
if ($this->getMaxSize() && $file->getSize() > $this->getMaxSize()) {
$this->addMessage(sprintf(
$this->translate('File %s is bigger than the allowed maximum size of %d'),
$file->getClientFileName(),
$file->getClientFilename(),
$this->getMaxSize()
));
@ -195,7 +201,7 @@ class FileValidator extends BaseValidator
if ($this->getMinSize() && $file->getSize() < $this->getMinSize()) {
$this->addMessage(sprintf(
$this->translate('File %s is smaller than the minimum required size of %d'),
$file->getClientFileName(),
$file->getClientFilename(),
$this->getMinSize()
));
@ -205,7 +211,7 @@ class FileValidator extends BaseValidator
if ($this->getMaxFileNameLength()) {
$strValidator = new StringLengthValidator(['max' => $this->getMaxFileNameLength()]);
if (! $strValidator->isValid($file->getClientFilename())) {
if (! $strValidator->isValid($file->getClientFilename() ?? '')) {
$this->addMessage(sprintf(
$this->translate('File name is longer than the allowed length of %d characters.'),
$this->maxFileNameLength
@ -217,8 +223,10 @@ class FileValidator extends BaseValidator
if (! empty($this->getAllowedMimeTypes())) {
$hasAllowedMimeType = false;
foreach ($this->getAllowedMimeTypes() as $type) {
$fileMimetype = $file->getClientMediaType();
if ($fileMimetype) {
foreach ($this->getAllowedMimeTypes() as $type) {
if (($pos = strpos($type, '/*')) !== false) { // image/*
$typePrefix = substr($type, 0, $pos);
if (Str::startsWith($fileMimetype, $typePrefix)) {
@ -230,13 +238,14 @@ class FileValidator extends BaseValidator
break;
}
}
}
if (! $hasAllowedMimeType) {
$this->addMessage(sprintf(
$this->translate('File %s is of type %s. Only %s allowed.'),
$file->getClientFileName(),
$file->getClientFilename(),
$file->getClientMediaType(),
implode(', ', $this->allowedMimeTypes)
implode(', ', $this->allowedMimeTypes ?? [])
));
$isValid = false;

View File

@ -11,14 +11,16 @@ class GreaterThanValidator extends BaseValidator
{
use Translation;
/** @var mixed Comparison value for greater than */
/** @var int|float Comparison value for greater than */
protected $min;
/**
* Create a new GreaterThanValidator
*
* Optional options:
* - min: (scalar) Comparison value for greater than, default 0
* - min: (int|float) Comparison value for greater than, default 0
*
* @param array{min?: int|float} $options
*/
public function __construct(array $options = [])
{
@ -28,7 +30,7 @@ class GreaterThanValidator extends BaseValidator
/**
* Get the min option
*
* @return mixed
* @return int|float
*/
public function getMin()
{
@ -38,7 +40,7 @@ class GreaterThanValidator extends BaseValidator
/**
* Set the min option
*
* @param mixed $min
* @param int|float $min
*
* @return $this
*/
@ -49,7 +51,12 @@ class GreaterThanValidator extends BaseValidator
return $this;
}
public function isValid($value)
/**
* @param int|float $value
*
* @return bool
*/
public function isValid($value): bool
{
// Multiple isValid() calls must not stack validation messages
$this->clearMessages();

View File

@ -18,7 +18,7 @@ class HostnameValidator extends BaseValidator
*
* @return boolean
*/
public function isValid($value)
public function isValid($value): bool
{
$this->clearMessages();
@ -26,7 +26,7 @@ class HostnameValidator extends BaseValidator
if (filter_var($asciiHostname, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME) === false) {
$this->addMessage(sprintf(
$this->translate("%s is not a valid host name."),
$value ?? ''
$value
));
return false;

View File

@ -11,7 +11,7 @@ class InArrayValidator extends BaseValidator
{
use Translation;
/** @var array The array */
/** @var ?mixed[] The array */
protected $haystack;
/** @var bool Whether the types of the needle in the haystack should also match */
@ -25,7 +25,7 @@ class InArrayValidator extends BaseValidator
* * `haystack`: (`array`) The array
* * `strict`: (`bool`) Whether the types of the needle in the haystack should also match, default `false`
*
* @param array $options
* @param array{haystack?: mixed[], strict?: bool} $options
*/
public function __construct(array $options = [])
{
@ -39,7 +39,7 @@ class InArrayValidator extends BaseValidator
/**
* Get the haystack
*
* @return array
* @return mixed[]
*/
public function getHaystack(): array
{
@ -49,7 +49,7 @@ class InArrayValidator extends BaseValidator
/**
* Set the haystack
*
* @param array $haystack
* @param mixed[] $haystack
*
* @return $this
*/
@ -84,7 +84,7 @@ class InArrayValidator extends BaseValidator
return $this;
}
public function isValid($value)
public function isValid($value): bool
{
// Multiple isValid() calls must not stack validation messages
$this->clearMessages();
@ -110,9 +110,9 @@ class InArrayValidator extends BaseValidator
/**
* Get the values from the specified array that are not present in the haystack
*
* @param array $values
* @param mixed[] $values
*
* @return array Values not found in the haystack
* @return mixed[] Values not found in the haystack
*/
protected function findInvalid(array $values = []): array
{

View File

@ -11,14 +11,16 @@ class LessThanValidator extends BaseValidator
{
use Translation;
/** @var mixed Comparison value for less than */
/** @var int|float Comparison value for less than */
protected $max;
/**
* Create a new LessThanValidator
*
* Optional options:
* - max: (int) Comparison value for less than, default 0
* - max: (int|float) Comparison value for less than, default 0
*
* @param array{max?: int|float} $options
*/
public function __construct(array $options = [])
{
@ -28,7 +30,7 @@ class LessThanValidator extends BaseValidator
/**
* Get the max option
*
* @return mixed
* @return int|float
*/
public function getMax()
{
@ -38,7 +40,7 @@ class LessThanValidator extends BaseValidator
/**
* Set the max option
*
* @param mixed $max
* @param int|float $max
*
* @return $this
*/
@ -49,7 +51,12 @@ class LessThanValidator extends BaseValidator
return $this;
}
public function isValid($value)
/**
* @param int|float $value
*
* @return bool
*/
public function isValid($value): bool
{
// Multiple isValid() calls must not stack validation messages
$this->clearMessages();

View File

@ -11,7 +11,12 @@ class PrivateKeyValidator extends BaseValidator
{
use Translation;
public function isValid($value)
/**
* @param string $value
*
* @return bool
*/
public function isValid($value): bool
{
// Multiple isValid() calls must not stack validation messages
$this->clearMessages();

View File

@ -13,10 +13,10 @@ class StringLengthValidator extends BaseValidator
{
use Translation;
/** @var mixed Minimum required length */
/** @var int Minimum required length */
protected $min;
/** @var mixed Maximum required length */
/** @var ?int Maximum required length */
protected $max;
/** @var ?string Encoding to use */
@ -26,9 +26,11 @@ class StringLengthValidator extends BaseValidator
* Create a new StringLengthValidator
*
* Optional options:
* - min: (scalar) Minimum required string length, default 0
* - max: (scalar) Maximum required string length, default null
* - encoding: (string) Encoding type, default null
* - min: (int) Minimum required string length, default 0
* - max: (int) Maximum required string length, default none
* - encoding: (string) Encoding type, default none
*
* @param array{min?: int, max?: int, encoding?: string} $options
*/
public function __construct(array $options = [])
{
@ -41,9 +43,9 @@ class StringLengthValidator extends BaseValidator
/**
* Get the minimum required string length
*
* @return mixed
* @return int
*/
public function getMin()
public function getMin(): int
{
return $this->min;
}
@ -51,13 +53,13 @@ class StringLengthValidator extends BaseValidator
/**
* Set the minimum required string length
*
* @param mixed $min
* @param int $min
*
* @return $this
*
* @throws LogicException When the $min is greater than the $max value
*/
public function setMin($min): self
public function setMin(int $min): self
{
if ($this->getMax() !== null && $min > $this->getMax()) {
throw new LogicException(
@ -77,9 +79,9 @@ class StringLengthValidator extends BaseValidator
/**
* Get the maximum required string length
*
* @return mixed
* @return ?int
*/
public function getMax()
public function getMax(): ?int
{
return $this->max;
}
@ -87,13 +89,13 @@ class StringLengthValidator extends BaseValidator
/**
* Set the minimum required string length
*
* @param mixed $max
* @param ?int $max
*
* @return $this
*
* @throws LogicException When the $min is greater than the $max value
*/
public function setMax($max): self
public function setMax(?int $max): self
{
if ($max !== null && $this->getMin() > $max) {
throw new LogicException(
@ -143,7 +145,12 @@ class StringLengthValidator extends BaseValidator
return $this;
}
public function isValid($value)
/**
* @param string $value
*
* @return bool
*/
public function isValid($value): bool
{
// Multiple isValid() calls must not stack validation messages
$this->clearMessages();

View File

@ -15,6 +15,7 @@ use UnexpectedValueException;
use function ipl\Stdlib\get_php_type;
/** @implements IteratorAggregate<int, Validator> */
class ValidatorChain implements Countable, IteratorAggregate, Validator
{
use Messages;
@ -23,10 +24,10 @@ class ValidatorChain implements Countable, IteratorAggregate, Validator
/** Default priority at which validators are added */
const DEFAULT_PRIORITY = 1;
/** @var PriorityQueue Validator chain */
/** @var PriorityQueue<int, Validator> Validator chain */
protected $validators;
/** @var SplObjectStorage Validators that break the chain on failure */
/** @var SplObjectStorage<Validator, null> Validators that break the chain on failure */
protected $validatorsThatBreakTheChain;
/**
@ -43,7 +44,7 @@ class ValidatorChain implements Countable, IteratorAggregate, Validator
/**
* Get the validators that break the chain
*
* @return SplObjectStorage
* @return SplObjectStorage<Validator, null>
*/
public function getValidatorsThatBreakTheChain()
{
@ -76,7 +77,7 @@ class ValidatorChain implements Countable, IteratorAggregate, Validator
/**
* Add the validators from the given validator specification to the chain
*
* @param iterable $validators
* @param static|Traversable<int|string, mixed> $validators
*
* @return $this
*
@ -149,7 +150,7 @@ class ValidatorChain implements Countable, IteratorAggregate, Validator
*
* @return $this
*/
public function addValidatorLoader($namespace, $postfix = null)
public function addValidatorLoader($namespace, $postfix = '')
{
$this->addPluginLoader('validator', $namespace, $postfix);
@ -221,6 +222,10 @@ class ValidatorChain implements Countable, IteratorAggregate, Validator
{
$validatorsThatBreakTheChain = $validatorChain->getValidatorsThatBreakTheChain();
/**
* @var int $priority
* @var Validator $validator
*/
foreach ($validatorChain->validators->yieldAll() as $priority => $validator) {
$this->add($validator, $validatorsThatBreakTheChain->contains($validator), $priority);
}
@ -236,11 +241,14 @@ class ValidatorChain implements Countable, IteratorAggregate, Validator
/**
* Export the chain as array
*
* @return array
* @return Validator[]
*/
public function toArray()
{
return array_values(iterator_to_array($this));
/** @var Validator[] $validators */
$validators = iterator_to_array($this);
return array_values($validators);
}
public function count(): int
@ -251,7 +259,7 @@ class ValidatorChain implements Countable, IteratorAggregate, Validator
/**
* Get an iterator for traversing the validators
*
* @return Validator[]|PriorityQueue
* @return PriorityQueue<int, Validator>
*/
public function getIterator(): Traversable
{
@ -259,7 +267,7 @@ class ValidatorChain implements Countable, IteratorAggregate, Validator
return clone $this->validators;
}
public function isValid($value)
public function isValid($value): bool
{
$this->clearMessages();

View File

@ -11,7 +11,11 @@ class X509CertValidator extends BaseValidator
{
use Translation;
public function isValid($value)
/**
* @param String $value
* @return bool
*/
public function isValid($value): bool
{
// Multiple isValid() calls must not stack validation messages
$this->clearMessages();

View File

@ -10,7 +10,6 @@
],
"require": {
"php": "^8.0",
"ext-json": "*",
"brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11 || ^0.12 || ^0.13",
"ramsey/collection": "^1.2 || ^2.0"
},

View File

@ -27,6 +27,8 @@ class BinaryUtils
* @param int $clockSeq The 16-bit clock sequence value before the variant is applied
*
* @return int The 16-bit clock sequence multiplexed with the UUID variant
*
* @pure
*/
public static function applyVariant(int $clockSeq): int
{
@ -42,6 +44,8 @@ class BinaryUtils
* @param int $version The version to apply to the `time_hi` field
*
* @return int The 16-bit time_hi field of the timestamp multiplexed with the UUID version number
*
* @pure
*/
public static function applyVersion(int $timeHi, int $version): int
{

View File

@ -50,6 +50,8 @@ class DegradedUuidBuilder implements UuidBuilderInterface
* @param string $bytes The byte string from which to construct a UUID
*
* @return DegradedUuid The DegradedUuidBuild returns an instance of Ramsey\Uuid\DegradedUuid
*
* @phpstan-impure
*/
public function build(CodecInterface $codec, string $bytes): UuidInterface
{

View File

@ -40,6 +40,8 @@ class FallbackBuilder implements UuidBuilderInterface
* @param string $bytes The byte string from which to construct a UUID
*
* @return UuidInterface an instance of a UUID object
*
* @pure
*/
public function build(CodecInterface $codec, string $bytes): UuidInterface
{

View File

@ -31,6 +31,8 @@ interface UuidBuilderInterface
* @param string $bytes The byte string from which to construct a UUID
*
* @return UuidInterface Implementations may choose to return more specific instances of UUIDs that implement UuidInterface
*
* @pure
*/
public function build(CodecInterface $codec, string $bytes): UuidInterface;
}

View File

@ -29,6 +29,8 @@ interface CodecInterface
* @param UuidInterface $uuid The UUID for which to create a hexadecimal string representation
*
* @return non-empty-string Hexadecimal string representation of a UUID
*
* @pure
*/
public function encode(UuidInterface $uuid): string;
@ -38,6 +40,8 @@ interface CodecInterface
* @param UuidInterface $uuid The UUID for which to create a binary string representation
*
* @return non-empty-string Binary string representation of a UUID
*
* @pure
*/
public function encodeBinary(UuidInterface $uuid): string;
@ -47,6 +51,8 @@ interface CodecInterface
* @param string $encodedUuid The hexadecimal string representation to convert into a UuidInterface instance
*
* @return UuidInterface An instance of a UUID decoded from a hexadecimal string representation
*
* @pure
*/
public function decode(string $encodedUuid): UuidInterface;
@ -56,6 +62,8 @@ interface CodecInterface
* @param string $bytes The binary string representation to convert into a UuidInterface instance
*
* @return UuidInterface An instance of a UUID decoded from a binary string representation
*
* @pure
*/
public function decodeBytes(string $bytes): UuidInterface;
}

View File

@ -32,6 +32,7 @@ class GuidStringCodec extends StringCodec
{
public function encode(UuidInterface $uuid): string
{
/** @phpstan-ignore possiblyImpure.methodCall */
$hex = bin2hex($uuid->getFields()->getBytes());
/** @var non-empty-string */
@ -52,8 +53,10 @@ class GuidStringCodec extends StringCodec
public function decode(string $encodedUuid): UuidInterface
{
/** @phpstan-ignore possiblyImpure.methodCall */
$bytes = $this->getBytes($encodedUuid);
/** @phpstan-ignore possiblyImpure.methodCall, possiblyImpure.methodCall */
return $this->getBuilder()->build($this, $this->swapBytes($bytes));
}

View File

@ -51,12 +51,15 @@ class OrderedTimeCodec extends StringCodec
public function encodeBinary(UuidInterface $uuid): string
{
if (
/** @phpstan-ignore possiblyImpure.methodCall */
!($uuid->getFields() instanceof Rfc4122FieldsInterface)
/** @phpstan-ignore possiblyImpure.methodCall */
|| $uuid->getFields()->getVersion() !== Uuid::UUID_TYPE_TIME
) {
throw new InvalidArgumentException('Expected version 1 (time-based) UUID');
}
/** @phpstan-ignore possiblyImpure.methodCall */
$bytes = $uuid->getFields()->getBytes();
return $bytes[6] . $bytes[7] . $bytes[4] . $bytes[5]
@ -84,10 +87,10 @@ class OrderedTimeCodec extends StringCodec
$uuid = parent::decodeBytes($rearrangedBytes);
if (
!($uuid->getFields() instanceof Rfc4122FieldsInterface)
|| $uuid->getFields()->getVersion() !== Uuid::UUID_TYPE_TIME
) {
/** @phpstan-ignore possiblyImpure.methodCall */
$fields = $uuid->getFields();
if (!$fields instanceof Rfc4122FieldsInterface || $fields->getVersion() !== Uuid::UUID_TYPE_TIME) {
throw new UnsupportedOperationException(
'Attempting to decode a non-time-based UUID using OrderedTimeCodec',
);

View File

@ -46,6 +46,7 @@ class StringCodec implements CodecInterface
public function encode(UuidInterface $uuid): string
{
/** @phpstan-ignore possiblyImpure.methodCall */
$hex = bin2hex($uuid->getFields()->getBytes());
/** @var non-empty-string */
@ -75,6 +76,7 @@ class StringCodec implements CodecInterface
*/
public function decode(string $encodedUuid): UuidInterface
{
/** @phpstan-ignore possiblyImpure.methodCall */
return $this->builder->build($this, $this->getBytes($encodedUuid));
}

View File

@ -55,6 +55,7 @@ class TimestampFirstCombCodec extends StringCodec
*/
public function encode(UuidInterface $uuid): string
{
/** @phpstan-ignore possiblyImpure.methodCall */
$bytes = $this->swapBytes($uuid->getFields()->getBytes());
return sprintf(
@ -83,18 +84,23 @@ class TimestampFirstCombCodec extends StringCodec
*/
public function decode(string $encodedUuid): UuidInterface
{
/** @phpstan-ignore possiblyImpure.methodCall */
$bytes = $this->getBytes($encodedUuid);
/** @phpstan-ignore possiblyImpure.methodCall */
return $this->getBuilder()->build($this, $this->swapBytes($bytes));
}
public function decodeBytes(string $bytes): UuidInterface
{
/** @phpstan-ignore possiblyImpure.methodCall */
return $this->getBuilder()->build($this, $this->swapBytes($bytes));
}
/**
* Swaps bytes according to the timestamp-first COMB rules
*
* @pure
*/
private function swapBytes(string $bytes): string
{

View File

@ -34,11 +34,17 @@ class BigNumberConverter implements NumberConverterInterface
$this->converter = new GenericNumberConverter(new BrickMathCalculator());
}
/**
* @pure
*/
public function fromHex(string $hex): string
{
return $this->converter->fromHex($hex);
}
/**
* @pure
*/
public function toHex(string $number): string
{
return $this->converter->toHex($number);

View File

@ -29,14 +29,20 @@ class GenericNumberConverter implements NumberConverterInterface
{
}
/**
* @pure
*/
public function fromHex(string $hex): string
{
return $this->calculator->fromBase($hex, 16)->toString();
}
/**
* @pure
*/
public function toHex(string $number): string
{
/** @phpstan-ignore-next-line PHPStan complains that this is not a non-empty-string. */
/** @phpstan-ignore return.type, possiblyImpure.new */
return $this->calculator->toBase(new IntegerObject($number), 16);
}
}

View File

@ -30,6 +30,8 @@ interface NumberConverterInterface
* @param string $hex The hexadecimal string representation to convert
*
* @return numeric-string String representation of an integer
*
* @pure
*/
public function fromHex(string $hex): string;
@ -40,6 +42,8 @@ interface NumberConverterInterface
* unsigned integers that are greater than `PHP_INT_MAX`.
*
* @return non-empty-string Hexadecimal string
*
* @pure
*/
public function toHex(string $number): string;
}

View File

@ -54,26 +54,36 @@ class GenericTimeConverter implements TimeConverterInterface
public function calculateTime(string $seconds, string $microseconds): Hexadecimal
{
/** @phpstan-ignore possiblyImpure.new */
$timestamp = new Time($seconds, $microseconds);
// Convert the seconds into a count of 100-nanosecond intervals.
$sec = $this->calculator->multiply(
$timestamp->getSeconds(),
new IntegerObject(self::SECOND_INTERVALS),
new IntegerObject(self::SECOND_INTERVALS), /** @phpstan-ignore possiblyImpure.new */
);
// Convert the microseconds into a count of 100-nanosecond intervals.
$usec = $this->calculator->multiply(
$timestamp->getMicroseconds(),
new IntegerObject(self::MICROSECOND_INTERVALS),
new IntegerObject(self::MICROSECOND_INTERVALS), /** @phpstan-ignore possiblyImpure.new */
);
// Combine the intervals of seconds and microseconds and add the count of 100-nanosecond intervals from the
// Gregorian calendar epoch to the Unix epoch. This gives us the correct count of 100-nanosecond intervals since
// the Gregorian calendar epoch for the given seconds and microseconds.
/** @var IntegerObject $uuidTime */
/**
* Combine the intervals of seconds and microseconds and add the count of 100-nanosecond intervals from the
* Gregorian calendar epoch to the Unix epoch. This gives us the correct count of 100-nanosecond intervals since
* the Gregorian calendar epoch for the given seconds and microseconds.
*
* @var IntegerObject $uuidTime
* @phpstan-ignore possiblyImpure.new
*/
$uuidTime = $this->calculator->add($sec, $usec, new IntegerObject(self::GREGORIAN_TO_UNIX_INTERVALS));
/**
* PHPStan considers CalculatorInterface::toHexadecimal, Hexadecimal:toString impure.
*
* @phpstan-ignore possiblyImpure.new
*/
return new Hexadecimal(str_pad($this->calculator->toHexadecimal($uuidTime)->toString(), 16, '0', STR_PAD_LEFT));
}
@ -83,7 +93,7 @@ class GenericTimeConverter implements TimeConverterInterface
// epoch. This gives us the number of 100-nanosecond intervals from the Unix epoch, which also includes the microtime.
$epochNanoseconds = $this->calculator->subtract(
$this->calculator->toInteger($uuidTimestamp),
new IntegerObject(self::GREGORIAN_TO_UNIX_INTERVALS),
new IntegerObject(self::GREGORIAN_TO_UNIX_INTERVALS), /** @phpstan-ignore possiblyImpure.new */
);
// Convert the 100-nanosecond intervals into seconds and microseconds.
@ -91,11 +101,12 @@ class GenericTimeConverter implements TimeConverterInterface
RoundingMode::HALF_UP,
6,
$epochNanoseconds,
new IntegerObject(self::SECOND_INTERVALS),
new IntegerObject(self::SECOND_INTERVALS), /** @phpstan-ignore possiblyImpure.new */
);
$split = explode('.', (string) $unixTimestamp, 2);
/** @phpstan-ignore possiblyImpure.new */
return new Time($split[0], $split[1] ?? 0);
}
}

View File

@ -79,8 +79,8 @@ class PhpTimeConverter implements TimeConverterInterface
public function calculateTime(string $seconds, string $microseconds): Hexadecimal
{
$seconds = new IntegerObject($seconds);
$microseconds = new IntegerObject($microseconds);
$seconds = new IntegerObject($seconds); /** @phpstan-ignore possiblyImpure.new */
$microseconds = new IntegerObject($microseconds); /** @phpstan-ignore possiblyImpure.new */
// Calculate the count of 100-nanosecond intervals since the Gregorian calendar epoch
// for the given seconds and microseconds.
@ -98,7 +98,10 @@ class PhpTimeConverter implements TimeConverterInterface
);
}
return new Hexadecimal(str_pad(dechex($uuidTime), 16, '0', STR_PAD_LEFT));
/** @phpstan-ignore possiblyImpure.new */
return new Hexadecimal(
str_pad(dechex($uuidTime), 16, '0', STR_PAD_LEFT)
);
}
public function convertTime(Hexadecimal $uuidTimestamp): Time
@ -114,6 +117,7 @@ class PhpTimeConverter implements TimeConverterInterface
return $this->fallbackConverter->convertTime($uuidTimestamp);
}
/** @phpstan-ignore possiblyImpure.new */
return new Time($splitTime['sec'], $splitTime['usec']);
}
@ -121,6 +125,8 @@ class PhpTimeConverter implements TimeConverterInterface
* @param float | int $time The time to split into seconds and microseconds
*
* @return string[]
*
* @pure
*/
private function splitTime(float | int $time): array
{

View File

@ -42,23 +42,35 @@ class UnixTimeConverter implements TimeConverterInterface
public function calculateTime(string $seconds, string $microseconds): Hexadecimal
{
/** @phpstan-ignore possiblyImpure.new */
$timestamp = new Time($seconds, $microseconds);
// Convert the seconds into milliseconds.
$sec = $this->calculator->multiply($timestamp->getSeconds(), new IntegerObject(self::MILLISECONDS));
$sec = $this->calculator->multiply(
$timestamp->getSeconds(),
new IntegerObject(self::MILLISECONDS) /** @phpstan-ignore possiblyImpure.new */
);
// Convert the microseconds into milliseconds; the scale is zero because we need to discard the fractional part.
$usec = $this->calculator->divide(
RoundingMode::DOWN, // Always round down to stay in the previous millisecond.
0,
$timestamp->getMicroseconds(),
new IntegerObject(self::MILLISECONDS),
new IntegerObject(self::MILLISECONDS), /** @phpstan-ignore possiblyImpure.new */
);
/** @var IntegerObject $unixTime */
$unixTime = $this->calculator->add($sec, $usec);
return new Hexadecimal(str_pad($this->calculator->toHexadecimal($unixTime)->toString(), 12, '0', STR_PAD_LEFT));
/** @phpstan-ignore possiblyImpure.new */
return new Hexadecimal(
str_pad(
$this->calculator->toHexadecimal($unixTime)->toString(),
12,
'0',
STR_PAD_LEFT
),
);
}
public function convertTime(Hexadecimal $uuidTimestamp): Time
@ -69,11 +81,12 @@ class UnixTimeConverter implements TimeConverterInterface
RoundingMode::HALF_UP,
6,
$milliseconds,
new IntegerObject(self::MILLISECONDS),
new IntegerObject(self::MILLISECONDS), /** @phpstan-ignore possiblyImpure.new */
);
$split = explode('.', (string) $unixTimestamp, 2);
/** @phpstan-ignore possiblyImpure.new */
return new Time($split[0], $split[1] ?? '0');
}
}

View File

@ -34,6 +34,8 @@ interface TimeConverterInterface
* @param string $microseconds A string representation of the micro-seconds associated with the time to calculate
*
* @return Hexadecimal The full UUID timestamp as a Hexadecimal value
*
* @pure
*/
public function calculateTime(string $seconds, string $microseconds): Hexadecimal;
@ -44,6 +46,8 @@ interface TimeConverterInterface
* of 100-nanosecond intervals since UTC 00:00:00.00, 15 October 1582.
*
* @return Time An instance of {@see Time}
*
* @pure
*/
public function convertTime(Hexadecimal $uuidTimestamp): Time;
}

View File

@ -26,6 +26,8 @@ interface FieldsInterface extends Serializable
{
/**
* Returns the bytes that comprise the fields
*
* @pure
*/
public function getBytes(): string;
}

View File

@ -25,6 +25,9 @@ use function hash;
*/
class DefaultNameGenerator implements NameGeneratorInterface
{
/**
* @pure
*/
public function generate(UuidInterface $ns, string $name, string $hashAlgorithm): string
{
try {

View File

@ -30,6 +30,8 @@ interface NameGeneratorInterface
* @param string $hashAlgorithm The hashing algorithm to use
*
* @return string A binary string
*
* @pure
*/
public function generate(UuidInterface $ns, string $name, string $hashAlgorithm): string;
}

View File

@ -29,16 +29,20 @@ use function uuid_parse;
*/
class PeclUuidNameGenerator implements NameGeneratorInterface
{
/**
* @pure
*/
public function generate(UuidInterface $ns, string $name, string $hashAlgorithm): string
{
$uuid = match ($hashAlgorithm) {
'md5' => uuid_generate_md5($ns->toString(), $name),
'sha1' => uuid_generate_sha1($ns->toString(), $name),
'md5' => uuid_generate_md5($ns->toString(), $name), /** @phpstan-ignore possiblyImpure.functionCall */
'sha1' => uuid_generate_sha1($ns->toString(), $name), /** @phpstan-ignore possiblyImpure.functionCall */
default => throw new NameException(
sprintf('Unable to hash namespace and name with algorithm \'%s\'', $hashAlgorithm),
),
};
/** @phpstan-ignore possiblyImpure.functionCall */
return (string) uuid_parse($uuid);
}
}

View File

@ -19,6 +19,7 @@ use DateTimeImmutable;
use DateTimeInterface;
use Ramsey\Uuid\Type\Hexadecimal;
use function assert;
use function hash;
use function pack;
use function str_pad;
@ -81,7 +82,8 @@ class UnixTimeGenerator implements TimeGeneratorInterface
$time = str_pad(BigInteger::of($time)->toBytes(false), 6, "\x00", STR_PAD_LEFT);
}
/** @var non-empty-string */
assert(strlen($time) === 6);
return $time . pack('n*', self::$rand[1], self::$rand[2], self::$rand[3], self::$rand[4], self::$rand[5]);
}

View File

@ -49,21 +49,28 @@ class GuidBuilder implements UuidBuilderInterface
* @param string $bytes The byte string from which to construct a UUID
*
* @return Guid The GuidBuilder returns an instance of Ramsey\Uuid\Guid\Guid
*
* @pure
*/
public function build(CodecInterface $codec, string $bytes): UuidInterface
{
try {
/** @phpstan-ignore possiblyImpure.new */
return new Guid($this->buildFields($bytes), $this->numberConverter, $codec, $this->timeConverter);
} catch (Throwable $e) {
/** @phpstan-ignore possiblyImpure.methodCall, possiblyImpure.methodCall */
throw new UnableToBuildUuidException($e->getMessage(), (int) $e->getCode(), $e);
}
}
/**
* Proxy method to allow injecting a mock for testing
*
* @pure
*/
protected function buildFields(string $bytes): Fields
{
/** @phpstan-ignore possiblyImpure.new */
return new Fields($bytes);
}
}

View File

@ -214,7 +214,10 @@ final class LazyUuidFromString implements UuidInterface
public function getBytes(): string
{
/** @var non-empty-string */
/**
* @var non-empty-string
* @phpstan-ignore possiblyImpure.functionCall, possiblyImpure.functionCall
*/
return (string) hex2bin(str_replace('-', '', $this->uuid));
}

View File

@ -49,9 +49,10 @@ final class BrickMathCalculator implements CalculatorInterface
$sum = BigInteger::of($augend->toString());
foreach ($addends as $addend) {
$sum = $sum->plus($addend->toString());
$sum = $sum->plus($addend->toString()); /** @phpstan-ignore possiblyImpure.methodCall */
}
/** @phpstan-ignore possiblyImpure.methodCall, possiblyImpure.new */
return new IntegerObject((string) $sum);
}
@ -60,9 +61,10 @@ final class BrickMathCalculator implements CalculatorInterface
$difference = BigInteger::of($minuend->toString());
foreach ($subtrahends as $subtrahend) {
$difference = $difference->minus($subtrahend->toString());
$difference = $difference->minus($subtrahend->toString()); /** @phpstan-ignore possiblyImpure.methodCall */
}
/** @phpstan-ignore possiblyImpure.methodCall, possiblyImpure.new */
return new IntegerObject((string) $difference);
}
@ -71,9 +73,11 @@ final class BrickMathCalculator implements CalculatorInterface
$product = BigInteger::of($multiplicand->toString());
foreach ($multipliers as $multiplier) {
/** @phpstan-ignore possiblyImpure.methodCall */
$product = $product->multipliedBy($multiplier->toString());
}
/** @phpstan-ignore possiblyImpure.methodCall, possiblyImpure.new */
return new IntegerObject((string) $product);
}
@ -83,24 +87,29 @@ final class BrickMathCalculator implements CalculatorInterface
NumberInterface $dividend,
NumberInterface ...$divisors,
): NumberInterface {
/** @phpstan-ignore possiblyImpure.methodCall */
$brickRounding = $this->getBrickRoundingMode($roundingMode);
$quotient = BigDecimal::of($dividend->toString());
foreach ($divisors as $divisor) {
/** @phpstan-ignore possiblyImpure.methodCall */
$quotient = $quotient->dividedBy($divisor->toString(), $scale, $brickRounding);
}
if ($scale === 0) {
/** @phpstan-ignore possiblyImpure.methodCall, possiblyImpure.methodCall, possiblyImpure.new */
return new IntegerObject((string) $quotient->toBigInteger());
}
/** @phpstan-ignore possiblyImpure.methodCall, possiblyImpure.new */
return new Decimal((string) $quotient);
}
public function fromBase(string $value, int $base): IntegerObject
{
try {
/** @phpstan-ignore possiblyImpure.methodCall, possiblyImpure.new */
return new IntegerObject((string) BigInteger::fromBase($value, $base));
} catch (MathException | \InvalidArgumentException $exception) {
throw new InvalidArgumentException(
@ -114,6 +123,7 @@ final class BrickMathCalculator implements CalculatorInterface
public function toBase(IntegerObject $value, int $base): string
{
try {
/** @phpstan-ignore possiblyImpure.methodCall */
return BigInteger::of($value->toString())->toBase($base);
} catch (MathException | \InvalidArgumentException $exception) {
throw new InvalidArgumentException(
@ -126,6 +136,7 @@ final class BrickMathCalculator implements CalculatorInterface
public function toHexadecimal(IntegerObject $value): Hexadecimal
{
/** @phpstan-ignore possiblyImpure.new */
return new Hexadecimal($this->toBase($value, 16));
}

View File

@ -32,6 +32,8 @@ interface CalculatorInterface
* @param NumberInterface ...$addends The additional integers to a add to the augend
*
* @return NumberInterface The sum of all the parameters
*
* @pure
*/
public function add(NumberInterface $augend, NumberInterface ...$addends): NumberInterface;
@ -42,6 +44,8 @@ interface CalculatorInterface
* @param NumberInterface ...$subtrahends The integers to subtract from the minuend
*
* @return NumberInterface The difference after subtracting all parameters
*
* @pure
*/
public function subtract(NumberInterface $minuend, NumberInterface ...$subtrahends): NumberInterface;
@ -52,6 +56,8 @@ interface CalculatorInterface
* @param NumberInterface ...$multipliers The factors by which to multiply the multiplicand
*
* @return NumberInterface The product of multiplying all the provided parameters
*
* @pure
*/
public function multiply(NumberInterface $multiplicand, NumberInterface ...$multipliers): NumberInterface;
@ -65,6 +71,8 @@ interface CalculatorInterface
* operations should take place (left-to-right)
*
* @return NumberInterface The quotient of dividing the provided parameters left-to-right
*
* @pure
*/
public function divide(
int $roundingMode,
@ -80,6 +88,8 @@ interface CalculatorInterface
* @param int $base The base to convert from (i.e., 2, 16, 32, etc.)
*
* @return IntegerObject The base-10 integer value of the converted value
*
* @pure
*/
public function fromBase(string $value, int $base): IntegerObject;
@ -90,16 +100,22 @@ interface CalculatorInterface
* @param int $base The base to convert to (i.e., 2, 16, 32, etc.)
*
* @return string The value represented in the specified base
*
* @pure
*/
public function toBase(IntegerObject $value, int $base): string;
/**
* Converts an Integer instance to a Hexadecimal instance
*
* @pure
*/
public function toHexadecimal(IntegerObject $value): Hexadecimal;
/**
* Converts a Hexadecimal instance to an Integer instance
*
* @pure
*/
public function toInteger(Hexadecimal $value): IntegerObject;
}

View File

@ -23,6 +23,7 @@ use Ramsey\Uuid\Uuid as BaseUuid;
* Nonstandard\Uuid is a UUID that doesn't conform to RFC 9562 (formerly RFC 4122)
*
* @immutable
* @pure
*/
final class Uuid extends BaseUuid
{

View File

@ -47,21 +47,28 @@ class UuidBuilder implements UuidBuilderInterface
* @param string $bytes The byte string from which to construct a UUID
*
* @return Uuid The Nonstandard\UuidBuilder returns an instance of Nonstandard\Uuid
*
* @pure
*/
public function build(CodecInterface $codec, string $bytes): UuidInterface
{
try {
/** @phpstan-ignore possiblyImpure.new */
return new Uuid($this->buildFields($bytes), $this->numberConverter, $codec, $this->timeConverter);
} catch (Throwable $e) {
/** @phpstan-ignore possiblyImpure.methodCall, possiblyImpure.methodCall */
throw new UnableToBuildUuidException($e->getMessage(), (int) $e->getCode(), $e);
}
}
/**
* Proxy method to allow injecting a mock for testing
*
* @pure
*/
protected function buildFields(string $bytes): Fields
{
/** @phpstan-ignore possiblyImpure.new */
return new Fields($bytes);
}
}

View File

@ -73,6 +73,9 @@ final class Fields implements FieldsInterface
}
}
/**
* @pure
*/
public function getBytes(): string
{
return $this->bytes;

View File

@ -114,6 +114,8 @@ interface FieldsInterface extends BaseFieldsInterface
* meaningful for this variant.
*
* @link https://www.rfc-editor.org/rfc/rfc9562#section-4.2 RFC 9562, 4.2. Version Field
*
* @pure
*/
public function getVersion(): ?int;
@ -121,6 +123,8 @@ interface FieldsInterface extends BaseFieldsInterface
* Returns true if these fields represent a nil UUID
*
* The nil UUID is a special form of UUID that is specified to have all 128 bits set to zero.
*
* @pure
*/
public function isNil(): bool;
}

View File

@ -23,11 +23,15 @@ trait MaxTrait
{
/**
* Returns the bytes that comprise the fields
*
* @pure
*/
abstract public function getBytes(): string;
/**
* Returns true if the byte string represents a max UUID
*
* @pure
*/
public function isMax(): bool
{

View File

@ -23,6 +23,8 @@ trait NilTrait
{
/**
* Returns the bytes that comprise the fields
*
* @pure
*/
abstract public function getBytes(): string;

View File

@ -60,6 +60,8 @@ class UuidBuilder implements UuidBuilderInterface
* @param string $bytes The byte string from which to construct a UUID
*
* @return Rfc4122UuidInterface UuidBuilder returns instances of Rfc4122UuidInterface
*
* @pure
*/
public function build(CodecInterface $codec, string $bytes): UuidInterface
{
@ -68,39 +70,53 @@ class UuidBuilder implements UuidBuilderInterface
$fields = $this->buildFields($bytes);
if ($fields->isNil()) {
/** @phpstan-ignore possiblyImpure.new */
return new NilUuid($fields, $this->numberConverter, $codec, $this->timeConverter);
}
if ($fields->isMax()) {
/** @phpstan-ignore possiblyImpure.new */
return new MaxUuid($fields, $this->numberConverter, $codec, $this->timeConverter);
}
return match ($fields->getVersion()) {
/** @phpstan-ignore possiblyImpure.new */
Uuid::UUID_TYPE_TIME => new UuidV1($fields, $this->numberConverter, $codec, $this->timeConverter),
Uuid::UUID_TYPE_DCE_SECURITY
/** @phpstan-ignore possiblyImpure.new */
=> new UuidV2($fields, $this->numberConverter, $codec, $this->timeConverter),
/** @phpstan-ignore possiblyImpure.new */
Uuid::UUID_TYPE_HASH_MD5 => new UuidV3($fields, $this->numberConverter, $codec, $this->timeConverter),
/** @phpstan-ignore possiblyImpure.new */
Uuid::UUID_TYPE_RANDOM => new UuidV4($fields, $this->numberConverter, $codec, $this->timeConverter),
/** @phpstan-ignore possiblyImpure.new */
Uuid::UUID_TYPE_HASH_SHA1 => new UuidV5($fields, $this->numberConverter, $codec, $this->timeConverter),
Uuid::UUID_TYPE_REORDERED_TIME
/** @phpstan-ignore possiblyImpure.new */
=> new UuidV6($fields, $this->numberConverter, $codec, $this->timeConverter),
Uuid::UUID_TYPE_UNIX_TIME
/** @phpstan-ignore possiblyImpure.new */
=> new UuidV7($fields, $this->numberConverter, $codec, $this->unixTimeConverter),
/** @phpstan-ignore possiblyImpure.new */
Uuid::UUID_TYPE_CUSTOM => new UuidV8($fields, $this->numberConverter, $codec, $this->timeConverter),
default => throw new UnsupportedOperationException(
'The UUID version in the given fields is not supported by this UUID builder',
),
};
} catch (Throwable $e) {
/** @phpstan-ignore possiblyImpure.methodCall, possiblyImpure.methodCall */
throw new UnableToBuildUuidException($e->getMessage(), (int) $e->getCode(), $e);
}
}
/**
* Proxy method to allow injecting a mock for testing
*
* @pure
*/
protected function buildFields(string $bytes): FieldsInterface
{
/** @phpstan-ignore possiblyImpure.new */
return new Fields($bytes);
}
}

View File

@ -40,8 +40,10 @@ final class Validator implements ValidatorInterface
public function validate(string $uuid): bool
{
/** @phpstan-ignore possiblyImpure.functionCall */
$uuid = strtolower(str_replace(['urn:', 'uuid:', 'URN:', 'UUID:', '{', '}'], '', $uuid));
/** @phpstan-ignore possiblyImpure.functionCall */
return $uuid === Uuid::NIL || $uuid === Uuid::MAX || preg_match('/' . self::VALID_PATTERN . '/Dms', $uuid);
}
}

View File

@ -41,6 +41,8 @@ trait VersionTrait
* meaningful for this variant.
*
* @link https://www.rfc-editor.org/rfc/rfc9562#section-4.2 RFC 9562, 4.2. Version Field
*
* @pure
*/
abstract public function getVersion(): ?int;

View File

@ -46,6 +46,8 @@ final class Hexadecimal implements TypeInterface
/**
* @return non-empty-string
*
* @pure
*/
public function toString(): string
{

View File

@ -58,6 +58,8 @@ final class Integer implements NumberInterface
/**
* @return numeric-string
*
* @pure
*/
public function toString(): string
{

View File

@ -43,11 +43,17 @@ final class Time implements TypeInterface
$this->microseconds = new IntegerObject($microseconds);
}
/**
* @pure
*/
public function getSeconds(): IntegerObject
{
return $this->seconds;
}
/**
* @pure
*/
public function getMicroseconds(): IntegerObject
{
return $this->microseconds;

View File

@ -24,7 +24,13 @@ use Serializable;
*/
interface TypeInterface extends JsonSerializable, Serializable
{
/**
* @pure
*/
public function toString(): string;
/**
* @pure
*/
public function __toString(): string;
}

View File

@ -448,9 +448,12 @@ class Uuid implements UuidInterface
* @return UuidInterface A UuidInterface instance created from a binary string representation
*
* @throws InvalidArgumentException
*
* @pure
*/
public static function fromBytes(string $bytes): UuidInterface
{
/** @phpstan-ignore impure.staticPropertyAccess */
if (!self::$factoryReplaced && strlen($bytes) === 16) {
$base16Uuid = bin2hex($bytes);
@ -468,6 +471,7 @@ class Uuid implements UuidInterface
);
}
/** @phpstan-ignore possiblyImpure.methodCall */
return self::getFactory()->fromBytes($bytes);
}
@ -479,16 +483,22 @@ class Uuid implements UuidInterface
* @return UuidInterface A UuidInterface instance created from a hexadecimal string representation
*
* @throws InvalidArgumentException
*
* @pure
*/
public static function fromString(string $uuid): UuidInterface
{
$uuid = strtolower($uuid);
/** @phpstan-ignore impure.staticPropertyAccess, possiblyImpure.functionCall */
if (!self::$factoryReplaced && preg_match(LazyUuidFromString::VALID_REGEX, $uuid) === 1) {
/** @phpstan-ignore possiblyImpure.functionCall */
assert($uuid !== '');
/** @phpstan-ignore possiblyImpure.new */
return new LazyUuidFromString($uuid);
}
/** @phpstan-ignore possiblyImpure.methodCall */
return self::getFactory()->fromString($uuid);
}
@ -518,13 +528,18 @@ class Uuid implements UuidInterface
* @return UuidInterface A UuidInterface instance created from the Hexadecimal object representing a hexadecimal number
*
* @throws InvalidArgumentException
*
* @pure
*/
public static function fromHexadecimal(Hexadecimal $hex): UuidInterface
{
/** @phpstan-ignore possiblyImpure.methodCall */
$factory = self::getFactory();
if (method_exists($factory, 'fromHexadecimal')) {
/** @phpstan-ignore possiblyImpure.methodCall */
$uuid = $factory->fromHexadecimal($hex);
/** @phpstan-ignore possiblyImpure.functionCall */
assert($uuid instanceof UuidInterface);
return $uuid;
@ -541,9 +556,12 @@ class Uuid implements UuidInterface
* @return UuidInterface A UuidInterface instance created from the string representation of a 128-bit integer
*
* @throws InvalidArgumentException
*
* @pure
*/
public static function fromInteger(string $integer): UuidInterface
{
/** @phpstan-ignore possiblyImpure.methodCall */
return self::getFactory()->fromInteger($integer);
}
@ -555,9 +573,12 @@ class Uuid implements UuidInterface
* @return bool True if the string is a valid UUID, false otherwise
*
* @phpstan-assert-if-true =non-empty-string $uuid
*
* @pure
*/
public static function isValid(string $uuid): bool
{
/** @phpstan-ignore possiblyImpure.methodCall, possiblyImpure.methodCall */
return self::getFactory()->getValidator()->validate($uuid);
}
@ -606,9 +627,12 @@ class Uuid implements UuidInterface
* @param string $name The name to use for creating a UUID
*
* @return UuidInterface A UuidInterface instance that represents a version 3 UUID
*
* @pure
*/
public static function uuid3($ns, string $name): UuidInterface
{
/** @phpstan-ignore possiblyImpure.methodCall */
return self::getFactory()->uuid3($ns, $name);
}
@ -629,9 +653,12 @@ class Uuid implements UuidInterface
* @param string $name The name to use for creating a UUID
*
* @return UuidInterface A UuidInterface instance that represents a version 5 UUID
*
* @pure
*/
public static function uuid5($ns, string $name): UuidInterface
{
/** @phpstan-ignore possiblyImpure.methodCall */
return self::getFactory()->uuid5($ns, $name);
}
@ -682,13 +709,19 @@ class Uuid implements UuidInterface
* and 65 will be replaced with the UUID variant. You MUST NOT rely on these bits for your application needs.
*
* @return UuidInterface A UuidInterface instance that represents a version 8 UUID
*
* @pure
*/
public static function uuid8(string $bytes): UuidInterface
{
/** @phpstan-ignore possiblyImpure.methodCall */
$factory = self::getFactory();
if (method_exists($factory, 'uuid8')) {
/** @var UuidInterface */
/**
* @var UuidInterface
* @phpstan-ignore possiblyImpure.methodCall
*/
return $factory->uuid8($bytes);
}

View File

@ -252,11 +252,17 @@ class UuidFactory implements UuidFactoryInterface
$this->validator = $validator;
}
/**
* @pure
*/
public function fromBytes(string $bytes): UuidInterface
{
return $this->codec->decodeBytes($bytes);
}
/**
* @pure
*/
public function fromString(string $uuid): UuidInterface
{
$uuid = strtolower($uuid);
@ -264,6 +270,9 @@ class UuidFactory implements UuidFactoryInterface
return $this->codec->decode($uuid);
}
/**
* @pure
*/
public function fromInteger(string $integer): UuidInterface
{
$hex = $this->numberConverter->toHex($integer);
@ -284,6 +293,9 @@ class UuidFactory implements UuidFactoryInterface
return $this->uuidFromBytesAndVersion($bytes, Uuid::UUID_TYPE_TIME);
}
/**
* @pure
*/
public function fromHexadecimal(Hexadecimal $hex): UuidInterface
{
return $this->codec->decode($hex->__toString());
@ -312,6 +324,7 @@ class UuidFactory implements UuidFactoryInterface
/**
* @inheritDoc
* @pure
*/
public function uuid3($ns, string $name): UuidInterface
{
@ -327,6 +340,7 @@ class UuidFactory implements UuidFactoryInterface
/**
* @inheritDoc
* @pure
*/
public function uuid5($ns, string $name): UuidInterface
{
@ -377,9 +391,12 @@ class UuidFactory implements UuidFactoryInterface
* and 65 will be replaced with the UUID variant. You MUST NOT rely on these bits for your application needs.
*
* @return UuidInterface A UuidInterface instance that represents a version 8 UUID
*
* @pure
*/
public function uuid8(string $bytes): UuidInterface
{
/** @phpstan-ignore possiblyImpure.methodCall */
return $this->uuidFromBytesAndVersion($bytes, Uuid::UUID_TYPE_CUSTOM);
}
@ -391,6 +408,8 @@ class UuidFactory implements UuidFactoryInterface
* @param string $bytes The byte string from which to construct a UUID
*
* @return UuidInterface An instance of UuidInterface, created from the provided bytes
*
* @pure
*/
public function uuid(string $bytes): UuidInterface
{
@ -406,6 +425,8 @@ class UuidFactory implements UuidFactoryInterface
* @param string $hashAlgorithm The hashing algorithm to use when hashing together the namespace and name
*
* @return UuidInterface An instance of UuidInterface, created by hashing together the provided namespace and name
*
* @pure
*/
private function uuidFromNsAndName(
UuidInterface | string $ns,
@ -419,6 +440,7 @@ class UuidFactory implements UuidFactoryInterface
$bytes = $this->nameGenerator->generate($ns, $name, $hashAlgorithm);
/** @phpstan-ignore possiblyImpure.methodCall */
return $this->uuidFromBytesAndVersion(substr($bytes, 0, 16), $version);
}

View File

@ -30,6 +30,8 @@ interface UuidFactoryInterface
* @param string $bytes A binary string
*
* @return UuidInterface A UuidInterface instance created from a binary string representation
*
* @pure
*/
public function fromBytes(string $bytes): UuidInterface;
@ -55,6 +57,8 @@ interface UuidFactoryInterface
* @param string $integer String representation of 128-bit integer
*
* @return UuidInterface A UuidInterface instance created from the string representation of a 128-bit integer
*
* @pure
*/
public function fromInteger(string $integer): UuidInterface;
@ -64,6 +68,8 @@ interface UuidFactoryInterface
* @param string $uuid A hexadecimal string
*
* @return UuidInterface A UuidInterface instance created from a hexadecimal string representation
*
* @pure
*/
public function fromString(string $uuid): UuidInterface;
@ -112,6 +118,8 @@ interface UuidFactoryInterface
* @param string $name The name to use for creating a UUID
*
* @return UuidInterface A UuidInterface instance that represents a version 3 UUID
*
* @pure
*/
public function uuid3($ns, string $name): UuidInterface;
@ -129,6 +137,8 @@ interface UuidFactoryInterface
* @param string $name The name to use for creating a UUID
*
* @return UuidInterface A UuidInterface instance that represents a version 5 UUID
*
* @pure
*/
public function uuid5($ns, string $name): UuidInterface;

View File

@ -60,6 +60,8 @@ interface UuidInterface extends
* Returns the binary string representation of the UUID
*
* @return non-empty-string
*
* @pure
*/
public function getBytes(): string;
@ -92,6 +94,8 @@ interface UuidInterface extends
* Returns the string standard representation of the UUID
*
* @return non-empty-string
*
* @pure
*/
public function toString(): string;
@ -99,6 +103,8 @@ interface UuidInterface extends
* Casts the UUID to the string standard representation
*
* @return non-empty-string
*
* @pure
*/
public function __toString(): string;
}

View File

@ -41,8 +41,10 @@ final class GenericValidator implements ValidatorInterface
public function validate(string $uuid): bool
{
/** @phpstan-ignore possiblyImpure.functionCall */
$uuid = str_replace(['urn:', 'uuid:', 'URN:', 'UUID:', '{', '}'], '', $uuid);
/** @phpstan-ignore possiblyImpure.functionCall */
return $uuid === Uuid::NIL || preg_match('/' . self::VALID_PATTERN . '/Dms', $uuid);
}
}

View File

@ -34,6 +34,8 @@ interface ValidatorInterface
* @param string $uuid The string to validate as a UUID
*
* @return bool True if the string is a valid UUID, false otherwise
*
* @pure
*/
public function validate(string $uuid): bool;
}

View File

@ -62,6 +62,8 @@ function v2(
* @param UuidInterface | string $ns The namespace (must be a valid UUID)
*
* @return non-empty-string Version 3 UUID as a string
*
* @pure
*/
function v3($ns, string $name): string
{
@ -84,6 +86,8 @@ function v4(): string
* @param UuidInterface | string $ns The namespace (must be a valid UUID)
*
* @return non-empty-string Version 5 UUID as a string
*
* @pure
*/
function v5($ns, string $name): string
{
@ -128,6 +132,8 @@ function v7(?DateTimeInterface $dateTime = null): string
* 65 will be replaced with the UUID variant. You MUST NOT rely on these bits for your application needs.
*
* @return non-empty-string Version 8 UUID as a string
*
* @pure
*/
function v8(string $bytes): string
{