mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-14 14:28:27 +08:00
Fixes #11275: Added possibility of unset or force replace former value in ArrayHelper::merge()
This commit is contained in:

committed by
Alexander Makarov

parent
0ac161b69d
commit
993f2aef28
@ -107,6 +107,8 @@ class BaseArrayHelper
|
||||
* type and are having the same key.
|
||||
* For integer-keyed elements, the elements from the latter array will
|
||||
* be appended to the former array.
|
||||
* You can use [[UnsetArrayValue]] object to unset value from previous array or
|
||||
* [[ReplaceArrayValue]] to force replace former value instead of recursive merging.
|
||||
* @param array $a array to be merged to
|
||||
* @param array $b array to be merged from. You can specify additional
|
||||
* arrays via third argument, fourth argument etc.
|
||||
@ -119,7 +121,11 @@ class BaseArrayHelper
|
||||
while (!empty($args)) {
|
||||
$next = array_shift($args);
|
||||
foreach ($next as $k => $v) {
|
||||
if (is_int($k)) {
|
||||
if ($v instanceof UnsetArrayValue) {
|
||||
unset($res[$k]);
|
||||
} elseif ($v instanceof ReplaceArrayValue) {
|
||||
$res[$k] = $v->value;
|
||||
} elseif (is_int($k)) {
|
||||
if (isset($res[$k])) {
|
||||
$res[] = $v;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user