public function withUri($uri) : Request { if (!$uri instanceof Uri) { $uri = new BasicUri($uri); } $new = clone $this; $new->uri = $uri; if ($new->hostFromUri) { $new->setHostFromUri(); } return $new; }