Skip to content

feat: add source-specific typed request input#10216

Open
memleakd wants to merge 1 commit into
codeigniter4:4.8from
memleakd:feat/source-explicit-request-input
Open

feat: add source-specific typed request input#10216
memleakd wants to merge 1 commit into
codeigniter4:4.8from
memleakd:feat/source-explicit-request-input

Conversation

@memleakd
Copy link
Copy Markdown
Contributor

Description

This PR proposes source-explicit typed input access for IncomingRequest:

$page = $request->getQueryInput()->integer('page', 1);
$remember = $request->getPostInput()->boolean('remember', false);
$name = $request->getPayloadInput()->string('name');

This builds on CodeIgniter\Input\InputData and gives applications a clearer way to consume raw request values without relying on mixed request input.

The new methods keep the input source visible at the call site:

  • getQueryInput() reads query-string parameters.
  • getPostInput() reads POST body parameters.
  • getPayloadInput() reads the request body payload.

getPayloadInput() follows the same request-source behavior used by Form Requests: JSON requests use the decoded JSON body, PUT, PATCH, and DELETE requests use parsed raw input when they are not multipart requests, and ordinary form requests use POST body parameters. For non-JSON GET and HEAD requests, payload input is empty so query-string reads remain explicit through getQueryInput().

These helpers do not validate input or replace Validation/FormRequest. They only provide fallback-friendly typed access to source-specific raw request data.

Tests cover source isolation, typed fallback access, JSON payloads, raw write-method payloads, POST payloads, empty GET/HEAD payloads, scalar JSON rejection, and invalid JSON behavior.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@github-actions github-actions Bot added the 4.8 PRs that target the `4.8` branch. label May 18, 2026
@memleakd memleakd force-pushed the feat/source-explicit-request-input branch from f4209f6 to b7de579 Compare May 18, 2026 12:27
Signed-off-by: memleakd <121398829+memleakd@users.noreply.github.com>
@memleakd memleakd force-pushed the feat/source-explicit-request-input branch from b7de579 to 7c31ebe Compare May 18, 2026 12:32
@memleakd
Copy link
Copy Markdown
Contributor Author

The current PHPStan failure appears unrelated to this PR. It is in system/View/Parser.php, which this PR does not touch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.8 PRs that target the `4.8` branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant