From 798558373fc3a98ca901e519e72b05ecfa42fb17 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 10 May 2016 11:10:02 +0200 Subject: [PATCH] ContainerLoader::load() swapped arguments (BC break) --- src/DI/ContainerLoader.php | 8 ++++++-- tests/DI/ContainerLoader.basic.phpt | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/DI/ContainerLoader.php b/src/DI/ContainerLoader.php index 54e7071b3..426f5b6ec 100644 --- a/src/DI/ContainerLoader.php +++ b/src/DI/ContainerLoader.php @@ -32,12 +32,16 @@ public function __construct($tempDirectory, $autoRebuild = FALSE) /** - * @param mixed * @param callable function (Nette\DI\Compiler $compiler): string|NULL + * @param mixed * @return string */ - public function load($key, $generator) + public function load($generator, $key = NULL) { + if (is_callable($key)) { // back compatiblity + trigger_error(__METHOD__ . ': order of arguments has been swapped.', E_USER_DEPRECATED); + list($generator, $key) = [$key, $generator]; + } $class = $this->getClassName($key); if (!class_exists($class, FALSE)) { $this->loadFile($class, $generator); diff --git a/tests/DI/ContainerLoader.basic.phpt b/tests/DI/ContainerLoader.basic.phpt index a694917ff..21475f6f2 100644 --- a/tests/DI/ContainerLoader.basic.phpt +++ b/tests/DI/ContainerLoader.basic.phpt @@ -17,7 +17,7 @@ $key = [1, 2]; $className = $cache->getClassName($key); Assert::match('Container%[\w]+%', $className); -$container = $cache->load($key, function () use ($className) { +$container = $cache->load(function () use ($className) { return "class $className {}"; -}); +}, $key); Assert::type($className, new $container);