-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Description
Description
The following code:
<?php
$url = new \Uri\WhatWg\Url('http://127.0.0.1:8080/path?query=123#fragment');
var_dump($url, $url->toAsciiString());
$url = $url->withPath('/hello-world');
var_dump($url, $url->toAsciiString());Resulted in this output:
object(Uri\WhatWg\Url)#1 (8) {
["scheme"]=>
string(4) "http"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
string(9) "127.0.0.1"
["port"]=>
int(8080)
["path"]=>
string(5) "/path"
["query"]=>
string(9) "query=123"
["fragment"]=>
string(8) "fragment"
}
string(45) "http://127.0.0.1:8080/path?query=123#fragment"
object(Uri\WhatWg\Url)#2 (8) {
["scheme"]=>
string(4) "http"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
NULL
["port"]=>
int(8080)
["path"]=>
string(12) "/hello-world"
["query"]=>
string(9) "query=123"
["fragment"]=>
string(8) "fragment"
}
string(36) "http:/hello-world?query=123#fragment"
But I expected this output instead:
object(Uri\WhatWg\Url)#1 (8) {
["scheme"]=>
string(4) "http"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
string(9) "127.0.0.1"
["port"]=>
int(8080)
["path"]=>
string(5) "/path"
["query"]=>
string(9) "query=123"
["fragment"]=>
string(8) "fragment"
}
string(45) "http://127.0.0.1:8080/path?query=123#fragment"
object(Uri\WhatWg\Url)#2 (8) {
["scheme"]=>
string(4) "http"
["username"]=>
NULL
["password"]=>
["host"]=>
string(9) "127.0.0.1"
NULL
["port"]=>
int(8080)
["path"]=>
string(12) "/hello-world"
["query"]=>
string(9) "query=123"
["fragment"]=>
string(8) "fragment"
}
string(36) "http://127.0.0.1:8080/hello-world?query=123#fragment"
PHP Version
PHP 8.5.0RC4 (cli) (built: Nov 6 2025 03:02:00) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.5.0RC4, Copyright (c) Zend Technologies
with Zend OPcache v8.5.0RC4, Copyright (c), by Zend Technologies
Operating System
macOS