Skip to content

Uri Fix classname and extra e.g., amend examples, describe normalization - #5548

Open
mmalferov wants to merge 44 commits into
php:masterfrom
mmalferov:patch-62
Open

Uri Fix classname and extra e.g., amend examples, describe normalization#5548
mmalferov wants to merge 44 commits into
php:masterfrom
mmalferov:patch-62

Conversation

@mmalferov

Copy link
Copy Markdown
Member

No description provided.

@mmalferov
mmalferov requested a review from TimWolla as a code owner May 8, 2026 23:45
@mmalferov mmalferov changed the title construct.xml Fix classname and extra e.g. Uri\WhatWg\Url::construct Fix classname and extra e.g. May 8, 2026
@mmalferov mmalferov changed the title Uri\WhatWg\Url::construct Fix classname and extra e.g. Uri\WhatWg\Url::construct Fix classname and extra e.g., amend example May 9, 2026
@mmalferov mmalferov changed the title Uri\WhatWg\Url::construct Fix classname and extra e.g., amend example Uri\WhatWg\Url::construct Fix classname and extra e.g., amend examples May 9, 2026
@mmalferov mmalferov changed the title Uri\WhatWg\Url::construct Fix classname and extra e.g., amend examples Uri Fix classname and extra e.g., amend examples May 17, 2026
@mmalferov mmalferov changed the title Uri Fix classname and extra e.g., amend examples Uri Fix classname and extra e.g., amend examples, describe normalization May 17, 2026
@jordikroon
jordikroon requested a review from kocsismate May 17, 2026 20:16
@TimWolla

Copy link
Copy Markdown
Member

FYI: This will conflict with #5471.

And is the return type `?static` accurate and not `?self` or literally `?Uri\WhatWg\Url`, and doesn't it confuse the reader, since the class is final?
```PHP_METHOD(Uri_Rfc3986_Uri, getPort)
{
	php_uri_property_read_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_PORT, PHP_URI_COMPONENT_READ_MODE_RAW);
}```

Judging by the source code, the `port` component, unlike the `password` or the `host` components, is not normalized. It seems that the mention of normalization was included in the description by mistake :)

```PHP_METHOD(Uri_Rfc3986_Uri, getPassword)
{
	php_uri_property_read_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_PASSWORD, PHP_URI_COMPONENT_READ_MODE_NORMALIZED_ASCII);
}```
mmalferov and others added 21 commits September 9, 2026 10:43
...an non-normalized in the return section for consistency with other methods
The example rewrites in the RFC 3986 getter pages overlap with php#5471, which
unifies the example URL across all of them; reverting them here leaves the two
pull requests disjoint. The normalization entities and the wording changes stay.

Also corrects four points in what is left:
- the normalization entity omitted dot segment removal, which is what getPath()
  visibly does
- the non-normalization entity claimed components are returned in their original
  form, which toRawString() and a resolved getRawPath() both contradict
- getPort() does normalize, it drops leading zeros, so the page keeps its wording
- Ipv4InIpv6InvalidCodePoint is also raised for an empty part, a leading zero and
  too many parts, not only for an invalid code point
The non-normalization entity said "No normalization is applied", which
toRawString() contradicts for an IPv6 host: the host is recomposed from its
parsed form, so [2001:DB8::1] comes back fully expanded and in lowercase even
when the input was already compressed. Drop the absolute claim, keep the four
clauses that do hold, add the dot segment mirror of the other entity, and state
the IPv6 exception on the toRawString() page itself.

Uri\WhatWg\Url::__construct() and ::parse() gave /foo as an example of "a valid
URL string", but both reject it without a baseUrl (MissingSchemeNonRelativeUrl).
Say so instead. Uri\WhatWg\Url::resolve() does accept it, and only needed the
duplicated "(e.g." removed, which is the third occurrence of the one this pull
request already fixed.
The three pages need a non-ASCII host, since getAsciiHost(), toAsciiString()
and toUnicodeString() only differ from getHost() and toString() on an
internationalized domain name; with a plain example.com they printed back their
own input. The label itself does not have to be an eighteen letter compound
though: the manual already uses "täst" for this on the intl idn pages, which
keeps the punycode short enough to read in a screen block.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants