Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Zend\Json\Server\Server::addFunction instantiates new class even an object was given as callable #4604

Closed
oliverwelter opened this issue Jun 7, 2013 · 1 comment
Labels
Milestone

Comments

@oliverwelter
Copy link

Zend\Json\Server\Server::addFunction instantiates a new object even if an object is given as a callable.
e.g.
$server->addFunction(array($this, 'remoteProcedure'));

This gets problematic in case the constructor has arguments or the object needs further initialisation.
In contrast to this Zend\Json\Server\Server::setClass reuses the given object.

The behaviour is caused by the difference in the call to
Zend\Server\AbstractServer::_buildSignature

setClass:
$definition = $this->_buildSignature($method, $class); (line 133)

addFunction:
$definition = $this->_buildSignature($method); (line 109)

If there are no reasons against it the fix would be
using
$definition = $this->_buildSignature($method, $class);
as well in addFunction.

@steverhoades
Copy link
Contributor

@sephritoth Please reference #5379 for fix.

gianarb pushed a commit to zendframework/zend-json that referenced this issue May 15, 2015
…r addFunction will no longer result in an error.
weierophinney added a commit to zendframework/zend-json that referenced this issue May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants