コード例 #1
0
 private function functionNeedsEnvironment(IdentifierNode $node)
 {
     $function = $this->environment->getFunction($node->getData('name'));
     if ($function->getOption('needs_environment')) {
         return true;
     }
     return !is_string($function->getCallback());
 }
コード例 #2
0
ファイル: SafeOutputVisitor.php プロジェクト: bugadani/minty
 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;
 }
コード例 #3
0
ファイル: Core.php プロジェクト: bugadani/minty
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);
}
コード例 #4
0
ファイル: CoreFunctionsTest.php プロジェクト: bugadani/minty
 /**
  * @dataProvider returnValueProvider
  */
 public function testFunctionReturnValues($function, $arguments, $expected)
 {
     $actual = call_user_func_array($this->env->getFunction($function)->getCallback(), $arguments);
     $this->assertEquals($expected, $actual);
 }