Are there any limitations or considerations when using Twig to render content before a method call in PHP?

When using Twig to render content before a method call in PHP, one limitation to consider is that Twig does not support calling PHP methods directly within the template. To work around this limitation, you can pass the necessary data to Twig from your PHP code and perform any method calls before passing the data to the template for rendering.

// PHP code to prepare data for Twig rendering
$data = [
    'result' => $object->someMethod(),
];

// Render Twig template with data
echo $twig->render('template.twig', $data);