diff --git a/src/Illuminate/Foundation/Application.php b/src/Illuminate/Foundation/Application.php index 080429721101..ea2a218a2a85 100755 --- a/src/Illuminate/Foundation/Application.php +++ b/src/Illuminate/Foundation/Application.php @@ -99,7 +99,7 @@ class Application extends Container implements ApplicationContract, CachesConfig /** * All of the registered service providers. * - * @var \Illuminate\Support\ServiceProvider[] + * @var array */ protected $serviceProviders = []; @@ -893,7 +893,9 @@ public function register($provider, $force = false) */ public function getProvider($provider) { - return array_values($this->getProviders($provider))[0] ?? null; + $name = is_string($provider) ? $provider : get_class($provider); + + return $this->serviceProviders[$name] ?? null; } /** @@ -928,9 +930,11 @@ public function resolveProvider($provider) */ protected function markAsRegistered($provider) { - $this->serviceProviders[] = $provider; + $class = get_class($provider); - $this->loadedProviders[get_class($provider)] = true; + $this->serviceProviders[$class] = $provider; + + $this->loadedProviders[$class] = true; } /** @@ -1384,7 +1388,7 @@ public function terminate() /** * Get the service providers that have been loaded. * - * @return array + * @return array */ public function getLoadedProviders() {