From faa7c833ba3517e8c82a1d81793cfd020fa72116 Mon Sep 17 00:00:00 2001 From: Anton Date: Wed, 24 Jul 2024 19:37:52 -0600 Subject: [PATCH 1/2] Declare bindings and singletons "magick" properties --- src/Illuminate/Foundation/Application.php | 14 +++++--------- src/Illuminate/Support/ServiceProvider.php | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/Illuminate/Foundation/Application.php b/src/Illuminate/Foundation/Application.php index 14de7d8916b4..e7ab77a88a8a 100755 --- a/src/Illuminate/Foundation/Application.php +++ b/src/Illuminate/Foundation/Application.php @@ -870,18 +870,14 @@ 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. - if (property_exists($provider, 'bindings')) { - foreach ($provider->bindings as $key => $value) { - $this->bind($key, $value); - } + foreach ($provider->bindings as $key => $value) { + $this->bind($key, $value); } - if (property_exists($provider, 'singletons')) { - foreach ($provider->singletons as $key => $value) { - $key = is_int($key) ? $value : $key; + 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 7395397a3eca..ea63c0734373 100755 --- a/src/Illuminate/Support/ServiceProvider.php +++ b/src/Illuminate/Support/ServiceProvider.php @@ -54,6 +54,20 @@ abstract class ServiceProvider */ protected static $publishableMigrationPaths = []; + /** + * All of the container bindings that should be registered. + * + * @var array + */ + public $bindings = []; + + /** + * All of the container singletons that should be registered. + * + * @var array + */ + public $singletons = []; + /** * Create a new service provider instance. * From dc13c20fc06adb09a25f4b905db8c609f501d32b Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 26 Jul 2024 08:47:52 +0300 Subject: [PATCH 2/2] Update ServiceProvider.php --- src/Illuminate/Support/ServiceProvider.php | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Illuminate/Support/ServiceProvider.php b/src/Illuminate/Support/ServiceProvider.php index ea63c0734373..a43ce9d444cd 100755 --- a/src/Illuminate/Support/ServiceProvider.php +++ b/src/Illuminate/Support/ServiceProvider.php @@ -20,53 +20,53 @@ abstract class ServiceProvider protected $app; /** - * All of the registered booting callbacks. + * All of the container bindings that should be registered. * * @var array */ - protected $bootingCallbacks = []; + public $bindings = []; /** - * All of the registered booted callbacks. + * All of the singletons that should be registered. * * @var array */ - protected $bootedCallbacks = []; + public $singletons = []; /** - * The paths that should be published. + * All of the registered booting callbacks. * * @var array */ - public static $publishes = []; + protected $bootingCallbacks = []; /** - * The paths that should be published by group. + * All of the registered booted callbacks. * * @var array */ - public static $publishGroups = []; + protected $bootedCallbacks = []; /** - * The migration paths available for publishing. + * The paths that should be published. * * @var array */ - protected static $publishableMigrationPaths = []; + public static $publishes = []; /** - * All of the container bindings that should be registered. + * The paths that should be published by group. * * @var array */ - public $bindings = []; + public static $publishGroups = []; /** - * All of the container singletons that should be registered. + * The migration paths available for publishing. * * @var array */ - public $singletons = []; + protected static $publishableMigrationPaths = []; /** * Create a new service provider instance.