Skip to content

[Code Quality] Http\Request::withHeader misuses PSR-7 naming for a mutating method #364

@s2x

Description

@s2x

Location

src/Http/Request.php:9-27

Problem

The class exposes withHeader() as a deprecated alias of setHeader(). In PSR-7 the withX prefix is reserved for methods that return a new instance with the change applied; the bundle's withHeader() actually mutates and returns $this. The naming sets up the wrong expectation for any developer used to PSR-7.

What to change

  • Remove the deprecated withHeader() alias once a migration path is announced, or rename it to a non-PSR-7 verb (addHeader, setHeader) and keep the alias only for backwards compatibility behind a deprecation notice that mentions the semantic mismatch.
  • Update the class-level PHPDoc to call out that this request is not PSR-7-compatible.

Acceptance criteria

  • Either the misleading withHeader() alias is removed, or its PHPDoc explicitly warns that it mutates and is not PSR-7-compliant.
  • Existing tests pass (vendor/bin/phpunit).
  • No behavioural change for users still calling the alias (until removal in a major).

Metadata

Metadata

Assignees

No one assigned

    Labels

    code-qualityCode quality improvementsminorMinor priority - code quality

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions