Is it expected behavior that action dependencies are not resolved from the container? For example, given a binding:
/**
* Register the service provider.
*/
public function register(): void
{
$this->app->singleton(OauthFactory::class, function ($app) {
return new OauthManager($app);
});
}
I would expect to be able to type hint OauthFactory:
public function handle(OauthFactory $oauth, Request $request): RedirectResponse
{
/** @var string $provider */
$provider = $request->route('provider');
return $this->handle($oauth->driver($provider));
}
But instead get an exception: Exception: Argument #1 ($oauth) must be of type Support\Oauth\Contracts\OauthFactory, Support\Oauth\OauthManager given. However, resolving directly from the container works:
public function handle(Request $request): RedirectResponse
{
/** @var string $provider */
$provider = $request->route('provider');
$oauth = app(OauthFactory::class);
return $oauth->driver($provider)->redirect();
}
Is it expected behavior that action dependencies are not resolved from the container? For example, given a binding:
I would expect to be able to type hint
OauthFactory
:But instead get an exception:
Exception: Argument #1 ($oauth) must be of type Support\Oauth\Contracts\OauthFactory, Support\Oauth\OauthManager given
. However, resolving directly from the container works:What am I missing?