diff --git a/src/Rector/RootResolverSignatureRector.php b/src/Rector/RootResolverSignatureRector.php index 33e1c2243..5bdf2e339 100644 --- a/src/Rector/RootResolverSignatureRector.php +++ b/src/Rector/RootResolverSignatureRector.php @@ -206,11 +206,11 @@ protected function isUselessSingleRootParam(ClassMethod $method): bool $type = $type->type; } - if ($type instanceof Identifier && $type->name === 'array') { - return false; + if (! $type instanceof Identifier) { + return true; } - return true; + return $type->name !== 'array'; } protected function prependRootParam(ClassMethod $method): void diff --git a/tests/Unit/Rector/RootResolverSignatureRector/bootstrap.php b/tests/Unit/Rector/RootResolverSignatureRector/bootstrap.php index af171e961..9d10e9116 100644 --- a/tests/Unit/Rector/RootResolverSignatureRector/bootstrap.php +++ b/tests/Unit/Rector/RootResolverSignatureRector/bootstrap.php @@ -8,6 +8,33 @@ define('LIGHTHOUSE_RECTOR_BOOTSTRAP_LOADED', true); +$errorHandler = set_error_handler(static fn (mixed ...$args): bool => false); +restore_error_handler(); +$exceptionHandler = set_exception_handler(static fn (mixed ...$args) => null); +restore_exception_handler(); + require_once __DIR__ . '/../../../../vendor/larastan/larastan/bootstrap.php'; +// Undo handlers registered by Laravel's HandleExceptions bootstrapper +// to avoid PHPUnit risky test warnings about leaked handlers. +for ($i = 0; $i < 10; ++$i) { + if (set_error_handler(static fn (mixed ...$args): bool => false) === $errorHandler) { + restore_error_handler(); + break; + } + + restore_error_handler(); + restore_error_handler(); +} + +for ($i = 0; $i < 10; ++$i) { + if (set_exception_handler(static fn (mixed ...$args) => null) === $exceptionHandler) { + restore_exception_handler(); + break; + } + + restore_exception_handler(); + restore_exception_handler(); +} + config()->set('lighthouse', require __DIR__ . '/../../../../src/lighthouse.php');