Skip to content

fix(http): recursively map nested uploaded files - #2255

Merged
xHeaven merged 2 commits into
tempestphp:3.xfrom
osbre:fix/nested-request-files
Aug 21, 2026
Merged

fix(http): recursively map nested uploaded files#2255
xHeaven merged 2 commits into
tempestphp:3.xfrom
osbre:fix/nested-request-files

Conversation

@osbre

@osbre osbre commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

PSR-7 exposes array-style file inputs, such as files[] or files[avatar], as nested arrays. The mapper previously assumed a single-level array with a callback typed to UploadedFileInterface, so passing a nested array threw TypeError.

Uploaded files are now mapped recursively to preserve this nested structure, and the $files docblocks on Request and IsRequest have been widened to array<array-key, Upload|array>.

Runtime behaviour for standard file uploads is unchanged, though static analysis tools may report new notices in code that assumes Upload[].

@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown

Benchmark Results

Comparison of fix/nested-request-files against 3.x (7e5cff65349956e14578e826a95d1f3ce6953761).

Open to see the benchmark results

No benchmark changes above ±5%.

Generated by phpbench against commit d698ba0

@xHeaven

xHeaven commented Aug 19, 2026

Copy link
Copy Markdown
Member

I'd prefer a test that actually exercises the reported behavior, other than that, LGTM.
Something like:

#[Test]
public function nested_uploaded_files_are_mapped_to_uploads(): void
{
    $request = $this->createServerRequest('POST')->withUploadedFiles([
        // ...
    ]);

    $mappedRequest = $this->mapper->map(
        from: $request,
        to: GenericRequest::class,
    );

    // asserts
}

@osbre

osbre commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @xHeaven - I updated the test

@xHeaven
xHeaven merged commit ae9c3e4 into tempestphp:3.x Aug 21, 2026
78 checks passed
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.

3 participants