From 85b71ee4b41e4854fcb7b5c615170326d15567d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C5=A0pa=C4=8Dek?= Date: Mon, 4 Nov 2024 14:05:09 +0100 Subject: [PATCH] IResponse: added DateTimeInterface to setCookie $expire param (#237) --- readme.md | 4 ++-- src/Http/IResponse.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 35fba5d0..7e294c6c 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'); 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,