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

Remove limitation on closures #11

Open
dnaber-de opened this issue Sep 24, 2014 · 1 comment
Open

Remove limitation on closures #11

dnaber-de opened this issue Sep 24, 2014 · 1 comment

Comments

@dnaber-de
Copy link

The current implementation (in 2.4.0) of WordPressClient::_logError() requires callbacks to be closures or function strings. Thus it is not possible to attach a class method as callback, which would make it easier to separate the callback from a logger.

However, if the callbacks would called instead by call_user_func_array() any callable type would be possible:

    private function _logError()
    {
        $callbacks = $this->_getCallback('error');
        $event = array(
            'event'    => 'error',
            'endpoint' => $this->_endPoint,
            'request'  => $this->_request,
            'proxy'    => $this->_proxyConfig,
            'auth'     => $this->_authConfig,
        );
        foreach($callbacks as $callback)
        {
            call_user_func_array($callback, array($this->_error, $event));
        }
    }
@franz-josef-kaiser
Copy link

@dnaber-de Try using the magic __invoke() method inside a class.

letrunghieu added a commit that referenced this issue Feb 3, 2016
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

2 participants