From 2201470dc84ac68b6ec90e1b2105658ab170b5cc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 21 Aug 2023 14:50:19 +0200 Subject: [PATCH] Update composer dependencies --- .../files/lib/system/api/composer.json | 4 +- .../files/lib/system/api/composer.lock | 26 +++++----- .../system/api/composer/autoload_classmap.php | 1 + .../system/api/composer/autoload_static.php | 1 + .../lib/system/api/composer/installed.json | 28 +++++----- .../lib/system/api/composer/installed.php | 20 ++++---- .../lib/system/api/cuyz/valinor/composer.json | 8 +-- .../Extension/TreeMapperPHPStanExtension.php | 4 +- .../Cache/Compiled/CompiledPhpFileCache.php | 7 ++- .../valinor/src/Cache/FileWatchingCache.php | 3 +- .../Warmup/RecursiveCacheWarmupService.php | 3 +- .../src/Definition/ClassDefinition.php | 3 +- .../src/Definition/FunctionDefinition.php | 3 +- .../src/Definition/FunctionsContainer.php | 3 +- .../src/Definition/MethodDefinition.php | 3 +- .../src/Definition/NativeAttributes.php | 18 ++++--- .../src/Definition/ParameterDefinition.php | 3 +- .../src/Definition/PropertyDefinition.php | 3 +- .../Cache/CacheClassDefinitionRepository.php | 3 +- .../CacheFunctionDefinitionRepository.php | 3 +- .../Cache/Compiler/AttributesCompiler.php | 36 +++++-------- .../Compiler/ParameterDefinitionCompiler.php | 11 ++-- .../Compiler/PropertyDefinitionCompiler.php | 3 +- .../Cache/Compiler/TypeCompiler.php | 2 +- .../ReflectionParameterDefinitionBuilder.php | 4 +- .../ReflectionPropertyDefinitionBuilder.php | 4 +- .../Reflection/ReflectionTypeResolver.php | 3 +- .../cuyz/valinor/src/Library/Container.php | 2 +- .../api/cuyz/valinor/src/Library/Settings.php | 6 +++ .../Object/DateTimeFormatConstructor.php | 2 +- .../src/Mapper/Object/DynamicConstructor.php | 4 +- .../InvalidConstructorReturnType.php | 6 +-- .../Factory/CacheObjectBuilderFactory.php | 3 +- .../Factory/CollisionObjectBuilderFactory.php | 4 +- .../ConstructorObjectBuilderFactory.php | 3 +- .../Factory/DateTimeObjectBuilderFactory.php | 25 ++++----- .../StrictTypesObjectBuilderFactory.php | 4 +- .../src/Mapper/Object/MethodObjectBuilder.php | 3 +- .../Object/NativeConstructorObjectBuilder.php | 4 +- .../Mapper/Object/ReflectionObjectBuilder.php | 4 +- .../Mapper/Source/Exception/InvalidJson.php | 6 ++- .../valinor/src/Mapper/Source/JsonSource.php | 11 ++-- .../cuyz/valinor/src/Mapper/Source/Source.php | 3 +- .../Mapper/Tree/Builder/ArrayNodeBuilder.php | 4 +- .../Mapper/Tree/Builder/CasterNodeBuilder.php | 3 +- .../Tree/Builder/CasterProxyNodeBuilder.php | 4 +- .../Tree/Builder/InterfaceNodeBuilder.php | 3 +- .../Tree/Builder/IterableNodeBuilder.php | 4 +- .../Mapper/Tree/Builder/ListNodeBuilder.php | 4 +- .../Tree/Builder/NativeClassNodeBuilder.php | 3 +- .../Mapper/Tree/Builder/ObjectNodeBuilder.php | 4 +- .../Mapper/Tree/Builder/RootNodeBuilder.php | 4 +- .../Mapper/Tree/Builder/ScalarNodeBuilder.php | 4 +- .../Tree/Builder/ShapedArrayNodeBuilder.php | 4 +- .../Mapper/Tree/Builder/StrictNodeBuilder.php | 3 +- .../Mapper/Tree/Builder/UnionNodeBuilder.php | 3 +- .../Tree/Builder/ValueAlteringNodeBuilder.php | 3 +- .../src/Mapper/Tree/Message/ErrorMessage.php | 4 +- .../Formatter/LocaleMessageFormatter.php | 4 +- .../Message/Formatter/MessageMapFormatter.php | 3 +- .../Mapper/Tree/Message/MessageBuilder.php | 12 ++--- .../valinor/src/Mapper/TypeTreeMapper.php | 3 +- .../api/cuyz/valinor/src/MapperBuilder.php | 20 +++++++- .../api/cuyz/valinor/src/Type/ClassType.php | 4 +- .../valinor/src/Type/Parser/CachedParser.php | 4 +- .../src/Type/Parser/Exception/InvalidType.php | 4 +- .../Exception/Template/InvalidTemplate.php | 4 +- .../Factory/LexingTypeParserFactory.php | 4 +- .../Specifications/AliasSpecification.php | 3 +- .../ClassContextSpecification.php | 3 +- .../TypeAliasAssignerSpecification.php | 3 +- .../Type/Parser/Lexer/AdvancedClassLexer.php | 3 +- .../src/Type/Parser/Lexer/AliasLexer.php | 3 +- .../Lexer/Token/AdvancedClassNameToken.php | 3 +- .../Type/Parser/Lexer/Token/ArrayToken.php | 3 +- .../Type/Parser/Lexer/Token/CaseFinder.php | 3 +- .../Type/Parser/Lexer/Token/EnumNameToken.php | 3 +- .../Parser/Lexer/Token/FloatValueToken.php | 4 +- .../Parser/Lexer/Token/IntegerValueToken.php | 4 +- .../src/Type/Parser/Lexer/Token/ListToken.php | 3 +- .../Type/Parser/Lexer/Token/NativeToken.php | 3 +- .../Type/Parser/Lexer/Token/QuoteToken.php | 4 +- .../src/Type/Parser/Lexer/Token/TypeToken.php | 3 +- .../Parser/Lexer/Token/UnknownSymbolToken.php | 4 +- .../src/Type/Parser/Lexer/TypeAliasLexer.php | 3 +- .../valinor/src/Type/Parser/LexingParser.php | 4 +- .../src/Type/Types/BooleanValueType.php | 4 +- .../valinor/src/Type/Types/FloatValueType.php | 4 +- .../src/Type/Types/IntegerValueType.php | 4 +- .../valinor/src/Type/Types/InterfaceType.php | 3 +- .../src/Type/Types/ShapedArrayElement.php | 3 +- .../src/Type/Types/StringValueType.php | 4 +- .../src/Type/Types/UnresolvableType.php | 36 ++++++------- .../src/Utility/String/StringCutter.php | 51 +++++++++++++++++++ .../src/Utility/String/StringFormatter.php | 2 +- .../Utility/String/StringFormatterError.php | 7 ++- .../cuyz/valinor/src/Utility/ValueDumper.php | 5 +- .../cron-expression/CHANGELOG.md | 12 +++++ .../dragonmantank/cron-expression/README.md | 2 +- .../cron-expression/phpstan.neon | 15 ------ .../src/Cron/CronExpression.php | 14 ++++- .../cron-expression/src/Cron/MinutesField.php | 1 + 102 files changed, 307 insertions(+), 335 deletions(-) create mode 100644 wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Utility/String/StringCutter.php delete mode 100644 wcfsetup/install/files/lib/system/api/dragonmantank/cron-expression/phpstan.neon diff --git a/wcfsetup/install/files/lib/system/api/composer.json b/wcfsetup/install/files/lib/system/api/composer.json index 0554681b25..c3c3af3549 100644 --- a/wcfsetup/install/files/lib/system/api/composer.json +++ b/wcfsetup/install/files/lib/system/api/composer.json @@ -10,8 +10,8 @@ } }, "require": { - "cuyz/valinor": "^1.4.0", - "dragonmantank/cron-expression": "^3.3.2", + "cuyz/valinor": "^1.5.0", + "dragonmantank/cron-expression": "^3.3.3", "erusev/parsedown": "^1.7.4", "ezyang/htmlpurifier": "^4.16", "guzzlehttp/guzzle": "^7.7.0", diff --git a/wcfsetup/install/files/lib/system/api/composer.lock b/wcfsetup/install/files/lib/system/api/composer.lock index 3a8385d04b..c75674ce37 100644 --- a/wcfsetup/install/files/lib/system/api/composer.lock +++ b/wcfsetup/install/files/lib/system/api/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d94553c231572f020140e0c1ed535635", + "content-hash": "19268d8275d6b8c74c4fc8303d9cb0f2", "packages": [ { "name": "cuyz/valinor", - "version": "1.4.0", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/CuyZ/Valinor.git", - "reference": "229098184cf5877ec01305461cdcb8a73379bf5b" + "reference": "668cd3f0f95c57d75981a31d63b5b1422606bc7e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/CuyZ/Valinor/zipball/229098184cf5877ec01305461cdcb8a73379bf5b", - "reference": "229098184cf5877ec01305461cdcb8a73379bf5b", + "url": "https://api.github.com/repos/CuyZ/Valinor/zipball/668cd3f0f95c57d75981a31d63b5b1422606bc7e", + "reference": "668cd3f0f95c57d75981a31d63b5b1422606bc7e", "shasum": "" }, "require": { @@ -69,7 +69,7 @@ ], "support": { "issues": "https://github.com/CuyZ/Valinor/issues", - "source": "https://github.com/CuyZ/Valinor/tree/1.4.0" + "source": "https://github.com/CuyZ/Valinor/tree/1.5.0" }, "funding": [ { @@ -77,20 +77,20 @@ "type": "github" } ], - "time": "2023-04-17T11:25:01+00:00" + "time": "2023-08-07T18:29:08+00:00" }, { "name": "dragonmantank/cron-expression", - "version": "v3.3.2", + "version": "v3.3.3", "source": { "type": "git", "url": "https://github.com/dragonmantank/cron-expression.git", - "reference": "782ca5968ab8b954773518e9e49a6f892a34b2a8" + "reference": "adfb1f505deb6384dc8b39804c5065dd3c8c8c0a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/782ca5968ab8b954773518e9e49a6f892a34b2a8", - "reference": "782ca5968ab8b954773518e9e49a6f892a34b2a8", + "url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/adfb1f505deb6384dc8b39804c5065dd3c8c8c0a", + "reference": "adfb1f505deb6384dc8b39804c5065dd3c8c8c0a", "shasum": "" }, "require": { @@ -130,7 +130,7 @@ ], "support": { "issues": "https://github.com/dragonmantank/cron-expression/issues", - "source": "https://github.com/dragonmantank/cron-expression/tree/v3.3.2" + "source": "https://github.com/dragonmantank/cron-expression/tree/v3.3.3" }, "funding": [ { @@ -138,7 +138,7 @@ "type": "github" } ], - "time": "2022-09-10T18:51:20+00:00" + "time": "2023-08-10T19:36:49+00:00" }, { "name": "erusev/parsedown", diff --git a/wcfsetup/install/files/lib/system/api/composer/autoload_classmap.php b/wcfsetup/install/files/lib/system/api/composer/autoload_classmap.php index 341fb46d74..dee9c56dcb 100644 --- a/wcfsetup/install/files/lib/system/api/composer/autoload_classmap.php +++ b/wcfsetup/install/files/lib/system/api/composer/autoload_classmap.php @@ -339,6 +339,7 @@ return array( 'CuyZ\\Valinor\\Utility\\Reflection\\PhpParser' => $vendorDir . '/cuyz/valinor/src/Utility/Reflection/PhpParser.php', 'CuyZ\\Valinor\\Utility\\Reflection\\Reflection' => $vendorDir . '/cuyz/valinor/src/Utility/Reflection/Reflection.php', 'CuyZ\\Valinor\\Utility\\Reflection\\TokenParser' => $vendorDir . '/cuyz/valinor/src/Utility/Reflection/TokenParser.php', + 'CuyZ\\Valinor\\Utility\\String\\StringCutter' => $vendorDir . '/cuyz/valinor/src/Utility/String/StringCutter.php', 'CuyZ\\Valinor\\Utility\\String\\StringFormatter' => $vendorDir . '/cuyz/valinor/src/Utility/String/StringFormatter.php', 'CuyZ\\Valinor\\Utility\\String\\StringFormatterError' => $vendorDir . '/cuyz/valinor/src/Utility/String/StringFormatterError.php', 'CuyZ\\Valinor\\Utility\\TypeHelper' => $vendorDir . '/cuyz/valinor/src/Utility/TypeHelper.php', diff --git a/wcfsetup/install/files/lib/system/api/composer/autoload_static.php b/wcfsetup/install/files/lib/system/api/composer/autoload_static.php index 4bad81d871..e3dd6453c9 100644 --- a/wcfsetup/install/files/lib/system/api/composer/autoload_static.php +++ b/wcfsetup/install/files/lib/system/api/composer/autoload_static.php @@ -521,6 +521,7 @@ class ComposerStaticInita1f5f7c74275d47a45049a2936db1d0d 'CuyZ\\Valinor\\Utility\\Reflection\\PhpParser' => __DIR__ . '/..' . '/cuyz/valinor/src/Utility/Reflection/PhpParser.php', 'CuyZ\\Valinor\\Utility\\Reflection\\Reflection' => __DIR__ . '/..' . '/cuyz/valinor/src/Utility/Reflection/Reflection.php', 'CuyZ\\Valinor\\Utility\\Reflection\\TokenParser' => __DIR__ . '/..' . '/cuyz/valinor/src/Utility/Reflection/TokenParser.php', + 'CuyZ\\Valinor\\Utility\\String\\StringCutter' => __DIR__ . '/..' . '/cuyz/valinor/src/Utility/String/StringCutter.php', 'CuyZ\\Valinor\\Utility\\String\\StringFormatter' => __DIR__ . '/..' . '/cuyz/valinor/src/Utility/String/StringFormatter.php', 'CuyZ\\Valinor\\Utility\\String\\StringFormatterError' => __DIR__ . '/..' . '/cuyz/valinor/src/Utility/String/StringFormatterError.php', 'CuyZ\\Valinor\\Utility\\TypeHelper' => __DIR__ . '/..' . '/cuyz/valinor/src/Utility/TypeHelper.php', diff --git a/wcfsetup/install/files/lib/system/api/composer/installed.json b/wcfsetup/install/files/lib/system/api/composer/installed.json index 989b93522e..7c4dc6ad7f 100644 --- a/wcfsetup/install/files/lib/system/api/composer/installed.json +++ b/wcfsetup/install/files/lib/system/api/composer/installed.json @@ -2,17 +2,17 @@ "packages": [ { "name": "cuyz/valinor", - "version": "1.4.0", - "version_normalized": "1.4.0.0", + "version": "1.5.0", + "version_normalized": "1.5.0.0", "source": { "type": "git", "url": "https://github.com/CuyZ/Valinor.git", - "reference": "229098184cf5877ec01305461cdcb8a73379bf5b" + "reference": "668cd3f0f95c57d75981a31d63b5b1422606bc7e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/CuyZ/Valinor/zipball/229098184cf5877ec01305461cdcb8a73379bf5b", - "reference": "229098184cf5877ec01305461cdcb8a73379bf5b", + "url": "https://api.github.com/repos/CuyZ/Valinor/zipball/668cd3f0f95c57d75981a31d63b5b1422606bc7e", + "reference": "668cd3f0f95c57d75981a31d63b5b1422606bc7e", "shasum": "" }, "require": { @@ -32,7 +32,7 @@ "rector/rector": "~0.15.0", "vimeo/psalm": "^5.0" }, - "time": "2023-04-17T11:25:01+00:00", + "time": "2023-08-07T18:29:08+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -66,7 +66,7 @@ ], "support": { "issues": "https://github.com/CuyZ/Valinor/issues", - "source": "https://github.com/CuyZ/Valinor/tree/1.4.0" + "source": "https://github.com/CuyZ/Valinor/tree/1.5.0" }, "funding": [ { @@ -78,17 +78,17 @@ }, { "name": "dragonmantank/cron-expression", - "version": "v3.3.2", - "version_normalized": "3.3.2.0", + "version": "v3.3.3", + "version_normalized": "3.3.3.0", "source": { "type": "git", "url": "https://github.com/dragonmantank/cron-expression.git", - "reference": "782ca5968ab8b954773518e9e49a6f892a34b2a8" + "reference": "adfb1f505deb6384dc8b39804c5065dd3c8c8c0a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/782ca5968ab8b954773518e9e49a6f892a34b2a8", - "reference": "782ca5968ab8b954773518e9e49a6f892a34b2a8", + "url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/adfb1f505deb6384dc8b39804c5065dd3c8c8c0a", + "reference": "adfb1f505deb6384dc8b39804c5065dd3c8c8c0a", "shasum": "" }, "require": { @@ -104,7 +104,7 @@ "phpstan/phpstan-webmozart-assert": "^1.0", "phpunit/phpunit": "^7.0|^8.0|^9.0" }, - "time": "2022-09-10T18:51:20+00:00", + "time": "2023-08-10T19:36:49+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -130,7 +130,7 @@ ], "support": { "issues": "https://github.com/dragonmantank/cron-expression/issues", - "source": "https://github.com/dragonmantank/cron-expression/tree/v3.3.2" + "source": "https://github.com/dragonmantank/cron-expression/tree/v3.3.3" }, "funding": [ { diff --git a/wcfsetup/install/files/lib/system/api/composer/installed.php b/wcfsetup/install/files/lib/system/api/composer/installed.php index ffe1d47fd3..8db1af4928 100644 --- a/wcfsetup/install/files/lib/system/api/composer/installed.php +++ b/wcfsetup/install/files/lib/system/api/composer/installed.php @@ -20,18 +20,18 @@ 'dev_requirement' => false, ), 'cuyz/valinor' => array( - 'pretty_version' => '1.4.0', - 'version' => '1.4.0.0', - 'reference' => '229098184cf5877ec01305461cdcb8a73379bf5b', + 'pretty_version' => '1.5.0', + 'version' => '1.5.0.0', + 'reference' => '668cd3f0f95c57d75981a31d63b5b1422606bc7e', 'type' => 'library', 'install_path' => __DIR__ . '/../cuyz/valinor', 'aliases' => array(), 'dev_requirement' => false, ), 'dragonmantank/cron-expression' => array( - 'pretty_version' => 'v3.3.2', - 'version' => '3.3.2.0', - 'reference' => '782ca5968ab8b954773518e9e49a6f892a34b2a8', + 'pretty_version' => 'v3.3.3', + 'version' => '3.3.3.0', + 'reference' => 'adfb1f505deb6384dc8b39804c5065dd3c8c8c0a', 'type' => 'library', 'install_path' => __DIR__ . '/../dragonmantank/cron-expression', 'aliases' => array(), @@ -187,8 +187,8 @@ 'psr/http-factory-implementation' => array( 'dev_requirement' => false, 'provided' => array( - 0 => '^1.1 || ^2.0', - 1 => '1.0', + 0 => '1.0', + 1 => '^1.1 || ^2.0', ), ), 'psr/http-message' => array( @@ -203,8 +203,8 @@ 'psr/http-message-implementation' => array( 'dev_requirement' => false, 'provided' => array( - 0 => '^1.1 || ^2.0', - 1 => '1.0', + 0 => '1.0', + 1 => '^1.1 || ^2.0', ), ), 'psr/http-server-handler' => array( diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/composer.json b/wcfsetup/install/files/lib/system/api/cuyz/valinor/composer.json index 6765e71f50..2e7a92015c 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/composer.json +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/composer.json @@ -51,13 +51,15 @@ "psalm --config=tests/StaticAnalysis/psalm-with-plugin.xml", "phpstan --configuration=tests/StaticAnalysis/phpstan-without-extension.neon.dist", "phpstan --configuration=tests/StaticAnalysis/phpstan-with-extension.neon.dist", - "@putenv PHP_CS_FIXER_IGNORE_ENV=1", "php-cs-fixer fix --dry-run", - "rector --dry-run" + "rector --dry-run", + "@check-todo" + ], + "check-todo": [ + "! git --no-pager grep --extended-regexp --ignore-case 'todo|fixme' -- ':!composer.json' ':!*/quality-assurance.yml'" ], "fix": [ "@putenv XDEBUG_MODE=off", - "@putenv PHP_CS_FIXER_IGNORE_ENV=1", "php-cs-fixer fix", "rector" ], diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/qa/PHPStan/Extension/TreeMapperPHPStanExtension.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/qa/PHPStan/Extension/TreeMapperPHPStanExtension.php index 18a2a49850..ac447d9db4 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/qa/PHPStan/Extension/TreeMapperPHPStanExtension.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/qa/PHPStan/Extension/TreeMapperPHPStanExtension.php @@ -20,9 +20,7 @@ use PHPStan\Type\UnionType; final class TreeMapperPHPStanExtension implements DynamicMethodReturnTypeExtension { - public function __construct(private TypeStringResolver $resolver) - { - } + public function __construct(private TypeStringResolver $resolver) {} public function getClass(): string { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Cache/Compiled/CompiledPhpFileCache.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Cache/Compiled/CompiledPhpFileCache.php index 97ffa69cb6..88cbe17963 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Cache/Compiled/CompiledPhpFileCache.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Cache/Compiled/CompiledPhpFileCache.php @@ -44,8 +44,7 @@ final class CompiledPhpFileCache implements CacheInterface public function __construct( private string $cacheDir, private CacheCompiler $compiler - ) { - } + ) {} public function has($key): bool { @@ -114,6 +113,10 @@ final class CompiledPhpFileCache implements CacheInterface public function clear(): bool { + if (! is_dir($this->cacheDir)) { + return true; + } + $success = true; /** @var FilesystemIterator $file */ diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Cache/FileWatchingCache.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Cache/FileWatchingCache.php index d9cf7b0767..770d38c689 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Cache/FileWatchingCache.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Cache/FileWatchingCache.php @@ -39,8 +39,7 @@ final class FileWatchingCache implements CacheInterface public function __construct( /** @var CacheInterface */ private CacheInterface $delegate - ) { - } + ) {} public function has($key): bool { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Cache/Warmup/RecursiveCacheWarmupService.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Cache/Warmup/RecursiveCacheWarmupService.php index 4d0af544f4..f22beca305 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Cache/Warmup/RecursiveCacheWarmupService.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Cache/Warmup/RecursiveCacheWarmupService.php @@ -28,8 +28,7 @@ final class RecursiveCacheWarmupService private ObjectImplementations $implementations, private ClassDefinitionRepository $classDefinitionRepository, private ObjectBuilderFactory $objectBuilderFactory - ) { - } + ) {} public function warmup(string ...$signatures): void { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/ClassDefinition.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/ClassDefinition.php index 1fac82a60f..74b11d49e7 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/ClassDefinition.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/ClassDefinition.php @@ -16,8 +16,7 @@ final class ClassDefinition private Methods $methods, private bool $isFinal, private bool $isAbstract, - ) { - } + ) {} /** * @return class-string diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/FunctionDefinition.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/FunctionDefinition.php index c8eb789065..77b6ddfb4a 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/FunctionDefinition.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/FunctionDefinition.php @@ -20,8 +20,7 @@ final class FunctionDefinition private bool $isClosure, private Parameters $parameters, private Type $returnType - ) { - } + ) {} public function name(): string { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/FunctionsContainer.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/FunctionsContainer.php index df7c0258af..d6269f5b16 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/FunctionsContainer.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/FunctionsContainer.php @@ -24,8 +24,7 @@ final class FunctionsContainer implements IteratorAggregate private FunctionDefinitionRepository $functionDefinitionRepository, /** @var array */ private array $callables - ) { - } + ) {} public function has(string|int $key): bool { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/MethodDefinition.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/MethodDefinition.php index 8d8910be5c..a04e8928d5 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/MethodDefinition.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/MethodDefinition.php @@ -16,8 +16,7 @@ final class MethodDefinition private bool $isStatic, private bool $isPublic, private Type $returnType - ) { - } + ) {} public function name(): string { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/NativeAttributes.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/NativeAttributes.php index c3ee736c17..f4a7b98022 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/NativeAttributes.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/NativeAttributes.php @@ -20,16 +20,14 @@ final class NativeAttributes implements Attributes { private AttributesContainer $delegate; - /** @var array> */ - private array $reflectionAttributes; + /** @var array> */ + private array $definition = []; /** * @param ReflectionClass|ReflectionProperty|ReflectionMethod|ReflectionFunction|ReflectionParameter $reflection */ public function __construct(ReflectionClass|ReflectionProperty|ReflectionMethod|ReflectionFunction|ReflectionParameter $reflection) { - $this->reflectionAttributes = $reflection->getAttributes(); - $attributes = array_filter( array_map( static function (ReflectionAttribute $attribute) { @@ -45,10 +43,14 @@ final class NativeAttributes implements Attributes return null; } }, - $this->reflectionAttributes, + $reflection->getAttributes(), ), ); + foreach ($reflection->getAttributes() as $attribute) { + $this->definition[$attribute->getName()] = $attribute->getArguments(); + } + $this->delegate = new AttributesContainer(...$attributes); } @@ -73,10 +75,10 @@ final class NativeAttributes implements Attributes } /** - * @return array> + * @return array> */ - public function reflectionAttributes(): array + public function definition(): array { - return $this->reflectionAttributes; + return $this->definition; } } diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/ParameterDefinition.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/ParameterDefinition.php index 16f2629332..6ea27a6c67 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/ParameterDefinition.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/ParameterDefinition.php @@ -17,8 +17,7 @@ final class ParameterDefinition private bool $isVariadic, private mixed $defaultValue, private Attributes $attributes - ) { - } + ) {} public function name(): string { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/PropertyDefinition.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/PropertyDefinition.php index c6e5a4b7b6..ac0aaaee16 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/PropertyDefinition.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/PropertyDefinition.php @@ -17,8 +17,7 @@ final class PropertyDefinition private mixed $defaultValue, private bool $isPublic, private Attributes $attributes - ) { - } + ) {} public function name(): string { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Cache/CacheClassDefinitionRepository.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Cache/CacheClassDefinitionRepository.php index 32d489a2d4..e1307d330d 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Cache/CacheClassDefinitionRepository.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Cache/CacheClassDefinitionRepository.php @@ -16,8 +16,7 @@ final class CacheClassDefinitionRepository implements ClassDefinitionRepository private ClassDefinitionRepository $delegate, /** @var CacheInterface */ private CacheInterface $cache - ) { - } + ) {} public function for(ClassType $type): ClassDefinition { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Cache/CacheFunctionDefinitionRepository.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Cache/CacheFunctionDefinitionRepository.php index 8fd31b2f35..65dec14647 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Cache/CacheFunctionDefinitionRepository.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Cache/CacheFunctionDefinitionRepository.php @@ -16,8 +16,7 @@ final class CacheFunctionDefinitionRepository implements FunctionDefinitionRepos private FunctionDefinitionRepository $delegate, /** @var CacheInterface */ private CacheInterface $cache - ) { - } + ) {} public function for(callable $function): FunctionDefinition { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Cache/Compiler/AttributesCompiler.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Cache/Compiler/AttributesCompiler.php index 401e10fc01..a872f9dd4a 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Cache/Compiler/AttributesCompiler.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Cache/Compiler/AttributesCompiler.php @@ -7,9 +7,7 @@ namespace CuyZ\Valinor\Definition\Repository\Cache\Compiler; use CuyZ\Valinor\Definition\Attributes; use CuyZ\Valinor\Definition\AttributesContainer; use CuyZ\Valinor\Definition\NativeAttributes; -use ReflectionAttribute; -use function array_map; use function count; use function implode; use function var_export; @@ -32,31 +30,25 @@ final class AttributesCompiler PHP; } - /** - * @param ReflectionAttribute $reflectionAttribute - */ - private function compileNativeAttribute(ReflectionAttribute $reflectionAttribute): string + private function compileNativeAttributes(NativeAttributes $attributes): string { - $name = $reflectionAttribute->getName(); - $arguments = $reflectionAttribute->getArguments(); - - /** @infection-ignore-all */ - if (count($arguments) > 0) { - $arguments = serialize($arguments); - $arguments = 'unserialize(' . var_export($arguments, true) . ')'; + $attributes = $attributes->definition(); - return "new $name(...$arguments)"; + if (count($attributes) === 0) { + return '[]'; } - return "new $name()"; - } + $attributesListCode = []; - private function compileNativeAttributes(NativeAttributes $attributes): string - { - $attributesListCode = array_map( - fn (ReflectionAttribute $attribute) => $this->compileNativeAttribute($attribute), - $attributes->reflectionAttributes() - ); + foreach ($attributes as $className => $arguments) { + if (count($arguments) === 0) { + $argumentsCode = ''; + } else { + $argumentsCode = '...unserialize(' . var_export(serialize($arguments), true) . ')'; + } + + $attributesListCode[] = "new $className($argumentsCode)"; + } return '...[' . implode(",\n", $attributesListCode) . ']'; } diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Cache/Compiler/ParameterDefinitionCompiler.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Cache/Compiler/ParameterDefinitionCompiler.php index d39d7f30a9..be0a590fdd 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Cache/Compiler/ParameterDefinitionCompiler.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Cache/Compiler/ParameterDefinitionCompiler.php @@ -6,16 +6,13 @@ namespace CuyZ\Valinor\Definition\Repository\Cache\Compiler; use CuyZ\Valinor\Definition\ParameterDefinition; -use function is_scalar; - /** @internal */ final class ParameterDefinitionCompiler { public function __construct( private TypeCompiler $typeCompiler, private AttributesCompiler $attributesCompiler - ) { - } + ) {} public function compile(ParameterDefinition $parameter): string { @@ -42,8 +39,8 @@ final class ParameterDefinitionCompiler { $defaultValue = $parameter->defaultValue(); - return is_scalar($defaultValue) - ? var_export($parameter->defaultValue(), true) - : 'unserialize(' . var_export(serialize($defaultValue), true) . ')'; + return is_object($defaultValue) + ? 'unserialize(' . var_export(serialize($defaultValue), true) . ')' + : var_export($defaultValue, true); } } diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Cache/Compiler/PropertyDefinitionCompiler.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Cache/Compiler/PropertyDefinitionCompiler.php index 7e4dd7d3b8..3a6fb9f087 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Cache/Compiler/PropertyDefinitionCompiler.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Cache/Compiler/PropertyDefinitionCompiler.php @@ -12,8 +12,7 @@ final class PropertyDefinitionCompiler public function __construct( private TypeCompiler $typeCompiler, private AttributesCompiler $attributesCompiler - ) { - } + ) {} public function compile(PropertyDefinition $property): string { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Cache/Compiler/TypeCompiler.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Cache/Compiler/TypeCompiler.php index c4f06c3591..a1a75a6df2 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Cache/Compiler/TypeCompiler.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Cache/Compiler/TypeCompiler.php @@ -163,7 +163,7 @@ final class TypeCompiler return "new $class($enumName, $pattern, [$cases])"; case $type instanceof UnresolvableType: $raw = var_export($type->toString(), true); - $message = var_export($type->getMessage(), true); + $message = var_export($type->message(), true); return "new $class($raw, $message)"; default: diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Reflection/ReflectionParameterDefinitionBuilder.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Reflection/ReflectionParameterDefinitionBuilder.php index 4b4122a25b..cc0d212072 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Reflection/ReflectionParameterDefinitionBuilder.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Reflection/ReflectionParameterDefinitionBuilder.php @@ -13,9 +13,7 @@ use ReflectionParameter; /** @internal */ final class ReflectionParameterDefinitionBuilder { - public function __construct(private AttributesRepository $attributesFactory) - { - } + public function __construct(private AttributesRepository $attributesFactory) {} public function for(ReflectionParameter $reflection, ReflectionTypeResolver $typeResolver): ParameterDefinition { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Reflection/ReflectionPropertyDefinitionBuilder.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Reflection/ReflectionPropertyDefinitionBuilder.php index e1909dc301..802f242c9d 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Reflection/ReflectionPropertyDefinitionBuilder.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Reflection/ReflectionPropertyDefinitionBuilder.php @@ -15,9 +15,7 @@ use ReflectionProperty; /** @internal */ final class ReflectionPropertyDefinitionBuilder { - public function __construct(private AttributesRepository $attributesRepository) - { - } + public function __construct(private AttributesRepository $attributesRepository) {} public function for(ReflectionProperty $reflection, ReflectionTypeResolver $typeResolver): PropertyDefinition { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Reflection/ReflectionTypeResolver.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Reflection/ReflectionTypeResolver.php index 3d3b94064a..ca6a4e1d1e 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Reflection/ReflectionTypeResolver.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Reflection/ReflectionTypeResolver.php @@ -21,8 +21,7 @@ final class ReflectionTypeResolver public function __construct( private TypeParser $nativeParser, private TypeParser $advancedParser - ) { - } + ) {} public function resolveType(\ReflectionProperty|\ReflectionParameter|\ReflectionFunctionAbstract $reflection): Type { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Library/Container.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Library/Container.php index dfa2f9c2f2..3fc9618f3c 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Library/Container.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Library/Container.php @@ -165,7 +165,7 @@ final class Container $factory = new ReflectionObjectBuilderFactory(); $factory = new ConstructorObjectBuilderFactory($factory, $settings->nativeConstructors, $constructors); $factory = new DateTimeZoneObjectBuilderFactory($factory, $this->get(FunctionDefinitionRepository::class)); - $factory = new DateTimeObjectBuilderFactory($factory, $this->get(FunctionDefinitionRepository::class)); + $factory = new DateTimeObjectBuilderFactory($factory, $settings->supportedDateFormats, $this->get(FunctionDefinitionRepository::class)); $factory = new CollisionObjectBuilderFactory($factory); if (! $settings->allowPermissiveTypes) { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Library/Settings.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Library/Settings.php index e18ebde2d3..143eac2f3f 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Library/Settings.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Library/Settings.php @@ -13,6 +13,9 @@ use Throwable; /** @internal */ final class Settings { + /** @var non-empty-array */ + public const DEFAULT_SUPPORTED_DATETIME_FORMATS = [DATE_ATOM, 'U']; + /** @var array */ public array $inferredMapping = []; @@ -28,6 +31,9 @@ final class Settings /** @var CacheInterface */ public CacheInterface $cache; + /** @var non-empty-array */ + public array $supportedDateFormats = self::DEFAULT_SUPPORTED_DATETIME_FORMATS; + public bool $enableFlexibleCasting = false; public bool $allowSuperfluousKeys = false; diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/DateTimeFormatConstructor.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/DateTimeFormatConstructor.php index 85bcb0579d..2e2c53f82c 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/DateTimeFormatConstructor.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/DateTimeFormatConstructor.php @@ -44,7 +44,7 @@ final class DateTimeFormatConstructor /** * @param class-string $className - * @param non-empty-string|positive-int $value + * @param non-empty-string|int $value */ #[DynamicConstructor] public function __invoke(string $className, string|int $value): DateTimeInterface diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/DynamicConstructor.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/DynamicConstructor.php index 6e5cc5f44a..b032c71a0e 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/DynamicConstructor.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/DynamicConstructor.php @@ -48,6 +48,4 @@ use CuyZ\Valinor\MapperBuilder; * @api */ #[Attribute(Attribute::TARGET_FUNCTION | Attribute::TARGET_METHOD)] -final class DynamicConstructor -{ -} +final class DynamicConstructor {} diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/Exception/InvalidConstructorReturnType.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/Exception/InvalidConstructorReturnType.php index 6498a1b091..136b66e29d 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/Exception/InvalidConstructorReturnType.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/Exception/InvalidConstructorReturnType.php @@ -16,13 +16,11 @@ final class InvalidConstructorReturnType extends LogicException $returnType = $function->returnType(); if ($returnType instanceof UnresolvableType) { - $message = $returnType->getMessage(); - $previous = $returnType; + $message = $returnType->message(); } else { $message = "Invalid return type `{$returnType->toString()}` for constructor `{$function->signature()}`, it must be a valid class name."; - $previous = null; } - parent::__construct($message, 1659446121, $previous); + parent::__construct($message, 1659446121); } } diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/Factory/CacheObjectBuilderFactory.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/Factory/CacheObjectBuilderFactory.php index 04144ce0e8..82f140072b 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/Factory/CacheObjectBuilderFactory.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/Factory/CacheObjectBuilderFactory.php @@ -15,8 +15,7 @@ final class CacheObjectBuilderFactory implements ObjectBuilderFactory private ObjectBuilderFactory $delegate, /** @var CacheInterface> */ private CacheInterface $cache - ) { - } + ) {} public function for(ClassDefinition $class): array { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/Factory/CollisionObjectBuilderFactory.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/Factory/CollisionObjectBuilderFactory.php index c65ecb664b..702a278b07 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/Factory/CollisionObjectBuilderFactory.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/Factory/CollisionObjectBuilderFactory.php @@ -15,9 +15,7 @@ use function next; /** @internal */ final class CollisionObjectBuilderFactory implements ObjectBuilderFactory { - public function __construct(private ObjectBuilderFactory $delegate) - { - } + public function __construct(private ObjectBuilderFactory $delegate) {} public function for(ClassDefinition $class): array { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/Factory/ConstructorObjectBuilderFactory.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/Factory/ConstructorObjectBuilderFactory.php index 2be3a24880..feff612f5c 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/Factory/ConstructorObjectBuilderFactory.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/Factory/ConstructorObjectBuilderFactory.php @@ -38,8 +38,7 @@ final class ConstructorObjectBuilderFactory implements ObjectBuilderFactory /** @var array */ private array $nativeConstructors, private FunctionsContainer $constructors - ) { - } + ) {} public function for(ClassDefinition $class): array { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/Factory/DateTimeObjectBuilderFactory.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/Factory/DateTimeObjectBuilderFactory.php index 282c4c7149..f1c80bc209 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/Factory/DateTimeObjectBuilderFactory.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/Factory/DateTimeObjectBuilderFactory.php @@ -7,6 +7,7 @@ namespace CuyZ\Valinor\Mapper\Object\Factory; use CuyZ\Valinor\Definition\ClassDefinition; use CuyZ\Valinor\Definition\FunctionObject; use CuyZ\Valinor\Definition\Repository\FunctionDefinitionRepository; +use CuyZ\Valinor\Library\Settings; use CuyZ\Valinor\Mapper\Object\DateTimeFormatConstructor; use CuyZ\Valinor\Mapper\Object\FunctionObjectBuilder; use CuyZ\Valinor\Mapper\Object\NativeConstructorObjectBuilder; @@ -23,9 +24,10 @@ final class DateTimeObjectBuilderFactory implements ObjectBuilderFactory { public function __construct( private ObjectBuilderFactory $delegate, + /** @var non-empty-array */ + private array $supportedDateFormats, private FunctionDefinitionRepository $functionDefinitionRepository - ) { - } + ) {} public function for(ClassDefinition $class): array { @@ -40,27 +42,18 @@ final class DateTimeObjectBuilderFactory implements ObjectBuilderFactory // Remove `DateTime` & `DateTimeImmutable` native constructors $builders = array_filter($builders, fn (ObjectBuilder $builder) => ! $builder instanceof NativeConstructorObjectBuilder); - $useDefaultBuilder = true; - - foreach ($builders as $builder) { - if (count($builder->describeArguments()) === 1) { - $useDefaultBuilder = false; - // @infection-ignore-all - break; - } - } + $buildersWithOneArgument = array_filter($builders, fn (ObjectBuilder $builder) => count($builder->describeArguments()) === 1); - if ($useDefaultBuilder) { - // @infection-ignore-all / Ignore memoization - $builders[] = $this->defaultBuilder($class->type()); + if (count($buildersWithOneArgument) === 0 || $this->supportedDateFormats !== Settings::DEFAULT_SUPPORTED_DATETIME_FORMATS) { + $builders[] = $this->internalDateTimeBuilder($class->type()); } return $builders; } - private function defaultBuilder(ClassType $type): FunctionObjectBuilder + private function internalDateTimeBuilder(ClassType $type): FunctionObjectBuilder { - $constructor = new DateTimeFormatConstructor(DATE_ATOM, 'U'); + $constructor = new DateTimeFormatConstructor(...$this->supportedDateFormats); $function = new FunctionObject($this->functionDefinitionRepository->for($constructor), $constructor); return new FunctionObjectBuilder($function, $type); diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/Factory/StrictTypesObjectBuilderFactory.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/Factory/StrictTypesObjectBuilderFactory.php index cfc8f0793d..372c20934a 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/Factory/StrictTypesObjectBuilderFactory.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/Factory/StrictTypesObjectBuilderFactory.php @@ -12,9 +12,7 @@ use CuyZ\Valinor\Utility\TypeHelper; /** @internal */ final class StrictTypesObjectBuilderFactory implements ObjectBuilderFactory { - public function __construct(private ObjectBuilderFactory $delegate) - { - } + public function __construct(private ObjectBuilderFactory $delegate) {} public function for(ClassDefinition $class): array { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/MethodObjectBuilder.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/MethodObjectBuilder.php index 3cca1c2eb6..25f25fd68e 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/MethodObjectBuilder.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/MethodObjectBuilder.php @@ -17,8 +17,7 @@ final class MethodObjectBuilder implements ObjectBuilder private string $className, private string $methodName, private Parameters $parameters - ) { - } + ) {} public function describeArguments(): Arguments { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/NativeConstructorObjectBuilder.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/NativeConstructorObjectBuilder.php index 30eb40aab8..ec7bedd304 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/NativeConstructorObjectBuilder.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/NativeConstructorObjectBuilder.php @@ -13,9 +13,7 @@ final class NativeConstructorObjectBuilder implements ObjectBuilder { private Arguments $arguments; - public function __construct(private ClassDefinition $class) - { - } + public function __construct(private ClassDefinition $class) {} public function describeArguments(): Arguments { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/ReflectionObjectBuilder.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/ReflectionObjectBuilder.php index 2bac6410db..54447c757d 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/ReflectionObjectBuilder.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Object/ReflectionObjectBuilder.php @@ -13,9 +13,7 @@ final class ReflectionObjectBuilder implements ObjectBuilder { private Arguments $arguments; - public function __construct(private ClassDefinition $class) - { - } + public function __construct(private ClassDefinition $class) {} public function describeArguments(): Arguments { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Source/Exception/InvalidJson.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Source/Exception/InvalidJson.php index ea6c31d5ce..6c9934fa9a 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Source/Exception/InvalidJson.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Source/Exception/InvalidJson.php @@ -4,16 +4,18 @@ declare(strict_types=1); namespace CuyZ\Valinor\Mapper\Source\Exception; +use JsonException; use RuntimeException; /** @internal */ final class InvalidJson extends RuntimeException implements InvalidSource { - public function __construct(private string $source) + public function __construct(private string $source, ?JsonException $previous = null) { parent::__construct( 'Invalid JSON source.', - 1566307185 + 1566307185, + $previous ); } diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Source/JsonSource.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Source/JsonSource.php index c85b9f66f4..e7465b5c5a 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Source/JsonSource.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Source/JsonSource.php @@ -9,11 +9,14 @@ use CuyZ\Valinor\Mapper\Source\Exception\InvalidSource; use CuyZ\Valinor\Mapper\Source\Exception\SourceNotIterable; use Iterator; use IteratorAggregate; +use JsonException; use Traversable; use function is_iterable; use function json_decode; +use const JSON_THROW_ON_ERROR; + /** * @api * @@ -29,10 +32,10 @@ final class JsonSource implements IteratorAggregate */ public function __construct(string $jsonSource) { - $source = json_decode($jsonSource, true); - - if ($source === null) { - throw new InvalidJson($jsonSource); + try { + $source = json_decode($jsonSource, associative: true, flags: JSON_THROW_ON_ERROR); + } catch (JsonException $e) { + throw new InvalidJson($jsonSource, $e); } if (! is_iterable($source)) { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Source/Source.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Source/Source.php index f50bf3229f..eb71f0f290 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Source/Source.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Source/Source.php @@ -21,8 +21,7 @@ final class Source implements IteratorAggregate private function __construct( /** @var iterable */ private iterable $delegate - ) { - } + ) {} /** * @param iterable $data diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/ArrayNodeBuilder.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/ArrayNodeBuilder.php index 3f0d1901ea..bcacaca5a6 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/ArrayNodeBuilder.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/ArrayNodeBuilder.php @@ -18,9 +18,7 @@ use function is_array; /** @internal */ final class ArrayNodeBuilder implements NodeBuilder { - public function __construct(private bool $enableFlexibleCasting) - { - } + public function __construct(private bool $enableFlexibleCasting) {} public function build(Shell $shell, RootNodeBuilder $rootBuilder): TreeNode { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/CasterNodeBuilder.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/CasterNodeBuilder.php index aefbf89ba1..a00634877d 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/CasterNodeBuilder.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/CasterNodeBuilder.php @@ -13,8 +13,7 @@ final class CasterNodeBuilder implements NodeBuilder public function __construct( /** @var array */ private array $builders - ) { - } + ) {} public function build(Shell $shell, RootNodeBuilder $rootBuilder): TreeNode { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/CasterProxyNodeBuilder.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/CasterProxyNodeBuilder.php index 1efe39cfcb..db2de428b2 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/CasterProxyNodeBuilder.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/CasterProxyNodeBuilder.php @@ -9,9 +9,7 @@ use CuyZ\Valinor\Mapper\Tree\Shell; /** @internal */ final class CasterProxyNodeBuilder implements NodeBuilder { - public function __construct(private NodeBuilder $delegate) - { - } + public function __construct(private NodeBuilder $delegate) {} public function build(Shell $shell, RootNodeBuilder $rootBuilder): TreeNode { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/InterfaceNodeBuilder.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/InterfaceNodeBuilder.php index edc1cae8e9..eb6a03c44f 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/InterfaceNodeBuilder.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/InterfaceNodeBuilder.php @@ -27,8 +27,7 @@ final class InterfaceNodeBuilder implements NodeBuilder private ObjectBuilderFactory $objectBuilderFactory, private ObjectNodeBuilder $objectNodeBuilder, private bool $enableFlexibleCasting - ) { - } + ) {} public function build(Shell $shell, RootNodeBuilder $rootBuilder): TreeNode { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/IterableNodeBuilder.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/IterableNodeBuilder.php index c615c0c62f..a3580ce0a2 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/IterableNodeBuilder.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/IterableNodeBuilder.php @@ -13,9 +13,7 @@ use function iterator_to_array; /** @internal */ final class IterableNodeBuilder implements NodeBuilder { - public function __construct(private NodeBuilder $delegate) - { - } + public function __construct(private NodeBuilder $delegate) {} public function build(Shell $shell, RootNodeBuilder $rootBuilder): TreeNode { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/ListNodeBuilder.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/ListNodeBuilder.php index 531b1beee4..8033c4d8c2 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/ListNodeBuilder.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/ListNodeBuilder.php @@ -17,9 +17,7 @@ use function is_array; /** @internal */ final class ListNodeBuilder implements NodeBuilder { - public function __construct(private bool $enableFlexibleCasting) - { - } + public function __construct(private bool $enableFlexibleCasting) {} public function build(Shell $shell, RootNodeBuilder $rootBuilder): TreeNode { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/NativeClassNodeBuilder.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/NativeClassNodeBuilder.php index eae3fac09e..f129b3d313 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/NativeClassNodeBuilder.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/NativeClassNodeBuilder.php @@ -20,8 +20,7 @@ final class NativeClassNodeBuilder implements NodeBuilder private ObjectBuilderFactory $objectBuilderFactory, private ObjectNodeBuilder $objectNodeBuilder, private bool $enableFlexibleCasting, - ) { - } + ) {} public function build(Shell $shell, RootNodeBuilder $rootBuilder): TreeNode { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/ObjectNodeBuilder.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/ObjectNodeBuilder.php index 060d854234..e0965e5b49 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/ObjectNodeBuilder.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/ObjectNodeBuilder.php @@ -14,9 +14,7 @@ use function count; /** @internal */ final class ObjectNodeBuilder { - public function __construct(private bool $allowSuperfluousKeys) - { - } + public function __construct(private bool $allowSuperfluousKeys) {} public function build(ObjectBuilder $builder, Shell $shell, RootNodeBuilder $rootBuilder): TreeNode { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/RootNodeBuilder.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/RootNodeBuilder.php index ed4da9c966..0afca986e6 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/RootNodeBuilder.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/RootNodeBuilder.php @@ -9,9 +9,7 @@ use CuyZ\Valinor\Mapper\Tree\Shell; /** @internal */ final class RootNodeBuilder { - public function __construct(private NodeBuilder $root) - { - } + public function __construct(private NodeBuilder $root) {} public function build(Shell $shell): TreeNode { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/ScalarNodeBuilder.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/ScalarNodeBuilder.php index 34528652bf..9a0d8a763f 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/ScalarNodeBuilder.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/ScalarNodeBuilder.php @@ -12,9 +12,7 @@ use function assert; /** @internal */ final class ScalarNodeBuilder implements NodeBuilder { - public function __construct(private bool $enableFlexibleCasting) - { - } + public function __construct(private bool $enableFlexibleCasting) {} public function build(Shell $shell, RootNodeBuilder $rootBuilder): TreeNode { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/ShapedArrayNodeBuilder.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/ShapedArrayNodeBuilder.php index 7fce746167..492d74a402 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/ShapedArrayNodeBuilder.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/ShapedArrayNodeBuilder.php @@ -17,9 +17,7 @@ use function is_array; /** @internal */ final class ShapedArrayNodeBuilder implements NodeBuilder { - public function __construct(private bool $allowSuperfluousKeys) - { - } + public function __construct(private bool $allowSuperfluousKeys) {} public function build(Shell $shell, RootNodeBuilder $rootBuilder): TreeNode { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/StrictNodeBuilder.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/StrictNodeBuilder.php index 84d9cfd668..ecff6142c4 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/StrictNodeBuilder.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/StrictNodeBuilder.php @@ -15,8 +15,7 @@ final class StrictNodeBuilder implements NodeBuilder private NodeBuilder $delegate, private bool $allowPermissiveTypes, private bool $enableFlexibleCasting - ) { - } + ) {} public function build(Shell $shell, RootNodeBuilder $rootBuilder): TreeNode { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/UnionNodeBuilder.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/UnionNodeBuilder.php index bf6babdaae..dd35ef87d3 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/UnionNodeBuilder.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/UnionNodeBuilder.php @@ -27,8 +27,7 @@ final class UnionNodeBuilder implements NodeBuilder private ObjectBuilderFactory $objectBuilderFactory, private ObjectNodeBuilder $objectNodeBuilder, private bool $enableFlexibleCasting - ) { - } + ) {} public function build(Shell $shell, RootNodeBuilder $rootBuilder): TreeNode { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/ValueAlteringNodeBuilder.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/ValueAlteringNodeBuilder.php index e833330039..66a6630dac 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/ValueAlteringNodeBuilder.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Builder/ValueAlteringNodeBuilder.php @@ -13,8 +13,7 @@ final class ValueAlteringNodeBuilder implements NodeBuilder public function __construct( private NodeBuilder $delegate, private FunctionsContainer $functions - ) { - } + ) {} public function build(Shell $shell, RootNodeBuilder $rootBuilder): TreeNode { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Message/ErrorMessage.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Message/ErrorMessage.php index ef2f6f9a58..1c53b35e5b 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Message/ErrorMessage.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Message/ErrorMessage.php @@ -7,6 +7,4 @@ namespace CuyZ\Valinor\Mapper\Tree\Message; use Throwable; /** @api */ -interface ErrorMessage extends Message, Throwable -{ -} +interface ErrorMessage extends Message, Throwable {} diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Message/Formatter/LocaleMessageFormatter.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Message/Formatter/LocaleMessageFormatter.php index 00f05b70f7..3dc93a3c40 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Message/Formatter/LocaleMessageFormatter.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Message/Formatter/LocaleMessageFormatter.php @@ -9,9 +9,7 @@ use CuyZ\Valinor\Mapper\Tree\Message\NodeMessage; /** @api */ final class LocaleMessageFormatter implements MessageFormatter { - public function __construct(private string $locale) - { - } + public function __construct(private string $locale) {} public function format(NodeMessage $message): NodeMessage { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Message/Formatter/MessageMapFormatter.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Message/Formatter/MessageMapFormatter.php index 08576e67ed..9ca30d56dd 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Message/Formatter/MessageMapFormatter.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Message/Formatter/MessageMapFormatter.php @@ -67,8 +67,7 @@ final class MessageMapFormatter implements MessageFormatter public function __construct( /** @var array */ private array $map - ) { - } + ) {} public function format(NodeMessage $message): NodeMessage { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Message/MessageBuilder.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Message/MessageBuilder.php index f9b4f44679..2230e12151 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Message/MessageBuilder.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Tree/Message/MessageBuilder.php @@ -31,9 +31,7 @@ final class MessageBuilder /** @var array */ private array $parameters = []; - private function __construct(private string $body) - { - } + private function __construct(private string $body) {} /** * @return self @@ -135,9 +133,11 @@ final class MessageBuilder /** * @param array $parameters */ - public function __construct(private string $body, private string $code, private array $parameters) - { - } + public function __construct( + private string $body, + private string $code, + private array $parameters + ) {} public function body(): string { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/TypeTreeMapper.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/TypeTreeMapper.php index 6103840d86..a9b4194c7e 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/TypeTreeMapper.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/TypeTreeMapper.php @@ -17,8 +17,7 @@ final class TypeTreeMapper implements TreeMapper public function __construct( private TypeParser $typeParser, private RootNodeBuilder $nodeBuilder - ) { - } + ) {} /** @pure */ public function map(string $signature, mixed $source): mixed diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/MapperBuilder.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/MapperBuilder.php index db4719f4a9..30c191fac5 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/MapperBuilder.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/MapperBuilder.php @@ -7,12 +7,12 @@ namespace CuyZ\Valinor; use CuyZ\Valinor\Library\Container; use CuyZ\Valinor\Library\Settings; use CuyZ\Valinor\Mapper\ArgumentsMapper; -use CuyZ\Valinor\Mapper\Object\DateTimeFormatConstructor; use CuyZ\Valinor\Mapper\Tree\Message\ErrorMessage; use CuyZ\Valinor\Mapper\TreeMapper; use Psr\SimpleCache\CacheInterface; use Throwable; +use function array_unique; use function is_callable; /** @api */ @@ -235,7 +235,23 @@ final class MapperBuilder */ public function supportDateFormats(string $format, string ...$formats): self { - return $this->registerConstructor(new DateTimeFormatConstructor($format, ...$formats)); + $clone = clone $this; + $clone->settings->supportedDateFormats = array_unique([$format, ...$formats]); + + return $clone; + } + + /** + * Returns the date formats supported during mapping. + * + * By default, any valid timestamp or ATOM-formatted value are accepted. + * Custom formats can be set using method `supportDateFormats()`. + * + * @return non-empty-array + */ + public function supportedDateFormats(): array + { + return $this->settings->supportedDateFormats; } /** diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/ClassType.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/ClassType.php index 2ab01829f0..62d6cda842 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/ClassType.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/ClassType.php @@ -5,6 +5,4 @@ declare(strict_types=1); namespace CuyZ\Valinor\Type; /** @internal */ -interface ClassType extends ObjectType -{ -} +interface ClassType extends ObjectType {} diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/CachedParser.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/CachedParser.php index 7cc049779b..1d1eefa73e 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/CachedParser.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/CachedParser.php @@ -12,9 +12,7 @@ final class CachedParser implements TypeParser /** @var array */ private array $types = []; - public function __construct(private TypeParser $delegate) - { - } + public function __construct(private TypeParser $delegate) {} public function parse(string $raw): Type { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Exception/InvalidType.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Exception/InvalidType.php index e691e117ae..ed730a57d8 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Exception/InvalidType.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Exception/InvalidType.php @@ -7,6 +7,4 @@ namespace CuyZ\Valinor\Type\Parser\Exception; use Throwable; /** @internal */ -interface InvalidType extends Throwable -{ -} +interface InvalidType extends Throwable {} diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Exception/Template/InvalidTemplate.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Exception/Template/InvalidTemplate.php index 1be411d26f..5e4594e466 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Exception/Template/InvalidTemplate.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Exception/Template/InvalidTemplate.php @@ -7,6 +7,4 @@ namespace CuyZ\Valinor\Type\Parser\Exception\Template; use Throwable; /** @internal */ -interface InvalidTemplate extends Throwable -{ -} +interface InvalidTemplate extends Throwable {} diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Factory/LexingTypeParserFactory.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Factory/LexingTypeParserFactory.php index 56718120e7..08d0eea3ae 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Factory/LexingTypeParserFactory.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Factory/LexingTypeParserFactory.php @@ -17,9 +17,7 @@ final class LexingTypeParserFactory implements TypeParserFactory { private TypeParser $nativeParser; - public function __construct(private TemplateParser $templateParser) - { - } + public function __construct(private TemplateParser $templateParser) {} public function get(TypeParserSpecification ...$specifications): TypeParser { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Factory/Specifications/AliasSpecification.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Factory/Specifications/AliasSpecification.php index 09cbe4eee7..59e706016a 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Factory/Specifications/AliasSpecification.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Factory/Specifications/AliasSpecification.php @@ -16,8 +16,7 @@ final class AliasSpecification implements TypeParserSpecification public function __construct( /** @var ReflectionClass|ReflectionFunction */ private Reflector $reflection - ) { - } + ) {} public function transform(TypeLexer $lexer): TypeLexer { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Factory/Specifications/ClassContextSpecification.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Factory/Specifications/ClassContextSpecification.php index fa508ad190..dcb3c628e1 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Factory/Specifications/ClassContextSpecification.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Factory/Specifications/ClassContextSpecification.php @@ -13,8 +13,7 @@ final class ClassContextSpecification implements TypeParserSpecification public function __construct( /** @var class-string */ private string $className - ) { - } + ) {} public function transform(TypeLexer $lexer): TypeLexer { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Factory/Specifications/TypeAliasAssignerSpecification.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Factory/Specifications/TypeAliasAssignerSpecification.php index 5818199717..140603610e 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Factory/Specifications/TypeAliasAssignerSpecification.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Factory/Specifications/TypeAliasAssignerSpecification.php @@ -14,8 +14,7 @@ final class TypeAliasAssignerSpecification implements TypeParserSpecification public function __construct( /** @var array */ private array $aliases - ) { - } + ) {} public function transform(TypeLexer $lexer): TypeLexer { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/AdvancedClassLexer.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/AdvancedClassLexer.php index 40bd49ba18..0ac28d38eb 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/AdvancedClassLexer.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/AdvancedClassLexer.php @@ -17,8 +17,7 @@ final class AdvancedClassLexer implements TypeLexer private TypeLexer $delegate, private TypeParserFactory $typeParserFactory, private TemplateParser $templateParser - ) { - } + ) {} public function tokenize(string $symbol): Token { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/AliasLexer.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/AliasLexer.php index d53c9b183e..96c2ac469d 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/AliasLexer.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/AliasLexer.php @@ -20,8 +20,7 @@ final class AliasLexer implements TypeLexer private TypeLexer $delegate, /** @var ReflectionClass|ReflectionFunction */ private Reflector $reflection - ) { - } + ) {} public function tokenize(string $symbol): Token { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/AdvancedClassNameToken.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/AdvancedClassNameToken.php index 70c42c75a4..e5bafa96a6 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/AdvancedClassNameToken.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/AdvancedClassNameToken.php @@ -46,8 +46,7 @@ final class AdvancedClassNameToken implements TraversingToken private ClassNameToken $delegate, private TypeParserFactory $typeParserFactory, private TemplateParser $templateParser - ) { - } + ) {} public function traverse(TokenStream $stream): Type { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/ArrayToken.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/ArrayToken.php index 24ea96183b..6d37b433e3 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/ArrayToken.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/ArrayToken.php @@ -36,8 +36,7 @@ final class ArrayToken implements TraversingToken /** @var class-string */ private string $arrayType, private string $symbol - ) { - } + ) {} public static function array(): self { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/CaseFinder.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/CaseFinder.php index e318ce8341..b5d34d8ecd 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/CaseFinder.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/CaseFinder.php @@ -19,8 +19,7 @@ final class CaseFinder public function __construct( /** @var array */ private array $cases - ) { - } + ) {} /** * @param list $tokens diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/EnumNameToken.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/EnumNameToken.php index 40dcad9625..513ba07bfb 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/EnumNameToken.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/EnumNameToken.php @@ -18,8 +18,7 @@ final class EnumNameToken implements TraversingToken public function __construct( /** @var class-string */ private string $enumName - ) { - } + ) {} public function traverse(TokenStream $stream): Type { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/FloatValueToken.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/FloatValueToken.php index d1851deb76..23e4784347 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/FloatValueToken.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/FloatValueToken.php @@ -11,9 +11,7 @@ use CuyZ\Valinor\Type\Types\FloatValueType; /** @internal */ final class FloatValueToken implements TraversingToken { - public function __construct(private float $value) - { - } + public function __construct(private float $value) {} public function traverse(TokenStream $stream): Type { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/IntegerValueToken.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/IntegerValueToken.php index 36c153e880..7e2373d04a 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/IntegerValueToken.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/IntegerValueToken.php @@ -11,9 +11,7 @@ use CuyZ\Valinor\Type\Types\IntegerValueType; /** @internal */ final class IntegerValueToken implements TraversingToken { - public function __construct(private int $value) - { - } + public function __construct(private int $value) {} public function traverse(TokenStream $stream): Type { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/ListToken.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/ListToken.php index c2fd225e9e..87254b609a 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/ListToken.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/ListToken.php @@ -21,8 +21,7 @@ final class ListToken implements TraversingToken /** @var class-string */ private string $listType, private string $symbol - ) { - } + ) {} public static function list(): self { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/NativeToken.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/NativeToken.php index e354526abe..f476bc46f2 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/NativeToken.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/NativeToken.php @@ -30,8 +30,7 @@ final class NativeToken implements TraversingToken private function __construct( private Type $type, private string $symbol - ) { - } + ) {} public static function accepts(string $symbol): bool { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/QuoteToken.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/QuoteToken.php index 055336633d..875ddd4ec9 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/QuoteToken.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/QuoteToken.php @@ -12,9 +12,7 @@ use CuyZ\Valinor\Type\Types\StringValueType; /** @internal */ final class QuoteToken implements TraversingToken { - public function __construct(private string $quoteType) - { - } + public function __construct(private string $quoteType) {} public function traverse(TokenStream $stream): Type { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/TypeToken.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/TypeToken.php index 4ab0852f10..cccffa0f05 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/TypeToken.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/TypeToken.php @@ -13,8 +13,7 @@ final class TypeToken implements TraversingToken public function __construct( private Type $type, private string $symbol - ) { - } + ) {} public function traverse(TokenStream $stream): Type { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/UnknownSymbolToken.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/UnknownSymbolToken.php index 09efdd7f57..010496294b 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/UnknownSymbolToken.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/Token/UnknownSymbolToken.php @@ -11,9 +11,7 @@ use CuyZ\Valinor\Type\Type; /** @internal */ final class UnknownSymbolToken implements TraversingToken { - public function __construct(private string $symbol) - { - } + public function __construct(private string $symbol) {} public function traverse(TokenStream $stream): Type { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/TypeAliasLexer.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/TypeAliasLexer.php index 89edf8e6db..698a929299 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/TypeAliasLexer.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/Lexer/TypeAliasLexer.php @@ -15,8 +15,7 @@ final class TypeAliasLexer implements TypeLexer private TypeLexer $delegate, /** @var array */ private array $aliases - ) { - } + ) {} public function tokenize(string $symbol): Token { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/LexingParser.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/LexingParser.php index ab4c5854d5..a1a8379c27 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/LexingParser.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Parser/LexingParser.php @@ -16,9 +16,7 @@ use function str_contains; /** @internal */ final class LexingParser implements TypeParser { - public function __construct(private TypeLexer $lexer) - { - } + public function __construct(private TypeLexer $lexer) {} public function parse(string $raw): Type { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/BooleanValueType.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/BooleanValueType.php index 119b2ddf10..8e1dea9aff 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/BooleanValueType.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/BooleanValueType.php @@ -22,9 +22,7 @@ final class BooleanValueType implements BooleanType, FixedType /** * @codeCoverageIgnore */ - private function __construct(private bool $value) - { - } + private function __construct(private bool $value) {} public static function true(): self { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/FloatValueType.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/FloatValueType.php index 1147faf1d4..a8a456f7db 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/FloatValueType.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/FloatValueType.php @@ -15,9 +15,7 @@ use function assert; /** @internal */ final class FloatValueType implements FloatType, FixedType { - public function __construct(private float $value) - { - } + public function __construct(private float $value) {} public function accepts(mixed $value): bool { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/IntegerValueType.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/IntegerValueType.php index dbb55686e2..f6cd7033b3 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/IntegerValueType.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/IntegerValueType.php @@ -17,9 +17,7 @@ use function is_bool; /** @internal */ final class IntegerValueType implements IntegerType, FixedType { - public function __construct(private int $value) - { - } + public function __construct(private int $value) {} public function accepts(mixed $value): bool { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/InterfaceType.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/InterfaceType.php index b7d9374233..4db2359d44 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/InterfaceType.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/InterfaceType.php @@ -20,8 +20,7 @@ final class InterfaceType implements ObjectType, GenericType private string $interfaceName, /** @var array */ private array $generics = [] - ) { - } + ) {} public function className(): string { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/ShapedArrayElement.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/ShapedArrayElement.php index bc6dc08663..fb76a8d7a3 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/ShapedArrayElement.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/ShapedArrayElement.php @@ -13,8 +13,7 @@ final class ShapedArrayElement private StringValueType|IntegerValueType $key, private Type $type, private bool $optional = false - ) { - } + ) {} public function key(): StringValueType|IntegerValueType { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/StringValueType.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/StringValueType.php index 19d0a66cf3..a3babe059e 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/StringValueType.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/StringValueType.php @@ -20,9 +20,7 @@ final class StringValueType implements StringType, FixedType { private string $quoteChar; - public function __construct(private string $value) - { - } + public function __construct(private string $value) {} public static function singleQuote(string $value): self { diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/UnresolvableType.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/UnresolvableType.php index 3d74be3f1a..a212e12478 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/UnresolvableType.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Type/Types/UnresolvableType.php @@ -9,26 +9,20 @@ use CuyZ\Valinor\Type\Parser\Exception\InvalidType; use CuyZ\Valinor\Type\Type; use CuyZ\Valinor\Utility\ValueDumper; use LogicException; -use Throwable; /** @internal */ -final class UnresolvableType extends LogicException implements Type +final class UnresolvableType implements Type { - private string $rawType; - - public function __construct(string $rawType, string $message, ?Throwable $previous = null) - { - $this->rawType = $rawType; - - parent::__construct($message, 1679578492, $previous); - } + public function __construct( + private string $rawType, + private string $message, + ) {} public static function forProperty(string $raw, string $signature, InvalidType $exception): self { return new self( $raw, - "The type `$raw` for property `$signature` could not be resolved: {$exception->getMessage()}", - $exception + "The type `$raw` for property `$signature` could not be resolved: {$exception->getMessage()}" ); } @@ -36,8 +30,7 @@ final class UnresolvableType extends LogicException implements Type { return new self( $raw, - "The type `$raw` for parameter `$signature` could not be resolved: {$exception->getMessage()}", - $exception + "The type `$raw` for parameter `$signature` could not be resolved: {$exception->getMessage()}" ); } @@ -45,8 +38,7 @@ final class UnresolvableType extends LogicException implements Type { return new self( $raw, - "The type `$raw` for return type of method `$signature` could not be resolved: {$exception->getMessage()}", - $exception + "The type `$raw` for return type of method `$signature` could not be resolved: {$exception->getMessage()}" ); } @@ -74,19 +66,23 @@ final class UnresolvableType extends LogicException implements Type { return new self( $raw, - "The type `$raw` for local alias `$name` of the class `{$type->className()}` could not be resolved: {$exception->getMessage()}", - $exception + "The type `$raw` for local alias `$name` of the class `{$type->className()}` could not be resolved: {$exception->getMessage()}" ); } + public function message(): string + { + return $this->message; + } + public function accepts(mixed $value): bool { - throw $this; + throw new LogicException(); } public function matches(Type $other): bool { - throw $this; + throw new LogicException(); } public function toString(): string diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Utility/String/StringCutter.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Utility/String/StringCutter.php new file mode 100644 index 0000000000..00fe67f174 --- /dev/null +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Utility/String/StringCutter.php @@ -0,0 +1,51 @@ += 0); + + return match (true) { + default => substr($s, 0, $cur), + // U+0080 - U+07FF + $cnt === 1 && (ord($s[$cur]) & 0b1110_0000) === 0b1100_0000, + // U+0800 - U+FFFF + $cnt === 2 && (ord($s[$cur]) & 0b1111_0000) === 0b1110_0000, + // U+10000 - U+10FFFF + $cnt === 3 && (ord($s[$cur]) & 0b1111_1000) === 0b1111_0000 => $s + }; + } +} diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Utility/String/StringFormatter.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Utility/String/StringFormatter.php index 5723bc6a4f..4fa5d286d0 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Utility/String/StringFormatter.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Utility/String/StringFormatter.php @@ -38,7 +38,7 @@ final class StringFormatter private static function formatWithIntl(string $locale, string $body, array $parameters): string { return MessageFormatter::formatMessage($locale, $body, $parameters) - ?: throw new StringFormatterError($body); + ?: throw new StringFormatterError($body, intl_get_error_message()); } /** diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Utility/String/StringFormatterError.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Utility/String/StringFormatterError.php index 418d9860a2..f99729377b 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Utility/String/StringFormatterError.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Utility/String/StringFormatterError.php @@ -9,8 +9,11 @@ use RuntimeException; /** @internal */ final class StringFormatterError extends RuntimeException { - public function __construct(string $body) + public function __construct(string $body, string $message = '') { - parent::__construct("Message formatter error using `$body`.", 1652901203); + if ($message !== '') { + $message = ": $message"; + } + parent::__construct("Message formatter error using `$body`$message.", 1652901203); } } diff --git a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Utility/ValueDumper.php b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Utility/ValueDumper.php index 21e95e4d01..8e61c26e81 100644 --- a/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Utility/ValueDumper.php +++ b/wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Utility/ValueDumper.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace CuyZ\Valinor\Utility; use BackedEnum; +use CuyZ\Valinor\Utility\String\StringCutter; use DateTimeInterface; use UnitEnum; @@ -112,11 +113,11 @@ final class ValueDumper return $string; } - $string = substr($string, 0, self::MAX_STRING_LENGTH + 1); + $string = StringCutter::cut($string, self::MAX_STRING_LENGTH + 1); for ($i = strlen($string) - 1; $i > 10; $i--) { if ($string[$i] === ' ') { - return substr($string, 0, $i) . '…'; + return StringCutter::cut($string, $i) . '…'; } } diff --git a/wcfsetup/install/files/lib/system/api/dragonmantank/cron-expression/CHANGELOG.md b/wcfsetup/install/files/lib/system/api/dragonmantank/cron-expression/CHANGELOG.md index 7b6df4b1cb..17ab2ce44d 100644 --- a/wcfsetup/install/files/lib/system/api/dragonmantank/cron-expression/CHANGELOG.md +++ b/wcfsetup/install/files/lib/system/api/dragonmantank/cron-expression/CHANGELOG.md @@ -1,5 +1,17 @@ # Change Log +## [3.3.3] - 2024-08-10 + +### Added +- N/A + +### Changed +- N/A + +### Fixed +- Added fixes for making sure `?` is not passed for both DOM and DOW (#148, thank you https://github.com/LeoVie) +- Fixed bug in Next Execution Time by sorting minutes properly (#160, thank you https://github.com/imyip) + ## [3.3.2] - 2022-09-19 ### Added diff --git a/wcfsetup/install/files/lib/system/api/dragonmantank/cron-expression/README.md b/wcfsetup/install/files/lib/system/api/dragonmantank/cron-expression/README.md index e853ad4555..494652c84e 100644 --- a/wcfsetup/install/files/lib/system/api/dragonmantank/cron-expression/README.md +++ b/wcfsetup/install/files/lib/system/api/dragonmantank/cron-expression/README.md @@ -84,4 +84,4 @@ Projects that Use cron-expression ================================= * Part of the [Laravel Framework](https://github.com/laravel/framework/) * Available as a [Symfony Bundle - setono/cron-expression-bundle](https://github.com/Setono/CronExpressionBundle) -* Framework agnostic, PHP-based job scheduler - [Crunz](https://github.com/lavary/crunz) +* Framework agnostic, PHP-based job scheduler - [Crunz](https://github.com/crunzphp/crunz) diff --git a/wcfsetup/install/files/lib/system/api/dragonmantank/cron-expression/phpstan.neon b/wcfsetup/install/files/lib/system/api/dragonmantank/cron-expression/phpstan.neon deleted file mode 100644 index bea9cb0dad..0000000000 --- a/wcfsetup/install/files/lib/system/api/dragonmantank/cron-expression/phpstan.neon +++ /dev/null @@ -1,15 +0,0 @@ -parameters: - checkMissingIterableValueType: false - - ignoreErrors: - - '#Call to an undefined method DateTimeInterface::add\(\)#' - - '#Call to an undefined method DateTimeInterface::modify\(\)#' - - '#Call to an undefined method DateTimeInterface::setDate\(\)#' - - '#Call to an undefined method DateTimeInterface::setTime\(\)#' - - '#Call to an undefined method DateTimeInterface::setTimezone\(\)#' - - '#Call to an undefined method DateTimeInterface::sub\(\)#' - - level: max - - paths: - - src/ diff --git a/wcfsetup/install/files/lib/system/api/dragonmantank/cron-expression/src/Cron/CronExpression.php b/wcfsetup/install/files/lib/system/api/dragonmantank/cron-expression/src/Cron/CronExpression.php index d5337cc57f..216ce432f1 100644 --- a/wcfsetup/install/files/lib/system/api/dragonmantank/cron-expression/src/Cron/CronExpression.php +++ b/wcfsetup/install/files/lib/system/api/dragonmantank/cron-expression/src/Cron/CronExpression.php @@ -177,6 +177,7 @@ class CronExpression * * @param string $expression CRON expression (e.g. '8 * * * *') * @param null|FieldFactoryInterface $fieldFactory Factory to create cron fields + * @throws InvalidArgumentException */ public function __construct(string $expression, FieldFactoryInterface $fieldFactory = null) { @@ -201,13 +202,22 @@ class CronExpression $split = preg_split('/\s/', $value, -1, PREG_SPLIT_NO_EMPTY); Assert::isArray($split); - $this->cronParts = $split; - if (\count($this->cronParts) < 5) { + $notEnoughParts = \count($split) < 5; + + $questionMarkInInvalidPart = array_key_exists(0, $split) && $split[0] === '?' + || array_key_exists(1, $split) && $split[1] === '?' + || array_key_exists(3, $split) && $split[3] === '?'; + + $tooManyQuestionMarks = array_key_exists(2, $split) && $split[2] === '?' + && array_key_exists(4, $split) && $split[4] === '?'; + + if ($notEnoughParts || $questionMarkInInvalidPart || $tooManyQuestionMarks) { throw new InvalidArgumentException( $value . ' is not a valid CRON expression' ); } + $this->cronParts = $split; foreach ($this->cronParts as $position => $part) { $this->setPart($position, $part); } diff --git a/wcfsetup/install/files/lib/system/api/dragonmantank/cron-expression/src/Cron/MinutesField.php b/wcfsetup/install/files/lib/system/api/dragonmantank/cron-expression/src/Cron/MinutesField.php index eda91098e8..f077e6ec51 100644 --- a/wcfsetup/install/files/lib/system/api/dragonmantank/cron-expression/src/Cron/MinutesField.php +++ b/wcfsetup/install/files/lib/system/api/dragonmantank/cron-expression/src/Cron/MinutesField.php @@ -49,6 +49,7 @@ class MinutesField extends AbstractField $current_minute = (int) $date->format('i'); $parts = false !== strpos($parts, ',') ? explode(',', $parts) : [$parts]; + sort($parts); $minutes = []; foreach ($parts as $part) { $minutes = array_merge($minutes, $this->getRangeForExpression($part, 59)); -- 2.20.1