Parse a query string into a QueryString object

@param string $query Query string to parse

@return self
171943
public static function fromString($query)
    {
        $q = new static();

        if ($query || $query === '0') {
            if ($query[0] == '?') {
                $query = substr($query, 1);
            }
            foreach (explode('&', $query) as $kvp) {
                $parts = explode('=', $kvp, 2);
                $key = rawurldecode($parts[0]);

                if ($paramIsPhpStyleArray = substr($key, -2) == '[]') {
                    $key = substr($key, 0, -2);
                }

                if (isset($parts[1])) {
                    $value = rawurldecode(str_replace('+', '%20', $parts[1]));
                    if ($paramIsPhpStyleArray && !$q->hasKey($key)) {
                        $value = array($value);
                    }
                    $q->add($key, $value);
                } else {
                    $q->add($key, null);
                }
            }
        }

        return $q;
    }
443198
function setQuery($query)
    {
        if ($query !== null) {
            $q = $this->getQuery();
            $q->with($q::parseWith($query));
        }

        return $this;
    }
1133121
protected function query_parse($query)
    {
        $start = $this->options['identifier_start'];
        $end   = $this->options['identifier_end'];
        $quote = self::DEFAULT_QUOTE;

        if ($start == $quote) {
            return $query;
        }

        $pos = 0;
        $in  = false;

        while ($pos = strpos($query, $quote, $pos)) {
            if ($query[$pos+1] == $quote) {  // skip escaped quote
                $pos += 2;
            }
            else {
                if ($in) {
                    $q  = $end;
                    $in = false;
                }
                else {
                    $q  = $start;
                    $in = true;
                }

                $query = substr_replace($query, $q, $pos, 1);
                $pos++;
            }
        }

        return $query;
    }
648741
protected function createSub($query)
    {
        // If the given query is a Closure, we will execute it while passing in a new
        // query instance to the Closure. This will give the developer a chance to
        // format and work with the query before we cast it to a raw SQL string.
        if ($query instanceof Closure) {
            $callback = $query;

            $callback($query = $this->forSubQuery());
        }

        return $this->parseSub($query);
    }
1079529
private function parseRewriteRule( $match, $query ) {
        $matches = [ ];
        $request_match = $this->request;
        if ( ! empty( $this->request ) && strpos( $match, $this->request ) === 0 ) {
            $request_match = $this->request . '/' . $this->request;
        }
        if (
            preg_match( "#^{$match}#", $request_match, $matches )
            || preg_match( "#^{$match}#", urldecode( $request_match ), $matches )
        ) {
            $varmatch = NULL;
            if ( $this->resolver->isVerbose() && preg_match( '/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch ) ) {
                $page = get_page_by_path( $matches[ $varmatch[1] ] );
                if ( ! $page ) {
                    return;
                }
            }
            $this->matched_rule = $match;
        }
        return $matches;
    }
1306451
protected function parseQuery(QueryInterface $query) {
        $operationList = $query->getStoredQueryCriteria();
        $pos = 0;
        foreach ($operationList as $operation) {
            if($pos > 0) {
                $this->addSeparator(true);
            }
            $this->parseOperation($operation);
            $pos++;
            
        }
        return $this;
    }
611984
public static Map<String, String> parseQueryString(String query) {
    Map<String, String> queryMap = new HashMap<>();
    if (query == null || query.isEmpty()) {
      return queryMap;
    }
    // The query string should escape '&'.
    String[] entries = query.split(String.valueOf(QUERY_SEPARATOR));

    try {
      for (String entry : entries) {
        // There should be at most 2 parts, since key and value both should escape '='.
        String[] parts = entry.split(String.valueOf(QUERY_KEY_VALUE_SEPARATOR));
        if (parts.length == 0) {
          // Skip this empty entry.
        } else if (parts.length == 1) {
          // There is no value part. Just use empty string as the value.
          String key = URLDecoder.decode(parts[0], "UTF-8");
          queryMap.put(key, "");
        } else {
          // Save the key and value.
          String key = URLDecoder.decode(parts[0], "UTF-8");
          String value = URLDecoder.decode(parts[1], "UTF-8");
          queryMap.put(key, value);
        }
      }
    } catch (UnsupportedEncodingException e) {
      // This is unexpected.
      throw new RuntimeException(e);
    }
    return queryMap;
  }
545716
public function parse($query)
    {
        $node = new Nodes\RootNode();
        $node->setValue($query);

        $l = new Nodes\UndefinedLogicNode();
        $node->addChild($l);

        $t = new Nodes\TextNode();
        $t->setValue($query);
        $l->addChild($t);

        // $this->addResolver(new Resolvers\TextResolver());

        foreach ($this->resolvers as $token) {
            $token->resolve($node);
        }

        // From Root to Logic
        $node = $node->getChildByIndex(0);

        if ($node === null) {
            throw new Exceptions\QuerySyntaxException($query);
        }

        $node->setParent(null);

        // If logic has only one child, skip to first key node
        if (count($node->getChildren()) === 1) {
            $node = $node->getChildByIndex(0);
            $node->setParent(null);
        }

        if ($node instanceof Nodes\UndefinedLogicNode) {
            throw new Exceptions\QuerySyntaxException($query);
        }

        return $node;
    }
329238
public function search($query)
    {
        if ($this->hasSearch()) {

            $search = $this->search;

            // If it's a anonymous function
            if (!is_string($search) && is_callable($search)) {
                call_user_func($search, $this, $query);
            }
        }

        return $this;
    }
1166128
protected function setQuery($query)
    {
        $this->uriString = null;

        $query = ltrim($query, '?');

        if (strpos($query, '#') !== false) {
            throw new InvalidArgumentException(
                'Query string must not include a URI fragment.'
            );
        }

        $this->query = static::encode($query);

        return $this;
    }
873648
public function query($query = NULL) {
        if (isset($query)) {
            $this->setQuery(self::cleanQuery($query));
            return $this;
        }
        return $this->getQuery();
    }
1035125
private function setQuery($query)
    {
        $this->query =  preg_replace_callback(
            '/(?:[^' . self::$charList . '%:@\/\?]+|%(?![A-Fa-f0-9]{2}))/',
            [$this, 'encode'],
            $query
        );

        return $this;
    }
651335
public Map<String, List<String>> parseQuery(String query)
    {
        Map<String, List<String>> queryParams = new LinkedHashMap<>();
        if (query != null) {
            for (NameValuePair params : URLEncodedUtils.parse(query, StandardCharsets.UTF_8)) {
                String name = params.getName();
                List<String> values = queryParams.get(name);
                if (values == null) {
                    values = new ArrayList<>();
                    queryParams.put(name, values);
                }
                values.add(params.getValue());
            }
        }
        return queryParams;
    }
872623
function querystring(query) {
      var parser = /([^=?&]+)=([^&]*)/g
        , result = {}
        , part;

      //
      // Little nifty parsing hack, leverage the fact that RegExp.exec increments
      // the lastIndex property so we can continue executing this loop until we've
      // parsed all results.
      //
      for (;
        part = parser.exec(query);
        result[decodeURIComponent(part[1])] = decodeURIComponent(part[2])
      );

      return result;
    }
134501
public function parse($query=null)
    {
        $this->checkQuery($query);
        
        return $this->getDb()->setQuery($this->getQuery())->parse();
    }
949545
private function parse(&$params, &$query) {

		//Check the type of param binding ("?" = all keys are numeric or ":" = all keys are strings)
	 	if(0 !== count(array_filter(array_keys($params), 'is_string'))) {
			
			preg_match_all('#:((?:[a-zA-Z_])(?:[a-zA-Z0-9-_]+)?)#', $query, $variables);

			if(true === isset($variables[0])) {

				$parameters = [];

				foreach($variables[0] as $index => $variable) {
					
					if(false === array_key_exists($variables[1][$index], $params)) {
						return trigger_error(sprintf('Parameter "%s" missing from bind parameters', $variables[1][$index]), E_USER_ERROR);
					}
					
					$parameters[] =& $params[$variables[1][$index]];
					$query = str_replace($variables[0][$index], '?', $query);
				}

				$params = $parameters;
			}
	 	}

		$bind = [];

		if(count($params) > 0) {

			$types = '';

			foreach($params as $param => $value) {

				switch(gettype($value)) {
		            
		            case 'NULL'		:
		            case 'string'	: $types .= 's'; break;

		            case 'boolean'	:
		            case 'integer'	: $types .= 'i'; break;
		            
		            case 'blob'		: $types .= 'b'; break;
		            
		            case 'double'	: $types .= 'd'; break;
		        }
			}

			$bind[] =& $types;

			foreach($params as $param => $value) {
				$bind[] =& $params[$param];
			}
		}

		return $bind;
	}
932111
private function parseQuery($query)
	{
		$string = '';
		if (is_array($query))
		{
			foreach ($query as $index => $value)
			{
				$string .= !empty($string) ? ' AND ' : '';
				$string .= $index . ':' . $value;
			}
		}
		else
		{
			$string = 'id:' . $query;
		}
		return $string;
	}