Skip to content

Commit

Permalink
[11.x] remove temporary variables (#53810)
Browse files Browse the repository at this point in the history
* remove simple temporary variables

the declared variable is only used once. inlining does not decrease readability.

my guess is it was originally written this way *before* we had arrow functions, and could inherit the outer `$this` scope.

also minor formatting update to use our new multiline chaining standard

* revert

* inline some more simple variables

also put each argument on separate line for multiline for better git diffs

* remove more temporary variables

a couple more real simple ones
  • Loading branch information
browner12 authored Dec 10, 2024
1 parent bde0abf commit 2484ce8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
12 changes: 7 additions & 5 deletions Access/Gate.php
Original file line number Diff line number Diff line change
Expand Up @@ -836,12 +836,14 @@ protected function formatAbilityToMethod($ability)
*/
public function forUser($user)
{
$callback = fn () => $user;

return new static(
$this->container, $callback, $this->abilities,
$this->policies, $this->beforeCallbacks, $this->afterCallbacks,
$this->guessPolicyNamesUsingCallback
$this->container,
fn () => $user,
$this->abilities,
$this->policies,
$this->beforeCallbacks,
$this->afterCallbacks,
$this->guessPolicyNamesUsingCallback,
);
}

Expand Down
4 changes: 1 addition & 3 deletions AuthManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,9 @@ protected function callCustomCreator($name, array $config)
*/
public function createSessionDriver($name, $config)
{
$provider = $this->createUserProvider($config['provider'] ?? null);

$guard = new SessionGuard(
$name,
$provider,
$this->createUserProvider($config['provider'] ?? null),
$this->app['session.store'],
rehashOnLogin: $this->app['config']->get('hashing.rehash_on_login', true),
);
Expand Down
8 changes: 5 additions & 3 deletions CreatesUserProviders.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ protected function getProviderConfiguration($provider)
*/
protected function createDatabaseProvider($config)
{
$connection = $this->app['db']->connection($config['connection'] ?? null);

return new DatabaseUserProvider($connection, $this->app['hash'], $config['table']);
return new DatabaseUserProvider(
$this->app['db']->connection($config['connection'] ?? null),
$this->app['hash'],
$config['table'],
);
}

/**
Expand Down

0 comments on commit 2484ce8

Please sign in to comment.