Extract a parameter from a given string

@param string $parameter The parameter string of a function
@param array  $variables The current scope

@return array
@throws SyntaxErrorException
@throws UndefinedSymbolException
487136
protected function extractParameter(string $parameter, array $variables): array
    {
        $result = preg_match(
            '/^\s*' . self::REGEX_VARIABLE . '(\s*,\s*(?<next>.+))?\s*$/is',
            $parameter,
            $matches
        );

        if ($result === 0) {
            throw new SyntaxErrorException("Invalid parameter list $parameter");
        }

        return empty($matches['next'])
            ? [$this->getValue($matches, $variables)]
            : array_merge(
                [$this->getValue($matches, $variables)],
                $this->extractParameter($matches['next'], $variables)
            );
    }
406921
protected function _toQuerystring($parameters) {
		$out = '';
		$keys = array_keys($parameters);
		$count = count($parameters);
		for ($i = 0; $i < $count; $i++) {
			$out .= $keys[$i] . '=' . $parameters[$keys[$i]];
			if ($i < $count - 1) {
				$out .= '&';
			}
		}
		return $out;
	}
344431
public function removeParameters(array $parameters = null)
  {
    if ($this->isLocked()) {
      return $this->getObj()->removeParameters($parameters)->setLocked();
    } else {
      return parent::removeParameters($parameters);
    }
  }
969140
private function validateParameters($parameters)
    {
        $allowedParameters = [
            'chunk-size',
            'element-uuid',
            'headers',
            'ttl',
            'uuid',
        ];

        foreach (array_keys($parameters) as $key) {
            if (!in_array($key, $allowedParameters)) {
                throw new MalformedParametersException();
            }
        }
    }
1370147
public static function create($parameters)
    {
        if (is_string($parameters)) {
            return self::fromString($parameters);
        }

        if (is_array($parameters)) {
            return self::fromArray($parameters);
        }

        throw new InvalidArgumentException('Invalid parameters type');
    }
876270
public function execute( $parameters = null )
    {
        if ( empty( $parameters ) )
        {
            $_result = $this->_statement->execute();
        }
        else
        {
            $_result = $this->_statement->execute( $parameters );
        }

        if ( false === $_result )
        {
            $this->_errorInfo = $this->_statement->errorInfo();
            Log::error( 'SQL error: [' . $this->_errorInfo[0] . '-' . $this->_errorInfo[1] . '] ' . $this->_errorInfo[2] );
        }

        return $this->_executeResult = $_result;
    }
648941
protected function passGetScope(array $parameters): ?array
    {
        $scope = $this->passReadStringValue($parameters, 'scope');

        return empty($scope) === false ? explode(' ', $scope) : null;
    }
584382
protected function codeGetScope(array $parameters): ?array
    {
        $scope = $this->codeReadStringValue($parameters, 'scope');

        return empty($scope) === false ? explode(' ', $scope) : null;
    }
166369
protected function validateByOwnMethod($ruleName, array $vars, array $parameters)
    {
        $method = $this->getMethodBySnakeCaseName($ruleName);

        $methodParams = Lambda::mergeArguments([$this, $method], $vars, $parameters);

        return call_user_func_array([$this, $method], $methodParams);
    }
1271933
public static function parameters(array $parameters)
    {
        $args = array();
        foreach ($parameters as $param) {
            $arg = '';

            if ($param->isPassedByReference()) {
                $arg .= '&';
            }

            $arg .= '$' . $param->getName();

            if ($param->isOptional()) {
                $arg .= ' = ';

                switch (true) {
                    case null === $param->getDefaultValue():
                        $arg .= 'null';
                        break;
                    case is_array($param->getDefaultValue()):
                        $arg .= 'array()';
                        break;
                    case is_bool($param->getDefaultValue()):
                        $arg .= $param->getDefaultValue() ? 'true' : 'false';
                        break;
                    case is_int($param->getDefaultValue()):
                        $arg .= $param->getDefaultValue();
                        break;
                    default:
                        $arg .= '\'' . str_replace('\'', '\\\'', $param->getDefaultValue()) . '\'';
                        break;
                }
            }

            $args[] = $arg;
        }

        return $args;
    }
974544
protected function clientGetScope(array $parameters): ?array
    {
        $scope = $this->clientReadStringValue($parameters, 'scope');

        return empty($scope) === false ? explode(' ', $scope) : null;
    }
1044257
protected function replaceRoutableParameters($parameters = array())
	{
		$parameters = is_array($parameters) ? $parameters : array($parameters);

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

		return $parameters;
	}
38829
def extract_variables_from_string(string)
      string.split(/ /).map do |defintion|
        match = defintion.match STRING_REG_EX
        next nil unless match

        { match[1] => match[2] }
      end.reject(&:nil?)
    end
536227
private function parametersToData(array $parameters)
    {
        $data = array();

        foreach ($parameters as $parameter) {
            $data[$parameter->getName()] = $this->parameterToData($parameter);
        }

        return (object) $data;
    }
419006
public function invoke(array $parameters): string
    {
        $string = '';
        foreach ($parameters as $parameter) {
            $string .= $parameter . ', ';
        }
        return substr($string, 0, -2);
    }
424195
public function getParameter($parameter)
    {
        $param_array = $this->getParameters();

        if (!empty($param_array) && array_key_exists($parameter, $param_array)) {
            return $param_array[$parameter];
        } else {
            throw new \Exception('UNKNOWN_PARAMETER');
        }
    }
490567
private function extract(iterable $extractors, string $method, array $arguments)
    {
        foreach ($extractors as $extractor) {
            if (null !== $value = $extractor->{$method}(...$arguments)) {
                return $value;
            }
        }
    }