$tests[] = array($node, 'twig_reverse_filter($this->env, "abc", true)');
// filter as an anonymous function
- $node = $this->createFilter(new Twig_Node_Expression_Constant('foo', 1), 'anonymous');
- $tests[] = array($node, 'call_user_func_array($this->env->getFilter(\'anonymous\')->getCallable(), array("foo"))');
+ if (version_compare(phpversion(), '5.3.0', '>=')) {
+ $node = $this->createFilter(new Twig_Node_Expression_Constant('foo', 1), 'anonymous');
+ $tests[] = array($node, 'call_user_func_array($this->env->getFilter(\'anonymous\')->getCallable(), array("foo"))');
+ }
return $tests;
}
protected function getEnvironment()
{
- $env = parent::getEnvironment();
- $env->addFilter(new Twig_SimpleFilter('anonymous', function () {}));
+ if (version_compare(phpversion(), '5.3.0', '>=')) {
+ return include 'PHP53/FilterTest.php';
+ }
- return $env;
+ return parent::getEnvironment();
}
}
$tests[] = array($node, 'twig_date_converter($this->env, 0, "America/Chicago")');
// function as an anonymous function
- $node = $this->createFunction('anonymous', array(new Twig_Node_Expression_Constant('foo', 1)));
- $tests[] = array($node, 'call_user_func_array($this->env->getFunction(\'anonymous\')->getCallable(), array("foo"))');
+ if (version_compare(phpversion(), '5.3.0', '>=')) {
+ $node = $this->createFunction('anonymous', array(new Twig_Node_Expression_Constant('foo', 1)));
+ $tests[] = array($node, 'call_user_func_array($this->env->getFunction(\'anonymous\')->getCallable(), array("foo"))');
+ }
return $tests;
}
protected function getEnvironment()
{
- $env = parent::getEnvironment();
- $env->addFunction(new Twig_SimpleFunction('anonymous', function () {}));
+ if (version_compare(phpversion(), '5.3.0', '>=')) {
+ return include 'PHP53/FunctionTest.php';
+ }
- return $env;
+ return parent::getEnvironment();
}
}
--- /dev/null
+<?php
+
+$env = new Twig_Environment();
+$env->addFilter(new Twig_SimpleFilter('anonymous', function () {}));
+
+return $env;
--- /dev/null
+<?php
+
+$env = new Twig_Environment();
+$env->addFunction(new Twig_SimpleFunction('anonymous', function () {}));
+
+return $env;
--- /dev/null
+<?php
+
+$env = new Twig_Environment();
+$env->addTest(new Twig_SimpleTest('anonymous', function () {}));
+
+return $env;
$tests[] = array($node, '(null === "foo")');
// test as an anonymous function
- $node = $this->createTest(new Twig_Node_Expression_Constant('foo', 1), 'anonymous', array(new Twig_Node_Expression_Constant('foo', 1)));
- $tests[] = array($node, 'call_user_func_array($this->env->getTest(\'anonymous\')->getCallable(), array("foo", "foo"))');
+ if (version_compare(phpversion(), '5.3.0', '>=')) {
+ $node = $this->createTest(new Twig_Node_Expression_Constant('foo', 1), 'anonymous', array(new Twig_Node_Expression_Constant('foo', 1)));
+ $tests[] = array($node, 'call_user_func_array($this->env->getTest(\'anonymous\')->getCallable(), array("foo", "foo"))');
+ }
return $tests;
}
protected function getEnvironment()
{
- $env = parent::getEnvironment();
- $env->addTest(new Twig_SimpleTest('anonymous', function () {}));
+ if (version_compare(phpversion(), '5.3.0', '>=')) {
+ return include 'PHP53/TestTest.php';
+ }
- return $env;
+ return parent::getEnvironment();
}
}