本文整理汇总了PHP中Twig_Environment::getUnaryOperators方法的典型用法代码示例。如果您正苦于以下问题:PHP Twig_Environment::getUnaryOperators方法的具体用法?PHP Twig_Environment::getUnaryOperators怎么用?PHP Twig_Environment::getUnaryOperators使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Twig_Environment
的用法示例。
在下文中一共展示了Twig_Environment::getUnaryOperators方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(Twig_Parser $parser, Twig_Environment $env = null)
{
$this->parser = $parser;
if ($env instanceof Twig_Environment) {
$this->env = $env;
$this->unaryOperators = $env->getUnaryOperators();
$this->binaryOperators = $env->getBinaryOperators();
} else {
@trigger_error('Passing the operators as constructor arguments to ' . __METHOD__ . ' is deprecated since version 1.27. Pass the environment instead.', E_USER_DEPRECATED);
$this->env = $parser->getEnvironment();
$this->unaryOperators = func_get_arg(1);
$this->binaryOperators = func_get_arg(2);
}
}
示例2: testRemoveExtension
public function testRemoveExtension()
{
$twig = new Twig_Environment(new Twig_Loader_String());
$twig->addExtension(new Twig_Tests_EnvironmentTest_Extension());
$twig->removeExtension('test');
$this->assertFalse(array_key_exists('test', $twig->getTags()));
$this->assertFalse(array_key_exists('foo_filter', $twig->getFilters()));
$this->assertFalse(array_key_exists('foo_function', $twig->getFunctions()));
$this->assertFalse(array_key_exists('foo_test', $twig->getTests()));
$this->assertFalse(array_key_exists('foo_unary', $twig->getUnaryOperators()));
$this->assertFalse(array_key_exists('foo_binary', $twig->getBinaryOperators()));
$this->assertFalse(array_key_exists('foo_global', $twig->getGlobals()));
$this->assertCount(2, $twig->getNodeVisitors());
}
示例3: testAddExtension
public function testAddExtension()
{
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
$twig->addExtension(new Twig_Tests_EnvironmentTest_Extension());
$this->assertArrayHasKey('test', $twig->getTags());
$this->assertArrayHasKey('foo_filter', $twig->getFilters());
$this->assertArrayHasKey('foo_function', $twig->getFunctions());
$this->assertArrayHasKey('foo_test', $twig->getTests());
$this->assertArrayHasKey('foo_unary', $twig->getUnaryOperators());
$this->assertArrayHasKey('foo_binary', $twig->getBinaryOperators());
$this->assertArrayHasKey('foo_global', $twig->getGlobals());
$visitors = $twig->getNodeVisitors();
$this->assertEquals('Twig_Tests_EnvironmentTest_NodeVisitor', get_class($visitors[2]));
}
示例4: testRemoveExtension
/**
* @group legacy
*/
public function testRemoveExtension()
{
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$twig->addExtension(new Twig_Tests_EnvironmentTest_Extension_WithDeprecatedName());
$twig->removeExtension('environment_test');
$this->assertFalse(array_key_exists('test', $twig->getTags()));
$this->assertFalse(array_key_exists('foo_filter', $twig->getFilters()));
$this->assertFalse(array_key_exists('foo_function', $twig->getFunctions()));
$this->assertFalse(array_key_exists('foo_test', $twig->getTests()));
$this->assertFalse(array_key_exists('foo_unary', $twig->getUnaryOperators()));
$this->assertFalse(array_key_exists('foo_binary', $twig->getBinaryOperators()));
$this->assertFalse(array_key_exists('foo_global', $twig->getGlobals()));
$this->assertCount(2, $twig->getNodeVisitors());
}