Problem/Motivation
The signature of TwigEnvironment::__construct() is:
public function __construct($root, CacheBackendInterface $cache, $twig_extension_hash, StateInterface $state, LoaderInterface $loader = NULL, array $options = []) {
However, passing NULL as $loader results in a fatal error:
PHP Fatal error: Uncaught TypeError: Argument 1 passed to Twig\Environment::setLoader() must implement interface Twig\Loader\LoaderInterface, null given, called in core/lib/Drupal/Core/Template/TwigEnvironment.php on line 98 and defined in vendor/twig/twig/src/Environment.php:604
This is because
$this->setLoader($loader);
and the setLoader() signature is
public function setLoader(LoaderInterface $loader)
Steps to reproduce
Proposed resolution
Remove the NULL default argument.