Skip to content

Commit e9bc894

Browse files
committed
fix: normalize return type and add PHPStan suppression for intentional type violation test
1 parent 0b34a37 commit e9bc894

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

‎system/Session/Handlers/Database/PostgreHandler.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected function prepareData(string $data): string
5959
* @param int $max_lifetime Sessions that have not updated
6060
* for the last max_lifetime seconds will be removed.
6161
*/
62-
public function gc(int $max_lifetime): int|false
62+
public function gc(int $max_lifetime): false|int
6363
{
6464
$separator = '\'';
6565
$interval = implode($separator, ['', "{$max_lifetime} second", '']);

‎system/Session/Handlers/DatabaseHandler.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public function destroy($id): bool
276276
*
277277
* @return false|int Returns the number of deleted sessions on success, or false on failure.
278278
*/
279-
public function gc(int $max_lifetime): int|false
279+
public function gc(int $max_lifetime): false|int
280280
{
281281
return $this->db->table($this->table)->where(
282282
'timestamp <',

‎tests/system/Session/Handlers/Database/AbstractHandlerTestCase.php‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use CodeIgniter\Test\ReflectionHelper;
2020
use Config\Database as DatabaseConfig;
2121
use Tests\Support\Database\Seeds\CITestSeeder;
22+
use TypeError;
2223

2324
/**
2425
* @internal
@@ -127,8 +128,8 @@ public function testGCRejectsNonInt(): void
127128
{
128129
$handler = $this->getInstance();
129130

130-
$this->expectException(\TypeError::class);
131-
$handler->gc('malicious; DROP TABLE sessions; --');
131+
$this->expectException(TypeError::class);
132+
$handler->gc('malicious; DROP TABLE sessions; --'); // @phpstan-ignore argument.type
132133
}
133134

134135
public function testGCWithZero(): void

0 commit comments

Comments
 (0)