#23965·php-src

Uri\Rfc3986\Uri::toString() doesn't drop an empty port

Author: kamil-tekielaCreated Sep 28, 2026Updated Sep 28, 2026
LabelsBugStatus: VerifiedStatus: Waiting for Third Party Library FixExtension: uri

Description

The following code:

php
<?php

require 'vendor/autoload.php';

$uri = new Uri\Rfc3986\Uri('https://example.com:');
var_dump($uri->getPort(), $uri->toRawString(), $uri->toString());

Resulted in this output:

NULL
string(20) "https://example.com:"
string(20) "https://example.com:"

But I expected this output instead:

NULL
string(20) "https://example.com:"
string(19) "https://example.com"

PHP Version

plain
8.5.4

Operating System

No response