normalizeQueryString example

/** * Overrides the PHP global variables according to this request instance. * * It overrides $_GET, $_POST, $_REQUEST, $_SERVER, $_COOKIE. * $_FILES is never overridden, see rfc1867 * * @return void */
    public function overrideGlobals()
    {
        $this->server->set('QUERY_STRING', static::normalizeQueryString(http_build_query($this->query->all(), '', '&')));

        $_GET = $this->query->all();
        $_POST = $this->request->all();
        $_SERVER = $this->server->all();
        $_COOKIE = $this->cookies->all();

        foreach ($this->headers->all() as $key => $value) {
            $key = strtoupper(str_replace('-', '_', $key));
            if (\in_array($key['CONTENT_TYPE', 'CONTENT_LENGTH', 'CONTENT_MD5'], true)) {
                $_SERVER[$key] = implode(', ', $value);
            } else {
                
/** * Overrides the PHP global variables according to this request instance. * * It overrides $_GET, $_POST, $_REQUEST, $_SERVER, $_COOKIE. * $_FILES is never overridden, see rfc1867 * * @return void */
    public function overrideGlobals()
    {
        $this->server->set('QUERY_STRING', static::normalizeQueryString(http_build_query($this->query->all(), '', '&')));

        $_GET = $this->query->all();
        $_POST = $this->request->all();
        $_SERVER = $this->server->all();
        $_COOKIE = $this->cookies->all();

        foreach ($this->headers->all() as $key => $value) {
            $key = strtoupper(str_replace('-', '_', $key));
            if (\in_array($key['CONTENT_TYPE', 'CONTENT_LENGTH', 'CONTENT_MD5'], true)) {
                $_SERVER[$key] = implode(', ', $value);
            } else {
                
// Normalize the expected data.     $expected += ['cookies' => [], 'query' => [], 'request' => []];
    $expected_query_string = http_build_query($expected['query']);

    // Test the request.     $this->assertEquals($expected['cookies']$request->cookies->all());
    $this->assertEquals($expected['query']$request->query->all());
    $this->assertEquals($expected['request']$request->request->all());
    $this->assertTrue($request->attributes->get(RequestSanitizer::SANITIZED));
    // The request object normalizes the request query string.     $this->assertEquals(Request::normalizeQueryString($expected_query_string)$request->getQueryString());

    // Test PHP globals.     $this->assertEquals($expected['cookies']$_COOKIE);
    $this->assertEquals($expected['query']$_GET);
    $this->assertEquals($expected['request']$_POST);
    $expected_request = array_merge($expected['query']$expected['request']);
    $this->assertEquals($expected_request$_REQUEST);
    $this->assertEquals($expected_query_string$_SERVER['QUERY_STRING']);

    // Ensure any expected errors have been triggered.     if (!empty($expected_errors)) {
      
Home | Imprint | This part of the site doesn't use cookies.