src/Merging/MergingTrait.php
public function merge($source)
    {
        if ($source instanceof MergingInterface) {
            $source = $source->toArray();
        } elseif ($source instanceof Traversable) {
            $source = iterator_to_array($source);
        } elseif ($source instanceof \stdClass) {
            $source = (array) $source;
        } elseif (! is_array($source)) {
            throw new InvalidArgumentException(sprintf(
                'Failed to merge with source of type "%s".',
                is_object($source) ? get_class($source) : gettype($source)
            ));
        }
        $this->container = $this->arrayMerge($this->container, $source);
    }
public function merge($source)
    {
        if ($source instanceof MergingInterface) {
            $source = $source->toArray();
        } elseif ($source instanceof Traversable) {
            $source = iterator_to_array($source);
        } elseif ($source instanceof \stdClass) {
            $source = (array) $source;
        } elseif (! is_array($source)) {
            throw new InvalidArgumentException(sprintf(
                'Failed to merge with source of type "%s".',
                is_object($source) ? get_class($source) : gettype($source)
            ));
        }
        $this->container = $this->arrayMerge($this->container, $source);
    }
public function merge ( $ source ) { if ( $ source instanceof MergingInterface ) { $ source = $ source -> toArray ( ) ; } elseif ( $ source instanceof Traversable ) { $ source = iterator_to_array ( $ source ) ; } elseif ( $ source instanceof \ stdClass ) { $ source = ( array ) $ source ; } elseif ( ! is_array ( $ source ) ) { throw new InvalidArgumentException ( sprintf ( 'Failed to merge with source of type "%s".' , is_object ( $ source ) ? get_class ( $ source ) : gettype ( $ source ) ) ) ; } $ this -> container = $ this -> arrayMerge ( $ this -> container , $ source ) ; }
Merges data from other data sources.

Any available data source will be converted into an array.
The values, that have an string keys, will be overwritten.
The values, that have an integer keys, will be added.
Any object that presents in the data source and implements the
MergingInterface, will be converted into array.

@param array|MergingInterface|\Traversable|\stdClass $source The data
source

@throws \InvalidArgumentException If the data source type is not
compatible
Merges data from other data sources .