RedisMock icon indicating copy to clipboard operation
RedisMock copied to clipboard

Not working with the Redis extension

Open mnapoli opened this issue 9 years ago • 9 comments

Maybe I'm doing it wrong but I cannot get this to work with the Redis extension. I'm running PHP 7, here is the list of warnings I'm getting:

Declaration of M6Web\Component\RedisMock\RedisMock_Redis_Adapter::scan(&$i_iterator, $str_pattern, $i_count) should be compatible with Redis::scan(&$i_iterator, $str_pattern = NULL, $i_count = NULL) Declaration of M6Web\Component\RedisMock\RedisMock_Redis_Adapter::hscan($str_key, &$i_iterator, $str_pattern, $i_count) should be compatible with Redis::hscan($str_key, &$i_iterator, $str_pattern = NULL, $i_count = NULL) Declaration of M6Web\Component\RedisMock\RedisMock_Redis_Adapter::zscan($str_key, &$i_iterator, $str_pattern, $i_count) should be compatible with Redis::zscan($str_key, &$i_iterator, $str_pattern = NULL, $i_count = NULL) Declaration of M6Web\Component\RedisMock\RedisMock_Redis_Adapter::sscan($str_key, &$i_iterator, $str_pattern, $i_count) should be compatible with Redis::sscan($str_key, &$i_iterator, $str_pattern = NULL, $i_count = NULL)

I'm suspecting this is because the default value of internal/extension classes cannot be read (see https://github.com/Ocramius/ProxyManager/issues/162 for example or also ParameterResolver.php#L97).

I'm wondering if it's sane to set a default value of null if we know there is a default value ($parameter->isOptional()) but we can't read it ($parameter->isDefaultValueAvailable())…

Has anyone managed to make this work with the Redis class of the Redis extension? (if so, which PHP version?)

mnapoli avatar Jan 26 '16 16:01 mnapoli

work fine with predis ~1.0 and php 7.0.1. Can you provide a simple test case ?

txs

omansour avatar Jan 26 '16 19:01 omansour

Predis is the client implemented in vanilla PHP, I experience the problem with the Redis extension.

mnapoli avatar Jan 26 '16 22:01 mnapoli

yes. can you show me a simple test case ? So I can reproduce ? Or its just while running the tests of RedisMock ?

omansour avatar Jan 27 '16 05:01 omansour

To reproduce:

$factory->getAdapter('Redis');

I've opened #47

mnapoli avatar Jan 27 '16 08:01 mnapoli

@mnapoli you're right the problem come from reflection who can't read default value from internal function/method.

With isOptional ()we can know if a method has a default value but setting this with a null value can result in same error if some methods use constant as default parameter.

mojoLyon avatar Jan 28 '16 13:01 mojoLyon

Yep but if null is the only default value in redis classes then this could be an acceptable solution. Unless you see another one? See https://github.com/Ocramius/ProxyManager/issues/162 also.

mnapoli avatar Jan 28 '16 15:01 mnapoli

Ok, if nullis the only default value in extension, your solution can fit

mojoLyon avatar Jan 28 '16 16:01 mojoLyon

@mnapoli We will try to have a look at that issue today.

omansour avatar Feb 05 '16 08:02 omansour

:+1: cool!

mnapoli avatar Feb 05 '16 08:02 mnapoli