If I am confident in the users of our webpage that they will never be messing with the Twig templates, then what risk is there to creating a |php filter for Twig that just does this?
{% set text = "echo 'Hello World';" %) {{ text | php }} Filter function:
function myPhpEvalFunction ($text = null) { return eval($text); }