From f69175cbe5cb9ea3db51dab01b6f0574dc6c94d5 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Thu, 24 Aug 2017 23:01:38 +0200 Subject: [PATCH] used setFactory() instead of misused setClass() --- src/Bridges/ApplicationDI/ApplicationExtension.php | 2 +- src/Bridges/ApplicationDI/LatteExtension.php | 2 +- tests/Bridges.DI/ApplicationExtension.basic.phpt | 4 ++-- .../Bridges.DI/ApplicationExtension.invalidLink.phpt | 4 ++-- tests/Bridges.DI/ApplicationExtension.scan.phpt | 12 ++++++------ 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Bridges/ApplicationDI/ApplicationExtension.php b/src/Bridges/ApplicationDI/ApplicationExtension.php index dd01d3318..934f37c0c 100644 --- a/src/Bridges/ApplicationDI/ApplicationExtension.php +++ b/src/Bridges/ApplicationDI/ApplicationExtension.php @@ -61,7 +61,7 @@ public function loadConfiguration() : UI\Presenter::INVALID_LINK_WARNING; $application = $builder->addDefinition($this->prefix('application')) - ->setClass(Nette\Application\Application::class) + ->setFactory(Nette\Application\Application::class) ->addSetup('$catchExceptions', [$config['catchExceptions']]) ->addSetup('$errorPresenter', [$config['errorPresenter']]); diff --git a/src/Bridges/ApplicationDI/LatteExtension.php b/src/Bridges/ApplicationDI/LatteExtension.php index 74960db44..a529f1cc2 100644 --- a/src/Bridges/ApplicationDI/LatteExtension.php +++ b/src/Bridges/ApplicationDI/LatteExtension.php @@ -46,7 +46,7 @@ public function loadConfiguration() $builder = $this->getContainerBuilder(); $builder->addDefinition($this->prefix('latteFactory')) - ->setClass(Latte\Engine::class) + ->setFactory(Latte\Engine::class) ->addSetup('setTempDirectory', [$this->tempDir]) ->addSetup('setAutoRefresh', [$this->debugMode]) ->addSetup('setContentType', [$config['xhtml'] ? Latte\Compiler::CONTENT_XHTML : Latte\Compiler::CONTENT_HTML]) diff --git a/tests/Bridges.DI/ApplicationExtension.basic.phpt b/tests/Bridges.DI/ApplicationExtension.basic.phpt index 9e37b1a14..07f1cefa1 100644 --- a/tests/Bridges.DI/ApplicationExtension.basic.phpt +++ b/tests/Bridges.DI/ApplicationExtension.basic.phpt @@ -17,9 +17,9 @@ test(function () { $compiler->addExtension('application', new ApplicationExtension(false)); $builder = $compiler->getContainerBuilder(); - $builder->addDefinition('myRouter')->setClass(Nette\Application\Routers\SimpleRouter::class); + $builder->addDefinition('myRouter')->setFactory(Nette\Application\Routers\SimpleRouter::class); $builder->addDefinition('myHttpRequest')->setFactory(Nette\Http\Request::class, [new DI\Statement(Nette\Http\UrlScript::class)]); - $builder->addDefinition('myHttpResponse')->setClass(Nette\Http\Response::class); + $builder->addDefinition('myHttpResponse')->setFactory(Nette\Http\Response::class); $code = $compiler->setClassName('Container1')->compile(); eval($code); diff --git a/tests/Bridges.DI/ApplicationExtension.invalidLink.phpt b/tests/Bridges.DI/ApplicationExtension.invalidLink.phpt index 8cd8a6a3b..8bbf937a4 100644 --- a/tests/Bridges.DI/ApplicationExtension.invalidLink.phpt +++ b/tests/Bridges.DI/ApplicationExtension.invalidLink.phpt @@ -19,9 +19,9 @@ function createCompiler($config) $compiler = new DI\Compiler; $compiler->loadConfig(Tester\FileMock::create($config, 'neon')); $builder = $compiler->getContainerBuilder(); - $builder->addDefinition('myRouter')->setClass(Nette\Application\Routers\SimpleRouter::class); + $builder->addDefinition('myRouter')->setFactory(Nette\Application\Routers\SimpleRouter::class); $builder->addDefinition('myHttpRequest')->setFactory(Nette\Http\Request::class, [new DI\Statement(Nette\Http\UrlScript::class)]); - $builder->addDefinition('myHttpResponse')->setClass(Nette\Http\Response::class); + $builder->addDefinition('myHttpResponse')->setFactory(Nette\Http\Response::class); return $compiler; } diff --git a/tests/Bridges.DI/ApplicationExtension.scan.phpt b/tests/Bridges.DI/ApplicationExtension.scan.phpt index e8bca158d..9bc49942d 100644 --- a/tests/Bridges.DI/ApplicationExtension.scan.phpt +++ b/tests/Bridges.DI/ApplicationExtension.scan.phpt @@ -18,9 +18,9 @@ test(function () { $compiler->addExtension('application', new ApplicationExtension); $builder = $compiler->getContainerBuilder(); - $builder->addDefinition('myRouter')->setClass(Nette\Application\Routers\SimpleRouter::class); + $builder->addDefinition('myRouter')->setFactory(Nette\Application\Routers\SimpleRouter::class); $builder->addDefinition('myHttpRequest')->setFactory(Nette\Http\Request::class, [new DI\Statement(Nette\Http\UrlScript::class)]); - $builder->addDefinition('myHttpResponse')->setClass(Nette\Http\Response::class); + $builder->addDefinition('myHttpResponse')->setFactory(Nette\Http\Response::class); $code = $compiler->setClassName('Container1')->compile(); eval($code); @@ -37,9 +37,9 @@ test(function () { $compiler->addExtension('application', new ApplicationExtension); $builder = $compiler->getContainerBuilder(); - $builder->addDefinition('myRouter')->setClass(Nette\Application\Routers\SimpleRouter::class); + $builder->addDefinition('myRouter')->setFactory(Nette\Application\Routers\SimpleRouter::class); $builder->addDefinition('myHttpRequest')->setFactory(Nette\Http\Request::class, [new DI\Statement(Nette\Http\UrlScript::class)]); - $builder->addDefinition('myHttpResponse')->setClass(Nette\Http\Response::class); + $builder->addDefinition('myHttpResponse')->setFactory(Nette\Http\Response::class); $code = $compiler->addConfig([ 'application' => [ 'scanDirs' => [__DIR__ . '/files'], @@ -60,9 +60,9 @@ test(function () { $compiler->addExtension('application', new ApplicationExtension(false, [__DIR__ . '/files'])); $builder = $compiler->getContainerBuilder(); - $builder->addDefinition('myRouter')->setClass(Nette\Application\Routers\SimpleRouter::class); + $builder->addDefinition('myRouter')->setFactory(Nette\Application\Routers\SimpleRouter::class); $builder->addDefinition('myHttpRequest')->setFactory(Nette\Http\Request::class, [new DI\Statement(Nette\Http\UrlScript::class)]); - $builder->addDefinition('myHttpResponse')->setClass(Nette\Http\Response::class); + $builder->addDefinition('myHttpResponse')->setFactory(Nette\Http\Response::class); $loader = new DI\Config\Loader; $config = $loader->load(Tester\FileMock::create(' services: