From b133911db007a3b684fb54871c963d5687d8ad05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C5=A0pa=C4=8Dek?= Date: Fri, 22 Mar 2024 03:21:33 +0100 Subject: [PATCH 1/2] Add string and DateTimeInterface to setCookie expire param In version 3.2.x and older, this was the type in the docblock. Close #233 --- src/Http/IResponse.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Http/IResponse.php b/src/Http/IResponse.php index 114af2a8..b71dfe29 100644 --- a/src/Http/IResponse.php +++ b/src/Http/IResponse.php @@ -397,7 +397,7 @@ function getHeaders(): array; function setCookie( string $name, string $value, - ?int $expire, + string|int|\DateTimeInterface|null $expire, ?string $path = null, ?string $domain = null, ?bool $secure = null, From ced42184ac3028b82baaf109232e0042bdc4c94e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C5=A0pa=C4=8Dek?= Date: Fri, 22 Mar 2024 03:23:57 +0100 Subject: [PATCH 2/2] Correct name for the $expire param, also type and description --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index ddb92992..7731214b 100644 --- a/readme.md +++ b/readme.md @@ -307,7 +307,7 @@ Sets the expiration of the HTTP document using the `Cache-Control` and `Expires` $httpResponse->setExpiration('1 hour'); ``` -setCookie(string $name, string $value, $time, string $path = null, string $domain = null, bool $secure = null, bool $httpOnly = null, string $sameSite = null) +setCookie(string $name, string $value, string|int|\DateTimeInterface|null $expire, string $path = null, string $domain = null, bool $secure = null, bool $httpOnly = null, string $sameSite = null) -------------------------------------------------------------------------------------------------------------------------------------------------------------- Sends a cookie. The default values ​​of the parameters are: - `$path` with scope to all directories (`'/'`) @@ -316,7 +316,7 @@ Sends a cookie. The default values ​​of the parameters are: - `$httpOnly` is true, so the cookie is inaccessible to JavaScript - `$sameSite` is null, so the flag is not specified -The time can be specified as a string or the number of seconds. +The `$expire` parameter can be specified as a string, an object implementing `DateTimeInterface`, or the number of seconds. ```php $httpResponse->setCookie('lang', 'en', '100 days');