It applies a series of patches to make sure things keep working despite Twig's codebase, which presents several pleasant surprises (global functions, hardcoded class names, dynamically rendered PHP code, etc).
The (dark) magic happens in scoper.inc.php
- Clone from git
Running this command will produce the scoped version of
Twig in the
vendor/bin/php-scoper add-prefix --prefix='My\Safe\Namespace'
Obviously, the patching is ridiculously hacky and may not work well between
different Twig versions (that's also why is the version hardcoded in
Be very careful if you upgrade Twig and test everything before putting it into
production. Otherwise, no guarantees are provided!