When I interpret the description (This callback will receive these parameters: array $tag, array $rendererStates, XenForo_BbCode_Formatter_Base $formatter.) correct, the Php class gets those three parameters handed over. So I guess it needs to take them as input logically, but which of them exactly includes which details?
I just tried to get the right information of the input BB-Code, e.g. how [bbcode]001[/bbcode] is handed over to the php-File. Figured out it seems to be all stored in the $tag variable. $tag['tag'] is the BB-Code string, e.g. 'bbcode', $tag['option'] seems to be an array to hand over the related options if available, $tag['original'] contains two strings, in this case '[bbcode]' and '[/bbcode]' and $tag['children'] seems to have the value between the bbcode-bracelets, e.g. 001.