PHPRedisMutex add missing type handling
TheLevti opened this issue · 2 comments
TheLevti commented
https://github.com/php-lock/lock/blob/master/classes/mutex/PHPRedisMutex.php#L55 does not handle a possible null
return type. Base on the redis documentation (https://redis.io/commands/set), if the NX or XX option is specified, the return type can be NULL if the condition is not met. If null is returned, the method shall return false to comply with the return type.
1) SomeTest::testSomething
TypeError: Return value of malkusch\lock\mutex\PHPRedisMutex::add() must be of the type bool, null returned
/vendor/malkusch/lock/classes/mutex/PHPRedisMutex.php:48
/vendor/malkusch/lock/classes/mutex/RedisMutex.php:82
/vendor/malkusch/lock/classes/mutex/SpinlockMutex.php:72
/vendor/malkusch/lock/classes/util/Loop.php:90
/vendor/malkusch/lock/classes/mutex/SpinlockMutex.php:75
/vendor/malkusch/lock/classes/mutex/LockMutex.php:37
/vendor/malkusch/lock/classes/util/DoubleCheckedLocking.php:68
TheLevti commented
I will create a pull request later today
TheLevti commented
False alarm. As it turned out it was some mocked redis driver that returned the wrong type.