BedrockStreaming/RedisMock

Not working with the Redis extension

mnapoli opened this issue · 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 Ocramius/ProxyManager#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?)

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

txs

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

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

To reproduce:

$factory->getAdapter('Redis');

I've opened #47

@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.

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 Ocramius/ProxyManager#162 also.

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

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

👍 cool!