Skip to content

Enhance request handling with query parameters and HTTP method access.#51

Merged
gustavofreze merged 1 commit intomainfrom
feature/develop
Feb 24, 2026
Merged

Enhance request handling with query parameters and HTTP method access.#51
gustavofreze merged 1 commit intomainfrom
feature/develop

Conversation

@gustavofreze
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings February 24, 2026 10:40
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 73620650b4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request enhances the HTTP Request handling capabilities by adding three major features: HTTP method access, query parameter support, and full URI access. It also improves body handling by supporting PSR-7 parsed body for non-JSON payloads like form data.

Changes:

  • Added Request::method() to retrieve HTTP method as a typed Method enum
  • Added Uri::toString() to access the complete request URI as a string
  • Added Uri::queryParameters() with typed access to query string parameters through a new QueryParameters class
  • Enhanced Body::from() to fall back to getParsedBody() when the stream is empty, supporting form-encoded and multipart requests
  • Updated all existing tests to mock getMethod() on ServerRequestInterface (required for the new method() API)

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Request.php Added method() function to return typed HTTP method enum
src/Internal/Request/Uri.php Added toString() and queryParameters() methods, updated class docblock
src/Internal/Request/QueryParameters.php New class providing typed access to query parameters, follows same pattern as Body
src/Internal/Request/Body.php Enhanced to support parsed body fallback when stream is empty
src/Internal/Request/Decoder.php Formatting change for multi-line constructor call
tests/RequestTest.php Added comprehensive tests for new features and updated all existing mocks
README.md Updated documentation with examples for new query parameters, URI, and method access features

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if ($streamFactory->isEmptyContent()) {
return new Body(data: []);
if (!$streamFactory->isEmptyContent()) {
return new Body(data: json_decode($streamFactory->content(), true));
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

The json_decode on line 22 can return null if the JSON is invalid or a non-array value if the JSON doesn't represent an array. This would cause a type error when constructing Body, which expects an array parameter. Consider adding a check to ensure json_decode returns an array before passing it to the constructor, falling through to the empty array case otherwise.

Suggested change
return new Body(data: json_decode($streamFactory->content(), true));
$decoded = json_decode($streamFactory->content(), true);
if (is_array($decoded)) {
return new Body(data: $decoded);
}

Copilot uses AI. Check for mistakes.
Comment on lines +27 to +30
public function method(): Method
{
return Method::from(value: $this->request->getMethod());
}
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

The Method::from() call will throw a ValueError if the HTTP method string returned by getMethod() is not one of the standard HTTP methods defined in the Method enum (GET, PUT, POST, HEAD, PATCH, TRACE, DELETE, OPTIONS, CONNECT). While this is acceptable for most cases, some applications may need to handle custom HTTP methods like PROPFIND, MKCOL, or other WebDAV methods. Consider documenting this behavior or adding a test that validates this throws an exception for non-standard methods to make the behavior explicit.

Copilot uses AI. Check for mistakes.
@gustavofreze gustavofreze merged commit 1f84af4 into main Feb 24, 2026
10 checks passed
@gustavofreze gustavofreze deleted the feature/develop branch February 24, 2026 10:46
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