From Class A I want to implement a callback that includes specific methods as parameters. Eg.
call_user_func_array($callback, ['$this->get', '$this->post']);
However this doesn't work. What I am aiming for here is to do this:
index.php
$API = new API();
$API->state('/users', function ($get, $post) {
$get('/', 'UserController.getAll');
});
API.php
public function state ($state, $callback) {
call_user_func_array($callback, ['$this->get', '$this->post']);
}
public method get ($uri, $ctrl) { echo 'getting'; }
public method post ($uri, $ctrl) { echo 'posting'; }
Thanks for any input! I do realize using $this->method, won't work as $this-> will not exist within the callback scope.