Execute $next saved as method property

Hello fellow slim’ers!

Im building class for auhentication used also as a middleware. But I have trouble with next. To simplify work i put $req, $res and $next in class properties, to call methods without parameters ex. sendUnauthorizedError() instead of sendUnautorizedError($res), but problem happened when i get to respond with $next($res,$req). How to call it?

How about return call_user_func($this->next, $this->req, $this->res)?? But beware that these are value objects! After modifying either of them you have to update the class properties.

1 Like

Thanks! I forgot about that function :slight_smile: I will try it soon, and response how its going.