From 1c1c24a4af8982af471b6c979087cc680325911d Mon Sep 17 00:00:00 2001 From: brendt Date: Wed, 24 Jun 2026 08:33:33 +0200 Subject: [PATCH 1/3] wip --- .../Testing/Http/HttpRouterTester.php | 32 ++++++++++++++----- .../Http/HttpRouterTesterIntegrationTest.php | 10 ++++++ 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/Tempest/Framework/Testing/Http/HttpRouterTester.php b/src/Tempest/Framework/Testing/Http/HttpRouterTester.php index 2f11ad8f50..477d19b19f 100644 --- a/src/Tempest/Framework/Testing/Http/HttpRouterTester.php +++ b/src/Tempest/Framework/Testing/Http/HttpRouterTester.php @@ -37,10 +37,22 @@ final class HttpRouterTester private(set) bool $includeSecFetchHeaders = true; + private(set) bool $throwExceptions = false; + public function __construct( private Container $container, ) {} + /** + * Configure whether exceptions should be thrown or not + */ + public function throwExceptions(bool $throwExceptions = true): self + { + $this->throwExceptions = $throwExceptions; + + return $this; + } + /** * Registers a route for testing purposes. * @@ -221,15 +233,19 @@ public function sendRequest(Request $request): TestResponseHelper /** @var Router $router */ $router = $this->container->get(Router::class); - try { + if ($this->throwExceptions) { $response = $router->dispatch(map($request)->with(RequestToPsrRequestMapper::class)->do()); - } catch (Throwable $throwable) { - return new TestResponseHelper( - response: $this->container->get(HttpExceptionHandler::class)->renderResponse($request, $throwable), - request: $request, - container: $this->container, - throwable: $throwable, - ); + } else { + try { + $response = $router->dispatch(map($request)->with(RequestToPsrRequestMapper::class)->do()); + } catch (Throwable $throwable) { + return new TestResponseHelper( + response: $this->container->get(HttpExceptionHandler::class)->renderResponse($request, $throwable), + request: $request, + container: $this->container, + throwable: $throwable, + ); + } } return new TestResponseHelper( diff --git a/tests/Integration/Testing/Http/HttpRouterTesterIntegrationTest.php b/tests/Integration/Testing/Http/HttpRouterTesterIntegrationTest.php index 739ee93daa..41fc5eb169 100644 --- a/tests/Integration/Testing/Http/HttpRouterTesterIntegrationTest.php +++ b/tests/Integration/Testing/Http/HttpRouterTesterIntegrationTest.php @@ -220,6 +220,16 @@ public function raw_body_string(): void $this->assertSame('ok', $response->request->raw); $this->assertSame([], $response->request->body); } + + #[Test] + public function test_throw_exceptions(): void + { + $this->expectException(Exception::class); + + $this->http + ->throwExceptions() + ->get('/fail'); + } } final class TestController From 440e8e93370bd533e1825636c42be144af92ccd4 Mon Sep 17 00:00:00 2001 From: brendt Date: Wed, 24 Jun 2026 08:33:36 +0200 Subject: [PATCH 2/3] wip --- .../auth/src/AccessControl/AccessDecision.php | 2 +- packages/auth/src/AccessControl/Policy.php | 2 +- .../CurrentAuthenticatableInitializer.php | 4 ++-- .../src/Exceptions/OAuthWasNotConfigured.php | 2 +- .../src/OAuth/Config/AppleOAuthConfig.php | 2 +- .../src/OAuth/Config/DiscordOAuthConfig.php | 2 +- .../src/OAuth/Config/FacebookOAuthConfig.php | 2 +- .../src/OAuth/Config/GenericOAuthConfig.php | 2 +- .../src/OAuth/Config/GitHubOAuthConfig.php | 2 +- .../src/OAuth/Config/GoogleOAuthConfig.php | 2 +- .../src/OAuth/Config/InstagramOAuthConfig.php | 2 +- .../src/OAuth/Config/LinkedInOAuthConfig.php | 2 +- .../src/OAuth/Config/MicrosoftOAuthConfig.php | 2 +- .../src/OAuth/Config/SlackOAuthConfig.php | 2 +- .../src/OAuth/Config/TwitchOAuthConfig.php | 2 +- .../auth/src/OAuth/OAuthClientInitializer.php | 4 ++-- .../auth/src/OAuth/Testing/OAuthTester.php | 2 +- packages/cache/src/Cache.php | 8 ++++---- packages/cache/src/CacheInitializer.php | 6 +++--- .../cache/src/Config/CustomCacheConfig.php | 2 +- .../src/Config/FilesystemCacheConfig.php | 2 +- .../cache/src/Config/InMemoryCacheConfig.php | 2 +- packages/cache/src/Config/PhpCacheConfig.php | 2 +- .../cache/src/Config/RedisCacheConfig.php | 2 +- packages/cache/src/GenericCache.php | 10 +++++----- packages/cache/src/GenericLock.php | 4 ++-- packages/cache/src/Lock.php | 4 ++-- packages/cache/src/Testing/CacheTester.php | 2 +- .../cache/src/Testing/RestrictedCache.php | 10 +++++----- .../Testing/RestrictedCacheInitializer.php | 4 ++-- packages/cache/src/Testing/TestingCache.php | 12 +++++------ packages/cache/src/Testing/TestingLock.php | 8 ++++---- .../Interactive/SearchComponent.php | 2 +- .../Interactive/SingleChoiceComponent.php | 4 ++-- .../Components/Interactive/TaskComponent.php | 4 ++-- .../Interactive/TextInputComponent.php | 2 +- .../src/Components/OptionCollection.php | 2 +- .../Components/Renderers/ChoiceRenderer.php | 2 +- .../Components/Renderers/KeyValueRenderer.php | 4 ++-- .../Static/StaticSearchComponent.php | 4 ++-- .../Static/StaticSingleChoiceComponent.php | 4 ++-- .../Components/Static/StaticTaskComponent.php | 2 +- packages/console/src/Console.php | 8 ++++---- packages/console/src/GenericConsole.php | 8 ++++---- packages/console/src/HasConsole.php | 8 ++++---- packages/container/src/Container.php | 6 +++--- packages/container/src/DynamicInitializer.php | 4 ++-- packages/container/src/GenericContainer.php | 20 +++++++++---------- packages/container/src/HasTag.php | 2 +- .../Fixtures/ContainerObjectEInitializer.php | 4 ++-- .../Fixtures/CountingDynamicInitializer.php | 4 ++-- .../container/tests/Fixtures/HasTagObject.php | 2 +- packages/core/src/ConfigCache.php | 4 ++-- .../tests/HasMoreIntegerAssertions.php | 2 +- packages/database/src/BelongsTo.php | 2 +- packages/database/src/BelongsToMany.php | 2 +- .../src/Builder/QueryBuilders/BuildsQuery.php | 2 +- .../QueryBuilders/UpdateQueryBuilder.php | 8 ++++---- packages/database/src/Config/MysqlConfig.php | 2 +- .../database/src/Config/PostgresConfig.php | 2 +- packages/database/src/Config/SQLiteConfig.php | 2 +- packages/database/src/Database.php | 2 +- packages/database/src/DatabaseInitializer.php | 4 ++-- packages/database/src/DatabaseSeeder.php | 2 +- packages/database/src/GenericDatabase.php | 2 +- packages/database/src/HasMany.php | 2 +- packages/database/src/HasManyThrough.php | 2 +- packages/database/src/HasOne.php | 2 +- packages/database/src/HasOneThrough.php | 2 +- packages/database/src/IsDatabaseModel.php | 6 +++--- packages/database/src/OnDatabase.php | 4 ++-- packages/database/src/QueryExecuted.php | 2 +- .../QueryStatements/CanExecuteStatement.php | 2 +- .../QueryStatements/CreateTableStatement.php | 2 +- .../src/QueryStatements/EnumStatement.php | 2 +- .../src/QueryStatements/FieldStatement.php | 2 +- packages/database/src/Relation.php | 2 +- .../src/DateTimeConvenienceMethods.php | 2 +- packages/datetime/src/DateTimeInterface.php | 2 +- .../src/TemporalConvenienceMethods.php | 2 +- packages/datetime/src/TemporalInterface.php | 2 +- packages/datetime/src/functions.php | 4 ++-- .../event-bus/src/CallableEventHandler.php | 2 +- packages/event-bus/src/EventHandler.php | 2 +- .../http-client/src/Testing/MockClient.php | 2 +- packages/http/src/Responses/Created.php | 2 +- packages/http/src/ServerSentEvent.php | 2 +- packages/http/src/ServerSentMessage.php | 2 +- packages/icon/src/IconCache.php | 4 ++-- .../tests/Fixtures/RecordingCache.php | 8 ++++---- .../kv-store/src/Redis/PhpRedisClient.php | 2 +- packages/kv-store/src/Redis/PredisClient.php | 2 +- packages/kv-store/src/Redis/Redis.php | 2 +- packages/log/src/Config/DailyLogConfig.php | 2 +- .../src/Config/MultipleChannelsLogConfig.php | 2 +- packages/log/src/Config/NullLogConfig.php | 2 +- packages/log/src/Config/SimpleLogConfig.php | 2 +- packages/log/src/Config/SlackLogConfig.php | 2 +- packages/log/src/Config/SysLogConfig.php | 2 +- packages/log/src/Config/WeeklyLogConfig.php | 2 +- packages/log/src/LoggerInitializer.php | 4 ++-- .../mail/src/EmailToSymfonyEmailMapper.php | 2 +- packages/mail/src/Envelope.php | 10 +++++----- packages/mail/src/GenericEmail.php | 10 +++++----- packages/mail/src/Testing/MailTester.php | 8 ++++---- .../mail/src/Transports/NullMailerConfig.php | 2 +- .../Transports/Postmark/PostmarkConfig.php | 2 +- .../src/Transports/ProvidesDefaultSender.php | 2 +- .../src/Transports/Ses/SesMailerConfig.php | 2 +- .../Transports/Ses/SesSmtpMailerConfig.php | 2 +- .../src/Transports/Smtp/SmtpMailerConfig.php | 2 +- .../router/src/RouteBindingInitializer.php | 4 ++-- .../storage/src/Config/AzureStorageConfig.php | 2 +- .../src/Config/CustomStorageConfig.php | 2 +- .../storage/src/Config/FTPStorageConfig.php | 2 +- .../src/Config/GoogleCloudStorageConfig.php | 2 +- .../src/Config/InMemoryStorageConfig.php | 2 +- .../storage/src/Config/LocalStorageConfig.php | 2 +- .../storage/src/Config/R2StorageConfig.php | 2 +- .../storage/src/Config/S3StorageConfig.php | 2 +- .../storage/src/Config/SFTPStorageConfig.php | 2 +- .../src/Config/ZipArchiveStorageConfig.php | 2 +- packages/storage/src/StorageInitializer.php | 4 ++-- .../Testing/RestrictedStorageInitializer.php | 4 ++-- .../storage/src/Testing/StorageTester.php | 2 +- packages/support/src/Arr/ManipulatesArray.php | 2 +- packages/support/src/Arr/functions.php | 2 +- packages/support/src/Math/functions.php | 4 ++-- packages/support/src/Namespace/functions.php | 8 ++++---- packages/support/src/Path/functions.php | 12 +++++------ packages/support/src/Random/functions.php | 2 +- packages/support/src/Regex/functions.php | 2 +- .../support/src/Str/ManipulatesString.php | 2 +- packages/support/src/Str/functions.php | 2 +- packages/support/tests/Math/MathsTest.php | 2 +- packages/support/tests/Path/FunctionsTest.php | 2 +- .../src/Exceptions/ValidationFailed.php | 2 +- packages/validation/src/Validator.php | 2 +- .../view/src/Parser/TempestViewCompiler.php | 6 ++---- packages/view/src/Parser/Token.php | 2 +- .../view/src/Renderers/BladeInitializer.php | 4 ++-- .../src/Renderers/TempestViewRenderer.php | 2 +- packages/view/src/Renderers/TwigConfig.php | 2 +- .../view/src/Renderers/TwigInitializer.php | 4 ++-- packages/vite/src/functions.php | 2 +- .../Testing/Http/TestResponseHelper.php | 4 ++-- .../Testing/TestingDatabaseInitializer.php | 4 ++-- tests/Fixtures/SecondTestDatabaseSeeder.php | 2 +- tests/Fixtures/TestDatabaseSeeder.php | 2 +- tests/Fixtures/TestResponseProcessor.php | 2 +- .../PolicyBasedAccessControlTest.php | 2 +- .../Commands/ContainerShowCommandTest.php | 6 +++--- .../Http/GenericResponseSenderTest.php | 2 +- tests/Integration/Mailer/SentEmailTest.php | 12 +++++------ .../Integration/Storage/StorageTesterTest.php | 2 +- 155 files changed, 258 insertions(+), 260 deletions(-) diff --git a/packages/auth/src/AccessControl/AccessDecision.php b/packages/auth/src/AccessControl/AccessDecision.php index 61df6ec22c..0c60083c4c 100644 --- a/packages/auth/src/AccessControl/AccessDecision.php +++ b/packages/auth/src/AccessControl/AccessDecision.php @@ -16,7 +16,7 @@ public function __construct( /** * Determines if access is granted or denied based on the provided decision. */ - public static function from(null|self|bool $decision): self + public static function from(self|bool|null $decision): self { if ($decision instanceof self) { return $decision; diff --git a/packages/auth/src/AccessControl/Policy.php b/packages/auth/src/AccessControl/Policy.php index 1e91841127..8a2d401555 100644 --- a/packages/auth/src/AccessControl/Policy.php +++ b/packages/auth/src/AccessControl/Policy.php @@ -18,6 +18,6 @@ final class Policy */ public function __construct( public ?string $resource = null, - public null|UnitEnum|string|iterable $action = null, + public UnitEnum|string|iterable|null $action = null, ) {} } diff --git a/packages/auth/src/Authentication/CurrentAuthenticatableInitializer.php b/packages/auth/src/Authentication/CurrentAuthenticatableInitializer.php index ad209316a2..74f7e765b0 100644 --- a/packages/auth/src/Authentication/CurrentAuthenticatableInitializer.php +++ b/packages/auth/src/Authentication/CurrentAuthenticatableInitializer.php @@ -15,12 +15,12 @@ */ final readonly class CurrentAuthenticatableInitializer implements DynamicInitializer { - public function canInitialize(ClassReflector $class, null|string|UnitEnum $tag): bool + public function canInitialize(ClassReflector $class, string|UnitEnum|null $tag): bool { return $class->implements(Authenticatable::class) || $class->is(Authenticatable::class); } - public function initialize(ClassReflector $class, null|string|UnitEnum $tag, Container $container): object + public function initialize(ClassReflector $class, string|UnitEnum|null $tag, Container $container): object { $authenticatable = $container->get(Authenticator::class)->current(); diff --git a/packages/auth/src/Exceptions/OAuthWasNotConfigured.php b/packages/auth/src/Exceptions/OAuthWasNotConfigured.php index 9a8e999910..fd591e2867 100644 --- a/packages/auth/src/Exceptions/OAuthWasNotConfigured.php +++ b/packages/auth/src/Exceptions/OAuthWasNotConfigured.php @@ -10,7 +10,7 @@ final class OAuthWasNotConfigured extends Exception implements AuthenticationException { - public static function configurationWasMissing(null|string|UnitEnum $tag): self + public static function configurationWasMissing(string|UnitEnum|null $tag): self { $tag = Str\parse($tag, default: null); diff --git a/packages/auth/src/OAuth/Config/AppleOAuthConfig.php b/packages/auth/src/OAuth/Config/AppleOAuthConfig.php index c67178e11c..31e888c93d 100644 --- a/packages/auth/src/OAuth/Config/AppleOAuthConfig.php +++ b/packages/auth/src/OAuth/Config/AppleOAuthConfig.php @@ -52,7 +52,7 @@ public function __construct( /** * Identifier for this OAuth configuration. */ - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} public function createProvider(): AbstractProvider diff --git a/packages/auth/src/OAuth/Config/DiscordOAuthConfig.php b/packages/auth/src/OAuth/Config/DiscordOAuthConfig.php index b1adf3e75e..23be934872 100644 --- a/packages/auth/src/OAuth/Config/DiscordOAuthConfig.php +++ b/packages/auth/src/OAuth/Config/DiscordOAuthConfig.php @@ -42,7 +42,7 @@ public function __construct( /** * Identifier for this OAuth configuration. */ - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} public function createProvider(): AbstractProvider diff --git a/packages/auth/src/OAuth/Config/FacebookOAuthConfig.php b/packages/auth/src/OAuth/Config/FacebookOAuthConfig.php index 376e19b86b..8babd40a00 100644 --- a/packages/auth/src/OAuth/Config/FacebookOAuthConfig.php +++ b/packages/auth/src/OAuth/Config/FacebookOAuthConfig.php @@ -48,7 +48,7 @@ public function __construct( /** * Identifier for this OAuth configuration. */ - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} public function createProvider(): AbstractProvider diff --git a/packages/auth/src/OAuth/Config/GenericOAuthConfig.php b/packages/auth/src/OAuth/Config/GenericOAuthConfig.php index c8a05e0cbe..929edeea3b 100644 --- a/packages/auth/src/OAuth/Config/GenericOAuthConfig.php +++ b/packages/auth/src/OAuth/Config/GenericOAuthConfig.php @@ -57,7 +57,7 @@ public function __construct( /** * Identifier for this OAuth configuration. */ - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, /** * Separator for the scopes, defaults to `,` if omitted. diff --git a/packages/auth/src/OAuth/Config/GitHubOAuthConfig.php b/packages/auth/src/OAuth/Config/GitHubOAuthConfig.php index cd0d3e82c6..513ebeb502 100644 --- a/packages/auth/src/OAuth/Config/GitHubOAuthConfig.php +++ b/packages/auth/src/OAuth/Config/GitHubOAuthConfig.php @@ -43,7 +43,7 @@ public function __construct( /** * Identifier for this OAuth configuration. */ - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} public function createProvider(): AbstractProvider diff --git a/packages/auth/src/OAuth/Config/GoogleOAuthConfig.php b/packages/auth/src/OAuth/Config/GoogleOAuthConfig.php index c1a0d8f5c8..f20482537f 100644 --- a/packages/auth/src/OAuth/Config/GoogleOAuthConfig.php +++ b/packages/auth/src/OAuth/Config/GoogleOAuthConfig.php @@ -43,7 +43,7 @@ public function __construct( /** * Identifier for this OAuth configuration. */ - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} public function createProvider(): AbstractProvider diff --git a/packages/auth/src/OAuth/Config/InstagramOAuthConfig.php b/packages/auth/src/OAuth/Config/InstagramOAuthConfig.php index 42a39e4b74..779f57fa42 100644 --- a/packages/auth/src/OAuth/Config/InstagramOAuthConfig.php +++ b/packages/auth/src/OAuth/Config/InstagramOAuthConfig.php @@ -42,7 +42,7 @@ public function __construct( /** * Identifier for this OAuth configuration. */ - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} public function createProvider(): AbstractProvider diff --git a/packages/auth/src/OAuth/Config/LinkedInOAuthConfig.php b/packages/auth/src/OAuth/Config/LinkedInOAuthConfig.php index 839b24dd23..e6bf72a239 100644 --- a/packages/auth/src/OAuth/Config/LinkedInOAuthConfig.php +++ b/packages/auth/src/OAuth/Config/LinkedInOAuthConfig.php @@ -42,7 +42,7 @@ public function __construct( /** * Identifier for this OAuth configuration. */ - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} public function createProvider(): AbstractProvider diff --git a/packages/auth/src/OAuth/Config/MicrosoftOAuthConfig.php b/packages/auth/src/OAuth/Config/MicrosoftOAuthConfig.php index 943c820901..b15bce2093 100644 --- a/packages/auth/src/OAuth/Config/MicrosoftOAuthConfig.php +++ b/packages/auth/src/OAuth/Config/MicrosoftOAuthConfig.php @@ -42,7 +42,7 @@ public function __construct( /** * Identifier for this OAuth configuration. */ - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} public function createProvider(): AbstractProvider diff --git a/packages/auth/src/OAuth/Config/SlackOAuthConfig.php b/packages/auth/src/OAuth/Config/SlackOAuthConfig.php index 212f40a4e6..96710b8d5a 100644 --- a/packages/auth/src/OAuth/Config/SlackOAuthConfig.php +++ b/packages/auth/src/OAuth/Config/SlackOAuthConfig.php @@ -42,7 +42,7 @@ public function __construct( /** * Identifier for this OAuth configuration. */ - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} public function createProvider(): AbstractProvider diff --git a/packages/auth/src/OAuth/Config/TwitchOAuthConfig.php b/packages/auth/src/OAuth/Config/TwitchOAuthConfig.php index e48e268f9d..12a3e83758 100644 --- a/packages/auth/src/OAuth/Config/TwitchOAuthConfig.php +++ b/packages/auth/src/OAuth/Config/TwitchOAuthConfig.php @@ -43,7 +43,7 @@ public function __construct( /** * Identifier for this OAuth configuration. */ - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} public function createProvider(): AbstractProvider diff --git a/packages/auth/src/OAuth/OAuthClientInitializer.php b/packages/auth/src/OAuth/OAuthClientInitializer.php index 234091ac4b..fd56fb25a1 100644 --- a/packages/auth/src/OAuth/OAuthClientInitializer.php +++ b/packages/auth/src/OAuth/OAuthClientInitializer.php @@ -18,13 +18,13 @@ final class OAuthClientInitializer implements DynamicInitializer { - public function canInitialize(ClassReflector $class, null|string|UnitEnum $tag): bool + public function canInitialize(ClassReflector $class, string|UnitEnum|null $tag): bool { return $class->getType()->matches(OAuthClient::class); } #[Singleton] - public function initialize(ClassReflector $class, null|string|UnitEnum $tag, Container $container): OAuthClient + public function initialize(ClassReflector $class, string|UnitEnum|null $tag, Container $container): OAuthClient { if (! $container->has(OAuthConfig::class, $tag)) { throw OAuthWasNotConfigured::configurationWasMissing($tag); diff --git a/packages/auth/src/OAuth/Testing/OAuthTester.php b/packages/auth/src/OAuth/Testing/OAuthTester.php index 5a68d16213..603c4cc91f 100644 --- a/packages/auth/src/OAuth/Testing/OAuthTester.php +++ b/packages/auth/src/OAuth/Testing/OAuthTester.php @@ -21,7 +21,7 @@ public function __construct( /** * Forces the usage of a testing OAuth client for the given provider. */ - public function fake(OAuthUser $user, null|string|UnitEnum $tag = null): TestingOAuthClient + public function fake(OAuthUser $user, string|UnitEnum|null $tag = null): TestingOAuthClient { $config = $this->container->get(OAuthConfig::class, $tag); $uri = $this->container->get(UriGenerator::class); diff --git a/packages/cache/src/Cache.php b/packages/cache/src/Cache.php index 19647a7146..ff4af7e8ba 100644 --- a/packages/cache/src/Cache.php +++ b/packages/cache/src/Cache.php @@ -24,12 +24,12 @@ interface Cache * @param null|Duration|DateTimeInterface $duration The duration for the lock, or an expiration date from which the duration will be calculated. If not specified, the lock will not expire. * @param null|Stringable|string $owner The owner of the lock, which will be used to identify the process releasing it. If not specified, a random string will be used. */ - public function lock(Stringable|string $key, null|Duration|DateTimeInterface $duration = null, null|Stringable|string $owner = null): Lock; + public function lock(Stringable|string $key, Duration|DateTimeInterface|null $duration = null, Stringable|string|null $owner = null): Lock; /** * Sets the specified key to the specified value in the cache. Optionally, specify an expiration. */ - public function put(Stringable|string $key, mixed $value, null|Duration|DateTimeInterface $expiration = null): CacheItemInterface; + public function put(Stringable|string $key, mixed $value, Duration|DateTimeInterface|null $expiration = null): CacheItemInterface; /** * Sets the specified keys to the specified values in the cache. Optionally, specify an expiration. @@ -40,7 +40,7 @@ public function put(Stringable|string $key, mixed $value, null|Duration|DateTime * @param iterable $values * @return array */ - public function putMany(iterable $values, null|Duration|DateTimeInterface $expiration = null): array; + public function putMany(iterable $values, Duration|DateTimeInterface|null $expiration = null): array; /** * Gets the value associated with the specified key from the cache. If the key does not exist, null is returned. @@ -77,7 +77,7 @@ public function decrement(Stringable|string $key, int $by = 1): int; * * @param null|Duration $stale Allow the value to be stale for the specified amount of time in addition to the time-to-live specified by `$expiration`. When a value is stale, it will still be returned as-is, but it will be refreshed in the background. */ - public function resolve(Stringable|string $key, Closure $callback, null|Duration|DateTimeInterface $expiration = null, ?Duration $stale = null): mixed; + public function resolve(Stringable|string $key, Closure $callback, Duration|DateTimeInterface|null $expiration = null, ?Duration $stale = null): mixed; /** * Removes the specified key from the cache. diff --git a/packages/cache/src/CacheInitializer.php b/packages/cache/src/CacheInitializer.php index 685c98c70f..0388109c9e 100644 --- a/packages/cache/src/CacheInitializer.php +++ b/packages/cache/src/CacheInitializer.php @@ -17,13 +17,13 @@ final readonly class CacheInitializer implements DynamicInitializer { - public function canInitialize(ClassReflector $class, null|string|UnitEnum $tag): bool + public function canInitialize(ClassReflector $class, string|UnitEnum|null $tag): bool { return $class->getType()->matches(Cache::class); } #[Singleton] - public function initialize(ClassReflector $class, null|string|UnitEnum $tag, Container $container): Cache + public function initialize(ClassReflector $class, string|UnitEnum|null $tag, Container $container): Cache { $config = $container->get(CacheConfig::class, $tag); @@ -35,7 +35,7 @@ public function initialize(ClassReflector $class, null|string|UnitEnum $tag, Con ); } - private function shouldCacheBeEnabled(null|string|UnitEnum $tag): bool + private function shouldCacheBeEnabled(string|UnitEnum|null $tag): bool { $globalCacheEnabled = (bool) env('CACHE_ENABLED', default: true); diff --git a/packages/cache/src/Config/CustomCacheConfig.php b/packages/cache/src/Config/CustomCacheConfig.php index d1f01b3d1c..d1a59b236c 100644 --- a/packages/cache/src/Config/CustomCacheConfig.php +++ b/packages/cache/src/Config/CustomCacheConfig.php @@ -22,7 +22,7 @@ public function __construct( /* * Identifies the {@see \Tempest\Cache\Cache} instance in the container, in case you need more than one configuration. */ - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} public function createAdapter(Container $container): AdapterInterface diff --git a/packages/cache/src/Config/FilesystemCacheConfig.php b/packages/cache/src/Config/FilesystemCacheConfig.php index 3aa09205b8..e39fb42fcf 100644 --- a/packages/cache/src/Config/FilesystemCacheConfig.php +++ b/packages/cache/src/Config/FilesystemCacheConfig.php @@ -27,7 +27,7 @@ public function __construct( /* * Identifies the {@see \Tempest\Cache\Cache} instance in the container, in case you need more than one configuration. */ - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} public function createAdapter(Container $container): FilesystemAdapter diff --git a/packages/cache/src/Config/InMemoryCacheConfig.php b/packages/cache/src/Config/InMemoryCacheConfig.php index afae826312..375563e475 100644 --- a/packages/cache/src/Config/InMemoryCacheConfig.php +++ b/packages/cache/src/Config/InMemoryCacheConfig.php @@ -16,7 +16,7 @@ public function __construct( /* * Identifies the {@see \Tempest\Cache\Cache} instance in the container, in case you need more than one configuration. */ - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} public function createAdapter(Container $container): ArrayAdapter diff --git a/packages/cache/src/Config/PhpCacheConfig.php b/packages/cache/src/Config/PhpCacheConfig.php index 85874b4346..2476320667 100644 --- a/packages/cache/src/Config/PhpCacheConfig.php +++ b/packages/cache/src/Config/PhpCacheConfig.php @@ -27,7 +27,7 @@ public function __construct( /* * Identifies the {@see \Tempest\Cache\Cache} instance in the container, in case you need more than one configuration. */ - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} public function createAdapter(Container $container): PhpFilesAdapter diff --git a/packages/cache/src/Config/RedisCacheConfig.php b/packages/cache/src/Config/RedisCacheConfig.php index 8c8dfb0ac4..df4838f525 100644 --- a/packages/cache/src/Config/RedisCacheConfig.php +++ b/packages/cache/src/Config/RedisCacheConfig.php @@ -21,7 +21,7 @@ public function __construct( /* * Identifies the {@see \Tempest\Cache\Cache} instance in the container, in case you need more than one configuration. */ - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} public function createAdapter(Container $container): RedisAdapter diff --git a/packages/cache/src/GenericCache.php b/packages/cache/src/GenericCache.php index b22329bcaa..3750d06fd9 100644 --- a/packages/cache/src/GenericCache.php +++ b/packages/cache/src/GenericCache.php @@ -20,10 +20,10 @@ public function __construct( private(set) CacheItemPoolInterface $adapter, public bool $enabled = true, private ?DeferredTasks $deferredTasks = null, - public null|UnitEnum|string $tag = null, + public UnitEnum|string|null $tag = null, ) {} - public function lock(Stringable|string $key, null|Duration|DateTimeInterface $duration = null, null|Stringable|string $owner = null): Lock + public function lock(Stringable|string $key, Duration|DateTimeInterface|null $duration = null, Stringable|string|null $owner = null): Lock { if ($duration instanceof DateTimeInterface) { $duration = $duration->since(DateTime::now()); @@ -46,7 +46,7 @@ public function has(Stringable|string $key): bool return $this->adapter->getItem((string) $key)->isHit(); } - public function put(Stringable|string $key, mixed $value, null|Duration|DateTimeInterface $expiration = null): CacheItemInterface + public function put(Stringable|string $key, mixed $value, Duration|DateTimeInterface|null $expiration = null): CacheItemInterface { $item = $this->adapter ->getItem((string) $key) @@ -67,7 +67,7 @@ public function put(Stringable|string $key, mixed $value, null|Duration|DateTime return $item; } - public function putMany(iterable $values, null|Duration|DateTimeInterface $expiration = null): array + public function putMany(iterable $values, Duration|DateTimeInterface|null $expiration = null): array { $items = []; @@ -144,7 +144,7 @@ public function getMany(iterable $key): array ); } - public function resolve(Stringable|string $key, Closure $callback, null|Duration|DateTimeInterface $expiration = null, ?Duration $stale = null): mixed + public function resolve(Stringable|string $key, Closure $callback, Duration|DateTimeInterface|null $expiration = null, ?Duration $stale = null): mixed { if (! $this->enabled) { return $callback(); diff --git a/packages/cache/src/GenericLock.php b/packages/cache/src/GenericLock.php index c752845539..6f2da2f564 100644 --- a/packages/cache/src/GenericLock.php +++ b/packages/cache/src/GenericLock.php @@ -17,7 +17,7 @@ public function __construct( private(set) ?Duration $duration = null, ) {} - public function locked(null|Stringable|string $by = null): bool + public function locked(Stringable|string|null $by = null): bool { if ($by === null) { return $this->cache->has($this->key); @@ -45,7 +45,7 @@ public function acquire(): bool return $this->cache->get($this->key) === $this->owner; } - public function execute(Closure $callback, null|DateTimeInterface|Duration $wait = null): mixed + public function execute(Closure $callback, DateTimeInterface|Duration|null $wait = null): mixed { $wait ??= Datetime::now(); $waitUntil = $wait instanceof Duration diff --git a/packages/cache/src/Lock.php b/packages/cache/src/Lock.php index e6ad9fc2ed..005f01c2c1 100644 --- a/packages/cache/src/Lock.php +++ b/packages/cache/src/Lock.php @@ -32,7 +32,7 @@ public function acquire(): bool; /** * Checks if the lock is currently held. */ - public function locked(null|Stringable|string $by = null): bool; + public function locked(Stringable|string|null $by = null): bool; /** * Executes the given callback while holding the lock. @@ -44,7 +44,7 @@ public function locked(null|Stringable|string $by = null): bool; * * @return TReturn The result of the callback. */ - public function execute(Closure $callback, null|DateTimeInterface|Duration $wait = null): mixed; + public function execute(Closure $callback, DateTimeInterface|Duration|null $wait = null): mixed; /** * Releases the lock. diff --git a/packages/cache/src/Testing/CacheTester.php b/packages/cache/src/Testing/CacheTester.php index c8023a706f..b547092e40 100644 --- a/packages/cache/src/Testing/CacheTester.php +++ b/packages/cache/src/Testing/CacheTester.php @@ -20,7 +20,7 @@ public function __construct( /** * Forces the usage of a testing cache. */ - public function fake(null|string|UnitEnum $tag = null): TestingCache + public function fake(string|UnitEnum|null $tag = null): TestingCache { $cache = new TestingCache( tag: Str\to_kebab_case(Str\parse($tag, default: 'default')), diff --git a/packages/cache/src/Testing/RestrictedCache.php b/packages/cache/src/Testing/RestrictedCache.php index a5b5526975..b5a27c57ab 100644 --- a/packages/cache/src/Testing/RestrictedCache.php +++ b/packages/cache/src/Testing/RestrictedCache.php @@ -17,7 +17,7 @@ final class RestrictedCache implements Cache public bool $enabled; public function __construct( - private null|string|UnitEnum $tag = null, + private string|UnitEnum|null $tag = null, ) {} private function resolveTag(): ?string @@ -25,7 +25,7 @@ private function resolveTag(): ?string return $this->tag instanceof UnitEnum ? $this->tag->name : $this->tag; } - public function lock(Stringable|string $key, null|Duration|DateTimeInterface $duration = null, null|Stringable|string $owner = null): Lock + public function lock(Stringable|string $key, Duration|DateTimeInterface|null $duration = null, Stringable|string|null $owner = null): Lock { throw new CacheUsageWasForbidden($this->resolveTag()); } @@ -35,12 +35,12 @@ public function has(Stringable|string $key): bool throw new CacheUsageWasForbidden($this->resolveTag()); } - public function put(Stringable|string $key, mixed $value, null|Duration|DateTimeInterface $expiration = null): CacheItemInterface + public function put(Stringable|string $key, mixed $value, Duration|DateTimeInterface|null $expiration = null): CacheItemInterface { throw new CacheUsageWasForbidden($this->resolveTag()); } - public function putMany(iterable $values, null|Duration|DateTimeInterface $expiration = null): array + public function putMany(iterable $values, Duration|DateTimeInterface|null $expiration = null): array { throw new CacheUsageWasForbidden($this->resolveTag()); } @@ -65,7 +65,7 @@ public function getMany(iterable $key): array throw new CacheUsageWasForbidden($this->resolveTag()); } - public function resolve(Stringable|string $key, Closure $callback, null|Duration|DateTimeInterface $expiration = null, ?Duration $stale = null): mixed + public function resolve(Stringable|string $key, Closure $callback, Duration|DateTimeInterface|null $expiration = null, ?Duration $stale = null): mixed { throw new CacheUsageWasForbidden($this->resolveTag()); } diff --git a/packages/cache/src/Testing/RestrictedCacheInitializer.php b/packages/cache/src/Testing/RestrictedCacheInitializer.php index ae4e9b9d7b..9f403d042d 100644 --- a/packages/cache/src/Testing/RestrictedCacheInitializer.php +++ b/packages/cache/src/Testing/RestrictedCacheInitializer.php @@ -13,13 +13,13 @@ #[SkipDiscovery] final class RestrictedCacheInitializer implements DynamicInitializer { - public function canInitialize(ClassReflector $class, null|string|UnitEnum $tag): bool + public function canInitialize(ClassReflector $class, string|UnitEnum|null $tag): bool { return $class->getType()->matches(Cache::class); } #[Singleton] - public function initialize(ClassReflector $class, null|string|UnitEnum $tag, Container $container): Cache + public function initialize(ClassReflector $class, string|UnitEnum|null $tag, Container $container): Cache { return new RestrictedCache($tag); } diff --git a/packages/cache/src/Testing/TestingCache.php b/packages/cache/src/Testing/TestingCache.php index 72748ac153..c1fd180ac1 100644 --- a/packages/cache/src/Testing/TestingCache.php +++ b/packages/cache/src/Testing/TestingCache.php @@ -39,7 +39,7 @@ public function __construct( $this->cache = new GenericCache($this->adapter); } - public function lock(Stringable|string $key, null|Duration|DateTimeInterface $duration = null, null|Stringable|string $owner = null): TestingLock + public function lock(Stringable|string $key, Duration|DateTimeInterface|null $duration = null, Stringable|string|null $owner = null): TestingLock { if ($duration instanceof DateTimeInterface) { $duration = $duration->since(DateTime::now()); @@ -58,12 +58,12 @@ public function has(Stringable|string $key): bool return $this->cache->has($key); } - public function put(Stringable|string $key, mixed $value, null|Duration|DateTimeInterface $expiration = null): CacheItemInterface + public function put(Stringable|string $key, mixed $value, Duration|DateTimeInterface|null $expiration = null): CacheItemInterface { return $this->cache->put($key, $value, $expiration); } - public function putMany(iterable $values, null|Duration|DateTimeInterface $expiration = null): array + public function putMany(iterable $values, Duration|DateTimeInterface|null $expiration = null): array { return $this->cache->putMany($values, $expiration); } @@ -88,7 +88,7 @@ public function getMany(iterable $key): array return $this->cache->getMany($key); } - public function resolve(Stringable|string $key, Closure $callback, null|Duration|DateTimeInterface $expiration = null, ?Duration $stale = null): mixed + public function resolve(Stringable|string $key, Closure $callback, Duration|DateTimeInterface|null $expiration = null, ?Duration $stale = null): mixed { return $this->cache->resolve($key, $callback, $expiration, $stale); } @@ -196,7 +196,7 @@ public function assertNotEmpty(): self /** * Asserts that the specified lock is being held. */ - public function assertLocked(string|Stringable $key, null|Stringable|string $by = null, null|DateTimeInterface|Duration $for = null): self + public function assertLocked(string|Stringable $key, Stringable|string|null $by = null, DateTimeInterface|Duration|null $for = null): self { $this->lock($key)->assertLocked($by, $for); @@ -206,7 +206,7 @@ public function assertLocked(string|Stringable $key, null|Stringable|string $by /** * Asserts that the specified lock is not being held. */ - public function assertNotLocked(string|Stringable $key, null|Stringable|string $by = null): self + public function assertNotLocked(string|Stringable $key, Stringable|string|null $by = null): self { $this->lock($key)->assertNotLocked($by); diff --git a/packages/cache/src/Testing/TestingLock.php b/packages/cache/src/Testing/TestingLock.php index 73bb7f98b3..cbec57d9c3 100644 --- a/packages/cache/src/Testing/TestingLock.php +++ b/packages/cache/src/Testing/TestingLock.php @@ -34,12 +34,12 @@ public function acquire(): bool return $this->lock->acquire(); } - public function locked(null|Stringable|string $by = null): bool + public function locked(Stringable|string|null $by = null): bool { return $this->lock->locked($by); } - public function execute(Closure $callback, null|DateTimeInterface|Duration $wait = null): mixed + public function execute(Closure $callback, DateTimeInterface|Duration|null $wait = null): mixed { return $this->lock->execute($callback, $wait); } @@ -52,7 +52,7 @@ public function release(bool $force = false): bool /** * Asserts that the specified lock is being held. */ - public function assertLocked(null|Stringable|string $by = null, null|DateTimeInterface|Duration $for = null): self + public function assertLocked(Stringable|string|null $by = null, DateTimeInterface|Duration|null $for = null): self { Assert::assertTrue( condition: $this->locked($by), @@ -83,7 +83,7 @@ public function assertLocked(null|Stringable|string $by = null, null|DateTimeInt /** * Asserts that the specified lock is not being held. */ - public function assertNotLocked(null|Stringable|string $by = null): self + public function assertNotLocked(Stringable|string|null $by = null): self { Assert::assertFalse( condition: $this->locked($by), diff --git a/packages/console/src/Components/Interactive/SearchComponent.php b/packages/console/src/Components/Interactive/SearchComponent.php index 055e4bdf1e..e5df7c1751 100644 --- a/packages/console/src/Components/Interactive/SearchComponent.php +++ b/packages/console/src/Components/Interactive/SearchComponent.php @@ -42,7 +42,7 @@ public function __construct( public string $label, public Closure $search, public bool $multiple = false, - public null|array|string $default = null, + public array|string|null $default = null, ) { $this->bufferEnabled = ! $this->multiple; $this->buffer = new TextBuffer(); diff --git a/packages/console/src/Components/Interactive/SingleChoiceComponent.php b/packages/console/src/Components/Interactive/SingleChoiceComponent.php index 75c4100f2b..ae5b30ca6f 100644 --- a/packages/console/src/Components/Interactive/SingleChoiceComponent.php +++ b/packages/console/src/Components/Interactive/SingleChoiceComponent.php @@ -37,7 +37,7 @@ final class SingleChoiceComponent implements InteractiveConsoleComponent, HasCur public function __construct( public string $label, iterable $options, - public null|int|UnitEnum|string $default = null, + public int|UnitEnum|string|null $default = null, ) { $this->bufferEnabled = false; $this->options = new OptionCollection($options); @@ -137,7 +137,7 @@ public function input(string $key): void } #[HandlesKey(Key::ENTER)] - public function enter(): null|int|string|Stringable|UnitEnum + public function enter(): int|string|Stringable|UnitEnum|null { return $this->options->getRawActiveOption($this->default); } diff --git a/packages/console/src/Components/Interactive/TaskComponent.php b/packages/console/src/Components/Interactive/TaskComponent.php index 8e30a6f6c3..5d39118c3f 100644 --- a/packages/console/src/Components/Interactive/TaskComponent.php +++ b/packages/console/src/Components/Interactive/TaskComponent.php @@ -50,7 +50,7 @@ final class TaskComponent implements InteractiveConsoleComponent, HasStaticCompo public function __construct( readonly string $label, - private null|Process|Closure $handler = null, + private Process|Closure|null $handler = null, ) { $this->startedAt = hrtime(as_number: true); $this->renderer = new TaskRenderer(new SpinnerRenderer(), $label); @@ -166,7 +166,7 @@ private function executeHandler(): never } } - private function resolveHandler(null|Process|Closure $handler): ?Closure + private function resolveHandler(Process|Closure|null $handler): ?Closure { if ($handler === null) { return null; diff --git a/packages/console/src/Components/Interactive/TextInputComponent.php b/packages/console/src/Components/Interactive/TextInputComponent.php index 18ef12e1e2..18fb1cb56b 100644 --- a/packages/console/src/Components/Interactive/TextInputComponent.php +++ b/packages/console/src/Components/Interactive/TextInputComponent.php @@ -30,7 +30,7 @@ final class TextInputComponent implements InteractiveConsoleComponent, HasCursor public function __construct( public string $label, - public null|int|string $default = null, + public int|string|null $default = null, public ?string $placeholder = null, public ?string $hint = null, bool $multiline = false, diff --git a/packages/console/src/Components/OptionCollection.php b/packages/console/src/Components/OptionCollection.php index 2fbee8b6cc..ad922e0393 100644 --- a/packages/console/src/Components/OptionCollection.php +++ b/packages/console/src/Components/OptionCollection.php @@ -178,7 +178,7 @@ public function getActive(): ?Option return $this->filteredOptions[$this->activeOption] ?? null; } - public function setActive(null|Stringable|UnitEnum|string $value): void + public function setActive(Stringable|UnitEnum|string|null $value): void { $value = match (true) { $value instanceof Stringable => $value->__toString(), diff --git a/packages/console/src/Components/Renderers/ChoiceRenderer.php b/packages/console/src/Components/Renderers/ChoiceRenderer.php index bceb85f73c..4f186769a2 100644 --- a/packages/console/src/Components/Renderers/ChoiceRenderer.php +++ b/packages/console/src/Components/Renderers/ChoiceRenderer.php @@ -19,7 +19,7 @@ final class ChoiceRenderer public function __construct( private bool $multiple = true, private int $maximumOptions = 10, - private null|Stringable|UnitEnum|string $default = null, + private Stringable|UnitEnum|string|null $default = null, ) {} public function render( diff --git a/packages/console/src/Components/Renderers/KeyValueRenderer.php b/packages/console/src/Components/Renderers/KeyValueRenderer.php index 98a96f1f23..dbe945b471 100644 --- a/packages/console/src/Components/Renderers/KeyValueRenderer.php +++ b/packages/console/src/Components/Renderers/KeyValueRenderer.php @@ -16,7 +16,7 @@ public const int MIN_WIDTH = 3; - public function render(Stringable|string $key, null|Stringable|string $value = null, bool $useAvailableWidth = false): string + public function render(Stringable|string $key, Stringable|string|null $value = null, bool $useAvailableWidth = false): string { $key = $this->cleanText($key)->append(' '); $value = $this->cleanText($value)->when( @@ -48,7 +48,7 @@ private function getTerminalWidth(): int return (int) $width - 5; } - private function cleanText(null|Stringable|string $text): ImmutableString + private function cleanText(Stringable|string|null $text): ImmutableString { $text = new ImmutableString($text)->trim(); diff --git a/packages/console/src/Components/Static/StaticSearchComponent.php b/packages/console/src/Components/Static/StaticSearchComponent.php index ba62597aa6..42da6cf268 100644 --- a/packages/console/src/Components/Static/StaticSearchComponent.php +++ b/packages/console/src/Components/Static/StaticSearchComponent.php @@ -20,14 +20,14 @@ public function __construct( public readonly string $label, public readonly Closure $search, public readonly bool $multiple = false, - public null|array|string $default = null, + public array|string|null $default = null, ) { if ($this->multiple) { $this->default = wrap($this->default); } } - public function render(Console $console): null|array|string + public function render(Console $console): array|string|null { if (! $console->supportsPrompting()) { return $this->default; diff --git a/packages/console/src/Components/Static/StaticSingleChoiceComponent.php b/packages/console/src/Components/Static/StaticSingleChoiceComponent.php index 6a923ab5ec..897884e959 100644 --- a/packages/console/src/Components/Static/StaticSingleChoiceComponent.php +++ b/packages/console/src/Components/Static/StaticSingleChoiceComponent.php @@ -19,12 +19,12 @@ public function __construct( public string $label, iterable $options, - public null|int|UnitEnum|string $default = null, + public int|UnitEnum|string|null $default = null, ) { $this->options = new OptionCollection($options); } - public function render(Console $console): null|int|UnitEnum|string + public function render(Console $console): int|UnitEnum|string|null { if (! $console->supportsPrompting()) { return $this->default; diff --git a/packages/console/src/Components/Static/StaticTaskComponent.php b/packages/console/src/Components/Static/StaticTaskComponent.php index ff92978aa3..4262bf3426 100644 --- a/packages/console/src/Components/Static/StaticTaskComponent.php +++ b/packages/console/src/Components/Static/StaticTaskComponent.php @@ -15,7 +15,7 @@ final class StaticTaskComponent implements StaticConsoleComponent { public function __construct( readonly string $label, - private null|Process|Closure $handler = null, + private Process|Closure|null $handler = null, ) {} public function render(Console $console): bool diff --git a/packages/console/src/Console.php b/packages/console/src/Console.php index 57875c72d4..0e86223202 100644 --- a/packages/console/src/Console.php +++ b/packages/console/src/Console.php @@ -59,14 +59,14 @@ public function component(InteractiveConsoleComponent $component, array $validat */ public function ask( string $question, - null|iterable|string $options = null, + iterable|string|null $options = null, mixed $default = null, bool $multiple = false, bool $multiline = false, ?string $placeholder = null, ?string $hint = null, array $validation = [], - ): null|int|string|Stringable|UnitEnum|array; + ): int|string|Stringable|UnitEnum|array|null; /** * Asks the user a question and returns the answer. @@ -88,12 +88,12 @@ public function progressBar(iterable $data, Closure $handler): array; * * @param Closure(string $search): array $search */ - public function search(string $label, Closure $search, bool $multiple = false, null|string|array $default = null): mixed; + public function search(string $label, Closure $search, bool $multiple = false, string|array|null $default = null): mixed; /** * Displays the progress of a task. */ - public function task(string $label, null|Process|Closure $handler): bool; + public function task(string $label, Process|Closure|null $handler): bool; /** * Displays a header. diff --git a/packages/console/src/GenericConsole.php b/packages/console/src/GenericConsole.php index a00fb2f1b8..ff416ecc70 100644 --- a/packages/console/src/GenericConsole.php +++ b/packages/console/src/GenericConsole.php @@ -207,14 +207,14 @@ public function component(InteractiveConsoleComponent $component, array $validat public function ask( string $question, - null|iterable|string $options = null, + iterable|string|null $options = null, mixed $default = null, bool $multiple = false, bool $multiline = false, ?string $placeholder = null, ?string $hint = null, array $validation = [], - ): null|int|string|Stringable|UnitEnum|array { + ): int|string|Stringable|UnitEnum|array|null { if ($this->isForced && $default) { return $default; } @@ -293,12 +293,12 @@ public function progressBar(iterable $data, Closure $handler): array return $this->component(new ProgressBarComponent($data, $handler)); } - public function task(string $label, null|Process|Closure $handler = null): bool + public function task(string $label, Process|Closure|null $handler = null): bool { return $this->component(new TaskComponent($label, $handler)); } - public function search(string $label, Closure $search, bool $multiple = false, null|string|array $default = null): mixed + public function search(string $label, Closure $search, bool $multiple = false, string|array|null $default = null): mixed { return $this->component(new SearchComponent($label, $search, $multiple, $default)); } diff --git a/packages/console/src/HasConsole.php b/packages/console/src/HasConsole.php index 7bd8432dcd..1316c48458 100644 --- a/packages/console/src/HasConsole.php +++ b/packages/console/src/HasConsole.php @@ -45,14 +45,14 @@ public function writeln(string $line = ''): self */ public function ask( string $question, - null|iterable|string $options = null, + iterable|string|null $options = null, mixed $default = null, bool $multiple = false, bool $multiline = false, ?string $placeholder = null, ?string $hint = null, array $validation = [], - ): null|int|string|Stringable|UnitEnum|array { + ): int|string|Stringable|UnitEnum|array|null { return $this->console->ask( question: $question, options: $options, @@ -99,7 +99,7 @@ public function progressBar(iterable $data, Closure $handler): array /** * @param Closure(string $search): array $search */ - public function search(string $label, Closure $search, bool $multiple = false, null|string|array $default = null): mixed + public function search(string $label, Closure $search, bool $multiple = false, string|array|null $default = null): mixed { return $this->console->search( label: $label, @@ -151,7 +151,7 @@ public function header(string $header, ?string $subheader = null): self return $this; } - public function task(string $label, null|Process|Closure $handler): bool + public function task(string $label, Process|Closure|null $handler): bool { return $this->console->task($label, $handler); } diff --git a/packages/container/src/Container.php b/packages/container/src/Container.php index 01a99fb705..dba11e198a 100644 --- a/packages/container/src/Container.php +++ b/packages/container/src/Container.php @@ -16,7 +16,7 @@ public function register(string $className, callable $definition): self; public function unregister(string $className, bool $tagged = false): self; - public function singleton(string $className, mixed $definition, null|string|UnitEnum $tag = null): self; + public function singleton(string $className, mixed $definition, string|UnitEnum|null $tag = null): self; public function config(object $config): self; @@ -25,9 +25,9 @@ public function config(object $config): self; * @param class-string $className * @return TClassName */ - public function get(string $className, null|string|UnitEnum $tag = null, mixed ...$params): mixed; + public function get(string $className, string|UnitEnum|null $tag = null, mixed ...$params): mixed; - public function has(string $className, null|string|UnitEnum $tag = null): bool; + public function has(string $className, string|UnitEnum|null $tag = null): bool; public function invoke(ClassReflector|MethodReflector|FunctionReflector|callable|string $method, mixed ...$params): mixed; diff --git a/packages/container/src/DynamicInitializer.php b/packages/container/src/DynamicInitializer.php index f650e83186..6bfe2aefe6 100644 --- a/packages/container/src/DynamicInitializer.php +++ b/packages/container/src/DynamicInitializer.php @@ -9,7 +9,7 @@ interface DynamicInitializer { - public function canInitialize(ClassReflector $class, null|string|UnitEnum $tag): bool; + public function canInitialize(ClassReflector $class, string|UnitEnum|null $tag): bool; - public function initialize(ClassReflector $class, null|string|UnitEnum $tag, Container $container): object; + public function initialize(ClassReflector $class, string|UnitEnum|null $tag, Container $container): object; } diff --git a/packages/container/src/GenericContainer.php b/packages/container/src/GenericContainer.php index 12e2538cc4..8ee0c5acbf 100644 --- a/packages/container/src/GenericContainer.php +++ b/packages/container/src/GenericContainer.php @@ -168,12 +168,12 @@ public function unregister(string $className, bool $tagged = false): self return $this; } - public function has(string $className, null|string|UnitEnum $tag = null): bool + public function has(string $className, string|UnitEnum|null $tag = null): bool { return isset($this->definitions[$className]) || isset($this->singletonDefinitions[$this->resolveTaggedName($className, $tag)]); } - public function singleton(string $className, mixed $definition, null|string|UnitEnum $tag = null): self + public function singleton(string $className, mixed $definition, string|UnitEnum|null $tag = null): self { if ($definition instanceof HasTag) { $tag = $definition->tag; @@ -205,7 +205,7 @@ public function config(object $config): self * @throws CircularDependencyEncountered * @throws TaggedDependencyCouldNotBeResolved */ - public function get(string $className, null|string|UnitEnum $tag = null, mixed ...$params): object + public function get(string $className, string|UnitEnum|null $tag = null, mixed ...$params): object { $this->resolveChain(); @@ -354,7 +354,7 @@ public function addDecorator(ClassReflector|string $decoratorClass, ClassReflect return $this; } - private function resolve(string $className, null|string|UnitEnum $tag = null, mixed ...$params): object + private function resolve(string $className, string|UnitEnum|null $tag = null, mixed ...$params): object { $instance = $this->resolveDependency($className, $tag, ...$params); @@ -365,7 +365,7 @@ private function resolve(string $className, null|string|UnitEnum $tag = null, mi return $instance; } - private function resolveDependency(string $className, null|string|UnitEnum $tag = null, mixed ...$params): object + private function resolveDependency(string $className, string|UnitEnum|null $tag = null, mixed ...$params): object { $class = new ClassReflector($className); @@ -434,7 +434,7 @@ private function initializerForBuiltin(TypeReflector $target, string $tag): ?Ini return null; } - private function initializerForClass(ClassReflector $target, null|string|UnitEnum $tag = null): null|Initializer|DynamicInitializer + private function initializerForClass(ClassReflector $target, string|UnitEnum|null $tag = null): Initializer|DynamicInitializer|null { // Initializers themselves can't be initialized, // otherwise you'd end up with infinite loops @@ -536,7 +536,7 @@ private function autowireDependencies(MethodReflector|FunctionReflector $method, return $dependencies; } - private function autowireDependency(ParameterReflector $parameter, null|string|UnitEnum $tag, mixed $providedValue = null): mixed + private function autowireDependency(ParameterReflector $parameter, string|UnitEnum|null $tag, mixed $providedValue = null): mixed { $parameterType = $parameter->getType(); @@ -576,7 +576,7 @@ private function autowireDependency(ParameterReflector $parameter, null|string|U throw $lastThrowable ?? new DependencyCouldNotBeAutowired($this->chain, new Dependency($parameter)); } - private function autowireObjectDependency(TypeReflector $type, null|string|UnitEnum $tag, mixed $providedValue, bool $lazy): mixed + private function autowireObjectDependency(TypeReflector $type, string|UnitEnum|null $tag, mixed $providedValue, bool $lazy): mixed { // If the provided value is of the right type, // don't waste time autowiring, return it! @@ -671,7 +671,7 @@ public function __clone(): void $this->chain = $this->chain?->clone(); } - private function resolveTaggedName(string $className, null|string|UnitEnum $tag): string + private function resolveTaggedName(string $className, string|UnitEnum|null $tag): string { if ($tag instanceof UnitEnum) { $tag = $tag->name; @@ -682,7 +682,7 @@ private function resolveTaggedName(string $className, null|string|UnitEnum $tag) : $className; } - private function resolveDecorator(string $className, mixed $instance, null|string|UnitEnum $tag = null, mixed ...$params): object + private function resolveDecorator(string $className, mixed $instance, string|UnitEnum|null $tag = null, mixed ...$params): object { foreach ($this->decorators[$className] ?? [] as $decoratorClass) { $decoratorClassReflector = new ClassReflector($decoratorClass); diff --git a/packages/container/src/HasTag.php b/packages/container/src/HasTag.php index 535bccf5a6..77d03e65b9 100644 --- a/packages/container/src/HasTag.php +++ b/packages/container/src/HasTag.php @@ -6,5 +6,5 @@ interface HasTag { - public null|string|UnitEnum $tag { get; } + public string|UnitEnum|null $tag { get; } } diff --git a/packages/container/tests/Fixtures/ContainerObjectEInitializer.php b/packages/container/tests/Fixtures/ContainerObjectEInitializer.php index 243854660a..b5347c4cac 100644 --- a/packages/container/tests/Fixtures/ContainerObjectEInitializer.php +++ b/packages/container/tests/Fixtures/ContainerObjectEInitializer.php @@ -11,12 +11,12 @@ final class ContainerObjectEInitializer implements DynamicInitializer { - public function canInitialize(ClassReflector $class, null|string|UnitEnum $tag): bool + public function canInitialize(ClassReflector $class, string|UnitEnum|null $tag): bool { return $class->getName() === ContainerObjectE::class; } - public function initialize(ClassReflector $class, null|string|UnitEnum $tag, Container $container): object + public function initialize(ClassReflector $class, string|UnitEnum|null $tag, Container $container): object { return new ContainerObjectE(); } diff --git a/packages/container/tests/Fixtures/CountingDynamicInitializer.php b/packages/container/tests/Fixtures/CountingDynamicInitializer.php index 938683ff09..bae2a1a75f 100644 --- a/packages/container/tests/Fixtures/CountingDynamicInitializer.php +++ b/packages/container/tests/Fixtures/CountingDynamicInitializer.php @@ -20,7 +20,7 @@ public static function reset(): void self::$instances = 0; } - public function canInitialize(ClassReflector $class, null|string|UnitEnum $tag): bool + public function canInitialize(ClassReflector $class, string|UnitEnum|null $tag): bool { if (! $this->counted) { $this->counted = true; @@ -30,7 +30,7 @@ public function canInitialize(ClassReflector $class, null|string|UnitEnum $tag): return false; } - public function initialize(ClassReflector $class, null|string|UnitEnum $tag, Container $container): object + public function initialize(ClassReflector $class, string|UnitEnum|null $tag, Container $container): object { throw new \LogicException('CountingDynamicInitializer should not initialize objects.'); } diff --git a/packages/container/tests/Fixtures/HasTagObject.php b/packages/container/tests/Fixtures/HasTagObject.php index 367cb1d7bb..f4e640114c 100644 --- a/packages/container/tests/Fixtures/HasTagObject.php +++ b/packages/container/tests/Fixtures/HasTagObject.php @@ -9,6 +9,6 @@ final class HasTagObject implements HasTag { public function __construct( public string $name, - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} } diff --git a/packages/core/src/ConfigCache.php b/packages/core/src/ConfigCache.php index bc3a5c491d..dd5ea9d1bb 100644 --- a/packages/core/src/ConfigCache.php +++ b/packages/core/src/ConfigCache.php @@ -28,7 +28,7 @@ public function clear(): void $this->pool->clear(); } - public function put(string $key, mixed $value, null|Duration|DateTimeInterface $expiresAt = null): CacheItemInterface + public function put(string $key, mixed $value, Duration|DateTimeInterface|null $expiresAt = null): CacheItemInterface { $item = $this->pool ->getItem($key) @@ -49,7 +49,7 @@ public function put(string $key, mixed $value, null|Duration|DateTimeInterface $ return $item; } - public function resolve(string $key, Closure $callback, null|Duration|DateTimeInterface $expiresAt = null): mixed + public function resolve(string $key, Closure $callback, Duration|DateTimeInterface|null $expiresAt = null): mixed { if (! $this->enabled) { return $callback(); diff --git a/packages/cryptography/tests/HasMoreIntegerAssertions.php b/packages/cryptography/tests/HasMoreIntegerAssertions.php index 3c09587945..ca56c31aff 100644 --- a/packages/cryptography/tests/HasMoreIntegerAssertions.php +++ b/packages/cryptography/tests/HasMoreIntegerAssertions.php @@ -6,7 +6,7 @@ trait HasMoreIntegerAssertions { - private function assertEqualsToMoreOrLess(int|float $expected, int|float $actual, int|float $margin, null|int|float $windowsMargin = null): void + private function assertEqualsToMoreOrLess(int|float $expected, int|float $actual, int|float $margin, int|float|null $windowsMargin = null): void { if ($windowsMargin && PHP_OS_FAMILY === 'Windows') { $margin = $windowsMargin; diff --git a/packages/database/src/BelongsTo.php b/packages/database/src/BelongsTo.php index 2624608929..5c0aa46853 100644 --- a/packages/database/src/BelongsTo.php +++ b/packages/database/src/BelongsTo.php @@ -195,7 +195,7 @@ private function getOwnerJoin(ModelInspector $ownerModel): string ); } - public function query(PrimaryKey $primaryKey, null|string|UnitEnum $onDatabase = null): QueryBuilder + public function query(PrimaryKey $primaryKey, string|UnitEnum|null $onDatabase = null): QueryBuilder { $relatedClassName = $this->property->getType()->getName(); $relatedModel = inspect(model: $this->property->getType()->asClass()); diff --git a/packages/database/src/BelongsToMany.php b/packages/database/src/BelongsToMany.php index 12cf61c623..c666a43bed 100644 --- a/packages/database/src/BelongsToMany.php +++ b/packages/database/src/BelongsToMany.php @@ -398,7 +398,7 @@ public function getExistsStatement(): WhereExistsStatement ); } - public function query(PrimaryKey $primaryKey, null|string|UnitEnum $onDatabase = null): QueryBuilder + public function query(PrimaryKey $primaryKey, string|UnitEnum|null $onDatabase = null): QueryBuilder { $ownerModel = inspect(model: $this->property->getClass()); $targetModel = inspect(model: $this->property->getIterableType()->asClass()); diff --git a/packages/database/src/Builder/QueryBuilders/BuildsQuery.php b/packages/database/src/Builder/QueryBuilders/BuildsQuery.php index 9ec20e8857..901a726e45 100644 --- a/packages/database/src/Builder/QueryBuilders/BuildsQuery.php +++ b/packages/database/src/Builder/QueryBuilders/BuildsQuery.php @@ -26,7 +26,7 @@ interface BuildsQuery /** * The database tag for targeting a specific database connection. */ - public null|string|UnitEnum $onDatabase { get; } + public string|UnitEnum|null $onDatabase { get; } /** * Creates a {@see Query} instance with the specified optional bindings. diff --git a/packages/database/src/Builder/QueryBuilders/UpdateQueryBuilder.php b/packages/database/src/Builder/QueryBuilders/UpdateQueryBuilder.php index 8d0b128684..8557b54c54 100644 --- a/packages/database/src/Builder/QueryBuilders/UpdateQueryBuilder.php +++ b/packages/database/src/Builder/QueryBuilders/UpdateQueryBuilder.php @@ -652,10 +652,10 @@ public function whereField(string $field, mixed $value, string|WhereOperator $op $operator = WhereOperator::fromOperator($operator); if ( - $this->model->hasPrimaryKey() && $field === $this->model->getPrimaryKey() && $this->hasRelationUpdates() && ( - $operator === WhereOperator::EQUALS - && (is_string($value) || is_int($value) || $value instanceof PrimaryKey) - ) + $this->model->hasPrimaryKey() + && $field === $this->model->getPrimaryKey() + && $this->hasRelationUpdates() + && ($operator === WhereOperator::EQUALS && (is_string($value) || is_int($value) || $value instanceof PrimaryKey)) ) { $this->primaryKeyForRelations = new PrimaryKey($value); } diff --git a/packages/database/src/Config/MysqlConfig.php b/packages/database/src/Config/MysqlConfig.php index e146df0343..56a6b6724e 100644 --- a/packages/database/src/Config/MysqlConfig.php +++ b/packages/database/src/Config/MysqlConfig.php @@ -97,6 +97,6 @@ public function __construct( public ?string $clientKey = null, public NamingStrategy $namingStrategy = new PluralizedSnakeCaseStrategy(), public MigrationNamingStrategy $migrationNaming = new DatePrefixStrategy(), - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} } diff --git a/packages/database/src/Config/PostgresConfig.php b/packages/database/src/Config/PostgresConfig.php index 173b1475f9..7112e80061 100644 --- a/packages/database/src/Config/PostgresConfig.php +++ b/packages/database/src/Config/PostgresConfig.php @@ -74,6 +74,6 @@ public function __construct( public bool $persistent = false, public NamingStrategy $namingStrategy = new PluralizedSnakeCaseStrategy(), public MigrationNamingStrategy $migrationNaming = new DatePrefixStrategy(), - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} } diff --git a/packages/database/src/Config/SQLiteConfig.php b/packages/database/src/Config/SQLiteConfig.php index 6b6cd72efd..f85d9ed115 100644 --- a/packages/database/src/Config/SQLiteConfig.php +++ b/packages/database/src/Config/SQLiteConfig.php @@ -66,6 +66,6 @@ public function __construct( public bool $persistent = false, public NamingStrategy $namingStrategy = new PluralizedSnakeCaseStrategy(), public MigrationNamingStrategy $migrationNaming = new DatePrefixStrategy(), - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} } diff --git a/packages/database/src/Database.php b/packages/database/src/Database.php index 966e492dee..26f54e601a 100644 --- a/packages/database/src/Database.php +++ b/packages/database/src/Database.php @@ -22,7 +22,7 @@ interface Database /** * The tag associated with this database, if any. */ - public null|string|UnitEnum $tag { get; } + public string|UnitEnum|null $tag { get; } /** * Executes the given query. diff --git a/packages/database/src/DatabaseInitializer.php b/packages/database/src/DatabaseInitializer.php index c3f59bbad4..39aacde011 100644 --- a/packages/database/src/DatabaseInitializer.php +++ b/packages/database/src/DatabaseInitializer.php @@ -18,13 +18,13 @@ final readonly class DatabaseInitializer implements DynamicInitializer { - public function canInitialize(ClassReflector $class, null|string|UnitEnum $tag): bool + public function canInitialize(ClassReflector $class, string|UnitEnum|null $tag): bool { return $class->getType()->matches(Database::class); } #[Singleton] - public function initialize(ClassReflector $class, null|string|UnitEnum $tag, Container $container): Database + public function initialize(ClassReflector $class, string|UnitEnum|null $tag, Container $container): Database { $container->singleton( className: Connection::class, diff --git a/packages/database/src/DatabaseSeeder.php b/packages/database/src/DatabaseSeeder.php index 3f6c754fa9..fa155d99db 100644 --- a/packages/database/src/DatabaseSeeder.php +++ b/packages/database/src/DatabaseSeeder.php @@ -6,5 +6,5 @@ interface DatabaseSeeder { - public function run(null|string|UnitEnum $database): void; + public function run(string|UnitEnum|null $database): void; } diff --git a/packages/database/src/GenericDatabase.php b/packages/database/src/GenericDatabase.php index 4dd5a09a81..c0382568e5 100644 --- a/packages/database/src/GenericDatabase.php +++ b/packages/database/src/GenericDatabase.php @@ -32,7 +32,7 @@ final class GenericDatabase implements Database get => $this->connection->config->dialect; } - public null|string|UnitEnum $tag { + public string|UnitEnum|null $tag { get => $this->connection->config->tag; } diff --git a/packages/database/src/HasMany.php b/packages/database/src/HasMany.php index 131ed75ed2..75685ad3aa 100644 --- a/packages/database/src/HasMany.php +++ b/packages/database/src/HasMany.php @@ -181,7 +181,7 @@ public function getExistsStatement(): WhereExistsStatement ); } - public function query(PrimaryKey $primaryKey, null|string|UnitEnum $onDatabase = null): QueryBuilder + public function query(PrimaryKey $primaryKey, string|UnitEnum|null $onDatabase = null): QueryBuilder { $relatedClassName = $this->property->getIterableType()->getName(); $parentModel = inspect(model: $this->property->getClass()); diff --git a/packages/database/src/HasManyThrough.php b/packages/database/src/HasManyThrough.php index 8ca17315fd..c06b1b9125 100644 --- a/packages/database/src/HasManyThrough.php +++ b/packages/database/src/HasManyThrough.php @@ -364,7 +364,7 @@ public function getExistsStatement(): WhereExistsStatement ); } - public function query(PrimaryKey $primaryKey, null|string|UnitEnum $onDatabase = null): QueryBuilder + public function query(PrimaryKey $primaryKey, string|UnitEnum|null $onDatabase = null): QueryBuilder { $relatedClassName = $this->property->getIterableType()->getName(); $ownerModel = inspect(model: $this->property->getClass()); diff --git a/packages/database/src/HasOne.php b/packages/database/src/HasOne.php index a21ec3fdd2..a5b4308e90 100644 --- a/packages/database/src/HasOne.php +++ b/packages/database/src/HasOne.php @@ -193,7 +193,7 @@ private function getRelationJoin(ModelInspector $relationModel): string ); } - public function query(PrimaryKey $primaryKey, null|string|UnitEnum $onDatabase = null): QueryBuilder + public function query(PrimaryKey $primaryKey, string|UnitEnum|null $onDatabase = null): QueryBuilder { $relatedClassName = $this->property->getType()->getName(); $parentModel = inspect(model: $this->property->getClass()); diff --git a/packages/database/src/HasOneThrough.php b/packages/database/src/HasOneThrough.php index 9cc553fad7..8f23cabafb 100644 --- a/packages/database/src/HasOneThrough.php +++ b/packages/database/src/HasOneThrough.php @@ -321,7 +321,7 @@ public function getExistsStatement(): WhereExistsStatement ); } - public function query(PrimaryKey $primaryKey, null|string|UnitEnum $onDatabase = null): QueryBuilder + public function query(PrimaryKey $primaryKey, string|UnitEnum|null $onDatabase = null): QueryBuilder { $relatedClassName = $this->property->getType()->getName(); $ownerModel = inspect(model: $this->property->getClass()); diff --git a/packages/database/src/IsDatabaseModel.php b/packages/database/src/IsDatabaseModel.php index ca6900397a..f94a1dd774 100644 --- a/packages/database/src/IsDatabaseModel.php +++ b/packages/database/src/IsDatabaseModel.php @@ -26,14 +26,14 @@ trait IsDatabaseModel public PrimaryKey $id; #[SkipValidation, Virtual] - private null|string|UnitEnum $onDatabase = null; + private string|UnitEnum|null $onDatabase = null; /** * Returns a query builder targeting the specified database connection. * * @return QueryBuilder */ - public static function on(null|string|UnitEnum $databaseTag): QueryBuilder + public static function on(string|UnitEnum|null $databaseTag): QueryBuilder { return self::queryBuilder()->onDatabase(databaseTag: $databaseTag); } @@ -41,7 +41,7 @@ public static function on(null|string|UnitEnum $databaseTag): QueryBuilder /** * Targets a specific database connection for this model instance. */ - public function onDatabase(null|string|UnitEnum $databaseTag): self + public function onDatabase(string|UnitEnum|null $databaseTag): self { $clone = clone $this; diff --git a/packages/database/src/OnDatabase.php b/packages/database/src/OnDatabase.php index d1a2912463..71fc92a4db 100644 --- a/packages/database/src/OnDatabase.php +++ b/packages/database/src/OnDatabase.php @@ -6,9 +6,9 @@ trait OnDatabase { - private(set) null|string|UnitEnum $onDatabase = null; + private(set) string|UnitEnum|null $onDatabase = null; - public function onDatabase(null|string|UnitEnum $databaseTag): self + public function onDatabase(string|UnitEnum|null $databaseTag): self { $clone = clone $this; diff --git a/packages/database/src/QueryExecuted.php b/packages/database/src/QueryExecuted.php index 2f1427ddc2..60cbc5738c 100644 --- a/packages/database/src/QueryExecuted.php +++ b/packages/database/src/QueryExecuted.php @@ -19,7 +19,7 @@ public function __construct( public string $sql, public array $bindings, public float $durationMs, - public null|string|UnitEnum $connectionName, + public string|UnitEnum|null $connectionName, public bool $failed, ) {} diff --git a/packages/database/src/QueryStatements/CanExecuteStatement.php b/packages/database/src/QueryStatements/CanExecuteStatement.php index 329ae55d8b..0c94fa5684 100644 --- a/packages/database/src/QueryStatements/CanExecuteStatement.php +++ b/packages/database/src/QueryStatements/CanExecuteStatement.php @@ -11,7 +11,7 @@ trait CanExecuteStatement { - public function execute(DatabaseDialect $dialect, null|string|UnitEnum $onDatabase): ?PrimaryKey + public function execute(DatabaseDialect $dialect, string|UnitEnum|null $onDatabase): ?PrimaryKey { $sql = $this->compile($dialect); diff --git a/packages/database/src/QueryStatements/CreateTableStatement.php b/packages/database/src/QueryStatements/CreateTableStatement.php index ec495ca68d..8e57ccf7a9 100644 --- a/packages/database/src/QueryStatements/CreateTableStatement.php +++ b/packages/database/src/QueryStatements/CreateTableStatement.php @@ -334,7 +334,7 @@ public function array(string $name, bool $nullable = false, array $default = []) /** * Adds an enum column to the table. Uses the `ENUM` type for MySQL, falls back to `TEXT` for SQLite, and uses a custom enum type for PostgreSQL. */ - public function enum(string $name, string $enumClass, bool $nullable = false, null|UnitEnum|BackedEnum $default = null): self + public function enum(string $name, string $enumClass, bool $nullable = false, UnitEnum|BackedEnum|null $default = null): self { $this->statements[] = new EnumStatement( name: $name, diff --git a/packages/database/src/QueryStatements/EnumStatement.php b/packages/database/src/QueryStatements/EnumStatement.php index afcbd27c1c..502b6d1177 100644 --- a/packages/database/src/QueryStatements/EnumStatement.php +++ b/packages/database/src/QueryStatements/EnumStatement.php @@ -19,7 +19,7 @@ public function __construct( /** @var class-string */ private string $enumClass, private bool $nullable = false, - private null|UnitEnum|BackedEnum $default = null, + private UnitEnum|BackedEnum|null $default = null, ) {} public function compile(DatabaseDialect $dialect): string diff --git a/packages/database/src/QueryStatements/FieldStatement.php b/packages/database/src/QueryStatements/FieldStatement.php index bad8067f27..2ad2eac153 100644 --- a/packages/database/src/QueryStatements/FieldStatement.php +++ b/packages/database/src/QueryStatements/FieldStatement.php @@ -10,7 +10,7 @@ final class FieldStatement implements QueryStatement { - private null|bool|string $alias = null; + private bool|string|null $alias = null; private ?string $aliasPrefix = null; diff --git a/packages/database/src/Relation.php b/packages/database/src/Relation.php index 911356a191..477707f7de 100644 --- a/packages/database/src/Relation.php +++ b/packages/database/src/Relation.php @@ -25,5 +25,5 @@ public function getJoinStatement(): JoinStatement; public function getExistsStatement(): WhereExistsStatement; - public function query(PrimaryKey $primaryKey, null|string|UnitEnum $onDatabase = null): QueryBuilder; + public function query(PrimaryKey $primaryKey, string|UnitEnum|null $onDatabase = null): QueryBuilder; } diff --git a/packages/datetime/src/DateTimeConvenienceMethods.php b/packages/datetime/src/DateTimeConvenienceMethods.php index b1a50acbbe..3fc235ac6a 100644 --- a/packages/datetime/src/DateTimeConvenienceMethods.php +++ b/packages/datetime/src/DateTimeConvenienceMethods.php @@ -927,7 +927,7 @@ public function isEndOfWeek(): bool * @see Locale::default() */ #[Override] - public function format(null|FormatPattern|string $pattern = null, ?Timezone $timezone = null, ?Locale $locale = null): string + public function format(FormatPattern|string|null $pattern = null, ?Timezone $timezone = null, ?Locale $locale = null): string { $timestamp = $this->getTimestamp(); diff --git a/packages/datetime/src/DateTimeInterface.php b/packages/datetime/src/DateTimeInterface.php index 837693c98c..80f8b66389 100644 --- a/packages/datetime/src/DateTimeInterface.php +++ b/packages/datetime/src/DateTimeInterface.php @@ -635,7 +635,7 @@ public function isEndOfWeek(): bool; * @see Locale::default() */ #[Override] - public function format(null|FormatPattern|string $pattern = null, ?Timezone $timezone = null, ?Locale $locale = null): string; + public function format(FormatPattern|string|null $pattern = null, ?Timezone $timezone = null, ?Locale $locale = null): string; /** * Provides a string representation of this {@see TemporalInterface} instance, formatted according to specified styles for date and time, diff --git a/packages/datetime/src/TemporalConvenienceMethods.php b/packages/datetime/src/TemporalConvenienceMethods.php index 99eae1d9c3..45ddccc093 100644 --- a/packages/datetime/src/TemporalConvenienceMethods.php +++ b/packages/datetime/src/TemporalConvenienceMethods.php @@ -461,7 +461,7 @@ public function convertToTimezone(?Timezone $timezone): DateTimeInterface * * @see https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax */ - public function format(null|FormatPattern|string $pattern = null, ?Timezone $timezone = null, ?Locale $locale = null): string + public function format(FormatPattern|string|null $pattern = null, ?Timezone $timezone = null, ?Locale $locale = null): string { $timestamp = $this->getTimestamp(); diff --git a/packages/datetime/src/TemporalInterface.php b/packages/datetime/src/TemporalInterface.php index 3b2c573d9d..e6faaad500 100644 --- a/packages/datetime/src/TemporalInterface.php +++ b/packages/datetime/src/TemporalInterface.php @@ -346,7 +346,7 @@ public function between(TemporalInterface $other): Duration; * @see Timezone::default() * @see Locale::default() */ - public function format(null|FormatPattern|string $pattern = null, ?Timezone $timezone = null, ?Locale $locale = null): string; + public function format(FormatPattern|string|null $pattern = null, ?Timezone $timezone = null, ?Locale $locale = null): string; /** * Formats this {@see TemporalInterface} instance to a string based on the RFC 3339 format, with additional diff --git a/packages/datetime/src/functions.php b/packages/datetime/src/functions.php index 40f83707ba..206d68aad5 100644 --- a/packages/datetime/src/functions.php +++ b/packages/datetime/src/functions.php @@ -80,7 +80,7 @@ function format_rfc3339(Timestamp $timestamp, ?SecondsStyle $secondsStyle = null function create_intl_date_formatter( ?DateStyle $dateStyle = null, ?TimeStyle $timeStyle = null, - null|FormatPattern|string $pattern = null, + FormatPattern|string|null $pattern = null, ?Timezone $timezone = null, ?Locale $locale = null, ): IntlDateFormatter { @@ -188,7 +188,7 @@ function intl_parse( string $rawString, ?DateStyle $dateStyle = null, ?TimeStyle $timeStyle = null, - null|FormatPattern|string $pattern = null, + FormatPattern|string|null $pattern = null, ?Timezone $timezone = null, ?Locale $locale = null, ): int { diff --git a/packages/event-bus/src/CallableEventHandler.php b/packages/event-bus/src/CallableEventHandler.php index 1ee0cbd3d3..b7f6c94303 100644 --- a/packages/event-bus/src/CallableEventHandler.php +++ b/packages/event-bus/src/CallableEventHandler.php @@ -10,7 +10,7 @@ final class CallableEventHandler { public function __construct( - public null|string|object $event, + public string|object|null $event, public EventHandler|Closure $handler, ) {} diff --git a/packages/event-bus/src/EventHandler.php b/packages/event-bus/src/EventHandler.php index d9a0151bf8..3886e3ec1e 100644 --- a/packages/event-bus/src/EventHandler.php +++ b/packages/event-bus/src/EventHandler.php @@ -15,7 +15,7 @@ final class EventHandler public MethodReflector $handler; public function __construct( - public null|string|object $event = null, + public string|object|null $event = null, ) {} public function setEventName(string $eventName): self diff --git a/packages/http-client/src/Testing/MockClient.php b/packages/http-client/src/Testing/MockClient.php index ae033c413e..9c04409457 100644 --- a/packages/http-client/src/Testing/MockClient.php +++ b/packages/http-client/src/Testing/MockClient.php @@ -71,7 +71,7 @@ public static function random(array $responses = []): ResponseBag * @param null|string|array $body * @param array $headers */ - public static function response(null|string|array $body = null, int $code = 200, array $headers = []): ResponseInterface + public static function response(string|array|null $body = null, int $code = 200, array $headers = []): ResponseInterface { $client = new self(); $response = $client->responseFactory->createResponse($code); diff --git a/packages/http/src/Responses/Created.php b/packages/http/src/Responses/Created.php index b9a41daf6b..d03f7bcf37 100644 --- a/packages/http/src/Responses/Created.php +++ b/packages/http/src/Responses/Created.php @@ -14,7 +14,7 @@ final class Created implements Response { use IsResponse; - public function __construct(string|array|null|View|JsonSerializable $body = null) + public function __construct(string|array|View|JsonSerializable|null $body = null) { $this->status = Status::CREATED; $this->body = $body; diff --git a/packages/http/src/ServerSentEvent.php b/packages/http/src/ServerSentEvent.php index 847bb0aaad..b9a9e6ba38 100644 --- a/packages/http/src/ServerSentEvent.php +++ b/packages/http/src/ServerSentEvent.php @@ -16,7 +16,7 @@ interface ServerSentEvent /** * Defines the event stream's reconnection time in case of a reconnection attempt. */ - public null|Duration|int $retryAfter { get; } + public Duration|int|null $retryAfter { get; } /** * The name of the event, which may be listened to by `EventSource#addEventListener`. diff --git a/packages/http/src/ServerSentMessage.php b/packages/http/src/ServerSentMessage.php index 48fc2055f6..e55d94fc16 100644 --- a/packages/http/src/ServerSentMessage.php +++ b/packages/http/src/ServerSentMessage.php @@ -24,7 +24,7 @@ public function __construct( JsonSerializable|Stringable|string|iterable $data, private(set) string $event = 'message', private(set) ?int $id = null, - private(set) null|Duration|int $retryAfter = null, + private(set) Duration|int|null $retryAfter = null, ) { $this->data = Json\encode($data); } diff --git a/packages/icon/src/IconCache.php b/packages/icon/src/IconCache.php index d3f3b05f4c..cc85dd0e90 100644 --- a/packages/icon/src/IconCache.php +++ b/packages/icon/src/IconCache.php @@ -50,7 +50,7 @@ public function clear(): void $this->pool->clear(); } - public function put(string $key, mixed $value, null|Duration|DateTimeInterface $expiresAt = null): CacheItemInterface + public function put(string $key, mixed $value, Duration|DateTimeInterface|null $expiresAt = null): CacheItemInterface { $item = $this->pool ->getItem($key) @@ -71,7 +71,7 @@ public function put(string $key, mixed $value, null|Duration|DateTimeInterface $ return $item; } - public function resolve(string $key, Closure $callback, null|Duration|DateTimeInterface $expiresAt = null): mixed + public function resolve(string $key, Closure $callback, Duration|DateTimeInterface|null $expiresAt = null): mixed { if (! $this->enabled) { return $callback(); diff --git a/packages/idempotency/tests/Fixtures/RecordingCache.php b/packages/idempotency/tests/Fixtures/RecordingCache.php index cd16d43600..7740ee31c5 100644 --- a/packages/idempotency/tests/Fixtures/RecordingCache.php +++ b/packages/idempotency/tests/Fixtures/RecordingCache.php @@ -27,7 +27,7 @@ public function __construct() $this->cache = new GenericCache(new ArrayAdapter()); } - public function lock(Stringable|string $key, null|Duration|DateTimeInterface $duration = null, null|Stringable|string $owner = null): Lock + public function lock(Stringable|string $key, Duration|DateTimeInterface|null $duration = null, Stringable|string|null $owner = null): Lock { $this->lastLockDuration = $duration instanceof Duration ? $duration : null; @@ -39,12 +39,12 @@ public function has(Stringable|string $key): bool return $this->cache->has($key); } - public function put(Stringable|string $key, mixed $value, null|Duration|DateTimeInterface $expiration = null): CacheItemInterface + public function put(Stringable|string $key, mixed $value, Duration|DateTimeInterface|null $expiration = null): CacheItemInterface { return $this->cache->put($key, $value, $expiration); } - public function putMany(iterable $values, null|Duration|DateTimeInterface $expiration = null): array + public function putMany(iterable $values, Duration|DateTimeInterface|null $expiration = null): array { return $this->cache->putMany($values, $expiration); } @@ -69,7 +69,7 @@ public function getMany(iterable $key): array return $this->cache->getMany($key); } - public function resolve(Stringable|string $key, Closure $callback, null|Duration|DateTimeInterface $expiration = null, ?Duration $stale = null): mixed + public function resolve(Stringable|string $key, Closure $callback, Duration|DateTimeInterface|null $expiration = null, ?Duration $stale = null): mixed { return $this->cache->resolve($key, $callback, $expiration, $stale); } diff --git a/packages/kv-store/src/Redis/PhpRedisClient.php b/packages/kv-store/src/Redis/PhpRedisClient.php index 9947924ba5..46b8643fa6 100644 --- a/packages/kv-store/src/Redis/PhpRedisClient.php +++ b/packages/kv-store/src/Redis/PhpRedisClient.php @@ -97,7 +97,7 @@ public function command(Stringable|string $command, Stringable|string ...$argume return $result; } - public function set(Stringable|string $key, mixed $value, null|Duration|DateTimeInterface $expiration = null): void + public function set(Stringable|string $key, mixed $value, Duration|DateTimeInterface|null $expiration = null): void { if ($expiration instanceof DateTimeInterface) { $expiration = $expiration->since(DateTime::now()); diff --git a/packages/kv-store/src/Redis/PredisClient.php b/packages/kv-store/src/Redis/PredisClient.php index d4a424a87f..ff72f047c6 100644 --- a/packages/kv-store/src/Redis/PredisClient.php +++ b/packages/kv-store/src/Redis/PredisClient.php @@ -59,7 +59,7 @@ public function command(Stringable|string $command, Stringable|string ...$argume return $result; } - public function set(Stringable|string $key, mixed $value, null|Duration|DateTimeInterface $expiration = null): void + public function set(Stringable|string $key, mixed $value, Duration|DateTimeInterface|null $expiration = null): void { if ($expiration instanceof DateTimeInterface) { $expiration = $expiration->since(DateTime::now()); diff --git a/packages/kv-store/src/Redis/Redis.php b/packages/kv-store/src/Redis/Redis.php index 9793d91467..cbea2fbef2 100644 --- a/packages/kv-store/src/Redis/Redis.php +++ b/packages/kv-store/src/Redis/Redis.php @@ -37,7 +37,7 @@ public function command(Stringable|string $command, Stringable|string ...$argume /** * Sets the given key/value pair, with an optional expiration. */ - public function set(Stringable|string $key, mixed $value, null|Duration|DateTimeInterface $expiration = null): void; + public function set(Stringable|string $key, mixed $value, Duration|DateTimeInterface|null $expiration = null): void; /** * Gets the value for the given key. diff --git a/packages/log/src/Config/DailyLogConfig.php b/packages/log/src/Config/DailyLogConfig.php index e6df856ac0..69c394ed87 100644 --- a/packages/log/src/Config/DailyLogConfig.php +++ b/packages/log/src/Config/DailyLogConfig.php @@ -43,6 +43,6 @@ public function __construct( private(set) bool $lockFilesDuringWrites = false, private(set) ?int $filePermission = null, private(set) ?string $prefix = null, - private(set) null|UnitEnum|string $tag = null, + private(set) UnitEnum|string|null $tag = null, ) {} } diff --git a/packages/log/src/Config/MultipleChannelsLogConfig.php b/packages/log/src/Config/MultipleChannelsLogConfig.php index 7ffef9125a..47a56a433a 100644 --- a/packages/log/src/Config/MultipleChannelsLogConfig.php +++ b/packages/log/src/Config/MultipleChannelsLogConfig.php @@ -22,6 +22,6 @@ final class MultipleChannelsLogConfig implements LogConfig public function __construct( private(set) array $channels, private(set) ?string $prefix, - private(set) null|UnitEnum|string $tag = null, + private(set) UnitEnum|string|null $tag = null, ) {} } diff --git a/packages/log/src/Config/NullLogConfig.php b/packages/log/src/Config/NullLogConfig.php index d72a4b711e..94d82f9580 100644 --- a/packages/log/src/Config/NullLogConfig.php +++ b/packages/log/src/Config/NullLogConfig.php @@ -16,6 +16,6 @@ final class NullLogConfig implements LogConfig */ public function __construct( private(set) ?string $prefix = null, - private(set) null|UnitEnum|string $tag = null, + private(set) UnitEnum|string|null $tag = null, ) {} } diff --git a/packages/log/src/Config/SimpleLogConfig.php b/packages/log/src/Config/SimpleLogConfig.php index ce9ceae012..fc3b3953b1 100644 --- a/packages/log/src/Config/SimpleLogConfig.php +++ b/packages/log/src/Config/SimpleLogConfig.php @@ -40,6 +40,6 @@ public function __construct( private(set) bool $useLocking = false, private(set) ?int $filePermission = null, private(set) ?string $prefix = null, - private(set) null|UnitEnum|string $tag = null, + private(set) UnitEnum|string|null $tag = null, ) {} } diff --git a/packages/log/src/Config/SlackLogConfig.php b/packages/log/src/Config/SlackLogConfig.php index c82fcef597..77585baae7 100644 --- a/packages/log/src/Config/SlackLogConfig.php +++ b/packages/log/src/Config/SlackLogConfig.php @@ -44,6 +44,6 @@ public function __construct( private(set) LogLevel $minimumLogLevel = LogLevel::DEBUG, private(set) array $channels = [], private(set) ?string $prefix = null, - private(set) null|UnitEnum|string $tag = null, + private(set) UnitEnum|string|null $tag = null, ) {} } diff --git a/packages/log/src/Config/SysLogConfig.php b/packages/log/src/Config/SysLogConfig.php index 09bca80756..ebb98882e8 100644 --- a/packages/log/src/Config/SysLogConfig.php +++ b/packages/log/src/Config/SysLogConfig.php @@ -43,6 +43,6 @@ public function __construct( private(set) int $flags = LOG_PID, private(set) array $channels = [], private(set) ?string $prefix = null, - private(set) null|UnitEnum|string $tag = null, + private(set) UnitEnum|string|null $tag = null, ) {} } diff --git a/packages/log/src/Config/WeeklyLogConfig.php b/packages/log/src/Config/WeeklyLogConfig.php index 93b87e0bf2..0df4f10e0e 100644 --- a/packages/log/src/Config/WeeklyLogConfig.php +++ b/packages/log/src/Config/WeeklyLogConfig.php @@ -43,6 +43,6 @@ public function __construct( private(set) ?string $prefix = null, private(set) bool $lockFilesDuringWrites = false, private(set) ?int $filePermission = null, - private(set) null|UnitEnum|string $tag = null, + private(set) UnitEnum|string|null $tag = null, ) {} } diff --git a/packages/log/src/LoggerInitializer.php b/packages/log/src/LoggerInitializer.php index c879433b76..5b05225198 100644 --- a/packages/log/src/LoggerInitializer.php +++ b/packages/log/src/LoggerInitializer.php @@ -15,13 +15,13 @@ final readonly class LoggerInitializer implements DynamicInitializer { - public function canInitialize(ClassReflector $class, null|string|UnitEnum $tag): bool + public function canInitialize(ClassReflector $class, string|UnitEnum|null $tag): bool { return $class->getType()->matches(Logger::class) || $class->getType()->matches(LoggerInterface::class); } #[Singleton] - public function initialize(ClassReflector $class, null|string|UnitEnum $tag, Container $container): LoggerInterface|Logger + public function initialize(ClassReflector $class, string|UnitEnum|null $tag, Container $container): LoggerInterface|Logger { return new GenericLogger( logConfig: $container->get(LogConfig::class, $tag), diff --git a/packages/mail/src/EmailToSymfonyEmailMapper.php b/packages/mail/src/EmailToSymfonyEmailMapper.php index d6f862b62d..7c26b7ec12 100644 --- a/packages/mail/src/EmailToSymfonyEmailMapper.php +++ b/packages/mail/src/EmailToSymfonyEmailMapper.php @@ -116,7 +116,7 @@ public function map(mixed $from, mixed $to): SymfonyEmail return $symfonyEmail; } - private function convertAddresses(null|string|array|EmailAddress $addresses): array + private function convertAddresses(string|array|EmailAddress|null $addresses): array { return arr($addresses) ->map(fn (string|EmailAddress|SymfonyAddress $address) => match (true) { diff --git a/packages/mail/src/Envelope.php b/packages/mail/src/Envelope.php index 650c224e60..566c29f186 100644 --- a/packages/mail/src/Envelope.php +++ b/packages/mail/src/Envelope.php @@ -9,11 +9,11 @@ final class Envelope { public function __construct( public ?string $subject, - public null|string|array|EmailAddress $to, - public null|string|array|EmailAddress $from = null, - public null|string|array|EmailAddress $cc = null, - public null|string|array|EmailAddress $bcc = null, - public null|string|array|EmailAddress $replyTo = null, + public string|array|EmailAddress|null $to, + public string|array|EmailAddress|null $from = null, + public string|array|EmailAddress|null $cc = null, + public string|array|EmailAddress|null $bcc = null, + public string|array|EmailAddress|null $replyTo = null, public array $headers = [], public EmailPriority $priority = EmailPriority::NORMAL, ) {} diff --git a/packages/mail/src/GenericEmail.php b/packages/mail/src/GenericEmail.php index 594db08ac5..dc147fde8c 100644 --- a/packages/mail/src/GenericEmail.php +++ b/packages/mail/src/GenericEmail.php @@ -21,13 +21,13 @@ final class GenericEmail implements Email, HasTextContent, HasAttachments public function __construct( public ?string $subject, - public null|string|array|EmailAddress $to, + public string|array|EmailAddress|null $to, public string|View $html, public string|View|null $text = null, - public null|string|array|EmailAddress $from = null, - public null|string|array|EmailAddress $cc = null, - public null|string|array|EmailAddress $bcc = null, - public null|string|array|EmailAddress $replyTo = null, + public string|array|EmailAddress|null $from = null, + public string|array|EmailAddress|null $cc = null, + public string|array|EmailAddress|null $bcc = null, + public string|array|EmailAddress|null $replyTo = null, public array $headers = [], public EmailPriority $priority = EmailPriority::NORMAL, /** @var Attachment[] */ diff --git a/packages/mail/src/Testing/MailTester.php b/packages/mail/src/Testing/MailTester.php index eb3097ec9e..ebb03f6c2d 100644 --- a/packages/mail/src/Testing/MailTester.php +++ b/packages/mail/src/Testing/MailTester.php @@ -236,7 +236,7 @@ public function assertNotBlindCarbonCopy(string|array $addresses): self /** * Asserts that the email has the given priority. */ - public function assertPriority(null|int|EmailPriority $priority): self + public function assertPriority(int|EmailPriority|null $priority): self { if ($priority instanceof EmailPriority) { $priority = $priority->value; @@ -412,7 +412,7 @@ public function assertHasHeader(string $header, ?string $value = null): self return $this; } - private function assertAddressListContains(null|string|array|EmailAddress $haystack, string|array $needles, string $message): self + private function assertAddressListContains(string|array|EmailAddress|null $haystack, string|array $needles, string $message): self { $needles = Arr\wrap($needles); $haystack = $this->convertAddresses($haystack); @@ -428,7 +428,7 @@ private function assertAddressListContains(null|string|array|EmailAddress $hayst return $this; } - private function assertAddressListDoesNotContain(null|string|array|EmailAddress $haystack, string|array $needles, string $message): self + private function assertAddressListDoesNotContain(string|array|EmailAddress|null $haystack, string|array $needles, string $message): self { $needles = Arr\wrap($needles); $haystack = $this->convertAddresses($haystack); @@ -444,7 +444,7 @@ private function assertAddressListDoesNotContain(null|string|array|EmailAddress return $this; } - private function convertAddresses(null|string|array|EmailAddress $addresses): array + private function convertAddresses(string|array|EmailAddress|null $addresses): array { return arr($addresses) ->map(fn (string|EmailAddress|SymfonyAddress $address) => match (true) { diff --git a/packages/mail/src/Transports/NullMailerConfig.php b/packages/mail/src/Transports/NullMailerConfig.php index fce9994e38..e7a35560a9 100644 --- a/packages/mail/src/Transports/NullMailerConfig.php +++ b/packages/mail/src/Transports/NullMailerConfig.php @@ -15,7 +15,7 @@ final class NullMailerConfig implements MailerConfig, ProvidesDefaultSender public string $transport = NullTransport::class; public function __construct( - public null|string|EmailAddress $defaultSender = null, + public string|EmailAddress|null $defaultSender = null, ) {} public function createTransport(): TransportInterface diff --git a/packages/mail/src/Transports/Postmark/PostmarkConfig.php b/packages/mail/src/Transports/Postmark/PostmarkConfig.php index 2e8a7741cc..a710e9253f 100644 --- a/packages/mail/src/Transports/Postmark/PostmarkConfig.php +++ b/packages/mail/src/Transports/Postmark/PostmarkConfig.php @@ -42,7 +42,7 @@ public function __construct( /** * Address from which emails are sent by default. */ - public null|string|EmailAddress $defaultSender = null, + public string|EmailAddress|null $defaultSender = null, /** * Whether to use Postmark's API or SMTP server. diff --git a/packages/mail/src/Transports/ProvidesDefaultSender.php b/packages/mail/src/Transports/ProvidesDefaultSender.php index fceb3701ae..5d7970b4db 100644 --- a/packages/mail/src/Transports/ProvidesDefaultSender.php +++ b/packages/mail/src/Transports/ProvidesDefaultSender.php @@ -9,5 +9,5 @@ interface ProvidesDefaultSender /** * The default address from which emails will be sent. */ - public null|string|EmailAddress $defaultSender { get; } + public string|EmailAddress|null $defaultSender { get; } } diff --git a/packages/mail/src/Transports/Ses/SesMailerConfig.php b/packages/mail/src/Transports/Ses/SesMailerConfig.php index f2f46a13f5..2f734f47b9 100644 --- a/packages/mail/src/Transports/Ses/SesMailerConfig.php +++ b/packages/mail/src/Transports/Ses/SesMailerConfig.php @@ -52,7 +52,7 @@ public function __construct( /** * Address from which emails are sent by default. */ - public null|string|EmailAddress $defaultSender = null, + public string|EmailAddress|null $defaultSender = null, /** * Whether to use Amazon SES's API or async HTTP transport. diff --git a/packages/mail/src/Transports/Ses/SesSmtpMailerConfig.php b/packages/mail/src/Transports/Ses/SesSmtpMailerConfig.php index 59352766b4..dfd3e57f29 100644 --- a/packages/mail/src/Transports/Ses/SesSmtpMailerConfig.php +++ b/packages/mail/src/Transports/Ses/SesSmtpMailerConfig.php @@ -45,7 +45,7 @@ public function __construct( /** * Address from which emails are sent by default. */ - public null|string|EmailAddress $from = null, + public string|EmailAddress|null $from = null, /** * Whether to use Amazon SES's API or SMTP server. diff --git a/packages/mail/src/Transports/Smtp/SmtpMailerConfig.php b/packages/mail/src/Transports/Smtp/SmtpMailerConfig.php index 5ee46e98ec..038f9570d1 100644 --- a/packages/mail/src/Transports/Smtp/SmtpMailerConfig.php +++ b/packages/mail/src/Transports/Smtp/SmtpMailerConfig.php @@ -46,7 +46,7 @@ public function __construct( /** * The default address from which emails will be sent. */ - public null|string|EmailAddress $defaultSender = null, + public string|EmailAddress|null $defaultSender = null, /** * Whether to use TLS for this connection. diff --git a/packages/router/src/RouteBindingInitializer.php b/packages/router/src/RouteBindingInitializer.php index 027e83d49b..64673edf65 100644 --- a/packages/router/src/RouteBindingInitializer.php +++ b/packages/router/src/RouteBindingInitializer.php @@ -12,12 +12,12 @@ final class RouteBindingInitializer implements DynamicInitializer { - public function canInitialize(ClassReflector $class, null|string|UnitEnum $tag): bool + public function canInitialize(ClassReflector $class, string|UnitEnum|null $tag): bool { return $class->getType()->matches(Bindable::class); } - public function initialize(ClassReflector $class, null|string|UnitEnum $tag, Container $container): object + public function initialize(ClassReflector $class, string|UnitEnum|null $tag, Container $container): object { $matchedRoute = $container->get(MatchedRoute::class); diff --git a/packages/storage/src/Config/AzureStorageConfig.php b/packages/storage/src/Config/AzureStorageConfig.php index 66f5055a04..9ccf99dcfc 100644 --- a/packages/storage/src/Config/AzureStorageConfig.php +++ b/packages/storage/src/Config/AzureStorageConfig.php @@ -35,7 +35,7 @@ public function __construct( /** * Identifier for this storage configuration. */ - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} public function createAdapter(): FilesystemAdapter diff --git a/packages/storage/src/Config/CustomStorageConfig.php b/packages/storage/src/Config/CustomStorageConfig.php index a4bb6d64f0..6105068f3d 100644 --- a/packages/storage/src/Config/CustomStorageConfig.php +++ b/packages/storage/src/Config/CustomStorageConfig.php @@ -25,7 +25,7 @@ public function __construct( /** * Identifier for this storage configuration. */ - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} public function createAdapter(): FilesystemAdapter diff --git a/packages/storage/src/Config/FTPStorageConfig.php b/packages/storage/src/Config/FTPStorageConfig.php index 9bc2006610..ad4f7011f7 100644 --- a/packages/storage/src/Config/FTPStorageConfig.php +++ b/packages/storage/src/Config/FTPStorageConfig.php @@ -39,7 +39,7 @@ public function __construct( /** * Identifier for this storage configuration. */ - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} public function createAdapter(): FilesystemAdapter diff --git a/packages/storage/src/Config/GoogleCloudStorageConfig.php b/packages/storage/src/Config/GoogleCloudStorageConfig.php index 78c9aaafb8..14680e233b 100644 --- a/packages/storage/src/Config/GoogleCloudStorageConfig.php +++ b/packages/storage/src/Config/GoogleCloudStorageConfig.php @@ -50,7 +50,7 @@ public function __construct( /** * Identifier for this storage configuration. */ - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} public function createAdapter(): FilesystemAdapter diff --git a/packages/storage/src/Config/InMemoryStorageConfig.php b/packages/storage/src/Config/InMemoryStorageConfig.php index d470257090..96e809d0d3 100644 --- a/packages/storage/src/Config/InMemoryStorageConfig.php +++ b/packages/storage/src/Config/InMemoryStorageConfig.php @@ -19,7 +19,7 @@ public function __construct( /** * Identifier for this storage configuration. */ - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} public function createAdapter(): FilesystemAdapter diff --git a/packages/storage/src/Config/LocalStorageConfig.php b/packages/storage/src/Config/LocalStorageConfig.php index 14b6e5a3cb..17437c4a86 100644 --- a/packages/storage/src/Config/LocalStorageConfig.php +++ b/packages/storage/src/Config/LocalStorageConfig.php @@ -24,7 +24,7 @@ public function __construct( /** * Identifier for this storage configuration. */ - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} public function createAdapter(): FilesystemAdapter diff --git a/packages/storage/src/Config/R2StorageConfig.php b/packages/storage/src/Config/R2StorageConfig.php index 6325d1d350..5a26443ce2 100644 --- a/packages/storage/src/Config/R2StorageConfig.php +++ b/packages/storage/src/Config/R2StorageConfig.php @@ -49,7 +49,7 @@ public function __construct( /** * Identifier for this storage configuration. */ - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} public function createAdapter(): FilesystemAdapter diff --git a/packages/storage/src/Config/S3StorageConfig.php b/packages/storage/src/Config/S3StorageConfig.php index f1f17f70f7..e6afcc19b3 100644 --- a/packages/storage/src/Config/S3StorageConfig.php +++ b/packages/storage/src/Config/S3StorageConfig.php @@ -65,7 +65,7 @@ public function __construct( /** * Identifier for this storage configuration. */ - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} public function createAdapter(): FilesystemAdapter diff --git a/packages/storage/src/Config/SFTPStorageConfig.php b/packages/storage/src/Config/SFTPStorageConfig.php index c2bfaae168..3666d9b36c 100644 --- a/packages/storage/src/Config/SFTPStorageConfig.php +++ b/packages/storage/src/Config/SFTPStorageConfig.php @@ -32,7 +32,7 @@ public function __construct( /** * Identifier for this storage configuration. */ - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} public function createAdapter(): FilesystemAdapter diff --git a/packages/storage/src/Config/ZipArchiveStorageConfig.php b/packages/storage/src/Config/ZipArchiveStorageConfig.php index 69b3aec1d8..6be0e2234c 100644 --- a/packages/storage/src/Config/ZipArchiveStorageConfig.php +++ b/packages/storage/src/Config/ZipArchiveStorageConfig.php @@ -30,7 +30,7 @@ public function __construct( /** * Identifier for this storage configuration. */ - public null|string|UnitEnum $tag = null, + public string|UnitEnum|null $tag = null, ) {} public function createAdapter(): FilesystemAdapter diff --git a/packages/storage/src/StorageInitializer.php b/packages/storage/src/StorageInitializer.php index 3e303a5a6f..75e6c1e547 100644 --- a/packages/storage/src/StorageInitializer.php +++ b/packages/storage/src/StorageInitializer.php @@ -11,13 +11,13 @@ final class StorageInitializer implements DynamicInitializer { - public function canInitialize(ClassReflector $class, null|string|UnitEnum $tag): bool + public function canInitialize(ClassReflector $class, string|UnitEnum|null $tag): bool { return $class->getType()->matches(Storage::class); } #[Singleton] - public function initialize(ClassReflector $class, null|string|UnitEnum $tag, Container $container): Storage + public function initialize(ClassReflector $class, string|UnitEnum|null $tag, Container $container): Storage { return new GenericStorage( storageConfig: $container->get(StorageConfig::class, $tag), diff --git a/packages/storage/src/Testing/RestrictedStorageInitializer.php b/packages/storage/src/Testing/RestrictedStorageInitializer.php index b52ee21372..006bb8964e 100644 --- a/packages/storage/src/Testing/RestrictedStorageInitializer.php +++ b/packages/storage/src/Testing/RestrictedStorageInitializer.php @@ -13,13 +13,13 @@ #[SkipDiscovery] final class RestrictedStorageInitializer implements DynamicInitializer { - public function canInitialize(ClassReflector $class, null|string|UnitEnum $tag): bool + public function canInitialize(ClassReflector $class, string|UnitEnum|null $tag): bool { return $class->getType()->matches(Storage::class); } #[Singleton] - public function initialize(ClassReflector $class, null|string|UnitEnum $tag, Container $container): Storage + public function initialize(ClassReflector $class, string|UnitEnum|null $tag, Container $container): Storage { return new RestrictedStorage($tag); } diff --git a/packages/storage/src/Testing/StorageTester.php b/packages/storage/src/Testing/StorageTester.php index ab13946c26..91941cb2c5 100644 --- a/packages/storage/src/Testing/StorageTester.php +++ b/packages/storage/src/Testing/StorageTester.php @@ -19,7 +19,7 @@ public function __construct( /** * Forces the usage of a testing storage. When setting `$persist` to `true`, the disk is not erased. */ - public function fake(null|string|UnitEnum $tag = null, bool $persist = false): TestingStorage + public function fake(string|UnitEnum|null $tag = null, bool $persist = false): TestingStorage { $storage = new TestingStorage( path: Str\to_kebab_case(Str\parse($tag, default: 'default')), diff --git a/packages/support/src/Arr/ManipulatesArray.php b/packages/support/src/Arr/ManipulatesArray.php index 42aa9fbbbf..8e2bd52504 100644 --- a/packages/support/src/Arr/ManipulatesArray.php +++ b/packages/support/src/Arr/ManipulatesArray.php @@ -283,7 +283,7 @@ public function flip(): self * * @return static */ - public function unique(null|Closure|string $key = null, bool $shouldBeStrict = false): self + public function unique(Closure|string|null $key = null, bool $shouldBeStrict = false): self { return $this->createOrModify(namespace\unique($this->value, $key, $shouldBeStrict)); } diff --git a/packages/support/src/Arr/functions.php b/packages/support/src/Arr/functions.php index da66bcbc44..f0b8a66308 100644 --- a/packages/support/src/Arr/functions.php +++ b/packages/support/src/Arr/functions.php @@ -454,7 +454,7 @@ function flip(iterable $array): array * * @return array|list */ -function unique(iterable $array, null|Closure|string $key = null, bool $shouldBeStrict = false): array +function unique(iterable $array, Closure|string|null $key = null, bool $shouldBeStrict = false): array { $array = to_array($array); diff --git a/packages/support/src/Math/functions.php b/packages/support/src/Math/functions.php index 298464ae40..c10c9e67e4 100644 --- a/packages/support/src/Math/functions.php +++ b/packages/support/src/Math/functions.php @@ -355,7 +355,7 @@ function max_by(iterable $numbers, Closure $numericFunction): mixed * * @return ($numbers is non-empty-list ? T : null) */ -function max(array $numbers): null|int|float +function max(array $numbers): int|float|null { $max = null; @@ -491,7 +491,7 @@ function min_by(iterable $numbers, Closure $numericFunction): mixed * * @return ($numbers is non-empty-list ? T : null) */ -function min(array $numbers): null|float|int +function min(array $numbers): float|int|null { $min = null; diff --git a/packages/support/src/Namespace/functions.php b/packages/support/src/Namespace/functions.php index 22308bdb11..e296c903ed 100644 --- a/packages/support/src/Namespace/functions.php +++ b/packages/support/src/Namespace/functions.php @@ -19,7 +19,7 @@ * to_fqcn('app/Auth/User'); // App\Auth\User * ``` */ -function to_fqcn(Stringable|string $path, null|Stringable|string $root = null): string +function to_fqcn(Stringable|string $path, Stringable|string|null $root = null): string { $namespace = prepare_namespace($path, $root) ->stripEnd('\\') @@ -50,7 +50,7 @@ function to_fqcn(Stringable|string $path, null|Stringable|string $root = null): * to_namespace('app/Auth/User'); // App\Auth\User * ``` */ -function to_namespace(Stringable|string $path, null|Stringable|string $root = null): string +function to_namespace(Stringable|string $path, Stringable|string|null $root = null): string { return prepare_namespace($path, $root) ->stripEnd('\\') @@ -73,7 +73,7 @@ function to_namespace(Stringable|string $path, null|Stringable|string $root = nu * to_psr4_namespace(new Psr4Namespace('App', 'app/'), 'app/Auth/User'); // App\Auth\User * ``` */ -function to_psr4_namespace(Psr4Namespace|array $namespaces, Stringable|string $path, null|Stringable|string $root = null): string +function to_psr4_namespace(Psr4Namespace|array $namespaces, Stringable|string $path, Stringable|string|null $root = null): string { $relativePath = prepare_namespace($path, $root) ->stripEnd('\\') @@ -113,7 +113,7 @@ function to_base_class_name(string $path): string * This function is used internally by other namespace-related functions. It is not meant for userland usage. * @internal */ -function prepare_namespace(Stringable|string $path, null|Stringable|string $root = null): ImmutableString +function prepare_namespace(Stringable|string $path, Stringable|string|null $root = null): ImmutableString { $normalized = new ImmutableString($path) ->stripStart($root ?? '') diff --git a/packages/support/src/Path/functions.php b/packages/support/src/Path/functions.php index f11d6675fd..f1c5faeff5 100644 --- a/packages/support/src/Path/functions.php +++ b/packages/support/src/Path/functions.php @@ -13,7 +13,7 @@ /** * Determines whether the given path is a relative path. The path is not checked against the filesystem. */ -function is_relative_path(null|Stringable|string ...$parts): bool +function is_relative_path(Stringable|string|null ...$parts): bool { return ! namespace\is_absolute_path(...$parts); } @@ -22,7 +22,7 @@ function is_relative_path(null|Stringable|string ...$parts): bool * Converts the given absolute path to a path relative to `$from`. * If the given path is not an absolute path, it is assumed to already by relative to `$from` and will be returned as-is. */ -function to_relative_path(null|Stringable|string $from, Stringable|string ...$parts): string +function to_relative_path(Stringable|string|null $from, Stringable|string ...$parts): string { $path = namespace\normalize(...$parts); $from = $from === null ? '' : (string) $from; @@ -51,7 +51,7 @@ function to_relative_path(null|Stringable|string $from, Stringable|string ...$pa /** * Determines whether the given path is an absolute path. The path is not checked against the filesystem. */ -function is_absolute_path(null|Stringable|string ...$parts): bool +function is_absolute_path(Stringable|string|null ...$parts): bool { $path = namespace\normalize(...$parts); @@ -69,7 +69,7 @@ function is_absolute_path(null|Stringable|string ...$parts): bool /** * Converts the given path to an absolute path. */ -function to_absolute_path(Stringable|string $cwd, null|Stringable|string ...$parts): string +function to_absolute_path(Stringable|string $cwd, Stringable|string|null ...$parts): string { $cwd = namespace\normalize($cwd); $path = namespace\normalize(...$parts); @@ -111,14 +111,14 @@ function to_absolute_path(Stringable|string $cwd, null|Stringable|string ...$par /** * Normalizes the given path to use forward-slashes. */ -function normalize(null|Stringable|string ...$paths): string +function normalize(Stringable|string|null ...$paths): string { if ($paths === []) { return ''; } $paths = array_map( - fn (null|Stringable|string $path) => $path === null ? '' : (string) $path, + fn (Stringable|string|null $path) => $path === null ? '' : (string) $path, $paths, ); diff --git a/packages/support/src/Random/functions.php b/packages/support/src/Random/functions.php index bd04943cf7..d820260230 100644 --- a/packages/support/src/Random/functions.php +++ b/packages/support/src/Random/functions.php @@ -85,7 +85,7 @@ function uuid(): string /** * Generates a 128-bit universally unique lexicographically sortable identifier. */ -function ulid(null|DateTimeInterface|NativeDateTimeInterface $time = null): string +function ulid(DateTimeInterface|NativeDateTimeInterface|null $time = null): string { return Ulid::generate($time ? DateTime::parse($time)->toNativeDateTime() : null); } diff --git a/packages/support/src/Regex/functions.php b/packages/support/src/Regex/functions.php index 5305d59713..a59e604948 100644 --- a/packages/support/src/Regex/functions.php +++ b/packages/support/src/Regex/functions.php @@ -101,7 +101,7 @@ function get_all_matches( function get_match( Stringable|string $subject, Stringable|string $pattern, - null|array|Stringable|int|string $match = null, + array|Stringable|int|string|null $match = null, mixed $default = null, int $flags = 0, int $offset = 0, diff --git a/packages/support/src/Str/ManipulatesString.php b/packages/support/src/Str/ManipulatesString.php index 868d6e82ca..7bd5cad51b 100644 --- a/packages/support/src/Str/ManipulatesString.php +++ b/packages/support/src/Str/ManipulatesString.php @@ -542,7 +542,7 @@ public function take(int $length): self * str('

Lorem ipsum

')->stripTags(allowed: 'strong'); // Lorem ipsum * ``` */ - public function stripTags(null|string|array $allowed = null): self + public function stripTags(string|array|null $allowed = null): self { return $this->createOrModify(strip_tags($this->value, $allowed)); } diff --git a/packages/support/src/Str/functions.php b/packages/support/src/Str/functions.php index 17fc68cd2e..5a5a1188a4 100644 --- a/packages/support/src/Str/functions.php +++ b/packages/support/src/Str/functions.php @@ -698,7 +698,7 @@ function chunk(Stringable|string $string, int $length): array /** * Strips HTML and PHP tags from the string. */ -function strip_tags(Stringable|string $string, null|string|array $allowed = null): string +function strip_tags(Stringable|string $string, string|array|null $allowed = null): string { $string = (string) $string; diff --git a/packages/support/tests/Math/MathsTest.php b/packages/support/tests/Math/MathsTest.php index 8c3a094235..5212d97dc1 100644 --- a/packages/support/tests/Math/MathsTest.php +++ b/packages/support/tests/Math/MathsTest.php @@ -288,7 +288,7 @@ public static function provide_max_va_cases(): array } #[DataProvider('provide_mean_cases')] - public function test_mean(null|int|float $expected, array $numbers): void + public function test_mean(int|float|null $expected, array $numbers): void { $this->assertSame($expected, Math\mean($numbers)); } diff --git a/packages/support/tests/Path/FunctionsTest.php b/packages/support/tests/Path/FunctionsTest.php index 16a52e12e9..614c167966 100644 --- a/packages/support/tests/Path/FunctionsTest.php +++ b/packages/support/tests/Path/FunctionsTest.php @@ -92,7 +92,7 @@ public function test_to_relative_path(string $from, ?string $path, string $expec #[TestWith(['/foo/bar', ['/foo/bar', '/baz'], '/foo/bar/baz'])] #[TestWith(['/foo/bar', ['/foo/bar', '/foo/bar'], '/foo/bar/foo/bar'])] #[TestWith(['/other/root', '/foo/bar', '/other/root/foo/bar'])] - public function test_to_absolute_path(string $cwd, null|array|string $path, string $expected): void + public function test_to_absolute_path(string $cwd, array|string|null $path, string $expected): void { $this->assertSame($expected, to_absolute_path($cwd, ...wrap($path))); } diff --git a/packages/validation/src/Exceptions/ValidationFailed.php b/packages/validation/src/Exceptions/ValidationFailed.php index fa6ee4ac4b..1b85612436 100644 --- a/packages/validation/src/Exceptions/ValidationFailed.php +++ b/packages/validation/src/Exceptions/ValidationFailed.php @@ -18,7 +18,7 @@ final class ValidationFailed extends Exception */ public function __construct( private(set) array $failingRules, - private(set) null|object|string $subject = null, + private(set) object|string|null $subject = null, private(set) array $errorMessages = [], private(set) ?string $targetClass = null, ) { diff --git a/packages/validation/src/Validator.php b/packages/validation/src/Validator.php index ca95be76dc..6e60fb6edb 100644 --- a/packages/validation/src/Validator.php +++ b/packages/validation/src/Validator.php @@ -67,7 +67,7 @@ public function validateObject(object $object): void * @param array> $failingRules * @param class-string|null $targetClass */ - public function createValidationFailureException(array $failingRules, null|object|string $subject = null, ?string $targetClass = null): ValidationFailed + public function createValidationFailureException(array $failingRules, object|string|null $subject = null, ?string $targetClass = null): ValidationFailed { return new ValidationFailed( failingRules: $failingRules, diff --git a/packages/view/src/Parser/TempestViewCompiler.php b/packages/view/src/Parser/TempestViewCompiler.php index 5bf850cba5..8cf85611c0 100644 --- a/packages/view/src/Parser/TempestViewCompiler.php +++ b/packages/view/src/Parser/TempestViewCompiler.php @@ -446,11 +446,9 @@ private function startLineMapRange(array $lineMapping): array private function canExtendLineMapRange(array $range, array $lineMapping): bool { return ( - $lineMapping['compiledLine'] - === ($range['compiledEndLine'] + 1) + $lineMapping['compiledLine'] === ($range['compiledEndLine'] + 1) && $lineMapping['sourcePath'] === $range['sourcePath'] - && $lineMapping['sourceLine'] - === ($range['sourceEndLine'] + 1) + && $lineMapping['sourceLine'] === ($range['sourceEndLine'] + 1) ); } diff --git a/packages/view/src/Parser/Token.php b/packages/view/src/Parser/Token.php index 0071961607..1ffe42d13a 100644 --- a/packages/view/src/Parser/Token.php +++ b/packages/view/src/Parser/Token.php @@ -55,7 +55,7 @@ public function addChild(Token $other): void $other->parent = $this; } - public function getAttribute(string $name): null|string|bool + public function getAttribute(string $name): string|bool|null { return $this->htmlAttributes[$name] ?? null; } diff --git a/packages/view/src/Renderers/BladeInitializer.php b/packages/view/src/Renderers/BladeInitializer.php index 56bb382710..61d92e3b9b 100644 --- a/packages/view/src/Renderers/BladeInitializer.php +++ b/packages/view/src/Renderers/BladeInitializer.php @@ -15,7 +15,7 @@ final readonly class BladeInitializer implements DynamicInitializer { - public function canInitialize(ClassReflector $class, null|string|UnitEnum $tag): bool + public function canInitialize(ClassReflector $class, string|UnitEnum|null $tag): bool { if (! class_exists(Blade::class)) { return false; @@ -25,7 +25,7 @@ public function canInitialize(ClassReflector $class, null|string|UnitEnum $tag): } #[Singleton] - public function initialize(ClassReflector $class, null|string|UnitEnum $tag, Container $container): object + public function initialize(ClassReflector $class, string|UnitEnum|null $tag, Container $container): object { $bladeConfig = $container->get(BladeConfig::class); diff --git a/packages/view/src/Renderers/TempestViewRenderer.php b/packages/view/src/Renderers/TempestViewRenderer.php index 3fc747beab..a228f9336d 100644 --- a/packages/view/src/Renderers/TempestViewRenderer.php +++ b/packages/view/src/Renderers/TempestViewRenderer.php @@ -168,7 +168,7 @@ private function renderCompiled(View $_view, string $_path): string return trim(ob_get_clean()); } - public function escape(null|string|HtmlString|Stringable $value): string + public function escape(string|HtmlString|Stringable|null $value): string { if ($value instanceof HtmlString) { return (string) $value; diff --git a/packages/view/src/Renderers/TwigConfig.php b/packages/view/src/Renderers/TwigConfig.php index c1d60db654..3e6c0b465b 100644 --- a/packages/view/src/Renderers/TwigConfig.php +++ b/packages/view/src/Renderers/TwigConfig.php @@ -13,7 +13,7 @@ */ public function __construct( public array $viewPaths = [], - public null|false|string $cachePath = null, + public false|string|null $cachePath = null, public bool $debug = false, public string $charset = 'utf-8', public bool $strictVariables = false, diff --git a/packages/view/src/Renderers/TwigInitializer.php b/packages/view/src/Renderers/TwigInitializer.php index 82ad4d0670..79428262df 100644 --- a/packages/view/src/Renderers/TwigInitializer.php +++ b/packages/view/src/Renderers/TwigInitializer.php @@ -14,7 +14,7 @@ final readonly class TwigInitializer implements DynamicInitializer { - public function canInitialize(ClassReflector $class, null|string|UnitEnum $tag): bool + public function canInitialize(ClassReflector $class, string|UnitEnum|null $tag): bool { if (! class_exists(Environment::class)) { return false; @@ -24,7 +24,7 @@ public function canInitialize(ClassReflector $class, null|string|UnitEnum $tag): } #[Singleton] - public function initialize(ClassReflector $class, null|string|UnitEnum $tag, Container $container): object + public function initialize(ClassReflector $class, string|UnitEnum|null $tag, Container $container): object { $twigConfig = $container->get(TwigConfig::class); $twigLoader = new FilesystemLoader($twigConfig->viewPaths); diff --git a/packages/vite/src/functions.php b/packages/vite/src/functions.php index 217fb0e4df..f747cbc62d 100644 --- a/packages/vite/src/functions.php +++ b/packages/vite/src/functions.php @@ -9,7 +9,7 @@ /** * Gets tags for the specified or configured `$entrypoints`. */ -function get_tags(null|string|array $entrypoints = null): array +function get_tags(string|array|null $entrypoints = null): array { return get(Vite::class)->getTags(is_array($entrypoints) ? $entrypoints : [$entrypoints]); } diff --git a/src/Tempest/Framework/Testing/Http/TestResponseHelper.php b/src/Tempest/Framework/Testing/Http/TestResponseHelper.php index 977af753d3..b3e244d53b 100644 --- a/src/Tempest/Framework/Testing/Http/TestResponseHelper.php +++ b/src/Tempest/Framework/Testing/Http/TestResponseHelper.php @@ -209,7 +209,7 @@ public function assertStatus(Status $expected): self return $this; } - public function assertHasCookie(string $key, null|string|Closure $value = null): self + public function assertHasCookie(string $key, string|Closure|null $value = null): self { /** @var array */ $cookies = Arr\map_with_keys( @@ -242,7 +242,7 @@ public function assertHasCookie(string $key, null|string|Closure $value = null): return $this; } - public function assertDoesNotHaveCookie(string $key, null|string|Closure $value = null): self + public function assertDoesNotHaveCookie(string $key, string|Closure|null $value = null): self { /** @var array */ $cookies = Arr\map_with_keys( diff --git a/src/Tempest/Framework/Testing/TestingDatabaseInitializer.php b/src/Tempest/Framework/Testing/TestingDatabaseInitializer.php index 20f79fc14e..6ea2b7b540 100644 --- a/src/Tempest/Framework/Testing/TestingDatabaseInitializer.php +++ b/src/Tempest/Framework/Testing/TestingDatabaseInitializer.php @@ -26,13 +26,13 @@ final class TestingDatabaseInitializer implements DynamicInitializer /** @var Connection[] */ private static array $connections = []; - public function canInitialize(ClassReflector $class, null|string|UnitEnum $tag): bool + public function canInitialize(ClassReflector $class, string|UnitEnum|null $tag): bool { return $class->getType()->matches(Database::class); } #[Singleton] - public function initialize(ClassReflector $class, null|string|UnitEnum $tag, Container $container): Database + public function initialize(ClassReflector $class, string|UnitEnum|null $tag, Container $container): Database { $tag = Str\parse($tag); diff --git a/tests/Fixtures/SecondTestDatabaseSeeder.php b/tests/Fixtures/SecondTestDatabaseSeeder.php index 6015a40ed5..a8f7a48b9b 100644 --- a/tests/Fixtures/SecondTestDatabaseSeeder.php +++ b/tests/Fixtures/SecondTestDatabaseSeeder.php @@ -10,7 +10,7 @@ final class SecondTestDatabaseSeeder implements DatabaseSeeder { - public function run(null|string|UnitEnum $database): void + public function run(string|UnitEnum|null $database): void { query(Book::class) ->insert( diff --git a/tests/Fixtures/TestDatabaseSeeder.php b/tests/Fixtures/TestDatabaseSeeder.php index 946c751f8f..86e3afe729 100644 --- a/tests/Fixtures/TestDatabaseSeeder.php +++ b/tests/Fixtures/TestDatabaseSeeder.php @@ -10,7 +10,7 @@ final class TestDatabaseSeeder implements DatabaseSeeder { - public function run(null|string|UnitEnum $database): void + public function run(string|UnitEnum|null $database): void { query(Book::class) ->insert( diff --git a/tests/Fixtures/TestResponseProcessor.php b/tests/Fixtures/TestResponseProcessor.php index 95780df3eb..b6f3792d89 100644 --- a/tests/Fixtures/TestResponseProcessor.php +++ b/tests/Fixtures/TestResponseProcessor.php @@ -10,7 +10,7 @@ final readonly class TestResponseProcessor implements ResponseProcessor { public function __construct( - private readonly Request $request, + private Request $request, ) {} public function process(Response $response): Response diff --git a/tests/Integration/Auth/AccessControl/PolicyBasedAccessControlTest.php b/tests/Integration/Auth/AccessControl/PolicyBasedAccessControlTest.php index 9adc1746c6..261c1e1777 100644 --- a/tests/Integration/Auth/AccessControl/PolicyBasedAccessControlTest.php +++ b/tests/Integration/Auth/AccessControl/PolicyBasedAccessControlTest.php @@ -472,7 +472,7 @@ public function readAndDownload(?Document $resource, ?User $subject): bool final class MultiAuthenticatablePolicy { #[Policy] - public function view(?Document $_resource, null|User|ServiceAccount $subject): bool + public function view(?Document $_resource, User|ServiceAccount|null $subject): bool { return $subject instanceof Authenticatable; } diff --git a/tests/Integration/Container/Commands/ContainerShowCommandTest.php b/tests/Integration/Container/Commands/ContainerShowCommandTest.php index 55253b5fce..1f72eab0ba 100644 --- a/tests/Integration/Container/Commands/ContainerShowCommandTest.php +++ b/tests/Integration/Container/Commands/ContainerShowCommandTest.php @@ -42,7 +42,7 @@ public function unregister(string $className, bool $tagged = false): self return $this; } - public function singleton(string $className, mixed $definition, null|string|UnitEnum $tag = null): self + public function singleton(string $className, mixed $definition, string|UnitEnum|null $tag = null): self { $this->container->singleton($className, $definition, $tag); @@ -56,12 +56,12 @@ public function config(object $config): self return $this; } - public function get(string $className, null|string|UnitEnum $tag = null, mixed ...$params): mixed + public function get(string $className, string|UnitEnum|null $tag = null, mixed ...$params): mixed { return $this->container->get($className, $tag, ...$params); } - public function has(string $className, null|string|UnitEnum $tag = null): bool + public function has(string $className, string|UnitEnum|null $tag = null): bool { return $this->container->has($className, $tag); } diff --git a/tests/Integration/Http/GenericResponseSenderTest.php b/tests/Integration/Http/GenericResponseSenderTest.php index 7102f293ef..6ac1232504 100644 --- a/tests/Integration/Http/GenericResponseSenderTest.php +++ b/tests/Integration/Http/GenericResponseSenderTest.php @@ -233,7 +233,7 @@ public function test_stream_with_custom_implementation(): void yield new class implements ServerSentEvent { public ?int $id = 1; - public null|Duration|int $retryAfter = null; + public Duration|int|null $retryAfter = null; public ?string $event = 'custom'; diff --git a/tests/Integration/Mailer/SentEmailTest.php b/tests/Integration/Mailer/SentEmailTest.php index c3739e67db..c38c9d0d13 100644 --- a/tests/Integration/Mailer/SentEmailTest.php +++ b/tests/Integration/Mailer/SentEmailTest.php @@ -193,14 +193,14 @@ public function test_html_path(): void private function sendTestEmail( ?string $subject = null, - null|string|array|EmailAddress $to = null, - null|string|array|EmailAddress $from = null, - null|string|array|EmailAddress $cc = null, - null|string|array|EmailAddress $bcc = null, - null|string|array|EmailAddress $replyTo = null, + string|array|EmailAddress|null $to = null, + string|array|EmailAddress|null $from = null, + string|array|EmailAddress|null $cc = null, + string|array|EmailAddress|null $bcc = null, + string|array|EmailAddress|null $replyTo = null, array $headers = [], EmailPriority $priority = EmailPriority::NORMAL, - null|string|View $html = null, + string|View|null $html = null, ?string $text = null, array $attachments = [], ): MailTester { diff --git a/tests/Integration/Storage/StorageTesterTest.php b/tests/Integration/Storage/StorageTesterTest.php index 00599b7e15..33000d7c2a 100644 --- a/tests/Integration/Storage/StorageTesterTest.php +++ b/tests/Integration/Storage/StorageTesterTest.php @@ -207,7 +207,7 @@ public function test_no_adapter(): void $this->container->config(new class implements StorageConfig { public string $adapter = 'UnknownClass'; - public null|string|UnitEnum $tag = null; + public string|UnitEnum|null $tag = null; public bool $readonly = false; From fe1d204d93fff4b9680849b1f3275b0e21a67b91 Mon Sep 17 00:00:00 2001 From: brendt Date: Wed, 24 Jun 2026 08:36:24 +0200 Subject: [PATCH 3/3] wip --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1efbf30236..a7083bcdb8 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,7 @@ "aws/aws-sdk-php": "^3.338.0", "azure-oss/storage-blob-flysystem": "^1.2", "brianium/paratest": "^7.14", - "carthage-software/mago": "1.16.0", + "carthage-software/mago": "1.30.0", "guzzlehttp/psr7": "^2.6.1", "league/flysystem-aws-s3-v3": "^3.25.1", "league/flysystem-ftp": "^3.25.1",