src/DotKey.php
public function set($key, $value)
    {
        $index = explode('.', $key);
        self::setValue($this->item, $index, $value, false, $err);
        
        if ($err) {
            $invalidPath = join('.', array_slice($index, 0, -1 * $err->incomplete));
            $reason = isset($err->var) ? "'$invalidPath' is a {$err->var}" : "'$invalidPath' doesn't exist";
            trigger_error("Unable to set '$key': $reason", E_USER_WARNING);
        } // @codeCoverageIgnore
        
        return $this->item;
    }
public function set($key, $value)
    {
        $index = explode('.', $key);
        self::setValue($this->item, $index, $value, false, $err);
        
        if ($err) {
            $invalidPath = join('.', array_slice($index, 0, -1 * $err->incomplete));
            $reason = isset($err->var) ? "'$invalidPath' is a {$err->var}" : "'$invalidPath' doesn't exist";
            trigger_error("Unable to set '$key': $reason", E_USER_WARNING);
        } // @codeCoverageIgnore
        
        return $this->item;
    }
Set a value

@param string $key    The index to fetch in dot notation
@param mixed  $value
@return object|array