Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.
This repository was 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

@oliverwelter

Description

@oliverwelter

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions