src/Collection.php
public function set($key, $value = null)
    {
        if (\is_array($key) && $value === null) {
            $this->items = $key;
            trigger_error('Replacing collection contents via set is deprecated', E_USER_DEPRECATED);
        } else {
            $this->offsetSet($key, $value);
        }

        return $this;
    }
public function set($key, $value = null)
    {
        if (\is_array($key) && $value === null) {
            $this->items = $key;
            trigger_error('Replacing collection contents via set is deprecated', E_USER_DEPRECATED);
        } else {
            $this->offsetSet($key, $value);
        }

        return $this;
    }
public function set ( $ key , $ value = null ) { if ( \ is_array ( $ key ) && $ value === null ) { $ this -> items = $ key ; trigger_error ( 'Replacing collection contents via set is deprecated' , E_USER_DEPRECATED ) ; } else { $ this -> offsetSet ( $ key , $ value ) ; } return $ this ; }
Add the item with key to the Collection

If item is an array and value is null, the Collection will be replaced with
the items.

Note: replacing the Collection contents is considered deprecated and will be removed
in the next major version.

@param mixed $key
@param mixed $value

@return $this
Add the item with key to the Collection