I answer this question exceptionally because you have to use a class method in it. So it isn't so simple than the million of answers about the subject.
One way to do it, change the pattern in a way the whole match is the yourclass::module
parameter and pass an array with $this
and the method name as second parameter:
$this->template = preg_replace_callback('/#module=\K\w+(?=#)/i', array($this, 'module'), $this->template);
or
$this->template = preg_replace_callback('/#module=\K\w+(?=#)/i', 'self::module', $this->template);
Other way, keep the same pattern and use the $that=$this;
trick:
$that = $this;
$this->template = preg_replace_callback('/#module=(\w+)#/i', function ($m) use ($that) {
return $that->module($m[1]);
}, $this->template);