Commit 4eb7906a by Qiang Xue

Fixes #3204: `yii\di\Container` did not handle the `$config` parameter well in…

Fixes #3204: `yii\di\Container` did not handle the `$config` parameter well in case when it does not have a default value
parent 0076aac0
......@@ -15,6 +15,7 @@ Yii Framework 2 Change Log
- Bug #3153: Fixed the bug that using "between" operator to build a SQL query will cause a PHP notice (gonimar)
- Bug #3184: Fixed the bug that client validation for string length comparison did not set error message correctly (Sergeygithub)
- Bug #3194: Date formatter works only for timestamps in the year range 1970 to 2038 (kartik-v)
- Bug #3204: `yii\di\Container` did not handle the `$config` parameter well in case when it does not have a default value (qiangxue)
- Enh #2837: Error page now shows arguments in stack trace method calls (samdark)
- Enh #3088: The debug and gii modules will manage their own URL rules now (hiltonjanfield, qiangxue)
- Enh #3103: debugger panel is now not displayed when printing a page (githubjeka)
......
......@@ -357,13 +357,13 @@ class Container extends Component
$dependencies[$index] = $param;
}
$dependencies = $this->resolveDependencies($dependencies, $reflection);
if (!empty($config) && !empty($dependencies) && is_a($class, 'yii\base\Object', true)) {
if (!empty($dependencies) && is_a($class, 'yii\base\Object', true)) {
// set $config as the last parameter (existing one will be overwritten)
$dependencies[count($dependencies) - 1] = $config;
$dependencies = $this->resolveDependencies($dependencies, $reflection);
return $reflection->newInstanceArgs($dependencies);
} else {
$dependencies = $this->resolveDependencies($dependencies, $reflection);
$object = $reflection->newInstanceArgs($dependencies);
foreach ($config as $name => $value) {
$object->$name = $value;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment