Skip to content

Fix deprecated property writes with symfony/http-foundation 8.1#417

Merged
binaryfire merged 7 commits into
hypervel:0.4from
anabeto93:fix/symfony-http-foundation-81-deprecations
Jul 6, 2026
Merged

Fix deprecated property writes with symfony/http-foundation 8.1#417
binaryfire merged 7 commits into
hypervel:0.4from
anabeto93:fix/symfony-http-foundation-81-deprecations

Conversation

@anabeto93

@anabeto93 anabeto93 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

With symfony/http-foundation 8.1 installed, every JSON request and every response construction triggers a deprecation:

Since symfony/http-foundation 8.1: Directly setting property "request" of "Hypervel\Http\Request" is deprecated; pass the POST data as a constructor argument or call "initialize()" instead.
Since symfony/http-foundation 8.1: Directly setting property "headers" of "Hypervel\Http\Response" is deprecated; pass the header bag as a constructor argument instead.

8.1 turned the bag properties into hooked properties, so the direct writes in Request::createFromBase() and Http\Response::__construct() now warn on every call.

  • createFromBase() fills the existing request bag via replace() and points the JSON cache at the same bag, preserving the aliasing behavior of the previous direct assignment (covered by a new test)
  • Response passes the headers through the parent constructor, which accepts them since 8.1

Test run:

vendor/bin/phpunit tests/Http/HttpRequestTest.php
OK (5 tests, 13 assertions)

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of JSON request payloads so values are consistently available via standard request input fields and remain in sync with the JSON cache.
    • Updated response initialization to set status and headers via the underlying framework constructor for more consistent behavior.
  • Tests
    • Added a regression test to confirm JSON content is correctly filled into the request bag and stays aliased with the JSON cache.

symfony/http-foundation 8.1 turned the Request/Response bag properties
into hooked properties whose setters trigger deprecation warnings.

Request::createFromBase() now fills the existing request bag via
replace() and points the JSON cache at the same bag, preserving the
aliasing behavior of the previous direct assignment. Http\Response
passes the headers through the parent constructor, which accepts them
since 8.1.
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@binaryfire, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 26 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b4e31223-8991-426f-b0b2-e1beb395c9b1

📥 Commits

Reviewing files that changed from the base of the PR and between a68759e and 38b6682.

📒 Files selected for processing (30)
  • _archive/src/filesystem/composer.json
  • _archive/src/serializer/composer.json
  • composer.json
  • dogfood/testbench-package/composer.json
  • src/console/composer.json
  • src/context/composer.json
  • src/core/composer.json
  • src/database/composer.json
  • src/filesystem/composer.json
  • src/fortify/composer.json
  • src/foundation/composer.json
  • src/horizon/composer.json
  • src/http-server/composer.json
  • src/http/composer.json
  • src/inertia/composer.json
  • src/mail/composer.json
  • src/notifications/composer.json
  • src/passkeys/composer.json
  • src/process/composer.json
  • src/prompts/composer.json
  • src/queue/composer.json
  • src/routing/composer.json
  • src/scout/composer.json
  • src/server/composer.json
  • src/support/composer.json
  • src/testbench/composer.json
  • src/testing/composer.json
  • src/tinker/composer.json
  • tests/Http/HttpRequestTest.php
  • tests/Http/HttpResponseTest.php
📝 Walkthrough

Walkthrough

This PR changes Request::createFromBase() to copy decoded JSON into the request bag and keep the JSON cache aligned with that bag. Response::__construct() now delegates status and header initialization to Symfony’s parent constructor. A test covers the request bag and JSON cache behavior.

Changes

HTTP Request/Response construction fixes

Layer / File(s) Summary
Request JSON bag aliasing fix
src/http/src/Request.php, tests/Http/HttpRequestTest.php
createFromBase() now replaces the request bag with decoded JSON content and sets the JSON cache to reference the same bag; a new test verifies the parsed JSON value appears in the request bag and remains aliased through the cache.
Response constructor delegation
src/http/src/Response.php
Removed the ResponseHeaderBag import and manual status/header setup; the constructor now calls the Symfony parent constructor with the provided status and headers, then sets content separately.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: replacing deprecated direct property writes for Symfony HttpFoundation 8.1 compatibility.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 6, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes deprecation warnings introduced by symfony/http-foundation 8.1's hooked-property mechanism, which turns direct writes to $request->request and $response->headers into deprecation notices. All symfony/* constraints are bumped from ^8.0 to ^8.1 to match the minimum required version.

  • Request: createFromBase() replaces the deprecated $newRequest->request = $newRequest->json() assignment with replace() + setJson($newRequest->request), preserving the original aliasing behavior between the request bag and the JSON cache.
  • Response: The constructor delegates to parent::__construct('', $status, $headers) to let Symfony initialize the ResponseHeaderBag via its own non-deprecated path, then calls setContent($content) to set the real body; setProtocolVersion('1.0') is now inherited from the parent constructor and confirmed by the new test.

Confidence Score: 5/5

The two core changes are narrow, well-understood, and covered by new tests — safe to merge.

Both the Request and Response fixes are straightforward adaptations to Symfony 8.1's hooked-property contract. The replace()+setJson() aliasing in createFromBase() faithfully reproduces the old direct-assignment behavior, and the parent-constructor delegation in Response preserves protocol version, status, and header initialization as confirmed by the regression tests.

No files require special attention.

Important Files Changed

Filename Overview
src/http/src/Request.php Replaces deprecated direct property assignment in createFromBase() with replace()+setJson() aliasing; logic and aliasing behavior are correct
src/http/src/Response.php Delegates header/status initialization to parent constructor to avoid deprecated property write; setProtocolVersion('1.0') is now inherited from parent constructor, confirmed by test
tests/Http/HttpRequestTest.php Four new tests covering JSON fill, aliasing, deprecation regression, and merge behavior; one test has swapped assertEquals arguments
tests/Http/HttpResponseTest.php New test asserting status, headers, protocol version, content, and original content are all initialized correctly after the constructor change
composer.json Bumps all symfony/* constraints from ^8.0 to ^8.1 to match the minimum version that introduced the hooked-property deprecations being fixed

Reviews (3): Last reviewed commit: "Raise Symfony component floor to 8.1" | Re-trigger Greptile

Comment thread src/http/src/Response.php Outdated
binaryfire and others added 6 commits July 6, 2026 14:45
Passing null invoked the overridden setContent() with an intermediate
null before the real content is set; the empty string matches the
constructor defaults.
Replace the bespoke JSON createFromBase regression test from the PR with the relevant Laravel request tests in Laravel order.

These tests cover filling the request input bag from JSON content, preserving the InputBag payload type exposed by Symfony, avoiding the Symfony 8.1 request-property deprecation path, and allowing JSON requests to merge derived data back into the request payload.
Add response constructor coverage for the Symfony 8.1-compatible initialization path.

The test locks in the public response contract while the constructor delegates header, status, and protocol initialization to Symfony: headers are retained, the status code remains correct, the default protocol version is preserved, JSONable content is encoded, and the original content remains the user-provided value rather than the constructor placeholder.
Update root and package composer manifests so Symfony component dependencies consistently require the 8.1 line.

The HTTP fixes in this PR rely on Symfony 8.1 behavior around hooked Request and Response bag properties. Since Hypervel 0.4 has not been released yet, align the component packages, dogfood package, and archived package manifests on a Symfony 8.1 minimum instead of carrying compatibility assumptions for 8.0.
@binaryfire

Copy link
Copy Markdown
Collaborator

@anabeto93 Thanks!

@binaryfire binaryfire merged commit 212f17d into hypervel:0.4 Jul 6, 2026
19 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.

2 participants