<commit_before><?php

namespace Bolt\Twig\Extension;

use Bolt;
use Bolt\Config;
use Bolt\Configuration\PathsProxy;
use Bolt\Storage\EntityManagerInterface;
use Bolt\Twig\SetcontentTokenParser;
use Bolt\Twig\SwitchTokenParser;
use Twig\Extension\AbstractExtension;
use Twig\Extension\GlobalsInterface;
use Twig\TwigFilter;
use Twig\TwigFunction;

/**
 * Bolt base Twig functionality and definitions.
 */
class BoltExtension extends AbstractExtension implements GlobalsInterface
{
    /** @var EntityManagerInterface */
    private $em;
    /** @var Config */
    private $config;
    /** @var PathsProxy */
    private $paths;

    /**
     * Constructor.
     *
     * @param EntityManagerInterface $em
     * @param Config                 $config
     * @param PathsProxy             $paths
     */
    public function __construct(EntityManagerInterface $em, Config $config, PathsProxy $paths)
    {
        $this->em = $em;
        $this->config = $config;
        $this->paths = $paths;
    }

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return 'Bolt';
    }

    /**
     * Used by setcontent tag.
     *
     * @return EntityManagerInterface
     */
    public function getStorage()
    {
        return $this->em;
    }

    /**
     * {@inheritdoc}
     */
    public function getFunctions()
    {
        $env  = ['needs_environment' => true];
        $deprecated = ['deprecated' => true];

        return [
            // @codingStandardsIgnoreStart
            new TwigFunction('first', 'twig_first', $env + $deprecated),
            new TwigFunction('last',  'twig_last', $env + $deprecated),
            // @codingStandardsIgnoreEnd
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function getFilters()
    {
        $env  = ['needs_environment' => true];
        $deprecated = ['deprecated' => true];

        return [
            new TwigFilter('ucfirst', 'twig_capitalize_string_filter', $env + $deprecated + ['alternative' => 'capitalize']),
        ];
    }

    /**
     * {@inheritdoc}
     *
     * As of Twig 2.x, the ability to register a global variable after runtime
     * or the extensions have been initialized will not be possible any longer,
     * but changing the value of an already registered global is possible.
     */
    public function getGlobals()
    {
        return [
            'bolt_name'    => Bolt\Version::name(),
            'bolt_version' => Bolt\Version::VERSION,
            'frontend'     => null,
            'backend'      => null,
            'async'        => null,
            'paths'        => $this->paths,
            'theme'        => null,
            'user'         => null,
            'users'        => null,
            'config'       => $this->config,
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function getTokenParsers()
    {
        $isLegacy = $this->config->get('general/compatibility/setcontent_legacy', false);
        $parsers = [
            new SetcontentTokenParser($isLegacy),
            new SwitchTokenParser(),
        ];

        return $parsers;
    }
}<commit_msg>Invert logic so setcontent legacy is on by default<commit_after><?php

namespace Bolt\Twig\Extension;

use Bolt;
use Bolt\Config;
use Bolt\Configuration\PathsProxy;
use Bolt\Storage\EntityManagerInterface;
use Bolt\Twig\SetcontentTokenParser;
use Bolt\Twig\SwitchTokenParser;
use Twig\Extension\AbstractExtension;
use Twig\Extension\GlobalsInterface;
use Twig\TwigFilter;
use Twig\TwigFunction;

/**
 * Bolt base Twig functionality and definitions.
 */
class BoltExtension extends AbstractExtension implements GlobalsInterface
{
    /** @var EntityManagerInterface */
    private $em;
    /** @var Config */
    private $config;
    /** @var PathsProxy */
    private $paths;

    /**
     * Constructor.
     *
     * @param EntityManagerInterface $em
     * @param Config                 $config
     * @param PathsProxy             $paths
     */
    public function __construct(EntityManagerInterface $em, Config $config, PathsProxy $paths)
    {
        $this->em = $em;
        $this->config = $config;
        $this->paths = $paths;
    }

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return 'Bolt';
    }

    /**
     * Used by setcontent tag.
     *
     * @return EntityManagerInterface
     */
    public function getStorage()
    {
        return $this->em;
    }

    /**
     * {@inheritdoc}
     */
    public function getFunctions()
    {
        $env  = ['needs_environment' => true];
        $deprecated = ['deprecated' => true];

        return [
            // @codingStandardsIgnoreStart
            new TwigFunction('first', 'twig_first', $env + $deprecated),
            new TwigFunction('last',  'twig_last', $env + $deprecated),
            // @codingStandardsIgnoreEnd
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function getFilters()
    {
        $env  = ['needs_environment' => true];
        $deprecated = ['deprecated' => true];

        return [
            new TwigFilter('ucfirst', 'twig_capitalize_string_filter', $env + $deprecated + ['alternative' => 'capitalize']),
        ];
    }

    /**
     * {@inheritdoc}
     *
     * As of Twig 2.x, the ability to register a global variable after runtime
     * or the extensions have been initialized will not be possible any longer,
     * but changing the value of an already registered global is possible.
     */
    public function getGlobals()
    {
        return [
            'bolt_name'    => Bolt\Version::name(),
            'bolt_version' => Bolt\Version::VERSION,
            'frontend'     => null,
            'backend'      => null,
            'async'        => null,
            'paths'        => $this->paths,
            'theme'        => null,
            'user'         => null,
            'users'        => null,
            'config'       => $this->config,
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function getTokenParsers()
    {
        $isLegacy = $this->config->get('general/compatibility/setcontent_legacy', true);
        $parsers = [
            new SetcontentTokenParser($isLegacy),
            new SwitchTokenParser(),
        ];

        return $parsers;
    }
}
{'fraction_non_alphanumeric': 0.12488083889418494, 'fraction_numerical': 0.00031776294884016526, 'mean_word_length': 1.9319981369352586, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1868104', 'n_tokens_mistral': 1815, 'n_tokens_neox': 1793, 'n_words': 416}