I'd probably go one of two routes:

  • Treat it like a black box: Run experiments in order to build a mental model that matches what it actually does.
  • Treat it like a white box: Grab the source code and a PHP debugger (I sure hope those exist!), and dig into how Twig lexes, parses, and evaluates its array expressions.

/