When running with PHP 8.3, the Redis cache component throws a TypeError with the message "Unsupported operand types: string * int" in the Cache.php file at line 251.
Details
File: vendor/yiisoft/yii2-redis/src/Cache.php
Line: 251
Code: $expire = (int) ($expire * 1000);
Error: Unsupported operand types: string * int
This error occurs because PHP 8.3 is more strict about type operations than previous versions. The $expire variable might be passed as a string in some cases, causing the multiplication operation to fail.
Proposed Solution
Change line 251 from:
php$expire = (int) ($expire * 1000);
To:
php$expire = (int) ((int)$expire * 1000);
This ensures that $expire is properly cast to an integer before the multiplication operation.
Environment
PHP version: 8.3
Yii2 Redis extension version: latest
Yii2 framework version: latest