Documentation

Uri
in package
implements Conditionable, UriInterface

FinalYes
Tags
phpstan-import-type

ComponentMap from UriString

phpstan-import-type

InputComponentMap from UriString

Table of Contents

Interfaces

Conditionable
UriInterface

Constants

ASCII  = " eiasntrolud][cmp'\ng|hv.fb,:=-q10C2*yx)(L9AS/P\"EjMIk3>5T<D4}B{8FwR67UGN;JzV#HOW_&!K?XQ%Y\\\tZ+~^\$@`\x00\x01\x02\x03\x04\x05\x06\x07\x08\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
All ASCII letters sorted by typical frequency of occurrence.
MAXIMUM_CACHED_ITEMS  = 100
Maximum number of cached items.
REGEXP_BINARY  = ',(;|^)base64$,'
Base64 content regular expression pattern.
REGEXP_FILE_PATH  = ',^(?<delim>/)?(?<volume>[a-zA-Z])(?:[:|\|]|%7C)(?<rest>.*)?,'
Regular expression pattern to for file URI.
REGEXP_HOST_PORT  = ',^(?<host>(\[.*]|[^:])*)(:(?<port>[^/?#]*))?$,x'
RFC3986 IPvFuture host and port component.
REGEXP_INVALID_CHARS  = '/[\x00-\x1f\x7f]/'
RFC3986 invalid characters.
REGEXP_MIMETYPE  = ',^\w+/[-.\w]+(?:\+[-.\w]+)?$,'
Mimetype regular expression pattern.
REGEXP_WINDOW_PATH  = ',^(?<root>[a-zA-Z][:|\|]),'
Windows filepath regular expression pattern.

Properties

$authority  : string|null
$fragment  : string|null
$host  : string|null
$origin  : string|null
$pass  : string|null
$path  : string
$port  : int|null
$query  : string|null
$scheme  : string|null
$uriAsciiString  : string
$uriUnicodeString  : string
$user  : string|null
$userInfo  : string|null

Methods

__debugInfo()  : ComponentMap
__toString()  : string
Returns the string representation as a URI reference.
createFromBaseUri()  : static
DEPRECATION WARNING! This method will be removed in the next major point release.
createFromComponents()  : self
DEPRECATION WARNING! This method will be removed in the next major point release.
createFromDataPath()  : self
DEPRECATION WARNING! This method will be removed in the next major point release.
createFromServer()  : self
DEPRECATION WARNING! This method will be removed in the next major point release.
createFromString()  : self
DEPRECATION WARNING! This method will be removed in the next major point release.
createFromUnixPath()  : self
DEPRECATION WARNING! This method will be removed in the next major point release.
createFromUri()  : self
DEPRECATION WARNING! This method will be removed in the next major point release.
createFromWindowsPath()  : self
DEPRECATION WARNING! This method will be removed in the next major point release.
equals()  : bool
fromBaseUri()  : self
DEPRECATION WARNING! This method will be removed in the next major point release.
fromComponents()  : self
Create a new instance from a hash representation of the URI similar to PHP parse_url function result.
fromData()  : self
Create a new instance from a data URI string.
fromFileContents()  : self
Create a new instance from a data file path.
fromRfc8089()  : static
Creates a new instance from a RFC8089 compatible URI.
fromServer()  : self
Create a new instance from the environment.
fromTemplate()  : self
Creates a new instance from a template.
fromUnixPath()  : self
Create a new instance from a Unix path string.
fromWindowsPath()  : self
Create a new instance from a local Windows path string.
getAuthority()  : string|null
Retrieve the authority component of the URI.
getComponents()  : ComponentMap
DEPRECATION WARNING! This method will be removed in the next major point release.
getFragment()  : string|null
Retrieve the fragment component of the URI.
getHost()  : string|null
Retrieve the host component of the URI.
getOrigin()  : string|null
getPassword()  : string|null
getPath()  : string
Retrieve the path component of the URI.
getPort()  : int|null
Retrieve the port component of the URI.
getQuery()  : string|null
Retrieve the query string of the URI.
getScheme()  : string|null
Retrieve the scheme component of the URI.
getUnicodeHost()  : string|null
getUserInfo()  : string|null
Retrieve the user information component of the URI.
getUsername()  : string|null
Returns the user component encoded value.
isAbsolute()  : bool
Tells whether the URI is absolute.
isAbsolutePath()  : bool
Tells whether the URI is an absolute path.
isCrossOrigin()  : bool
Tells whether two URI do not share the same origin.
isDomainHost()  : bool
isIpHost()  : bool
isIpv4Host()  : bool
isIpv6Host()  : bool
isIpvFutureHost()  : bool
isLocalFile()  : bool
Tells whether the `file` scheme base URI represents a local file.
isNetworkPath()  : bool
Tells whether the URI is a network path.
isOpaque()  : bool
Tells whether the URI is opaque or not.
isRegisteredNameHost()  : bool
isRelativePath()  : bool
Tells whether the URI is a relative path.
isSameDocument()  : bool
Tells whether both URIs refer to the same document.
isSameOrigin()  : bool
jsonSerialize()  : string
Returns the string representation as a URI reference.
new()  : self
Create a new instance from a string.
normalize()  : static
Normalize a URI by applying non-destructive and destructive normalization rules as defined in RFC3986 and RFC3987.
parse()  : self|null
Returns a new instance from a URI and a Base URI.or null on failure.
relativize()  : static
Relativize a URI according to a base URI.
resolve()  : static
Resolves a URI against a base URI using RFC3986 rules.
toAsciiString()  : string
Returns the string representation as a URI reference.
toComponents()  : ComponentMap
Returns an associative array containing all the URI components.
toDisplayString()  : string
Returns the human-readable string representation of the URI as an IRI.
toFileContents()  : int|null
Save the data to a specific file.
toRfc8089()  : string|null
Returns a string representation of a File URI according to RFC8089.
toString()  : string
Returns the string representation as a URI reference.
toUnicodeString()  : string
Returns the string representation as a URI reference.
toUnixPath()  : string|null
Returns the Unix filesystem path.
toWindowsPath()  : string|null
Returns the Windows filesystem path.
tryNew()  : self|null
Create a new instance from a string or a stringable structure or returns null on failure.
when()  : static
Apply the callback if the given "condition" is (or resolves to) true.
withFragment()  : static
Return an instance with the specified URI fragment.
withHost()  : static
Return an instance with the specified host.
withPassword()  : static
withPath()  : static
Return an instance with the specified path.
withPort()  : static
Return an instance with the specified port.
withQuery()  : static
Return an instance with the specified query string.
withScheme()  : static
Return an instance with the specified scheme.
withUserInfo()  : static
Return an instance with the specified user information.
withUsername()  : static
__construct()  : mixed
assertValidPath()  : void
Assert the path is a compliant with RFC2397.
assertValidRfc3986Uri()  : void
assert the URI internal state is valid.
assertValidState()  : void
assert the URI scheme is valid.
fetchHostname()  : array{0: string|null, 1: int|null}
Returns the environment host.
fetchRequestUri()  : array<int, string|null>
Returns the environment path.
fetchScheme()  : string
Returns the environment scheme.
fetchUserInfo()  : array<string|int, mixed>
Returns the environment user info.
filterString()  : string|null
Filter a string.
formatDataPath()  : string
Filter the Path component.
formatFilePath()  : string
Format the path component for the URI scheme file.
formatHost()  : string|null
Validate and Format the Host component.
formatPath()  : string
Format the Path component.
formatPathWithEmptyBaseQuery()  : string
Formatting the path to keep a resolvable URI.
formatPort()  : int|null
Format the Port component.
formatRelativePath()  : string
Formatting the path to keep a valid URI.
formatScheme()  : string|null
Format the Scheme and Host component.
getSegments()  : array<string|int, string>
returns the path segments.
isNonEmptyHostUri()  : bool
URI validation for URI schemes which disallow the empty '' host.
isNonEmptyHostUriWithoutFragment()  : bool
URI validation for URIs schemes which disallow the empty '' host and forbids the fragment component.
isNonEmptyHostUriWithoutFragmentAndQuery()  : bool
URI validation for URIs schemes which disallow the empty '' host and forbids fragment and query components.
isUriWithSchemeAndPathOnly()  : bool
URI validation for URI schemes which allows only scheme and path components.
isUriWithSchemeHostAndPathOnly()  : bool
URI validation for URI schemes which allows only scheme, host and path components.
isValidBlob()  : bool
isValidMailto()  : bool
relativizePath()  : string
Relatives the URI for an authority-less target URI.
setOrigin()  : string|null
Sets the URI origin.
validateEmailList()  : bool
validateParameter()  : bool
Validate mediatype parameter.

Constants

ASCII

All ASCII letters sorted by typical frequency of occurrence.

private string ASCII = " eiasntrolud][cmp'\ng|hv.fb,:=-q10C2*yx)(L9AS/P\"EjMIk3>5T<D4}B{8FwR67UGN;JzV#HOW_&!K?XQ%Y\\\tZ+~^\$@`\x00\x01\x02\x03\x04\x05\x06\x07\x08\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"

MAXIMUM_CACHED_ITEMS

Maximum number of cached items.

private int MAXIMUM_CACHED_ITEMS = 100

REGEXP_FILE_PATH

Regular expression pattern to for file URI.

private string REGEXP_FILE_PATH = ',^(?<delim>/)?(?<volume>[a-zA-Z])(?:[:|\|]|%7C)(?<rest>.*)?,'

contains the volume but not the volume separator. The volume separator may be URL-encoded (| as %7C) by formatPath(), so we account for that here.

REGEXP_HOST_PORT

RFC3986 IPvFuture host and port component.

private string REGEXP_HOST_PORT = ',^(?<host>(\[.*]|[^:])*)(:(?<port>[^/?#]*))?$,x'

REGEXP_WINDOW_PATH

Windows filepath regular expression pattern.

private string REGEXP_WINDOW_PATH = ',^(?<root>[a-zA-Z][:|\|]),'

contains both the volume and volume separator.

Properties

$authority read-only

private string|null $authority

$fragment read-only

private string|null $fragment

$host read-only

private string|null $host

$origin read-only

private string|null $origin

$pass read-only

private string|null $pass

$path read-only

private string $path

$port read-only

private int|null $port

$query read-only

private string|null $query

$scheme read-only

private string|null $scheme

$uriAsciiString read-only

private string $uriAsciiString

$uriUnicodeString read-only

private string $uriUnicodeString

$user read-only

private string|null $user

$userInfo read-only

private string|null $userInfo

Methods

__debugInfo()

public __debugInfo() : ComponentMap
Return values
ComponentMap

__toString()

Returns the string representation as a URI reference.

public __toString() : string
Return values
string

createFromBaseUri()

DEPRECATION WARNING! This method will be removed in the next major point release.

public static createFromBaseUri(Stringable|UriInterface|string $uri[, Stringable|UriInterface|string|null $baseUri = null ]) : static

Since version 7.0.0

use League\Uri\Uri::fromBaseUri() instead

Parameters
$uri : Stringable|UriInterface|string
$baseUri : Stringable|UriInterface|string|null = null
Tags
codeCoverageIgnore
see
Uri::fromBaseUri()

Creates a new instance from a URI and a Base URI.

The returned URI must be absolute.

Return values
static

createFromComponents()

DEPRECATION WARNING! This method will be removed in the next major point release.

public static createFromComponents([InputComponentMap $components = [] ]) : self

Since version 7.0.0

use League\Uri\Uri::fromComponents() instead

Parameters
$components : InputComponentMap = []

a hash representation of the URI similar to PHP parse_url function result

Tags
codeCoverageIgnore
see
Uri::fromComponents()
Return values
self

createFromDataPath()

DEPRECATION WARNING! This method will be removed in the next major point release.

public static createFromDataPath(string $path[, resource|null $context = null ]) : self

Since version 7.0.0

use League\Uri\Uri::fromDataPath() instead

Parameters
$path : string
$context : resource|null = null
Tags
throws
MissingFeature

If ext/fileinfo is not installed

throws
SyntaxError

If the file does not exist or is not readable

see
Uri::fromFileContents()
codeCoverageIgnore
Return values
self

createFromServer()

DEPRECATION WARNING! This method will be removed in the next major point release.

public static createFromServer(array<string|int, mixed> $server) : self

Since version 7.0.0

use League\Uri\Uri::fromServer() instead

Parameters
$server : array<string|int, mixed>
Tags
codeCoverageIgnore
see
Uri::fromServer()

Create a new instance from the environment.

Return values
self

createFromString()

DEPRECATION WARNING! This method will be removed in the next major point release.

public static createFromString([Stringable|string $uri = '' ]) : self

Since version 7.0.0

use League\Uri\Uri::new() instead

Parameters
$uri : Stringable|string = ''
Tags
codeCoverageIgnore
see
Uri::new()
Return values
self

createFromUnixPath()

DEPRECATION WARNING! This method will be removed in the next major point release.

public static createFromUnixPath([string $uri = '' ]) : self

Since version 7.0.0

use League\Uri\Uri::fromUnixPath() instead

Parameters
$uri : string = ''
Tags
codeCoverageIgnore
see
Uri::fromUnixPath()

Create a new instance from a Unix path string.

Return values
self

createFromUri()

DEPRECATION WARNING! This method will be removed in the next major point release.

public static createFromUri(UriInterface|UriInterface $uri) : self

Since version 7.0.0

use League\Uri\Uri::new() instead

Parameters
$uri : UriInterface|UriInterface
Tags
codeCoverageIgnore
see
Uri::new()

Create a new instance from a URI object.

Return values
self

createFromWindowsPath()

DEPRECATION WARNING! This method will be removed in the next major point release.

public static createFromWindowsPath([string $uri = '' ]) : self

Since version 7.0.0

use League\Uri\Uri::fromWindowsPath() instead

Parameters
$uri : string = ''
Tags
codeCoverageIgnore
see
Uri::fromWindowsPath()

Create a new instance from a local Windows path string.

Return values
self

fromBaseUri()

DEPRECATION WARNING! This method will be removed in the next major point release.

public static fromBaseUri(Url|Uri|Stringable|string $uri[, Url|Uri|Stringable|string|null $baseUri = null ]) : self

Since version 7.6.0

use League\Uri\Uri::parse() instead

Parameters
$uri : Url|Uri|Stringable|string
$baseUri : Url|Uri|Stringable|string|null = null
Tags
codeCoverageIgnore
see
Uri::parse()

Creates a new instance from a URI and a Base URI.

The returned URI must be absolute.

Return values
self

fromComponents()

Create a new instance from a hash representation of the URI similar to PHP parse_url function result.

public static fromComponents([InputComponentMap $components = [] ]) : self
Parameters
$components : InputComponentMap = []

a hash representation of the URI similar to PHP parse_url function result

Return values
self

fromData()

Create a new instance from a data URI string.

public static fromData(Stringable|string $data[, string $mimetype = '' ][, string $parameters = '' ]) : self
Parameters
$data : Stringable|string
$mimetype : string = ''
$parameters : string = ''
Tags
throws
SyntaxError

If the parameter syntax is invalid

Return values
self

fromFileContents()

Create a new instance from a data file path.

public static fromFileContents(SplFileInfo|SplFileObject|resource|Stringable|string $path[, resource|null $context = null ]) : self
Parameters
$path : SplFileInfo|SplFileObject|resource|Stringable|string
$context : resource|null = null
Tags
throws
MissingFeature

If ext/fileinfo is not installed

throws
SyntaxError

If the file does not exist or is not readable

Return values
self

fromServer()

Create a new instance from the environment.

public static fromServer(array<string|int, mixed> $server) : self
Parameters
$server : array<string|int, mixed>
Return values
self

fromTemplate()

Creates a new instance from a template.

public static fromTemplate(UriTemplate|Stringable|string $template[, iterable<string|int, mixed> $variables = [] ]) : self
Parameters
$template : UriTemplate|Stringable|string
$variables : iterable<string|int, mixed> = []
Tags
throws
TemplateCanNotBeExpanded

if the variables are invalid or missing

throws
UriException

if the resulting expansion cannot be converted to a UriInterface instance

Return values
self

fromUnixPath()

Create a new instance from a Unix path string.

public static fromUnixPath(Stringable|string $path) : self
Parameters
$path : Stringable|string
Return values
self

fromWindowsPath()

Create a new instance from a local Windows path string.

public static fromWindowsPath(Stringable|string $path) : self
Parameters
$path : Stringable|string
Return values
self

getAuthority()

Retrieve the authority component of the URI.

public getAuthority() : string|null

If no scheme is present, this method MUST return a null value.

If the port component is not set or is the standard port for the current scheme, it SHOULD NOT be included.

Return values
string|null

getComponents()

DEPRECATION WARNING! This method will be removed in the next major point release.

public getComponents() : ComponentMap

Since version 7.5.0

use League\Uri\Uri::toComponents() instead

Tags
codeCoverageIgnore
see
Uri::toComponents()
Return values
ComponentMap

getFragment()

Retrieve the fragment component of the URI.

public getFragment() : string|null

If no host is present this method MUST return a null value.

The leading "#" character is not part of the fragment and MUST NOT be added.

The value returned MUST be percent-encoded, but MUST NOT double-encode any characters. To determine what characters to encode, please refer to RFC 3986, Sections 2 and 3.5.

Return values
string|null

getHost()

Retrieve the host component of the URI.

public getHost() : string|null

If no host is present this method MUST return a null value.

The value returned MUST be normalized to lowercase, per RFC 3986 Section 3.2.2.

Return values
string|null

getOrigin()

public getOrigin() : string|null
Return values
string|null

getPassword()

public getPassword() : string|null
Return values
string|null

getPath()

Retrieve the path component of the URI.

public getPath() : string

The path can either be empty or absolute (starting with a slash) or rootless (not starting with a slash). Implementations MUST support all three syntaxes.

Normally, the empty path "" and absolute path "/" are considered equal as defined in RFC 7230 Section 2.7.3. But this method MUST NOT automatically do this normalization because in contexts with a trimmed base path, e.g. the front controller, this difference becomes significant. It's the task of the user to handle both "" and "/".

The value returned MUST be percent-encoded, but MUST NOT double-encode any characters. To determine what characters to encode, please refer to RFC 3986, Sections 2 and 3.3.

As an example, if the value should include a slash ("/") not intended as delimiter between path segments, that value MUST be passed in encoded form (e.g., "%2F") to the instance.

Return values
string

getPort()

Retrieve the port component of the URI.

public getPort() : int|null

If a port is present, and it is non-standard for the current scheme, this method MUST return it as an integer. If the port is the standard port used with the current scheme, this method SHOULD return null.

If no port is present, and no scheme is present, this method MUST return a null value.

If no port is present, but a scheme is present, this method MAY return the standard port for that scheme, but SHOULD return null.

Return values
int|null

getQuery()

Retrieve the query string of the URI.

public getQuery() : string|null

If no host is present this method MUST return a null value.

The leading "?" character is not part of the query and MUST NOT be added.

The value returned MUST be percent-encoded, but MUST NOT double-encode any characters. To determine what characters to encode, please refer to RFC 3986, Sections 2 and 3.4.

As an example, if a value in a key/value pair of the query string should include an ampersand ("&") not intended as a delimiter between values, that value MUST be passed in encoded form (e.g., "%26") to the instance.

Return values
string|null

getScheme()

Retrieve the scheme component of the URI.

public getScheme() : string|null

If no scheme is present, this method MUST return a null value.

The value returned MUST be normalized to lowercase, per RFC 3986 Section 3.1.

The trailing ":" character is not part of the scheme and MUST NOT be added.

Return values
string|null

getUnicodeHost()

public getUnicodeHost() : string|null
Return values
string|null

getUserInfo()

Retrieve the user information component of the URI.

public getUserInfo() : string|null

If no scheme is present, this method MUST return a null value.

If a user is present in the URI, this will return that value; additionally, if the password is also present, it will be appended to the user value, with a colon (":") separating the values.

The trailing "@" character is not part of the user information and MUST NOT be added.

Return values
string|null

isAbsolute()

Tells whether the URI is absolute.

public isAbsolute() : bool
Return values
bool

isAbsolutePath()

Tells whether the URI is an absolute path.

public isAbsolutePath() : bool
Return values
bool

isCrossOrigin()

Tells whether two URI do not share the same origin.

public isCrossOrigin(Uri|Url|Urn|Stringable|string $uri) : bool
Parameters
$uri : Uri|Url|Urn|Stringable|string
Return values
bool

isDomainHost()

public isDomainHost() : bool
Return values
bool

isIpHost()

public isIpHost() : bool
Return values
bool

isIpv4Host()

public isIpv4Host() : bool
Return values
bool

isIpv6Host()

public isIpv6Host() : bool
Return values
bool

isIpvFutureHost()

public isIpvFutureHost() : bool
Return values
bool

isLocalFile()

Tells whether the `file` scheme base URI represents a local file.

public isLocalFile() : bool
Return values
bool

isNetworkPath()

Tells whether the URI is a network path.

public isNetworkPath() : bool
Return values
bool

isOpaque()

Tells whether the URI is opaque or not.

public isOpaque() : bool

A URI is opaque if and only if it is absolute and does not have an authority path.

Return values
bool

isRegisteredNameHost()

public isRegisteredNameHost() : bool
Return values
bool

isRelativePath()

Tells whether the URI is a relative path.

public isRelativePath() : bool
Return values
bool

new()

Create a new instance from a string.

public static new([Uri|Url|Urn|Stringable|string $uri = '' ]) : self
Parameters
$uri : Uri|Url|Urn|Stringable|string = ''
Return values
self

normalize()

Normalize a URI by applying non-destructive and destructive normalization rules as defined in RFC3986 and RFC3987.

public normalize() : static
Return values
static

parse()

Returns a new instance from a URI and a Base URI.or null on failure.

public static parse(Uri|Url|Urn|Stringable|string $uri[, Uri|Url|Urn|Stringable|string|null $baseUri = null ]) : self|null

The returned URI must be absolute if a base URI is provided

Parameters
$uri : Uri|Url|Urn|Stringable|string
$baseUri : Uri|Url|Urn|Stringable|string|null = null
Return values
self|null

relativize()

Relativize a URI according to a base URI.

public relativize(Uri|Url|UriInterface|Stringable|Urn|string $uri) : static

This method MUST retain the state of the submitted URI instance, and return a URI instance of the same type that contains the applied modifications.

This method MUST be transparent when dealing with error and exceptions. It MUST not alter of silence them apart from validating its own parameters.

Parameters
$uri : Uri|Url|UriInterface|Stringable|Urn|string
Return values
static

resolve()

Resolves a URI against a base URI using RFC3986 rules.

public resolve(Uri|Url|UriInterface|Stringable|Urn|string $uri) : static

This method MUST retain the state of the submitted URI instance, and return a URI instance of the same type that contains the applied modifications.

This method MUST be transparent when dealing with errors and exceptions. It MUST not alter or silence them apart from validating its own parameters.

Parameters
$uri : Uri|Url|UriInterface|Stringable|Urn|string
Return values
static

toComponents()

Returns an associative array containing all the URI components.

public toComponents() : ComponentMap
Return values
ComponentMap

toFileContents()

Save the data to a specific file.

public toFileContents(SplFileInfo|SplFileObject|resource|Stringable|string $destination[, resource|null $context = null ]) : int|null

The method returns the number of bytes written to the file or null for any other scheme except the data scheme

Parameters
$destination : SplFileInfo|SplFileObject|resource|Stringable|string
$context : resource|null = null
Tags
throws
RuntimeException

if the content cannot be stored.

Return values
int|null

toRfc8089()

Returns a string representation of a File URI according to RFC8089.

public toRfc8089() : string|null

The method will return null if the URI scheme is not the file scheme

Tags
see
https://datatracker.ietf.org/doc/html/rfc8089
Return values
string|null

toUnicodeString()

Returns the string representation as a URI reference.

public toUnicodeString() : string

The host is converted to its UNICODE representation if available

Return values
string

toUnixPath()

Returns the Unix filesystem path.

public toUnixPath() : string|null

The method will return null if a scheme is present and is not the file scheme

Return values
string|null

toWindowsPath()

Returns the Windows filesystem path.

public toWindowsPath() : string|null

The method will return null if a scheme is present and is not the file scheme

Return values
string|null

tryNew()

Create a new instance from a string or a stringable structure or returns null on failure.

public static tryNew([Uri|Url|Urn|Stringable|string $uri = '' ]) : self|null
Parameters
$uri : Uri|Url|Urn|Stringable|string = ''
Return values
self|null

when()

Apply the callback if the given "condition" is (or resolves to) true.

public when(callable|bool $condition, callable $onSuccess[, callable|null $onFail = null ]) : static
Parameters
$condition : callable|bool
$onSuccess : callable
$onFail : callable|null = null
Return values
static

withFragment()

Return an instance with the specified URI fragment.

public withFragment(Stringable|string|null $fragment) : static

This method MUST retain the state of the current instance, and return an instance that contains the specified URI fragment.

Users can provide both encoded and decoded fragment characters. Implementations ensure the correct encoding as outlined in getFragment().

A null value provided for the fragment is equivalent to removing the fragment information.

Parameters
$fragment : Stringable|string|null
Return values
static

withHost()

Return an instance with the specified host.

public withHost(Stringable|string|null $host) : static

This method MUST retain the state of the current instance, and return an instance that contains the specified host.

A null value provided for the host is equivalent to removing the host information.

Parameters
$host : Stringable|string|null
Return values
static

withPassword()

public withPassword(Stringable|string|null $password) : static
Parameters
$password : Stringable|string|null
Return values
static

withPath()

Return an instance with the specified path.

public withPath(Stringable|string $path) : static

This method MUST retain the state of the current instance, and return an instance that contains the specified path.

The path can either be empty or absolute (starting with a slash) or rootless (not starting with a slash). Implementations MUST support all three syntaxes.

Users can provide both encoded and decoded path characters. Implementations ensure the correct encoding as outlined in getPath().

Parameters
$path : Stringable|string
Return values
static

withPort()

Return an instance with the specified port.

public withPort(int|null $port) : static

This method MUST retain the state of the current instance, and return an instance that contains the specified port.

A null value provided for the port is equivalent to removing the port information.

Parameters
$port : int|null
Return values
static

withQuery()

Return an instance with the specified query string.

public withQuery(Stringable|string|null $query) : static

This method MUST retain the state of the current instance, and return an instance that contains the specified query string.

Users can provide both encoded and decoded query characters. Implementations ensure the correct encoding as outlined in getQuery().

A null value provided for the query is equivalent to removing the query information.

Parameters
$query : Stringable|string|null
Return values
static

withScheme()

Return an instance with the specified scheme.

public withScheme(Stringable|string|null $scheme) : static

This method MUST retain the state of the current instance, and return an instance that contains the specified scheme.

A null value provided for the scheme is equivalent to removing the scheme information.

Parameters
$scheme : Stringable|string|null
Return values
static

withUserInfo()

Return an instance with the specified user information.

public withUserInfo(Stringable|string|null $user[, Stringable|string|null $password = null ]) : static

This method MUST retain the state of the current instance, and return an instance that contains the specified user information.

Password is optional, but the user information MUST include the user; a null value for the user is equivalent to removing user information.

Parameters
$user : Stringable|string|null
$password : Stringable|string|null = null
Return values
static

withUsername()

public withUsername(Stringable|string|null $user) : static
Parameters
$user : Stringable|string|null
Return values
static

__construct()

private __construct(string|null $scheme, string|null $user, string|null $pass, string|null $host, int|null $port, string $path, string|null $query, string|null $fragment) : mixed
Parameters
$scheme : string|null
$user : string|null
$pass : string|null
$host : string|null
$port : int|null
$path : string
$query : string|null
$fragment : string|null

assertValidPath()

Assert the path is a compliant with RFC2397.

private static assertValidPath(string $mimetype, string $parameters, string $data) : void
Parameters
$mimetype : string
$parameters : string
$data : string
Tags
link
https://tools.ietf.org/html/rfc2397
throws
SyntaxError

If the mediatype or the data are not compliant with the RFC2397

fetchHostname()

Returns the environment host.

private static fetchHostname(array<string|int, mixed> $server) : array{0: string|null, 1: int|null}
Parameters
$server : array<string|int, mixed>
Tags
throws
SyntaxError

If the host cannot be detected

Return values
array{0: string|null, 1: int|null}

fetchRequestUri()

Returns the environment path.

private static fetchRequestUri(array<string|int, mixed> $server) : array<int, string|null>
Parameters
$server : array<string|int, mixed>
Return values
array<int, string|null>

fetchScheme()

Returns the environment scheme.

private static fetchScheme(array<string|int, mixed> $server) : string
Parameters
$server : array<string|int, mixed>
Return values
string

fetchUserInfo()

Returns the environment user info.

private static fetchUserInfo(array<string|int, mixed> $server) : array<string|int, mixed>
Parameters
$server : array<string|int, mixed>
Return values
array<string|int, mixed>

{0: ?string, 1: ?string}

filterString()

Filter a string.

private filterString(Stringable|string|null $str) : string|null
Parameters
$str : Stringable|string|null
Tags
throws
SyntaxError

if the submitted data cannot be converted to string

Return values
string|null

formatFilePath()

Format the path component for the URI scheme file.

private static formatFilePath(string $path) : string
Parameters
$path : string
Return values
string

formatHost()

Validate and Format the Host component.

private formatHost(string|null $host) : string|null
Parameters
$host : string|null
Return values
string|null

formatPath()

Format the Path component.

private formatPath(string $path) : string
Parameters
$path : string
Return values
string

formatPathWithEmptyBaseQuery()

Formatting the path to keep a resolvable URI.

private static formatPathWithEmptyBaseQuery(string $path) : string
Parameters
$path : string
Return values
string

formatPort()

Format the Port component.

private formatPort([int|null $port = null ]) : int|null
Parameters
$port : int|null = null
Tags
throws
SyntaxError
Return values
int|null

formatRelativePath()

Formatting the path to keep a valid URI.

private static formatRelativePath(string $path, string $basePath) : string
Parameters
$path : string
$basePath : string
Return values
string

formatScheme()

Format the Scheme and Host component.

private formatScheme(string|null $scheme) : string|null
Parameters
$scheme : string|null
Tags
throws
SyntaxError

if the scheme is invalid

Return values
string|null

getSegments()

returns the path segments.

private static getSegments(string $path) : array<string|int, string>
Parameters
$path : string
Return values
array<string|int, string>

isNonEmptyHostUri()

URI validation for URI schemes which disallow the empty '' host.

private isNonEmptyHostUri() : bool
Return values
bool

isNonEmptyHostUriWithoutFragment()

URI validation for URIs schemes which disallow the empty '' host and forbids the fragment component.

private isNonEmptyHostUriWithoutFragment() : bool
Return values
bool

isNonEmptyHostUriWithoutFragmentAndQuery()

URI validation for URIs schemes which disallow the empty '' host and forbids fragment and query components.

private isNonEmptyHostUriWithoutFragmentAndQuery() : bool
Return values
bool

isUriWithSchemeAndPathOnly()

URI validation for URI schemes which allows only scheme and path components.

private isUriWithSchemeAndPathOnly() : bool
Return values
bool

isUriWithSchemeHostAndPathOnly()

URI validation for URI schemes which allows only scheme, host and path components.

private isUriWithSchemeHostAndPathOnly() : bool
Return values
bool

isValidBlob()

private isValidBlob() : bool
Return values
bool

isValidMailto()

private isValidMailto() : bool
Return values
bool

relativizePath()

Relatives the URI for an authority-less target URI.

private static relativizePath(string $path, string $basePath) : string
Parameters
$path : string
$basePath : string
Return values
string

setOrigin()

Sets the URI origin.

private setOrigin() : string|null

The origin read-only property of the URL interface returns a string containing the Unicode serialization of the represented URL.

Return values
string|null

validateEmailList()

private static validateEmailList(string $emails) : bool
Parameters
$emails : string
Return values
bool

validateParameter()

Validate mediatype parameter.

private static validateParameter(string $parameter) : bool
Parameters
$parameter : string
Return values
bool

        
On this page

Search results