public static function set(array $array, ...$args): array
    {
        if (empty($args)) {
            throw new \ArgumentCountError('Too few arguments to function xobotyi\A::set(), 1 passed, at least 2 expected');
        }

        if (is_string($args[0]) || is_numeric($args[0])) {
            if (!isset($args[1]) && !\array_key_exists(1, $args)) {
                throw new \ArgumentCountError('Too few arguments to function xobotyi\A::set(), 2 passed, at least 3 expected when second is string');
            }

            $args = [$args[0] => $args[1]];
        } else if (\is_array($args[0])) {
            $args = $args[0];
        } else {
            throw new \TypeError("Argument 2 passed to xobotyi\A::set() must be of the type array or string, " . gettype($args[0]) . " given");
        }

        foreach ($args as $path => &$value) {
            if ($path === '') {
                continue;
            }

            $path = self::splitPath($path);

            if (empty($path)) {
                continue;
            }

            $scope = &$array;

            for ($i = 0; $i < count($path) - 1; $i++) {
                if (!isset($scope[$path[$i]]) || !\is_array($scope[$path[$i]])) {
                    $scope[$path[$i]] = [];
                }

                $scope = &$scope[$path[$i]];
            }

            $scope[$path[$i]] = $value;
        }

        return $array;
    }