populateGlobals example

        // URI is found, and also fixes the QUERY_STRING Server var and $_GET array.         if (trim($uri, '/') === '' && strncmp($query, '/', 1) === 0) {
            $query                   = explode('?', $query, 2);
            $uri                     = $query[0];
            $_SERVER['QUERY_STRING'] = $query[1] ?? '';
        } else {
            $_SERVER['QUERY_STRING'] = $query;
        }

        // Update our globals for values likely to been have changed         parse_str($_SERVER['QUERY_STRING']$_GET);
        $this->populateGlobals('server');
        $this->populateGlobals('get');

        $uri = URI::removeDotSegments($uri);

        return ($uri === '/' || $uri === '') ? '/' : ltrim($uri, '/');
    }

    /** * Parse QUERY_STRING * * Will parse QUERY_STRING and automatically detect the URI from it. * * @deprecated 4.4.0 Moved to SiteURIFactory. */

    public function fetchGlobal(string $method$index = null, ?int $filter = null, $flags = null)
    {
        $method = strtolower($method);

        if (isset($this->globals[$method])) {
            $this->populateGlobals($method);
        }

        // Null filters cause null values to return.         $filter ??= FILTER_DEFAULT;
        $flags = is_array($flags) ? $flags : (is_numeric($flags) ? (int) $flags : 0);

        // Return all values when $index is null         if ($index === null) {
            $values = [];

            foreach ($this->globals[$method] as $key => $value) {
                

    public function call(string $method, string $path, ?array $params = null)
    {
        // Simulate having a blank session         $_SESSION                  = [];
        $_SERVER['REQUEST_METHOD'] = $method;

        $request = $this->setupRequest($method$path);
        $request = $this->setupHeaders($request);
        $request = $this->populateGlobals($method$request$params);
        $request = $this->setRequestBody($request$params);

        // Initialize the RouteCollection         if ($routes = $this->routes) {
            $routes = Services::routes()->loadRoutes();
        }

        $routes->setHTTPVerb($method);

        // Make sure any other classes that might call the request         // instance get the right one.
        // not relevant to unit testing         if (\ob_get_level() > 0 && (isset($this->clean) || $this->clean === true)) {
            \ob_end_clean(); // @codeCoverageIgnore         }

        // Simulate having a blank session         $_SESSION                  = [];
        $_SERVER['REQUEST_METHOD'] = $method;

        $request = $this->setupRequest($method$path);
        $request = $this->setupHeaders($request);
        $request = $this->populateGlobals($method$request$params);
        $request = $this->setRequestBody($request);

        // Initialize the RouteCollection         if ($routes = $this->routes) {
            $routes = Services::routes()->loadRoutes();
        }

        $routes->setHTTPVerb($method);

        // Make sure any other classes that might call the request         // instance get the right one.
Home | Imprint | This part of the site doesn't use cookies.