<commit_before><?php

namespace Heyday\CacheInclude;

use Symfony\Component\ExpressionLanguage\ExpressionLanguage as SymfonyExpressionLanguage;

/**
 * Class ExpressionLanguage
 * @package Heyday\CacheInclude
 */
class ExpressionLanguage extends SymfonyExpressionLanguage
{
    /**
     *
     */
    protected function registerFunctions()
    {
        parent::registerFunctions();

        $this->register(
            'list',
            function ($arg) {
                return sprintf('%s::get()', $arg);
            },
            function (array $variables, $value) {
                return \DataList::create($value);
            }
        );

        $this->register(
            'instanceof',
            function ($arg0, $arg1) {
                return sprintf('%s instanceof %s', $arg0, $arg1);
            },
            function (array $variables, $arg0, $arg1) {
                return $arg0 instanceof $arg1;
            }
        );
    }
} <commit_msg>Remove closures from Expression language<commit_after><?php

namespace Heyday\CacheInclude;

use Symfony\Component\ExpressionLanguage\ExpressionLanguage as SymfonyExpressionLanguage;

/**
 * Class ExpressionLanguage
 * @package Heyday\CacheInclude
 */
class ExpressionLanguage extends SymfonyExpressionLanguage
{
    protected function registerFunctions()
    {
        parent::registerFunctions();

        $this->register(
            'list',
            array($this, 'listCompiler'),
            array($this, 'listEvaluator')
        );

        $this->register(
            'instanceof',
            array($this, 'instanceofCompiler'),
            array($this, 'instanceofEvaluator')
        );
    }

    /**
     * @param $arg
     * @return string
     */
    public function listCompiler($arg)
    {
        return sprintf('%s::get()', $arg);
    }

    /**
     * @param array $variables
     * @param $value
     * @return static
     */
    public function listEvaluator(array $variables, $value)
    {
        return \DataList::create($value);
    }

    /**
     * @param $arg0
     * @param $arg1
     * @return string
     */
    public function instanceofCompiler($arg0, $arg1)
    {
        return sprintf('%s instanceof %s', $arg0, $arg1);
    }

    /**
     * @param array $variables
     * @param $arg0
     * @param $arg1
     * @return bool
     */
    public function instanceofEvaluator(array $variables, $arg0, $arg1)
    {
        return $arg0 instanceof $arg1;
    }
}
{'fraction_non_alphanumeric': 0.12413793103448276, 'fraction_numerical': 0.008113590263691683, 'mean_word_length': 2.063354037267081, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '2821063', 'n_tokens_mistral': 677, 'n_tokens_neox': 669, 'n_words': 146}