public static function extendTwigEnvironment(
        ContainerInterface $container,
        ?TwigEnvironment $twig = null
    ): ?TwigEnvironment {
        if ($twig !== null) {
            if ($container->has(Lexer::class)) {
                $twig->setLexer($container->get(Lexer::class));
            }

            if ($twig->isDebug() && \class_exists(VarCloner::class)) {
                $twig->addExtension(new DumpExtension());
            }

            self::registerViserioTwigExtension($twig, $container);
        }

        return $twig;
    }
public static function extendTwigEnvironment(
        ContainerInterface $container,
        ?TwigEnvironment $twig = null
    ): ?TwigEnvironment {
        if ($twig !== null) {
            if ($container->has(Lexer::class)) {
                $twig->setLexer($container->get(Lexer::class));
            }

            if ($twig->isDebug() && \class_exists(VarCloner::class)) {
                $twig->addExtension(new DumpExtension());
            }

            self::registerViserioTwigExtension($twig, $container);
        }

        return $twig;
    }
public static function extendTwigEnvironment ( ContainerInterface $ container , ? TwigEnvironment $ twig = null ) : ? TwigEnvironment { if ( $ twig !== null ) { if ( $ container -> has ( Lexer :: class ) ) { $ twig -> setLexer ( $ container -> get ( Lexer :: class ) ) ; } if ( $ twig -> isDebug ( ) && \ class_exists ( VarCloner :: class ) ) { $ twig -> addExtension ( new DumpExtension ( ) ) ; } self :: registerViserioTwigExtension ( $ twig , $ container ) ; } return $ twig ; }
Extend the twig environment.

@param \Psr\Container\ContainerInterface $container
@param null|\Twig\Environment            $twig

@return null|\Twig\Environment
Extend the twig environment .