Skip to content

Document ext/uri#5392

Open
kocsismate wants to merge 5 commits intophp:masterfrom
kocsismate:uri
Open

Document ext/uri#5392
kocsismate wants to merge 5 commits intophp:masterfrom
kocsismate:uri

Conversation

@kocsismate
Copy link
Member

@kocsismate kocsismate commented Feb 26, 2026

Another attempt to document ext/uri after #5060

Some of my sentences are very clunky, so I am happy to receive suggestions.

@kocsismate kocsismate force-pushed the uri branch 7 times, most recently from 0667c3e to c074b2a Compare March 1, 2026 21:38
@kocsismate kocsismate force-pushed the uri branch 4 times, most recently from 3ec979f to 893cc0e Compare March 14, 2026 20:39
@kocsismate kocsismate marked this pull request as ready for review March 14, 2026 20:40
Copy link
Member

@TimWolla TimWolla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass at comments. Didn't yet look at all files, but this looks like a good start. Will take another look after you reviewed my comments to avoid looking at all files twice in case they change.

<refsect1 role="seealso">
&reftitle.seealso;
<simplelist>
<member><methodname>Uri\WhatWg\Url::getPassword</methodname></member>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here it might make sense to also link to Uri\WhatWg\Url::withUsername (second position).

Suggested change
<member><methodname>Uri\WhatWg\Url::getPassword</methodname></member>
<member><methodname>Uri\WhatWg\Url::getPassword</methodname></member>
<member><methodname>Uri\WhatWg\Url::withUsername</methodname></member>

Copy link
Member Author

@kocsismate kocsismate Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think doing so would make more sense for Uri because password is just a pseudo component together with username. For WHATWG URL, they are completely separate components with not much more connection than e.g. the host and port. I'm not against adding it though, so if you have a strong opinion, then I'm fine with it.

Comment on lines +58 to +59
<member><methodname>Uri\Rfc3986\Uri::toRawString</methodname></member>
<member><methodname>Uri\Rfc3986\Uri::toString</methodname></member>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<member><methodname>Uri\Rfc3986\Uri::toRawString</methodname></member>
<member><methodname>Uri\Rfc3986\Uri::toString</methodname></member>
<member><methodname>Uri\Rfc3986\Uri::toString</methodname></member>

I think having just one here is sufficient to point users into the right direction.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't pick just one of the toString methods, and in the same way, I wouldn't pick only one of the getters. I think including both variants wouldn't hurt, and if someone actually wants to look up the omitted variant then the extra link saves them an extra navigation step.

All in all, IMO it's not a huge deal either way, but I pretty much like the completeness here.

Comment on lines +58 to +59
<member><methodname>Uri\Rfc3986\Uri::toRawString</methodname></member>
<member><methodname>Uri\Rfc3986\Uri::toString</methodname></member>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<member><methodname>Uri\Rfc3986\Uri::toRawString</methodname></member>
<member><methodname>Uri\Rfc3986\Uri::toString</methodname></member>
<member><methodname>Uri\Rfc3986\Uri::toString</methodname></member>

Also applies to the other getters (if they list both the raw and normalized versions).

Comment on lines +68 to +76
<?php
$url = \Uri\WhatWg\Url::parse("https://example.com");

if ($url === null) {
echo "Invalid URL"
} else {
echo "Valid URL " . $uri->toAsciiString();
}
?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<?php
$url = \Uri\WhatWg\Url::parse("https://example.com");
if ($url === null) {
echo "Invalid URL"
} else {
echo "Valid URL " . $uri->toAsciiString();
}
?>
<?php
$url = \Uri\WhatWg\Url::parse("https://example.com");
if ($url !== null) {
echo "Valid URL ", $url->toAsciiString();
} else {
echo "Invalid URL";
}
?>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't like the echo "...", "" construct, so I left this one out from the changes. I think regular concatenation is more widely known

&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>uri</parameter></term>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it actually called uri in the stubs? 🙈

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because uri tries to suggest that relative references are also possible (which are called by WHATWG URL as "relative URL strings"). This was my best idea back then.

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.

2 participants