Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Second parameter of lpush should be variable-length argument list #1146

Open
kwidua opened this issue Feb 13, 2023 · 3 comments · May be fixed by #1160
Open

Second parameter of lpush should be variable-length argument list #1146

kwidua opened this issue Feb 13, 2023 · 3 comments · May be fixed by #1160
Assignees

Comments

@kwidua
Copy link

kwidua commented Feb 13, 2023

Describe the bug
When calling lpush($key, json_encode($values)) I get a psalm error Argument 2 of lpush expects array<array-key, mixed>, but false|non-empty-string provided.
The ClientInterface defines the method as * @method int lpush($key, array $values)
but it should be * @method int lpush($key, ...$values).

In your test you also do not pass an array as $values, but a string:
$redis->lpush('metavars', 'foo');

Some other functions in the ClientInterface are probably affected as well (lpushx, rpush..).

Versions (please complete the following information):

  • Predis: [1.1.10]
  • PHP [ 8.1.x]
  • Redis Server [e.g. 6.0.0]
  • OS [Ubuntu 20.04]
@kwidua kwidua added the bug label Feb 13, 2023
@tillkruss
Copy link
Member

What's the value of json_encode($values)?

@kwidua
Copy link
Author

kwidua commented Feb 14, 2023

What's the value of json_encode($values)?

@tillkruss Sorry, forgot that json_encode can return false. The value of json_encode($values) is a string. This occurs with every string.

@tillkruss
Copy link
Member

@kwidua: Oh, I see. You get a PHP Psalm warning. Feel free to open a PR 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants