Replace null parameters with their defaults.

@param  array  $parameters
@return array
768969
protected function replaceDefaults(array $parameters)
	{
		foreach ($parameters as $key => &$value)
		{
			$value = isset($value) ? $value : array_get($this->defaults, $key);
		}

		return $parameters;
	}
370670
private function buildRequestParameters($parameters)
    {
        if (NULL === $parameters || empty($parameters)) {
            return null;
        }

        if (is_string($parameters)) {
            return $parameters;
        }

        $paramOut = '';
        foreach ($parameters as $key=>$value) {
            $paramOut .= $key.'=';
            if (is_array($value)){
                $paramOut .= join(',', $value);
            }else{
                $paramOut .= $value;
            }
            $paramOut .= '&';
        }

        return $paramOut;
    }
979744
public function withParameters(array $parameters): self
    {
        $query = $this;

        foreach ($parameters as $key => $parameter) {
            $query = $query->withParameter($key, $parameter);
        }

        return $query;
    }
194605
public function removeParameters(array $parameters = null)
  {
    $this->parameters = array();

    if ($parameters) {
      $this->addParameters($parameters);
    }

    return $this;
  }
344431
public function removeParameters(array $parameters = null)
  {
    if ($this->isLocked()) {
      return $this->getObj()->removeParameters($parameters)->setLocked();
    } else {
      return parent::removeParameters($parameters);
    }
  }
1046085
public static function normalizeParameters(array $parameters) {
    $normalized = $parameters;

    $timezone = new \DateTimeZone(\Drupal::config('system.date')->get('timezone')['default']);

    // The old site has a habit to provide empty filter_date. Fix it here.
    if (empty($normalized['filter_date'])) {
      $date = DrupalDateTime::createFromTimestamp(REQUEST_TIME, $timezone);
      $normalized['filter_date'] = $date->format(self::$dateFilterFormat);
    }

    // Convert date parameter to timestamp.
    // Date parameter can by with leading zero or not.
    $origin_dtz = new \DateTimeZone(date_default_timezone_get());
    $remote_dtz = new \DateTimeZone(\Drupal::config('system.date')->get('timezone')['default']);
    $origin_dt = new \DateTime('now', $origin_dtz);
    $remote_dt = new \DateTime('now', $remote_dtz);
    $offset = $origin_dtz->getOffset($origin_dt) - $remote_dtz->getOffset($remote_dt);

    // Add offset. Function strtotime() uses default timezone.
    if ($timestamp = strtotime($normalized['filter_date'])) {
      $timestamp += $offset;
    }
    else {
      $date = DrupalDateTime::createFromTimestamp(REQUEST_TIME, $timezone);
      $timestamp = $date->format('U');
    }

    // Add timestamp.
    $normalized['filter_timestamp'] = $timestamp;

    // Finally, normalize filter_date.
    $date = DrupalDateTime::createFromTimestamp($normalized['filter_timestamp'], $timezone);
    $normalized['filter_date'] = $date->format(self::$dateFilterFormat);

    // Add default filter_length.
    if (!isset($normalized['filter_length'])) {
      $normalized['filter_length'] = 'day';
    }

    // Apply 'week' logic if class is selected.
    if (isset($parameters['class']) && is_numeric($parameters['class'])) {
      $normalized['filter_length'] = 'week';
      $normalized['view_mode'] = 'class';
      $normalized['groupex_class'] = 'groupex_table_class_individual';
    }

    return $normalized;
  }
63920
protected static function _prepareMatchParams($parameters) {
		foreach (Set::normalize($parameters) as $token => $scope) {
			if (strpos($token, 'T_') !== 0) {
				unset($parameters[$token]);

				foreach (['before', 'after'] as $key) {
					if (!isset($scope[$key])) {
						continue;
					}
					$items = [];

					foreach ((array) $scope[$key] as $item) {
						$items[] = (strpos($item, 'T_') !== 0)  ? static::token($item) : $item;
					}
					$scope[$key] = $items;
				}
				$parameters[static::token($token)] = $scope;
			}
		}
		return $parameters;
	}
1291403
private function makeParameters(array $parameters): array
    {
        return array_map(function (ReflectionParameter $parameter) {
            $class = $parameter->getClass();

            if ($class instanceof ReflectionClass) {
                return $this->make($class->getName());
            }

            if ($parameter->isDefaultValueAvailable()) {
                return $parameter->getDefaultValue();
            }

            return null;
        }, $parameters);
    }
290927
private function createRequestBody(array $parameters): array
    {
        $resources = [];
        foreach ($parameters as $key => $values) {
            if (!is_array($values)) {
                $values = [$values];
            }
            foreach ($values as $value) {
                $resources[] = [
                    'name' => $key,
                    'content' => $value,
                ];
            }
        }

        return $resources;
    }
1289588
private function parseParameters(array $parameters)
    {
        if (empty($parameters)) {
            return '';
        }

        $parameters = implode('&', array_map(
            function ($value, $key) {
                return sprintf('%s=%s', $key, urlencode($value));
            },
            $parameters,
            array_keys($parameters)
        ));

        return "&{$parameters}";
    }
409833
protected function getSortedParameters($parameters)
    {
        \uksort($parameters, 'strcmp');

        foreach ($parameters as $key => $value) {
            if (\is_array($value)) {
                \uksort($parameters[$key], 'strcmp');
            }
        }

        return $parameters;
    }
911252
public function changeActiveEntities(array $parameters = []) {
      $options = [];
      if ($parameters) {
         $options['body'] = json_encode($parameters);
      }
      $response = $this->client->request('post', 'changeActiveEntities', $options);
      return [
         'statusCode' => $response->getStatusCode(),
         'body' => $response->getBody()->getContents(),
      ];
   }
768621
protected function replaceDefaults(array $parameters)
    {
        foreach ($parameters as $key => &$value) {
            $value = isset($value) ? $value : ArrayHelper::get($this->defaults, $key);
        }
        foreach ($this->defaults as $key => $value) {
            if (!isset($parameters[$key])) {
                $parameters[$key] = $value;
            }
        }

        return $parameters;
    }
931384
public function transform(array $parameters)
    {
        $transformed = array();

        foreach ($parameters as $name => $value) {
            $transformed[$name] = $this->transformerResolver->resolve($value)->transform($value);
        }

        return $transformed;
    }
1134323
private function resolveFilterCriteria(array $parameters)
    {
        $baseCriteria = $this->buildBaseCriteria($parameters);
        $registeredCriteria = $this->buildRegisteredCriteria($parameters);
        $filterCriteria = $this->getFilterCriteria($parameters);

        if (null === $filterCriteria) {
            $filterCriteria = [];
        }

        if ($filterCriteria instanceof Criterion) {
            $filterCriteria = [$filterCriteria];
        }

        $criteria = array_merge($baseCriteria, $registeredCriteria, $filterCriteria);

        if (empty($criteria)) {
            return null;
        }

        if (1 === count($criteria)) {
            return $criteria[0];
        }

        return new LogicalAnd($criteria);
    }
1078218
public function formatParameters($parameters)
    {
        $parameters = Arr::wrap($parameters);

        foreach ($parameters as $key => $parameter) {
            if ($parameter instanceof UrlRoutable) {
                $parameters[$key] = $parameter->getRouteKey();
            }
        }

        return $parameters;
    }
1299309
public function setParameters(array $parameters)
    {
        $this->_parameters       = array();
        $this->_parameterNameMap = array();
        $this->addParameters($parameters);
        return $this;
    }