From 8a860171a27980151ef11cb09dc5c4e3e1e0bac5 Mon Sep 17 00:00:00 2001 From: Chris Kankiewicz Date: Thu, 6 Feb 2020 08:54:54 -0700 Subject: [PATCH] Removed references to $config in the AppManager class before it's instantiated --- app/src/Bootstrap/AppManager.php | 31 ++++++++++++----------------- tests/Bootstrap/AppManangerTest.php | 2 +- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/app/src/Bootstrap/AppManager.php b/app/src/Bootstrap/AppManager.php index 1537a6e..c03a72f 100644 --- a/app/src/Bootstrap/AppManager.php +++ b/app/src/Bootstrap/AppManager.php @@ -6,7 +6,6 @@ use App\Providers; use DI\Bridge\Slim\Bridge; use DI\Container; use Invoker\CallableResolver; -use PHLAK\Config\Config; use Slim\App; use Tightenco\Collect\Support\Collection; @@ -27,9 +26,6 @@ class AppManager /** @var Container The applicaiton container */ protected $container; - /** @var Config The application config */ - protected $config; - /** @var CallableResolver The callable resolver */ protected $callableResolver; @@ -38,10 +34,9 @@ class AppManager * * @param \DI\Container $container */ - public function __construct(Container $container, Config $config, CallableResolver $callableResolver) + public function __construct(Container $container, CallableResolver $callableResolver) { $this->container = $container; - $this->config = $config; $this->callableResolver = $callableResolver; } @@ -66,13 +61,13 @@ class AppManager */ protected function registerProviders(): void { - Collection::make(self::PROVIDERS)->merge( - $this->config->get('app.providers', []) - )->each(function (string $provider) { - $this->container->call( - $this->callableResolver->resolve($provider) - ); - }); + Collection::make(self::PROVIDERS)->each( + function (string $provider) { + $this->container->call( + $this->callableResolver->resolve($provider) + ); + } + ); } /** @@ -84,10 +79,10 @@ class AppManager */ protected function registerMiddlewares(App $app): void { - Collection::make(self::MIDDLEWARES)->merge( - $this->config->get('app.middlewares', []) - )->each(function (string $middleware) use ($app) { - $app->add($middleware); - }); + Collection::make(self::MIDDLEWARES)->each( + function (string $middleware) use ($app) { + $app->add($middleware); + } + ); } } diff --git a/tests/Bootstrap/AppManangerTest.php b/tests/Bootstrap/AppManangerTest.php index 1375a32..ed1994a 100644 --- a/tests/Bootstrap/AppManangerTest.php +++ b/tests/Bootstrap/AppManangerTest.php @@ -12,7 +12,7 @@ class AppManangerTest extends TestCase public function test_it_returns_an_app_instance(): void { $callableResolver = $this->container->get(CallableResolver::class); - $app = (new AppManager($this->container, $this->config, $callableResolver))(); + $app = (new AppManager($this->container, $callableResolver))(); $this->assertInstanceOf(App::class, $app); }