[$obj, 'myCallbackMethod']
[MyClass::class, 'myCallbackMethod']
'MyClass::myCallbackMethod'
<?php
class TestListener
{
// сигнатуру тут лишнюю для простоты примера просто убрал
public function onContentPrepare(&$row) {
$row->text = preg_replace_callback('|{gold}|', [$this, 'insertgold'], $row->text);
}
public function insertgold(array $matches)
{
return $matches[0] . 'Called';
}
}
// Example
$string = new stdClass();
$string->text = 'TestText with gold and gold ';
$listener = new TestListener();
$listener->onContentPrepare($string);
var_dump($string->text ); //TestText with goldCalled and goldCalled