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

Pass handle to 'progress' callable #2173

Closed
wants to merge 1 commit into from
Closed

Pass handle to 'progress' callable #2173

wants to merge 1 commit into from

Conversation

simPod
Copy link
Contributor

@simPod simPod commented Oct 21, 2018

The progress callable accepts 5 parameters where first is the handle as mentioned here http://php.net/manual/en/function.curl-setopt.php

image

Current state of the library passes only 4 arguments and removes the first argument containing the handle because it was not available in php versions <5.5. However this library requires 5.5+ so it can be added https://github.com/guzzle/guzzle/blob/master/composer.json#L16

I guess it's BC break.

array_shift($args);
}
call_user_func_array($progress, $args);
};
Copy link
Member

@gmponos gmponos Oct 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am correct what guzzle library was doing here is to wrap one callable function inside another.

So this call_user_func_array($progress, $args); calls the developers callback function that he added from his options.

According to the docs the handler argument is not supposed to be set from the developer and that's why this part of the code exists:

                if (is_resource($args[0])) {
                    array_shift($args);
                }

If you ask why the handler does not exists. Most probably it's because guzzle provides an abstraction layer. Developers should not care about the handler that the guzzle internally uses.. So my guess is that guzzle maintainers didn't want when a developer is setting this option having to think about the handler that the client internally uses.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but it's for compatibility purpose as it doesn't exists in old php versions. It's also documented there.

The handle is eg. accessible here

public $handle;
public and not internal

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you leave this as unresolved? I believe that guzzle maintainers should share their toughs on this.

@simPod
Copy link
Contributor Author

simPod commented Oct 22, 2018

The handle however is not very handy as I found out https://stackoverflow.com/a/52930054/519333

@simPod
Copy link
Contributor Author

simPod commented Oct 22, 2018

Maybe we can reorder args and put handle as the last one. Then it won't even be BC

@gmponos
Copy link
Member

gmponos commented Jul 12, 2020

Closing.. as this PR makes the consumers of Client class to be aware of the handler and loses the purpose of a client abstraction.

If another maintainer feels differently we can re-discuss.

@gmponos gmponos closed this Jul 12, 2020
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

Successfully merging this pull request may close these issues.

None yet

2 participants