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.
This commit is contained in:
DarkZmaj
2026-10-06 15:16:49 +01:00
committed by GitHub
parent 0a3bb17f06
commit be0509dfb7
3 changed files with 6 additions and 10 deletions
@@ -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;
}
@@ -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'));
@@ -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) {