protected static function mergeObjects(stdClass &$target, stdClass ...$sources): void
    {
        foreach ($sources as $source) {
            foreach ($source as $key => $value) {
                if (str_starts_with($key, 'i__')) {
                    continue;
                }

                if (isset($target->$key) && is_object($value) && is_object($target->$key)) {
                    static::mergeObjects($target->$key, $value);
                } else {
                    $target->$key = $value;
                }
            }
        }
    }
protected static function mergeObjects(stdClass &$target, stdClass ...$sources): void
    {
        foreach ($sources as $source) {
            foreach ($source as $key => $value) {
                if (str_starts_with($key, 'i__')) {
                    continue;
                }

                if (isset($target->$key) && is_object($value) && is_object($target->$key)) {
                    static::mergeObjects($target->$key, $value);
                } else {
                    $target->$key = $value;
                }
            }
        }
    }
protected static function mergeObjects ( stdClass & $ target , stdClass ... $ sources ) : void { foreach ( $ sources as $ source ) { foreach ( $ source as $ key => $ value ) { if ( str_starts_with ( $ key , 'i__' ) ) { continue ; } if ( isset ( $ target -> $ key ) && is_object ( $ value ) && is_object ( $ target -> $ key ) ) { static :: mergeObjects ( $ target -> $ key , $ value ) ; } else { $ target -> $ key = $ value ; } } } }
Recursive merge of 2 or more objects

@param stdClass   $target   The object that will be modified
@param stdClass[] $sources  Source objects
@return void
Recursive merge of 2 or more objects