Skip to content

refactor(http): make Request::$uri into a Uri object - #2311

Draft
NeoIsRecursive wants to merge 3 commits into
tempestphp:4.xfrom
NeoIsRecursive:refactor/make-request-uri-property-an-uri-object
Draft

NeoIsRecursive wants to merge 3 commits into
tempestphp:4.xfrom
NeoIsRecursive:refactor/make-request-uri-property-an-uri-object

Conversation

@NeoIsRecursive

@NeoIsRecursive NeoIsRecursive commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

I wanted to draft something before doing more.

Some thoughts I have got so far:

  • Should tempests Uri class implement the Psr UriInterface (or some adapter?) since it is converted to one of those in both the toPsrRequestMapper and in the httpClient (maybe some other place too).
  • Should tempest "ensure" requests uri:s has a host and scheme? (mainly an issue in tests I would guess, where the Uri class currently can output stuff like:///test-redirect-back-url#), would there be any issuea falling back to BASE_URI?
  • More utility methods/getters on the Uri class, like $origin = scheme + host and $href = path + query + hash, how should these be named? Would perhaps solve the issue above by passing arround relative urls.
  • Is password/userinfo in uri:s something an http application needs to care about?

I never remember the difference between Url and Uri so might have some terminology wrong, sorry if that is the case :P (did some reading, and perhaps adding an URL class might be better since that forces a scheme etc. uri might be to generic here, not sure)

Closes #2307

@NeoIsRecursive

NeoIsRecursive commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor Author

Sorry for the ping @innocenzi, just wanted to ask if you think this is the way to go here? (the changes to Request interface).

And i'm not sure about how the Connect requests should work (failing test), havent encountered one of those before :3

@innocenzi

Copy link
Copy Markdown
Member

Yeah, I think the change to the Request interface is good. I wouldn't be opposed to keeping path and query as a proxy to uri->* if someone asked.

Should tempests Uri class implement the Psr UriInterface (or some adapter?) since it is converted to one of those in both the toPsrRequestMapper and in the httpClient (maybe some other place too).

I'd say no, the interface is noisy and uses getter methods instead of properties

More utility methods/getters on the Uri class, like $origin = scheme + host and $href = path + query + hash, how should these be named? Would perhaps solve the issue above by passing arround relative urls.

Naming is hard, come up with your best 😅

Is password/userinfo in uri:s something an http application needs to care about?

Probably at some point, but if we don't have the need right now, I'd say let's not bother

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