/** * @param array $options * @param CacheInterface $cache * * @return Parser */ protected function createParser($options = [], CacheInterface $cache = null) { $parser = new Parser($options, $cache); // test functions $parser->addFunctions(['_color' => function (FunctionRegistry $registry, Node $a) { if ($a->value === 'evil red') { return new ColorNode('600'); } }, 'increment' => function (FunctionRegistry $registry, Node $a) { return new DimensionNode($a->value + 1); }, 'add' => function (FunctionRegistry $registry, Node $a, Node $b) { return new DimensionNode($a->value + $b->value); }]); return $parser; }