At the moment the dispatcher supports in several way the use of functions as controllers, instead of the pair controller/method.
Usually the function is used as fallback when the method does not exist in the controller.
And this is implemented in a slightly odd way: using a function as controller, because it first instantiate the default controller, and then if the "possible method" doesn't exist it is checked as a function...pseudo code:
$possible_method = 'myMethod';
$controller = new MyController();
if (method_exists($controller, $possible_method))
$controller->{$possible_method}();
elseif (function_exists($possible_method))
$possible_method();
else
{
$controller = new BoardIndex_Controller();
$controller->action_index();
}
What I'm proposing is to deprecate and immediately remove (from 1.1) the function_exists block.
Leading to something like:
$possible_method = 'myMethod';
$controller = new MyController();
if (method_exists($controller, $possible_method))
$controller->{$possible_method}();
else
{
$controller = new BoardIndex_Controller();
$controller->action_index();
}
Then, I think that since we have in 1.1 an autoloader that takes care of controllers, we could even use:
$possible_method = 'myMethod';
$possible_controller = 'MyController';
if (method_exists($possible_controller, $possible_method))
{
$controller = new $possible_controller();
$method = $possible_method;
}
else
{
$controller = new BoardIndex_Controller();
$method = 'action_index';
}
$controller->{$method}();
Do you see anything broken with that?
ETA: forgot to add that ElkArte itself uses only classes as controllers, so the function version would be used only by addons.