If you are testing by editing an existing post, note that you must change at least one character for Flarum to re-generate the formatted post. If the content is identical from before the edit Flarum skips that step.
It's best to always create new posts/discussions while testing formatter configuration changes.
EDIT: just to be extra sure this should be working, I tested JoshyPHP code on my test forum and it works as intended, both in previews and final posts. I had never seen the PHP arrow functions used in the context of Flarum before but assuming your PHP version supports them it's perfectly fine (seems to be from PHP 7.4 and up).