builds/returns an array compatible with the result from parse_url()

@param string $uri
@return array compatible with parse_url()
426751
public function &toArray()
	{
		$arr =	[];

		if ($this->_scheme !== null)
			$arr['scheme']		=	$this->_scheme;

		if ($this->_user !== null)
			$arr['user']		=	$this->_user;

		if ($this->_pass !== null)
			$arr['pass']		=	$this->_pass;

		if ($this->_host !== null)
			$arr['host']		=	$this->_host;

		if ($this->_port !== null)
			$arr['port']		=	$this->_port;

		if ($this->_path !== null)
			$arr['path']		=	$this->_path;

		if ($this->_query !== null)
			$arr['query']		=	$this->_query;

		if ($this->_frag !== null)
			$arr['fragment']	=	$this->_frag;

		return $arr;
	}
192461
protected function parse($uri)
	{
		// Set the original URI to fall back on
		$this->uri = $uri;

		/*
		 * Parse the URI and populate the object fields. If URI is parsed properly,
		 * set method return value to true.
		 */

		$parts = UriHelper::parse_url($uri);

		$retval = ($parts) ? true : false;

		// We need to replace &amp; with & for parse_str to work right...
		if (isset($parts['query']) && strpos($parts['query'], '&amp;'))
		{
			$parts['query'] = str_replace('&amp;', '&', $parts['query']);
		}

		$this->scheme   = isset($parts['scheme']) ? $parts['scheme'] : null;
		$this->user     = isset($parts['user']) ? $parts['user'] : null;
		$this->pass     = isset($parts['pass']) ? $parts['pass'] : null;
		$this->host     = isset($parts['host']) ? $parts['host'] : null;
		$this->port     = isset($parts['port']) ? $parts['port'] : null;
		$this->path     = isset($parts['path']) ? $parts['path'] : null;
		$this->query    = isset($parts['query']) ? $parts['query'] : null;
		$this->fragment = isset($parts['fragment']) ? $parts['fragment'] : null;

		// Parse the query
		if (isset($parts['query']))
		{
			parse_str($parts['query'], $this->vars);
		}

		return $retval;
	}
748886
static function headerOverrideArray( $uri )
    {
        $headerArray = array();

        if ( !eZHTTPHeader::enabled() )
        {
            return $headerArray;
        }

        $contentView = false;

        $uriString = eZURLAliasML::cleanURL( $uri->uriString() );

        // If content/view used, get url alias for node
        if ( strpos( $uriString, 'content/view/' ) === 0 )
        {
            $urlParts = explode( '/', $uriString );
            $nodeID = $urlParts[3];
            if ( !$nodeID )
            {
                return $headerArray;
            }

            $node = eZContentObjectTreeNode::fetch( $nodeID );
            if ( !$node )
            {
                return $headerArray;
            }

            $uriString = $node->pathWithNames();
            $contentView = true;
        }
        else
        {
            $uriCopy = clone $uri;
            eZURLAliasML::translate( $uriCopy );
            if ( strpos( $uriCopy->uriString(), 'content/view' ) === 0 )
            {
                $contentView = true;
            }
        }

        $uriString = '/' . eZURLAliasML::cleanURL( $uriString );
        $ini = eZINI::instance();

        foreach( $ini->variable( 'HTTPHeaderSettings', 'HeaderList' ) as $header )
        {
            foreach( $ini->variable( 'HTTPHeaderSettings', $header ) as $path => $value )
            {
                $path = '/' . eZURLAliasML::cleanURL( $path );
                if ( strlen( $path ) == 1 &&
                     ( !$contentView && ( $ini->variable( 'HTTPHeaderSettings', 'OnlyForContent' ) === 'enabled' ) ) &&
                     $uriString != '/' )
                {
                    continue;
                }

                if ( strpos( $uriString, $path ) === 0 )
                {
                    $config = eZStringUtils::explodeStr( $value, ';' );
                    $headerValue = $config[0];
                    $depth = isset( $config[1] ) ? $config[1] : null;
                    $level = isset( $config[2] ) ? $config[2] : null;

                    if ( $header == 'Expires' )
                    {
                        $headerValue = gmdate( 'D, d M Y H:i:s', time() + $headerValue ) . ' GMT';
                    }

                    if ( $depth === null )
                    {
                        $headerArray[$header] = $headerValue;
                    }
                    else
                    {
                        $pathLevel = count( explode( '/', $path ) );
                        $uriLevel = count( explode( '/', $uriString ) );
                        if ( $level === null )
                        {
                            if ( $uriLevel <= $pathLevel + $depth )
                            {
                                $headerArray[$header] = $headerValue;
                            }
                        }
                        else
                        {
                            if ( $uriLevel <= $pathLevel + $depth &&
                                 $uriLevel >= $pathLevel + $level )
                            {
                                $headerArray[$header] = $headerValue;
                            }
                        }
                    }
                }
            }
        }

        return $headerArray;
    }
508100
private function match(string $uri, string $routeUri): ?array
    {
        if ($uri === $routeUri) {
            return [];
        }

        return $this->getArguments($uri, $routeUri);
    }
859839
protected function transformToMetadata($uri) {
    if (is_array($uri)) {
      return $uri;
    }
    $exploded = explode($this->fedora->getBaseUri(), $uri);
    return $this->getMetadata($exploded[1]);
  }
466565
protected function makeUriRelativeTo($uri, $root)
    {
        if (!$root) {
            return $uri;
        }

        if (is_array($uri)) {
            $uris = [];
            foreach ($uri as $u) {
                $uris[] = $this->makeUriRelativeTo($u, $root);
            }
            return $uris;
        }

        if (substr($uri, 0, 1) === '/' || preg_match('/^([a-zA-Z]+:\/\/|[a-zA-Z]:\/|[a-zA-Z]:\\\)/', $uri)) {
            return $uri;
        }
        return rtrim($root, '/') . "/$uri";
    }
402078
protected function _parseFromString($uri)
    {
        if (false === $parts = parse_url($uri))
            throw new \InvalidArgumentException(sprintf(
                'Malformed uri (%s).'
                , $uri
            ));

        $this->scheme    = isset($parts['scheme'])   ? $parts['scheme']   : '';
        $this->userInfo  = isset($parts['user'])     ? $parts['user']     : '';
        $this->host      = isset($parts['host'])     ? $this->_filterHost($parts['host']) : '';
        $this->port      = isset($parts['port'])     ? $parts['port']     : null;
        $this->path      = isset($parts['path'])     ? $parts['path']     : '';
        $this->query     = isset($parts['query'])    ? $parts['query']    : '';
        $this->fragment  = isset($parts['fragment']) ? $parts['fragment'] : '';

        if (isset($parts['pass']))
            $this->userInfo .= ':' . $parts['pass'];
    }
1000822
public function load(string $uri): \stdClass
    {
        $response = $this->reader->read($uri);

        foreach ($this->parsers as $parser) {
            if (!$parser->canParse($response->getContentType())) {
                continue;
            }

            return $parser->parse($response->getContent());
        }

        throw new ResourceNotParsableException("No parser for response of '$uri''");
    }
678260
protected function _uri_string($uri)
	{
		if ($this->item('enable_query_strings') == FALSE)
		{
			if (is_array($uri))
			{
				$uri = implode('/', $uri);
			}
			$uri = trim($uri, '/');
		}
		else
		{
			if (is_array($uri))
			{
				$i = 0;
				$str = '';
				foreach ($uri as $key => $val)
				{
					$prefix = ($i == 0) ? '' : '&';
					$str .= $prefix.$key.'='.$val;
					$i++;
				}
				$uri = $str;
			}
		}
	    return $uri;
	}
695305
protected function parse($uri)
    {
        $uri     = (string) $uri;
        $matches = array();

        preg_match('!' . self::getPattern() . '!', $uri, $matches);

        $scheme    = isset($matches[2]) ? $matches[2] : null;
        $authority = isset($matches[4]) ? $matches[4] : null;
        $path      = isset($matches[5]) ? $matches[5] : null;
        $query     = isset($matches[7]) ? $matches[7] : null;
        $fragment  = isset($matches[9]) ? $matches[9] : null;

        $this->scheme    = $scheme;
        $this->authority = $authority;
        $this->path      = $path;
        $this->query     = $query;
        $this->fragment  = $fragment;

        $this->parseAuthority($authority);
        $this->parseParameters($query);
    }
124173
public function get($uri, $fields = array())
    {
        $fields_string = '';
        foreach ($fields as $key => $value) {
            $fields_string .= $key . '=' . $value . '&';
        }
        rtrim($fields_string, '&');
        $url = $this->getURI($uri) . '?' . $fields_string;
        return get($url, $this->getAuth());
    }
814864
private function parseUri($uri)
    {
        $components = parse_url($uri);

        if (!$components) {
            throw new InvalidValueException('Invalid URI.');
        }

        $this->scheme   = isset($components['scheme'])   ? $this->filterScheme($components['scheme']) : '';
        $this->host     = isset($components['host'])     ? $components['host'] : '';
        $this->port     = isset($components['port'])     ? $this->filterPort($components['port']) : 0;
        $this->user     = isset($components['user'])     ? decode($components['user']) : '';
        $this->password = isset($components['pass'])     ? decode($components['pass']) : '';
        $this->path     = isset($components['path'])     ? $this->parsePath($components['path']) : '';
        $this->query    = isset($components['query'])    ? $this->parseQuery($components['query']) : [];
        $this->fragment = isset($components['fragment']) ? $this->parseFragment($components['fragment']) : '';
    }
399337
public function toRequestArray(string $uri = ''): array
    {
        $r = [];
        if (!empty($this->raw)) {
            $priorities = [];
            /** @var $cookie Cookie */
            foreach ($this->raw as $cookie) {
                if ($cookie->isValid($uri)) {
                    //Session cookie or unexpired && match domain path
                    $priority = strlen($cookie->domain); //Record priority, the higher the match, the higher the priority
                    if (!isset($r[$cookie->name]) || $priorities[$cookie->name] < $priority) {
                        //The cookie of the name is not set or the cookie set has a lower priority than the current cookie
                        $r[$cookie->name] = $cookie->value;
                        $priorities[$cookie->name] = $priority;
                    }
                }
            }
        }

        return $r;
    }
337154
protected function httpGet($uri)
    {
        $results = [];
        // Start requesting at page 1
        $page = 1;
        $pageSize = 100;
        // We dont know how many pages there are, so assume 1 until we know
        $pagecount = 1;
        while ($page <= $pagecount) {
            //echo('fetching page '.$page.' of '.$pagecount.' current result size is '.count($results).PHP_EOL);
            $this->log[] = [
                        'request' => [
                                    'method' => 'GET',
                                    'uri'    => $uri.'?page='.$page.'&per_page='.$pageSize,
                                    ],
                        ];
            $response = \Httpful\Request::get($uri.'?page='.$page)
                                                    ->basicAuth($this->username, $this->password)
                                                    ->expectsType(\Httpful\Mime::JSON)
                                                    ->parseWith(function ($body) {
                                                        return \Metaclassing\Utility::decodeJson($body);
                                                    })
                                                    ->send()
                                                    ->body;
            $this->log[count($this->log) - 1]['response'] = $response;

            $resultKey = '';
            if (isset($response['zones'])) {
                $resultKey = 'zones';
            }
            if (isset($response['resource_records'])) {
                $resultKey = 'resource_records';
            }
            if (!$resultKey) {
                throw new \Exception('Unhandled results key, check dns client logs for details');
            }
            foreach ($response[$resultKey] as $result) {
                array_push($results, $result);
            }
            // Now that we KNOW the pagecount, update that and increment our page counter
            if (isset($response['total_count'])) {
                $totalResults = $response['total_count'];
                $pagecount = ceil($totalResults / $pageSize);
            }
            // And get the next page ready for the next request
            $page++;
        }

        return $results;
    }
295852
protected function _parseUri($uri)
    {
        $parts = parse_url($uri);

        if (false === $parts) {
            throw new \InvalidArgumentException(
                'The source URI string appears to be malformed'
            );
        }

        $this->_scheme    = isset($parts['scheme'])   ? $this->_filterScheme($parts['scheme']) : '';
        $this->_userInfo  = isset($parts['user'])     ? $parts['user']     : '';
        $this->_host      = isset($parts['host'])     ? $parts['host']     : '';
        $this->_port      = isset($parts['port'])     ? $parts['port']     : null;
        $this->_path      = isset($parts['path'])     ? $this->_filterPath($parts['path']) : '';
        $this->_query     = isset($parts['query'])    ? $this->_filterQuery($parts['query']) : '';
        $this->_fragment  = isset($parts['fragment']) ? $this->_filterFragment($parts['fragment']) : '';

        if (isset($parts['pass'])) {
            $this->_userInfo .= ':' . $parts['pass'];
        }
    }
198118
public function validateUri($uri)
    {
        $query = http_build_query(array_merge(
            $this->getOptions()->buildOptions(),
            array('uri' => $uri)
        ));

        $context = stream_context_create(array(
            'http' => array(
                'method' => 'GET',
                'header' => 'User-Agent: HTMLValidator',
            )
        ));

        $data = $this->sendRequest($this->validatorUri . '?' . $query, $context);

        return $this->parseSOAP12Response($data);
    }
1297940
public function &findPageByUri($uri)
    {
        foreach ($this->getRootSection()->getSections() as $section) {
            if ($page = $section->findPageByUri($uri)) {
                return $page;
            }
        }

        return;
    }