Skip to content

feat(metadata): use uri RFC 3986 on PHP8.5#7565

Open
SVillette wants to merge 1 commit intoapi-platform:mainfrom
SVillette:feature-use-rfc3986-uri
Open

feat(metadata): use uri RFC 3986 on PHP8.5#7565
SVillette wants to merge 1 commit intoapi-platform:mainfrom
SVillette:feature-use-rfc3986-uri

Conversation

@SVillette
Copy link
Copy Markdown

Q A
Branch? main
Tickets -
License MIT
Doc PR api-platform/docs#...

This PR replaces the usage of parse_url() method by the new rfc 3986 URI API on PHP8.5.
cc @soyuka this is the subject we talk about at the SymfonyCon hackday.

Still in draft as it's missing some tests.

@SVillette SVillette marked this pull request as draft November 29, 2025 13:59
@SVillette SVillette force-pushed the feature-use-rfc3986-uri branch 2 times, most recently from c91971d to c442327 Compare November 30, 2025 10:38
@soyuka soyuka marked this pull request as ready for review December 11, 2025 14:05
@soyuka
Copy link
Copy Markdown
Member

soyuka commented Dec 11, 2025

could you maybe rebase this?

@SVillette SVillette force-pushed the feature-use-rfc3986-uri branch from c442327 to bc53a3b Compare December 12, 2025 10:01
@SVillette
Copy link
Copy Markdown
Author

@soyuka PR is rebased.
However these changes break a test in ApiPlatform\Metadata\Tests\Util\IriHelperTest as http:/// is considered valid with the new Uri\Rfc3986\Uri class. WDYT about it?

@VincentLanglet
Copy link
Copy Markdown
Contributor

I feel like this work could be simpler by exposing the require method in a BCHelper class or by using a polyfill like https://github.com/thephpleague/uri-polyfill

@stale
Copy link
Copy Markdown

stale bot commented Mar 29, 2026

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Mar 29, 2026
@stale stale bot closed this Apr 5, 2026
@soyuka soyuka reopened this Apr 6, 2026
@stale stale bot removed the stale label Apr 6, 2026
@@ -25,6 +26,10 @@ class IriHelperTest extends TestCase
{
public function testHelpers(): void
Copy link
Copy Markdown
Contributor

@alexislefebvre alexislefebvre Apr 17, 2026

Choose a reason for hiding this comment

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

Suggested change
public function testHelpers(): void
#[RequiresPhp('>= 8.5.0')]
public function testHelpers(): void

and the import:

use PHPUnit\Framework\Attributes\RequiresPhp;

This is supported by PHPUnit: https://docs.phpunit.de/en/12.5/writing-tests-for-phpunit.html#skipping-tests-using-attributes

Then the check on PHP_VERSION_ID can be removed.


Note: updated with full version to avoid an issue: symfony/symfony#63987

$this->assertSame('/hello.json?foo=bar&bar=3&page=2', IriHelper::createIri($parsed['uri'], $parsed['parameters'], 'page', 2.));
}

public function testHelpersWithNetworkPathAndRFC3986(): void
Copy link
Copy Markdown
Contributor

@alexislefebvre alexislefebvre Apr 17, 2026

Choose a reason for hiding this comment

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

Suggested change
public function testHelpersWithNetworkPathAndRFC3986(): void
#[RequiresPhp('< 8.5.0')]
public function testHelpersWithNetworkPathAndRFC3986(): void

@alexislefebvre
Copy link
Copy Markdown
Contributor

I feel like this work could be simpler by exposing the require method in a BCHelper class or by using a polyfill like https://github.com/thephpleague/uri-polyfill

I like these ideas.

@SVillette Would you like to update your PR with this idea?

I’m not sure if adding a dependency for this is worth it. WDYT @soyuka ?

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.

4 participants