Skip to content
Permalink
Browse files

Helpers::merge() supports PREVENT_MERGING on top array

  • Loading branch information...
dg committed Mar 12, 2019
1 parent 74c237b commit adf9c5db0912c830ab628b2faed8bcec508109ae
Showing with 6 additions and 6 deletions.
  1. +6 −6 src/DI/Config/Helpers.php
@@ -28,17 +28,17 @@ final class Helpers
*/
public static function merge($left, $right)
{
if (is_array($left) && isset($left[self::PREVENT_MERGING])) {
unset($left[self::PREVENT_MERGING]);
return $left;
}
if (is_array($left) && is_array($right)) {
foreach ($left as $key => $val) {
if (is_int($key)) {
$right[] = $val;
} else {
if (is_array($val) && isset($val[self::PREVENT_MERGING])) {
unset($val[self::PREVENT_MERGING]);
} elseif (isset($right[$key])) {
$val = static::merge($val, $right[$key]);
}
$right[$key] = $val;
$right[$key] = static::merge($val, $right[$key] ?? null);
}
}
return $right;

0 comments on commit adf9c5d

Please sign in to comment.
You can’t perform that action at this time.