From be0509dfb7d2275b9772ad8c166c3fd8a03d76e2 Mon Sep 17 00:00:00 2001 From: DarkZmaj Date: Tue, 6 Oct 2026 16:16:49 +0200 Subject: [PATCH] Apply the Rector changes reported on the current branch (#7251) ## Problem `vendor/bin/rector --dry-run` reports three files that would change, which fails the Static Analysis job of the Tests workflow. ## Reproduction Run `vendor/bin/rector --dry-run --no-progress-bar` on a clean checkout with PHP 8.4, as the workflow does. Rector lists `PasswordBroker.php`, `PasswordBrokerManager.php` and `FileController.php`. With PHP 8.3 the command reports nothing, because some rules depend on the running PHP version. ## Root cause Recent changes in these three files were merged without running Rector, so they differ from the style the project enforces. ## Fix Apply exactly the changes Rector prints: * `PasswordBroker`: compare the callback with `instanceof Closure` instead of `!== null`. * `PasswordBrokerManager`: use `throw_unless` and `throw_if` with the exception class string. * `FileController`: name the caught exception `$daemonConnectionException` after its type. ## Testing * `vendor/bin/rector --dry-run` no longer reports changes locally, and PHPStan and Pint still pass. * The authentication integration tests and the server file integration tests pass (86 tests). * I could not run Rector under PHP 8.4 locally, so the Static Analysis job of this pull request is the confirmation. ## Compatibility considerations Behaviour is unchanged. The `instanceof Closure` check is stricter than a null check only for callbacks that are not closures, and the parameter is already typed as a nullable closure. --- .../Illuminate/Auth/Passwords/PasswordBroker.php | 2 +- .../Illuminate/Auth/Passwords/PasswordBrokerManager.php | 8 ++------ .../Controllers/Api/Client/Servers/FileController.php | 6 +++--- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/app/Extensions/Illuminate/Auth/Passwords/PasswordBroker.php b/app/Extensions/Illuminate/Auth/Passwords/PasswordBroker.php index 64572cfaa..777e941e8 100644 --- a/app/Extensions/Illuminate/Auth/Passwords/PasswordBroker.php +++ b/app/Extensions/Illuminate/Auth/Passwords/PasswordBroker.php @@ -40,7 +40,7 @@ class PasswordBroker extends IlluminatePasswordBroker $token = $this->tokens->create($user); - if ($callback !== null) { + if ($callback instanceof Closure) { return JsonValueGuard::nullableString($callback($user, $token)) ?? static::RESET_LINK_SENT; } diff --git a/app/Extensions/Illuminate/Auth/Passwords/PasswordBrokerManager.php b/app/Extensions/Illuminate/Auth/Passwords/PasswordBrokerManager.php index 35e4a58e9..6af7bf102 100644 --- a/app/Extensions/Illuminate/Auth/Passwords/PasswordBrokerManager.php +++ b/app/Extensions/Illuminate/Auth/Passwords/PasswordBrokerManager.php @@ -23,17 +23,13 @@ class PasswordBrokerManager extends IlluminatePasswordBrokerManager $config = $this->app->make(ConfigRepository::class); $prefix = "auth.passwords.{$name}"; - if (! $config->has($prefix)) { - throw new InvalidArgumentException("Password resetter [{$name}] is not defined."); - } + throw_unless($config->has($prefix), InvalidArgumentException::class, "Password resetter [{$name}] is not defined."); $users = $this->app->make(AuthManager::class)->createUserProvider( JsonValueGuard::nullableString($config->get("{$prefix}.provider")) ); - if ($users === null) { - throw new InvalidArgumentException("Password resetter [{$name}] has no user provider."); - } + throw_if($users === null, InvalidArgumentException::class, "Password resetter [{$name}] has no user provider."); $key = JsonValueGuard::string($config->get('app.key')); diff --git a/app/Http/Controllers/Api/Client/Servers/FileController.php b/app/Http/Controllers/Api/Client/Servers/FileController.php index ead2e613c..954d24888 100644 --- a/app/Http/Controllers/Api/Client/Servers/FileController.php +++ b/app/Http/Controllers/Api/Client/Servers/FileController.php @@ -417,12 +417,12 @@ class FileController extends ClientApiController try { $contents = $lister->list($server, '/'.implode('/', $segments)); - } catch (DaemonConnectionException $exception) { - if ($exception->getStatusCode() === Response::HTTP_NOT_FOUND) { + } catch (DaemonConnectionException $daemonConnectionException) { + if ($daemonConnectionException->getStatusCode() === Response::HTTP_NOT_FOUND) { return false; } - throw $exception; + throw $daemonConnectionException; } foreach ($contents as $entry) {