Skip to content

IResponse::setCookie() missing $sameSite parameter while deprecated constants point to SameSite enum #248

@martinbohmcz

Description

@martinbohmcz

Version: 3.4.0

Bug Description

IResponse::setCookie() declares only 7 parameters, but the concrete Response::setCookie() adds SameSite|string|null $sameSite = null as the 8th. At the same time, 3.4.0 deprecated IResponse::SameSiteLax/SameSiteStrict/SameSiteNone constants with the note "use Nette\Http\SameSite enum".

Following this migration advice while calling setCookie() through IResponse (which is what Presenter::getHttpResponse() returns) triggers a PHPStan error:

Method Nette\Http\IResponse::setCookie() invoked with 8 parameters, 3–7 required.

The only workaround is a @phpstan-ignore arguments.count suppression, which is unsatisfying given that 3.4.0 actively guides users toward the enum.

Steps To Reproduce

// $this->getHttpResponse() returns IResponse
$this->getHttpResponse()->setCookie('name', 'value', '+1 year', '/', null, true, true, SameSite::Strict);
// PHPStan level 6: Method Nette\Http\IResponse::setCookie() invoked with 8 parameters, 3-7 required.

Expected Behavior

Using Nette\Http\SameSite enum in setCookie() via the IResponse interface works without PHPStan suppression, consistent with the deprecation notice in 3.4.0.

Possible Solution

Add SameSite|string|null $sameSite = null (and optionally bool $partitioned = false) to IResponse::setCookie() to match the concrete Response class signature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions