I'd like to propose a short solution for handling this. First, we need to define a new service.
$di->setShared("static", new \StaticWrapper());`
With the wrapper class looking like this:
Class StaticWrapper
{
public function __call($name, $arguments) {
return call_user_func_array($name, $arguments);
}
public function class($className, $methodName, $arguments=array()) {
return call_user_func_array(array($className, $methodName), $arguments);
}
}
In the template, you can now call things like:
static.myGlobalStaticFunction(foo, bar); {# global static #}
static.class("\Some\Namespaced\Class", "classMethod", [foo, bar]); {# class method #}
The DI will automatically place our new service in the template.