I am trying to register a route with fast route using an Object and static method with the following code:
static public function registerRoute( RouteCollector &$r ): void {
$r->addRoute(['GET', 'OPTIONS'], '/password', array( self::class, 'renderChallenge') );
}
instead of the handler being called I instead get the following error message:
Argument 1 passed to Middlewares\Utils\CallableHandler::__construct() must be callable, object given, called in /src/vendor/middlewares/utils/src/RequestHandlerContainer.php on line 51
In the course of trying to debug I decided to test if what I was passing was callable using the following:
// Regular function to check if something is callable
function isThisCallable( callable $callable ) {
call_user_func( $callable );
}
// Modified code from above
static public function registerRoutes( RouteCollector &$r ): void {
$r->addRoute(['GET', 'OPTIONS'], '/password', function() {
isThisCallable( array(static::class, 'renderChallenge') );
} );
}
This test code ran as expected and called the static object's method. Is this a bug or is there another way I should be passing an object and method as the handler?
I am trying to register a route with fast route using an Object and static method with the following code:
instead of the handler being called I instead get the following error message:
Argument 1 passed to Middlewares\Utils\CallableHandler::__construct() must be callable, object given, called in /src/vendor/middlewares/utils/src/RequestHandlerContainer.php on line 51In the course of trying to debug I decided to test if what I was passing was callable using the following:
This test code ran as expected and called the static object's method. Is this a bug or is there another way I should be passing an object and method as the handler?