A Path extended with scheme/host/user/password/port/query/fragment -- a full PSR-7 UriInterface, plus the same ArrayAccess/basepath machinery as Path (accessed via string keys: 'scheme', 'host', 'user', 'password', 'port', 'query', 'fragment', 'path' -- alongside Path's own numeric segment indices).
class MMO\core\helpers\Uri extends MMO\core\helpers\Path
implements Psr\Http\Message\UriInterface
A mutable clone of $this to apply one change to, later restored (restoreImmutability) to $this's own immutability state -- used by every with*() method below.
A mutable clone of $this to apply one change to, later restored (restoreImmutability) to $this's own immutability state -- used by every with*() method below.
protected function cloneForWith(): selfNOTE: a plain `clone $this` does NOT reset the [`Path::isImmutable`](https://mmoframework.fr/documentation/mmo.core/php/helpers/Path.md#path-isimmutable) flag (unlike [`Path::toMutable`](https://mmoframework.fr/documentation/mmo.core/php/helpers/Path.md#path-tomutable) /
See
Path::toImmutable, which always explicitly set it after cloning), so mutating the clone used to immediately throw "immutable. cannot be changed." for ANY Uri that started out immutable -- which is the normal case (e.g. every Request's own URI is always immutable, see aRequest::setUri()).
PSR-7's "[user-info@]host[:port]" format NOTE: this used to delegate to \MMO\core\uris\join(), which is built for rendering a FULL uri string -- given a 'scheme' key it prepends "scheme:", and given a 'host' key it unconditionally prepends "//" first (both wrong for a bare authority). It also reads the password under the key 'pass', not 'password' (the key this method used to pass), which silently dropped it too. Net effect: this was a real, demonstrated bug -- since aRequest::setUri() sets the Host header from getAuthority(), every Request ended up with a Host header like "https://user:secret@example.com:8080" instead of "example.com:8080".
NOTE: was declared int (non-nullable), unlike PSR-7's own UriInterface::getPort(): ?int -- a URI with no explicit port (the common case) always crashed with "Return value must be of type int, null returned".
the server root: scheme + authority + basepath (no relative path, query or fragment) NOTE: see getAuthority -- same 'pass' vs 'password' key fix applies here.
PSR-7's own "username[:password]" format -- no scheme/host/'@', unlike the rest of the URI NOTE: this used to delegate to \MMO\core\uris\join(), which only ever renders user/password when a 'host' key is ALSO present (it's meant for building a full URI, not extracting just the userinfo substring) -- so that call could never produce any output at all, on top of also referencing the undeclared $this->pass (the real property is $password).
Re-root this URI onto $uri. If $uri has an authority (scheme/host/...), every URI component is replaced by $uri's; otherwise (a plain path), only the path's basepath is affected (same as Path::rebase).
function rebase(MMO\core\helpers\Path|array|string|bool $uri): void
- scheme: if false, remove the scheme. - host: if false, remove the host. - user: if false, remove the user. - pass: if false, remove the pass. - port: if false, remove the port. - path: if false, remove the path. - query: if false, remove the query. - fragment: if false, remove the fragment. - basepath: if false, remove the basepath. if string, render the relative path compare to basepath