Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

(no description)

File Size: 740 lines (22 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: Uri  - X-Ref

PSR-7 URI implementation.

__construct(string $uri = '')   X-Ref
No description

parse(string $url)   X-Ref
UTF-8 aware \parse_url() replacement.

The internal function produces broken output for non ASCII domain names
(IDN) when used with locales other than "C".

On the other hand, cURL understands IDN correctly only when UTF-8 locale
is configured ("C.UTF-8", "en_US.UTF-8", etc.).

return: array|false

__toString()   X-Ref
No description

composeComponents(?string $scheme, ?string $authority, string $path, ?string $query, ?string $fragment)   X-Ref
Composes a URI reference string from its various components.

Usually this method does not need to be called manually but instead is used indirectly via
`Psr\Http\Message\UriInterface::__toString`.

PSR-7 UriInterface treats an empty component the same as a missing component as
getQuery(), getFragment() etc. always return a string. This explains the slight
difference to RFC 3986 Section 5.3.

Another adjustment is that the authority separator is added even when the authority is missing/empty
for the "file" scheme. This is because PHP stream functions like `file_get_contents` only work with
`file:///myfile` but not with `file:/myfile` although they are equivalent according to RFC 3986. But
`file:///` is the more common syntax for the file scheme anyway (Chrome for example redirects to
that format).


isDefaultPort(UriInterface $uri)   X-Ref
Whether the URI has the default port of the current scheme.

`Psr\Http\Message\UriInterface::getPort` may return null or the standard port. This method can be used
independently of the implementation.

isAbsolute(UriInterface $uri)   X-Ref
Whether the URI is absolute, i.e. it has a scheme.

An instance of UriInterface can either be an absolute URI or a relative reference. This method returns true
if it is the former. An absolute URI has a scheme. A relative reference is used to express a URI relative
to another URI, the base URI. Relative references can be divided into several forms:
- network-path references, e.g. '//example.com/path'
- absolute-path references, e.g. '/path'
- relative-path references, e.g. 'subpath'


isNetworkPathReference(UriInterface $uri)   X-Ref
Whether the URI is a network-path reference.

A relative reference that begins with two slash characters is termed an network-path reference.


isAbsolutePathReference(UriInterface $uri)   X-Ref
Whether the URI is a absolute-path reference.

A relative reference that begins with a single slash character is termed an absolute-path reference.


isRelativePathReference(UriInterface $uri)   X-Ref
Whether the URI is a relative-path reference.

A relative reference that does not begin with a slash character is termed a relative-path reference.


isSameDocumentReference(UriInterface $uri, UriInterface $base = null)   X-Ref
Whether the URI is a same-document reference.

A same-document reference refers to a URI that is, aside from its fragment
component, identical to the base URI. When no base URI is given, only an empty
URI reference (apart from its fragment) is considered a same-document reference.

param: UriInterface      $uri  The URI to check
param: UriInterface|null $base An optional base URI to compare against

withoutQueryValue(UriInterface $uri, string $key)   X-Ref
Creates a new URI with a specific query string value removed.

Any existing query string values that exactly match the provided key are
removed.

param: UriInterface $uri URI to use as a base.
param: string       $key Query string key to remove.

withQueryValue(UriInterface $uri, string $key, ?string $value)   X-Ref
Creates a new URI with a specific query string value.

Any existing query string values that exactly match the provided key are
removed and replaced with the given key value pair.

A value of null will set the query string key without a value, e.g. "key"
instead of "key=value".

param: UriInterface $uri   URI to use as a base.
param: string       $key   Key to set.
param: string|null  $value Value to set

withQueryValues(UriInterface $uri, array $keyValueArray)   X-Ref
Creates a new URI with multiple specific query string values.

It has the same behavior as withQueryValue() but for an associative array of key => value.

param: UriInterface               $uri           URI to use as a base.
param: array<string, string|null> $keyValueArray Associative array of key and values

fromParts(array $parts)   X-Ref
Creates a URI from a hash of `parse_url` components.


getScheme()   X-Ref
No description

getAuthority()   X-Ref
No description

getUserInfo()   X-Ref
No description

getHost()   X-Ref
No description

getPort()   X-Ref
No description

getPath()   X-Ref
No description

getQuery()   X-Ref
No description

getFragment()   X-Ref
No description

withScheme($scheme)   X-Ref
No description

withUserInfo($user, $password = null)   X-Ref
No description

withHost($host)   X-Ref
No description

withPort($port)   X-Ref
No description

withPath($path)   X-Ref
No description

withQuery($query)   X-Ref
No description

withFragment($fragment)   X-Ref
No description

jsonSerialize()   X-Ref
No description

applyParts(array $parts)   X-Ref
Apply parse_url parts to a URI.

param: array $parts Array of parse_url parts to apply.

filterScheme($scheme)   X-Ref

param: mixed $scheme

filterUserInfoComponent($component)   X-Ref

param: mixed $component

filterHost($host)   X-Ref

param: mixed $host

filterPort($port)   X-Ref

param: mixed $port

getFilteredQueryString(UriInterface $uri, array $keys)   X-Ref

param: string[] $keys
return: string[]

generateQueryString(string $key, ?string $value)   X-Ref
No description

removeDefaultPort()   X-Ref
No description

filterPath($path)   X-Ref
Filters the path of a URI

param: mixed $path

filterQueryAndFragment($str)   X-Ref
Filters the query string or fragment of a URI.

param: mixed $str

rawurlencodeMatchZero(array $match)   X-Ref
No description

validateState()   X-Ref
No description