Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

rodrigopedra
Copy link
Contributor

Once upon a time, in the distant land of Laravel 5.1, the Illuminate\Auth\AuthManager class still extended the Illuminate\Support\Manager class and had a common entry point to create drivers:

protected function createDriver($driver)
{
$guard = parent::createDriver($driver);
// When using the remember me functionality of the authentication services we
// will need to be set the encryption instance of the guard, which allows
// secure, encrypted cookie values to get generated for those cookies.
if (method_exists($guard, 'setCookieJar')) {
$guard->setCookieJar($this->app['cookie']);
}
if (method_exists($guard, 'setDispatcher')) {
$guard->setDispatcher($this->app['events']);
}
if (method_exists($guard, 'setRequest')) {
$guard->setRequest($this->app->refresh('request', $guard, 'setRequest'));
}
return $guard;
}

As a generic entry point for an arbitrary Guard, the method_exists checks were necessary to properly configure a guard instance.

Many refactorings came, and the Illuminate\Auth\AuthManager evolved to a thing of its own, but the method_exists checks remained as a leftover from that distant past and ended up on a different method createSessionDriver() that does not create a generic instance anymore.

As we now create a concrete class, we know by fact which methods it has and don't need to check for their existence anymore.

This PR:

  • Removes unnecessary method_exists() checks from the Illuminate\Auth\AuthManager@createSessionDriver() method

@taylorotwell taylorotwell merged commit 2b99f17 into laravel:12.x Aug 29, 2025
65 checks passed
@rodrigopedra rodrigopedra deleted the feature-cleanup branch August 29, 2025 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants