setByPath
@param array|\ArrayAccess &$data
@param string $path
@param mixed $value
@param string $separator
@return  boolean
165494
public static function setByPath(&$data, $path, $value, $separator = '.')
    {
        if (false === strpos($path, $separator)) {
            $data[$path] = $value;

            return true;
        }

        if (!$nodes = Str::toArray($path, $separator)) {
            return false;
        }

        $dataTmp = &$data;

        foreach ($nodes as $node) {
            if (\is_array($dataTmp)) {
                if (empty($dataTmp[$node])) {
                    $dataTmp[$node] = [];
                }

                $dataTmp = &$dataTmp[$node];
            } else {
                // If a node is value but path is not go to the end, we replace this value as a new store.
                // Then next node can insert new value to this store.
                $dataTmp = array();
            }
        }

        // Now, path go to the end, means we get latest node, set value to this node.
        $dataTmp = $value;

        return true;
    }
1315820
public function set($path, $value)
    {
        // if is readonly
        if ($this->readonly && $this->has($path)) {
            throw new RuntimeException("Config data have been setting readonly. don't allow change.");
        }

        return parent::set($path, $value);
    }
240415
public static function set(array &$input, $namespace, $value, $separator = '.')
    {
        $keys  = explode($separator, $namespace);
        $pointer = &$input;

        while (count($keys) > 0) {
            $key = array_shift($keys);
            $pointer[$key] = isset($pointer[$key]) ? $pointer[$key] : [];
            $pointer = &$pointer[$key];
        }

        $pointer = $value;

        return $input;
    }
1158585
private function setValueByReference(array &$array, array $path, $value)
    {
        while (count($path) > 1) {
            $key = array_shift($path);
            $array = &$array[$key];
        }

        $key = reset($path);
        $array[$key] = $value;
    }
966095
public static function setByPath(&$data, string $path, $value, string $separator = '.'): void
    {
        if (false === \strpos($path, $separator)) {
            $data[$path] = $value;
            return;
        }

        if (!$nodes = \array_filter(\explode($separator, $path))) {
            return;
        }

        $dataTmp = &$data;

        foreach ($nodes as $node) {
            if (\is_array($dataTmp)) {
                if (empty($dataTmp[$node])) {
                    $dataTmp[$node] = [];
                }

                $dataTmp = &$dataTmp[$node];
            } else {
                // If a node is value but path is not go to the end, we replace this value as a new store.
                // Then next node can insert new value to this store.
                $dataTmp = [];
            }
        }

        // Now, path go to the end, means we get latest node, set value to this node.
        $dataTmp = $value;
    }
360424
public function setSeparator($separator)
    {
        if (!in_array(
            $separator,
            [
                ' ',
                '-'
            ],
            true
        )
        ) {
            $separator = ' ';
        }

        $this->separator = $separator;

        return $this;
    }
738563
public function set($path, $value)
    {
        PropertyAccessor::setByPath($this->values, $this->path($path), $value);
    }
641526
public function prepend($path, $data, $separator = PHP_EOL)
    {
        if ($this->exists($path)) {
            return $this->put($path, $data.$separator.$this->get($path));
        }

        return $this->put($path, $data);
    }
1178737
public function set($path, $value, $constraint = null)
    {
        if ($constraint === null) {
            $constraint = $this->constraint;
        }

        if ($constraint) {
            $value = json_decode(json_encode($value), true);
        }

        if (is_null($path)) {
            $this->item[] = $value;
            return;
        }

        $path = explode($this->separator, $path);
        $last = array_pop($path);
        $item = &$this->item;

        foreach ($path as $key) {
            if (!array_key_exists($key, $item) || !is_array($item[$key])) {
                $item[$key] = array();
            }

            $item = &$item[$key];
        }

        $item[$last] = $value;
    }
862731
public static function setByPath(&$data, $path, $value, $separator = '.', $storeType = 'array')
	{
		$nodes = array_values(array_filter(explode($separator, $path), 'strlen'));

		if (empty($nodes))
		{
			return false;
		}

		/**
		 * A closure as inner function to create data store.
		 *
		 * @param string $type
		 *
		 * @return  array
		 *
		 * @throws \InvalidArgumentException
		 */
		$createStore = function($type)
		{
			if (strtolower($type) == 'array')
			{
				return array();
			}

			if (class_exists($type))
			{
				return new $type;
			}

			throw new \InvalidArgumentException(sprintf('Type or class: %s not exists', $type));
		};

		$dataTmp = &$data;

		foreach ($nodes as $node)
		{
			if (is_object($dataTmp))
			{
				if (empty($dataTmp->$node))
				{
					$dataTmp->$node = $createStore($storeType);
				}

				$dataTmp = &$dataTmp->$node;
			}
			elseif (is_array($dataTmp))
			{
				if (empty($dataTmp[$node]))
				{
					$dataTmp[$node] = $createStore($storeType);
				}

				$dataTmp = &$dataTmp[$node];
			}
			else
			{
				// If a node is value but path is not go to the end, we replace this value as a new store.
				// Then next node can insert new value to this store.
				$dataTmp = &$createStore($storeType);
			}
		}

		// Now, path go to the end, means we get latest node, set value to this node.
		$dataTmp = $value;

		return true;
	}
845921
public function set($path, $value)
    {
        $parts = explode('.', $path);
        switch (count($parts)) {
            case 2:
                $this->_data[$parts[0]][$parts[1]] = $value;
                break;
            case 1:
                $this->_data[$parts[0]] = $value;
                break;
            case 0:
                throw new RuntimeException('Path was empty.');
            default:
                throw new RuntimeException('Too many parts in path.');
        }
    }
407907
static function pathSet(&$values, $pathParts, $value) {
        $r = &$values;
        $last = array_pop($pathParts);
        foreach ($pathParts as $part) {
            if (!isset($r[$part])) {
                $r[$part] = array();
            }
            $r = &$r[$part];
        }
        $r[$last] = $value;
    }
233556
public function set($path, $value)
    {
        // special case, root element.
        if ($path === '/') {
            $this->data = (array) $value;
            return $this;
        }

        $chunks = $this->splitPath($path);
        $scope  = &$this->data;
        $count  = count($chunks);

        while ($count > 1) {
            $sub   = array_shift($chunks);
            $count = count($chunks);

            if ((!(isset($scope[$sub]) && is_array($scope[$sub])))) {
                $scope[$sub] = [];
            }

            $scope = &$scope[$sub];
        }

        $sub = $chunks[0];

        if ($value === null) {
            unset($scope[$sub]);

            return $this;
        }

        $scope[$sub] = $value;

        return $this;
    }
738061
public function set($path, $value)
    {
        if (!empty($path)) {
            $at   = &$this->getValues();
            $keys = $this->explode($path);

            while (count($keys) > 0) {
                if (count($keys) === 1) {
                    if (is_array($at)) {
                        $at[array_shift($keys)] = $value;
                    } else {
                        throw new \RuntimeException("Can not set value at this path ($path) because is not array.");
                    }
                } else {
                    $key = array_shift($keys);
                    if (!isset($at[$key])) {
                        $at[$key] = [];
                    }
                    $at = &$at[$key];
                }
            }
        } else {
            $this->values = $value;
        }
    }
457275
protected function getArrayFromValue($value, $separator = ',')
    {
        if (!is_array($value)) {
            $value = explode($separator, $value);
        }

        return $value;
    }
757590
public function set($path, $value = self::NULL_ARGUMENT)
    {
        $request = $this->createRequest('PUT', $path, $value);
        return $this->handleRequest($request);
    }
1040309
public function addData($path, $value)
    {
        $path = explode('.', $path);

        if (empty($path[0])) {
            return;
        }

        $jsdata = $this->app['jsdata'];
        $part = &$jsdata;

        foreach ($path as $key) {
            if (!isset($part[$key])) {
                $part[$key] = [];
            }

            $part = &$part[$key];
        }

        $part = $value;
        $this->app['jsdata'] = $jsdata;
    }