private function functionNeedsEnvironment(IdentifierNode $node) { $function = $this->environment->getFunction($node->getData('name')); if ($function->getOption('needs_environment')) { return true; } return !is_string($function->getCallback()); }
private function isFunctionSafe(Node $function) { if (!$this->environment->hasFunction($function->getData('name'))) { return false; } $safeFor = $this->environment->getFunction($function->getData('name'))->getOption('is_safe'); if (is_array($safeFor)) { return in_array($this->autofilter, $safeFor, true); } return $safeFor === true || $safeFor === $this->autofilter; }
function template_function_filter(Environment $environment, $data, $for = 'html') { if (!is_string($data)) { return $data; } if (!$environment->hasFunction('filter_' . $for)) { $for = $environment->getOption('default_autofilter_strategy'); } return $environment->getFunction('filter_' . $for)->call($data); }
/** * @dataProvider returnValueProvider */ public function testFunctionReturnValues($function, $arguments, $expected) { $actual = call_user_func_array($this->env->getFunction($function)->getCallback(), $arguments); $this->assertEquals($expected, $actual); }