public function mergeWith(self $objects): self
    {
        $clone = clone $this;
        foreach ($objects->objects as $reference => $object) {
            $clone->objects[$reference] = $object;
            $clone->array[$reference] = $object->getInstance();
        }
        
        return $clone;
    }
public function mergeWith(self $objects): self
    {
        $clone = clone $this;
        foreach ($objects->objects as $reference => $object) {
            $clone->objects[$reference] = $object;
            $clone->array[$reference] = $object->getInstance();
        }
        
        return $clone;
    }
public function mergeWith ( self $ objects ) : self { $ clone = clone $ this ; foreach ( $ objects -> objects as $ reference => $ object ) { $ clone -> objects [ $ reference ] = $ object ; $ clone -> array [ $ reference ] = $ object -> getInstance ( ) ; } return $ clone ; }
Creates a new instance with the new objects. If objects with the same reference already exists, they will be
overridden by the new ones.

@param ObjectBag $objects
Creates a new instance with the new objects . If objects with the same reference already exists they will be overridden by the new ones .