ZF-2215: Zend_Rest_Client adds last given argument as arg1


When using named arguments Zend_Rest_Client adds an additional argument named arg1 to the call. In combination with Zend_Rest_Server the first given argument is overwritten by the last one.

$client = new Zend_Rest_Client('http://www.example.com/rest/');

$erg =  $client->get();

get() uses this URL:



Had the same issue. Solved the problem by commenting out one line of Zend/Rest/Client.php. See below: $this->_data['arg1'] = $args[0];

public function __call($method, $args)
    $methods = array('post', 'get', 'delete', 'put');

    if (in_array(strtolower($method), $methods)) {
        if (!isset($args[0])) {
            $args[0] = $this->_uri->getPath();
        $this->_data['rest'] = 1;
        $data = array_slice($args, 1) + $this->_data;
        $response = $this->{'rest' . $method}($args[0], $data);
        return new Zend_Rest_Client_Result($response->getBody());
    } else {
        // More than one arg means it's definitely a Zend_Rest_Server
        if (sizeof($args) == 1) {
            $this->_data[$method] = $args[0];
            //$this->_data['arg1']  = $args[0];
        } else {
            $this->_data['method'] = $method;
            if (sizeof($args) > 0) {
                foreach ($args as $key => $arg) {
                    $key = 'arg' . $key;
                    $this->_data[$key] = $arg;
        return $this;

Looks like issues ZF-2467, ZF-2215, ZF-2044 are all related to this problem.

This issue is still existing in v1.5.2.

...and is still existing in v1.5.3...

Does it depend on ZF-4089, doesn't it?

Sorry, but the changes in v1.6.2 doesn't fix this issue. Have a look at the original description. When stepping through a debugger one can see that the first call $client->method('divide'); results in $this->_data['method'] being set to 'method' on line 240. $this->_data['arg1'] is set to 'divide' on line 241.

Maybe the whole call sequence used in the original description is wrong. But I have my doubts. When writing line 240 as $this->_data[$method] = $args[0]; and omitting line 241 the call sequence used in the original desription of this issue will work as expected. And it doesn't seem to have any problematic side effects.

I have to correct my last comment. The described workaround doesn't work if the call uses exactly one parameter. So it seems that Zend_Rest_Client cannot be used with the call sequence described above by Carsten Möhrke. The reason why I also had problems with this is because I followed a chapter in the (german) book about Zend Framework written by Carsten Möhrke.

So there are two options:

1: Zend_Rest_Client is intended to support a call sequence where one uses a call of e.g. client->method('divide') and setting named parameters the way Carsten Möhrke did above. Then this issue is still unresolved.

2: Zend_Rest_Client is not intended to support a call sequence as in Carsten Möhrke's above example.

Thank You for Your detailed explanation , Johannes Schlimm.

Now, I understand if we call functions twice more before post(), get(), delete() or put(), it causes wrong uri parameter.

Solved in r12048

Changing issues in preparation for the 1.7.0 release.