lib/Util.php
public static function mergeIniObjectContents(
        $baseContent,
        $contentToImport,
        $flags = 0,
        $ignoredSection = array()
    )
    {
        $contentToImport = (array) $contentToImport;

        foreach ($contentToImport as $k => $v) {
            if (!isset($baseContent->$k)) {
                $baseContent->$k = $v;
                continue;
            }

            if (($flags & self::NOT_MERGE_PROTECTED_DIRECTIVE) && $k[0] == '_') {
                continue;
            }

            if (in_array($k, $ignoredSection)) {
                continue;
            }

            if (is_array($v)) {
                // this is a section or a array value
                if (!is_array($baseContent->$k)) {
                    $baseContent->$k = $v;
                } else {
                    if ($flags & self::NORMAL_MERGE_ARRAY_VALUES_WITH_INTEGER_KEYS) {
                        if (self::hasOnlyIntegerKeys($v) && self::hasOnlyIntegerKeys($baseContent->$k)) {
                            $baseContent->$k = array_merge($baseContent->$k, $v);
                            continue;
                        }
                        $newbase = $baseContent->$k;
                    } else {
                        // first, in the case of an array value, clean the $base value, by removing all values with numerical keys
                        // as it does not make sens to merge two simple arrays here.
                        $newbase = array();
                        foreach ($baseContent->$k as $k2 => $v2) {
                            if (is_string($k2)) {
                                $newbase[$k2] = $v2;
                            }
                        }
                    }
                    $baseContent->$k = self::mergeSectionContent($newbase, $v, $flags);
                }
            } else {
                $baseContent->$k = $v;
            }
        }

        return $baseContent;
    }
public static function mergeIniObjectContents(
        $baseContent,
        $contentToImport,
        $flags = 0,
        $ignoredSection = array()
    )
    {
        $contentToImport = (array) $contentToImport;

        foreach ($contentToImport as $k => $v) {
            if (!isset($baseContent->$k)) {
                $baseContent->$k = $v;
                continue;
            }

            if (($flags & self::NOT_MERGE_PROTECTED_DIRECTIVE) && $k[0] == '_') {
                continue;
            }

            if (in_array($k, $ignoredSection)) {
                continue;
            }

            if (is_array($v)) {
                // this is a section or a array value
                if (!is_array($baseContent->$k)) {
                    $baseContent->$k = $v;
                } else {
                    if ($flags & self::NORMAL_MERGE_ARRAY_VALUES_WITH_INTEGER_KEYS) {
                        if (self::hasOnlyIntegerKeys($v) && self::hasOnlyIntegerKeys($baseContent->$k)) {
                            $baseContent->$k = array_merge($baseContent->$k, $v);
                            continue;
                        }
                        $newbase = $baseContent->$k;
                    } else {
                        // first, in the case of an array value, clean the $base value, by removing all values with numerical keys
                        // as it does not make sens to merge two simple arrays here.
                        $newbase = array();
                        foreach ($baseContent->$k as $k2 => $v2) {
                            if (is_string($k2)) {
                                $newbase[$k2] = $v2;
                            }
                        }
                    }
                    $baseContent->$k = self::mergeSectionContent($newbase, $v, $flags);
                }
            } else {
                $baseContent->$k = $v;
            }
        }

        return $baseContent;
    }
merge two simple StdClass object.

@param object $baseContent     the object which receives new properties
@param object $contentToImport the object providing new properties
@param int    $flags           a combination of constants NOT_MERGE_*, NORMAL_MERGE_*
@param array  $ignoredSection  list of sections or top level parameters that
should not be merged

@return object $baseContent