Skip to content

Commit d0a8856

Browse files
committed
ContainerLoader::load() swapped arguments (BC break)
1 parent e3c82aa commit d0a8856

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/DI/ContainerLoader.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,16 @@ public function __construct($tempDirectory, $autoRebuild = FALSE)
3232

3333

3434
/**
35-
* @param mixed
3635
* @param callable function (Nette\DI\Compiler $compiler): string|NULL
36+
* @param mixed
3737
* @return string
3838
*/
39-
public function load($key, $generator)
39+
public function load($generator, $key = NULL)
4040
{
41+
if (!is_callable($generator)) { // back compatiblity
42+
trigger_error(__METHOD__ . ': order of arguments has been swapped.', E_USER_DEPRECATED);
43+
list($generator, $key) = [$key, $generator];
44+
}
4145
$class = $this->getClassName($key);
4246
if (!class_exists($class, FALSE)) {
4347
$this->loadFile($class, $generator);

tests/DI/ContainerLoader.basic.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ $key = [1, 2];
1717
$className = $cache->getClassName($key);
1818
Assert::match('Container%[\w]+%', $className);
1919

20-
$container = $cache->load($key, function () use ($className) {
20+
$container = $cache->load(function () use ($className) {
2121
return "class $className {}";
22-
});
22+
}, $key);
2323
Assert::type($className, new $container);

0 commit comments

Comments
 (0)