Skip to content

Commit

Permalink
ContainerLoader::load() swapped arguments (BC break)
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed May 10, 2016
1 parent 6150ff1 commit 7985583
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/DI/ContainerLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions tests/DI/ContainerLoader.basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit 7985583

Please sign in to comment.