From 5eb1215041b02f7846cbe182b8fabb22e73e3bdf Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Fri, 26 Jul 2024 12:38:04 +0200 Subject: [PATCH] =?UTF-8?q?Revert=20"[11.x]=20Declare=20bindings=20and=20s?= =?UTF-8?q?ingletons=20properties=20in=20Service=20Provider=E2=80=A6"=20(#?= =?UTF-8?q?52288)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit ed28a456f6b4799c33a59840fd68ea9f0922d463. --- src/Illuminate/Foundation/Application.php | 14 +++++++++----- src/Illuminate/Support/ServiceProvider.php | 14 -------------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/Illuminate/Foundation/Application.php b/src/Illuminate/Foundation/Application.php index 8e3daa139886..75abb18b6b48 100755 --- a/src/Illuminate/Foundation/Application.php +++ b/src/Illuminate/Foundation/Application.php @@ -870,14 +870,18 @@ public function register($provider, $force = false) // If there are bindings / singletons set as properties on the provider we // will spin through them and register them with the application, which // serves as a convenience layer while registering a lot of bindings. - foreach ($provider->bindings as $key => $value) { - $this->bind($key, $value); + if (property_exists($provider, 'bindings')) { + foreach ($provider->bindings as $key => $value) { + $this->bind($key, $value); + } } - foreach ($provider->singletons as $key => $value) { - $key = is_int($key) ? $value : $key; + if (property_exists($provider, 'singletons')) { + foreach ($provider->singletons as $key => $value) { + $key = is_int($key) ? $value : $key; - $this->singleton($key, $value); + $this->singleton($key, $value); + } } $this->markAsRegistered($provider); diff --git a/src/Illuminate/Support/ServiceProvider.php b/src/Illuminate/Support/ServiceProvider.php index a43ce9d444cd..7395397a3eca 100755 --- a/src/Illuminate/Support/ServiceProvider.php +++ b/src/Illuminate/Support/ServiceProvider.php @@ -19,20 +19,6 @@ abstract class ServiceProvider */ protected $app; - /** - * All of the container bindings that should be registered. - * - * @var array - */ - public $bindings = []; - - /** - * All of the singletons that should be registered. - * - * @var array - */ - public $singletons = []; - /** * All of the registered booting callbacks. *