diff --git a/system/Session/Handlers/ArrayHandler.php b/system/Session/Handlers/ArrayHandler.php index 2643173cc742..5d8bf6188567 100644 --- a/system/Session/Handlers/ArrayHandler.php +++ b/system/Session/Handlers/ArrayHandler.php @@ -80,7 +80,7 @@ public function destroy($id): bool * @param int $max_lifetime Sessions that have not updated * for the last max_lifetime seconds will be removed. */ - public function gc($max_lifetime): int + public function gc(int $max_lifetime): int { return 1; } diff --git a/system/Session/Handlers/Database/PostgreHandler.php b/system/Session/Handlers/Database/PostgreHandler.php index 1471d44d1860..37ab7e6dfdc1 100644 --- a/system/Session/Handlers/Database/PostgreHandler.php +++ b/system/Session/Handlers/Database/PostgreHandler.php @@ -59,7 +59,7 @@ protected function prepareData(string $data): string * @param int $max_lifetime Sessions that have not updated * for the last max_lifetime seconds will be removed. */ - public function gc($max_lifetime): false|int + public function gc(int $max_lifetime): false|int { $separator = '\''; $interval = implode($separator, ['', "{$max_lifetime} second", '']); diff --git a/system/Session/Handlers/DatabaseHandler.php b/system/Session/Handlers/DatabaseHandler.php index c4ce2b8222e7..6ddd8a3c0d9b 100644 --- a/system/Session/Handlers/DatabaseHandler.php +++ b/system/Session/Handlers/DatabaseHandler.php @@ -276,7 +276,7 @@ public function destroy($id): bool * * @return false|int Returns the number of deleted sessions on success, or false on failure. */ - public function gc($max_lifetime): false|int + public function gc(int $max_lifetime): false|int { return $this->db->table($this->table)->where( 'timestamp <', diff --git a/system/Session/Handlers/FileHandler.php b/system/Session/Handlers/FileHandler.php index f5e9261af0f4..6920c0e388b4 100644 --- a/system/Session/Handlers/FileHandler.php +++ b/system/Session/Handlers/FileHandler.php @@ -263,7 +263,7 @@ public function destroy($id): bool * @param int $max_lifetime Sessions that have not updated * for the last max_lifetime seconds will be removed. */ - public function gc($max_lifetime): false|int + public function gc(int $max_lifetime): false|int { if (! is_dir($this->savePath) || ($directory = opendir($this->savePath)) === false) { $this->logger->debug("Session: Garbage collector couldn't list files under directory '" . $this->savePath . "'."); diff --git a/system/Session/Handlers/MemcachedHandler.php b/system/Session/Handlers/MemcachedHandler.php index 7b7775916019..0225afdc726c 100644 --- a/system/Session/Handlers/MemcachedHandler.php +++ b/system/Session/Handlers/MemcachedHandler.php @@ -255,7 +255,7 @@ public function destroy($id): bool * @param int $max_lifetime Sessions that have not updated * for the last max_lifetime seconds will be removed. */ - public function gc($max_lifetime): int + public function gc(int $max_lifetime): int { return 1; } diff --git a/system/Session/Handlers/RedisHandler.php b/system/Session/Handlers/RedisHandler.php index 54f628c4789b..3e5a4a2bbe7e 100644 --- a/system/Session/Handlers/RedisHandler.php +++ b/system/Session/Handlers/RedisHandler.php @@ -341,7 +341,7 @@ public function destroy($id): bool * @param int $max_lifetime Sessions that have not updated * for the last max_lifetime seconds will be removed. */ - public function gc($max_lifetime): int + public function gc(int $max_lifetime): int { return 1; } diff --git a/user_guide_src/source/changelogs/v4.8.0.rst b/user_guide_src/source/changelogs/v4.8.0.rst index 013625054260..1327ebdb2be5 100644 --- a/user_guide_src/source/changelogs/v4.8.0.rst +++ b/user_guide_src/source/changelogs/v4.8.0.rst @@ -73,6 +73,7 @@ Method Signature Changes - **Database:** The following methods have had their signatures updated to remove deprecated parameters: - ``CodeIgniter\Database\Forge::_createTable()`` no longer accepts the deprecated ``$ifNotExists`` parameter. The method signature is now ``_createTable(string $table, array $attributes)``. - **Model:** ``CodeIgniter\BaseModel`` now requires the ``chunkRows()``, ``chunkById()``, and ``chunkRowsById()`` methods. Custom classes extending ``BaseModel`` directly must implement them. +- **Session:** The ``$max_lifetime`` parameter of the following ``gc()`` methods now has the native ``int`` type, matching ``SessionHandlerInterface``: ``ArrayHandler::gc()``, ``DatabaseHandler::gc()``, ``FileHandler::gc()``, ``MemcachedHandler::gc()``, ``PostgreHandler::gc()``, ``RedisHandler::gc()``. Property Scope Changes ======================