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

Is there a reason you are preferring variadic calls? #37

Open
kaecyra opened this issue Jan 26, 2017 · 2 comments
Open

Is there a reason you are preferring variadic calls? #37

kaecyra opened this issue Jan 26, 2017 · 2 comments

Comments

@kaecyra
Copy link
Contributor

kaecyra commented Jan 26, 2017

To me, this makes the library a little harder to use for certain cases. Specifically, if you want to query a changing list of queues, you seem to have to call getJob() using call_user_func_array. Unless there's another usage you suggest?

@dominics
Copy link
Contributor

dominics commented Mar 5, 2017

The splat operator ("argument unpacking") is helpful. The only remaining annoyance is the $options array, because you can't use positional arguments after argument unpacking. So, I end up doing something like:

$queues = ['something', 'something_else'];
$options = ['count' => 3];

$args = $queues;
$args[] = $options;

$jobs = $this->disque->getJob(...$args);

Still annoying, but at least avoids call_user_func_array.

@mariano
Copy link
Owner

mariano commented Mar 7, 2017

@kaecyra I don't have any strong preference towards variadics, I just enjoy writing getJob('q1', 'q2'). I do see how it's annoying when dealing with a dynamic list of queues.

As @dominics suggested this can be simplified using unpacking, and i'd add that you can actually get around the $options issue with a one liner:

getJob(...array_merge($queues, [$options]));

Would you agree that's an acceptable workaround to avoid an API change, or do you feel you have use cases where something else needs to be offered?

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

No branches or pull requests

3 participants