4 * This file is part of Twig.
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
11 class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
14 * @expectedException LogicException
16 public function testDisplayBlocksAcceptTemplateOnlyAsBlocks()
18 $template = $this->getMockForAbstractClass('Twig_Template', array(), '', false);
19 $template->displayBlock('foo', array(), array('foo' => array(new stdClass(), 'foo')));
23 * @dataProvider getAttributeExceptions
25 public function testGetAttributeExceptions($template, $message)
27 $templates = array('index' => $template);
28 $env = new Twig_Environment(new Twig_Loader_Array($templates), array('strict_variables' => true));
29 $template = $env->loadTemplate('index');
34 'empty_array' => array(),
35 'array' => array('foo' => 'foo'),
36 'array_access' => new Twig_TemplateArrayAccessObject(),
37 'magic_exception' => new Twig_TemplateMagicPropertyObjectWithException(),
38 'object' => new stdClass(),
42 $template->render($context);
43 $this->fail('Accessing an invalid attribute should throw an exception.');
44 } catch (Twig_Error_Runtime $e) {
45 $this->assertSame(sprintf($message, 'index'), $e->getMessage());
49 public function getAttributeExceptions()
52 array('{{ string["a"] }}', 'Impossible to access a key ("a") on a string variable ("foo") in "%s" at line 1.'),
53 array('{{ null["a"] }}', 'Impossible to access a key ("a") on a null variable in "%s" at line 1.'),
54 array('{{ empty_array["a"] }}', 'Key "a" does not exist as the array is empty in "%s" at line 1.'),
55 array('{{ array["a"] }}', 'Key "a" for array with keys "foo" does not exist in "%s" at line 1.'),
56 array('{{ array_access["a"] }}', 'Key "a" in object with ArrayAccess of class "Twig_TemplateArrayAccessObject" does not exist in "%s" at line 1.'),
57 array('{{ string.a }}', 'Impossible to access an attribute ("a") on a string variable ("foo") in "%s" at line 1.'),
58 array('{{ string.a() }}', 'Impossible to invoke a method ("a") on a string variable ("foo") in "%s" at line 1.'),
59 array('{{ null.a }}', 'Impossible to access an attribute ("a") on a null variable in "%s" at line 1.'),
60 array('{{ null.a() }}', 'Impossible to invoke a method ("a") on a null variable in "%s" at line 1.'),
61 array('{{ empty_array.a }}', 'Key "a" does not exist as the array is empty in "%s" at line 1.'),
62 array('{{ array.a }}', 'Key "a" for array with keys "foo" does not exist in "%s" at line 1.'),
63 array('{{ attribute(array, -10) }}', 'Key "-10" for array with keys "foo" does not exist in "%s" at line 1.'),
64 array('{{ array_access.a }}', 'Neither the property "a" nor one of the methods "a()", "geta()"/"isa()" or "__call()" exist and have public access in class "Twig_TemplateArrayAccessObject" in "%s" at line 1.'),
65 array('{% from _self import foo %}{% macro foo(obj) %}{{ obj.missing_method() }}{% endmacro %}{{ foo(array_access) }}', 'Neither the property "missing_method" nor one of the methods "missing_method()", "getmissing_method()"/"ismissing_method()" or "__call()" exist and have public access in class "Twig_TemplateArrayAccessObject" in "%s" at line 1.'),
66 array('{{ magic_exception.test }}', 'An exception has been thrown during the rendering of a template ("Hey! Don\'t try to isset me!") in "%s" at line 1.'),
67 array('{{ object["a"] }}', 'Impossible to access a key "a" on an object of class "stdClass" that does not implement ArrayAccess interface in "%s" at line 1.'),
72 * @dataProvider getGetAttributeWithSandbox
74 public function testGetAttributeWithSandbox($object, $item, $allowed)
76 $twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
77 $policy = new Twig_Sandbox_SecurityPolicy(array(), array(), array(/*method*/), array(/*prop*/), array());
78 $twig->addExtension(new Twig_Extension_Sandbox($policy, !$allowed));
79 $template = new Twig_TemplateTest($twig);
82 $template->getAttribute($object, $item, array(), 'any');
87 $this->addToAssertionCount(1);
89 } catch (Twig_Sandbox_SecurityError $e) {
93 $this->addToAssertionCount(1);
96 $this->assertContains('is not allowed', $e->getMessage());
100 public function getGetAttributeWithSandbox()
103 array(new Twig_TemplatePropertyObject(), 'defined', false),
104 array(new Twig_TemplatePropertyObject(), 'defined', true),
105 array(new Twig_TemplateMethodObject(), 'defined', false),
106 array(new Twig_TemplateMethodObject(), 'defined', true),
113 public function testGetAttributeWithTemplateAsObject()
115 // to be removed in 2.0
116 $twig = new Twig_Environment($this->getMockBuilder('Twig_TemplateTestLoaderInterface')->getMock());
117 //$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface', 'Twig_SourceContextLoaderInterface')->getMock());
119 $template = new Twig_TemplateTest($twig, 'index.twig');
120 $template1 = new Twig_TemplateTest($twig, 'index1.twig');
122 $this->assertInstanceof('Twig_Markup', $template->getAttribute($template1, 'string'));
123 $this->assertEquals('some_string', $template->getAttribute($template1, 'string'));
125 $this->assertInstanceof('Twig_Markup', $template->getAttribute($template1, 'true'));
126 $this->assertEquals('1', $template->getAttribute($template1, 'true'));
128 $this->assertInstanceof('Twig_Markup', $template->getAttribute($template1, 'zero'));
129 $this->assertEquals('0', $template->getAttribute($template1, 'zero'));
131 $this->assertNotInstanceof('Twig_Markup', $template->getAttribute($template1, 'empty'));
132 $this->assertSame('', $template->getAttribute($template1, 'empty'));
134 $this->assertFalse($template->getAttribute($template1, 'env', array(), Twig_Template::ANY_CALL, true));
135 $this->assertFalse($template->getAttribute($template1, 'environment', array(), Twig_Template::ANY_CALL, true));
136 $this->assertFalse($template->getAttribute($template1, 'getEnvironment', array(), Twig_Template::METHOD_CALL, true));
137 $this->assertFalse($template->getAttribute($template1, 'displayWithErrorHandling', array(), Twig_Template::METHOD_CALL, true));
142 * @expectedDeprecation Calling "string" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0.
143 * @expectedDeprecation Calling "string" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0.
144 * @expectedDeprecation Calling "true" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0.
145 * @expectedDeprecation Calling "true" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0.
146 * @expectedDeprecation Calling "zero" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0.
147 * @expectedDeprecation Calling "zero" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0.
148 * @expectedDeprecation Calling "empty" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0.
149 * @expectedDeprecation Calling "empty" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0.
150 * @expectedDeprecation Calling "renderBlock" on template "index.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use block("name") instead).
151 * @expectedDeprecation Calling "displayBlock" on template "index.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use block("name") instead).
152 * @expectedDeprecation Calling "hasBlock" on template "index.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use "block("name") is defined" instead).
153 * @expectedDeprecation Calling "render" on template "index.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use include("index.twig") instead).
154 * @expectedDeprecation Calling "display" on template "index.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use include("index.twig") instead).
155 * @expectedDeprecation Calling "renderBlock" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use block("name", template) instead).
156 * @expectedDeprecation Calling "displayBlock" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use block("name", template) instead).
157 * @expectedDeprecation Calling "hasBlock" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use "block("name", template) is defined" instead).
158 * @expectedDeprecation Calling "render" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use include("index1.twig") instead).
159 * @expectedDeprecation Calling "display" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use include("index1.twig") instead).
161 public function testGetAttributeWithTemplateAsObjectForDeprecations()
163 // to be removed in 2.0
164 $twig = new Twig_Environment($this->getMockBuilder('Twig_TemplateTestLoaderInterface')->getMock());
165 //$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface', 'Twig_SourceContextLoaderInterface')->getMock());
167 $template = new Twig_TemplateTest($twig, 'index.twig');
168 $template1 = new Twig_TemplateTest($twig, 'index1.twig');
170 $this->assertInstanceof('Twig_Markup', $template->getAttribute($template1, 'string'));
171 $this->assertEquals('some_string', $template->getAttribute($template1, 'string'));
173 $this->assertInstanceof('Twig_Markup', $template->getAttribute($template1, 'true'));
174 $this->assertEquals('1', $template->getAttribute($template1, 'true'));
176 $this->assertInstanceof('Twig_Markup', $template->getAttribute($template1, 'zero'));
177 $this->assertEquals('0', $template->getAttribute($template1, 'zero'));
179 $this->assertNotInstanceof('Twig_Markup', $template->getAttribute($template1, 'empty'));
180 $this->assertSame('', $template->getAttribute($template1, 'empty'));
182 $blocks = array('name' => array($template1, 'block_name'));
184 // trigger some deprecation notice messages to check them with @expectedDeprecation
185 $template->getAttribute($template, 'renderBlock', array('name', array(), $blocks));
186 $template->getAttribute($template, 'displayBlock', array('name', array(), $blocks));
187 $template->getAttribute($template, 'hasBlock', array('name', array()));
188 $template->getAttribute($template, 'render', array(array()));
189 $template->getAttribute($template, 'display', array(array()));
191 $template->getAttribute($template1, 'renderBlock', array('name', array(), $blocks));
192 $template->getAttribute($template1, 'displayBlock', array('name', array(), $blocks));
193 $template->getAttribute($template1, 'hasBlock', array('name', array()));
194 $template->getAttribute($template1, 'render', array(array()));
195 $template->getAttribute($template1, 'display', array(array()));
197 $this->assertFalse($template->getAttribute($template1, 'env', array(), Twig_Template::ANY_CALL, true));
198 $this->assertFalse($template->getAttribute($template1, 'environment', array(), Twig_Template::ANY_CALL, true));
199 $this->assertFalse($template->getAttribute($template1, 'getEnvironment', array(), Twig_Template::METHOD_CALL, true));
200 $this->assertFalse($template->getAttribute($template1, 'displayWithErrorHandling', array(), Twig_Template::METHOD_CALL, true));
205 * @expectedDeprecation Silent display of undefined block "unknown" in template "index.twig" is deprecated since version 1.29 and will throw an exception in 2.0. Use the "block('unknown') is defined" expression to test for block existence.
206 * @expectedDeprecation Silent display of undefined block "unknown" in template "index.twig" is deprecated since version 1.29 and will throw an exception in 2.0. Use the "block('unknown') is defined" expression to test for block existence.
208 public function testRenderBlockWithUndefinedBlock()
210 $twig = new Twig_Environment($this->getMockBuilder('Twig_TemplateTestLoaderInterface')->getMock());
212 $template = new Twig_TemplateTest($twig, 'index.twig');
213 $template->renderBlock('unknown', array());
214 $template->displayBlock('unknown', array());
217 public function testGetAttributeOnArrayWithConfusableKey()
219 $template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
221 $array = array('Zero', 'One', -1 => 'MinusOne', '' => 'EmptyString', '1.5' => 'FloatButString', '01' => 'IntegerButStringWithLeadingZeros');
223 $this->assertSame('Zero', $array[false]);
224 $this->assertSame('One', $array[true]);
225 $this->assertSame('One', $array[1.5]);
226 $this->assertSame('One', $array['1']);
227 $this->assertSame('MinusOne', $array[-1.5]);
228 $this->assertSame('FloatButString', $array['1.5']);
229 $this->assertSame('IntegerButStringWithLeadingZeros', $array['01']);
230 $this->assertSame('EmptyString', $array[null]);
232 $this->assertSame('Zero', $template->getAttribute($array, false), 'false is treated as 0 when accessing an array (equals PHP behavior)');
233 $this->assertSame('One', $template->getAttribute($array, true), 'true is treated as 1 when accessing an array (equals PHP behavior)');
234 $this->assertSame('One', $template->getAttribute($array, 1.5), 'float is casted to int when accessing an array (equals PHP behavior)');
235 $this->assertSame('One', $template->getAttribute($array, '1'), '"1" is treated as integer 1 when accessing an array (equals PHP behavior)');
236 $this->assertSame('MinusOne', $template->getAttribute($array, -1.5), 'negative float is casted to int when accessing an array (equals PHP behavior)');
237 $this->assertSame('FloatButString', $template->getAttribute($array, '1.5'), '"1.5" is treated as-is when accessing an array (equals PHP behavior)');
238 $this->assertSame('IntegerButStringWithLeadingZeros', $template->getAttribute($array, '01'), '"01" is treated as-is when accessing an array (equals PHP behavior)');
239 $this->assertSame('EmptyString', $template->getAttribute($array, null), 'null is treated as "" when accessing an array (equals PHP behavior)');
243 * @dataProvider getGetAttributeTests
245 public function testGetAttribute($defined, $value, $object, $item, $arguments, $type)
247 $template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
249 $this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type));
253 * @dataProvider getGetAttributeTests
255 public function testGetAttributeStrict($defined, $value, $object, $item, $arguments, $type, $exceptionMessage = null)
257 $template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('strict_variables' => true)));
260 $this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type));
262 if (method_exists($this, 'expectException')) {
263 $this->expectException('Twig_Error_Runtime');
264 if (null !== $exceptionMessage) {
265 $this->expectExceptionMessage($exceptionMessage);
268 $this->setExpectedException('Twig_Error_Runtime', $exceptionMessage);
270 $this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type));
275 * @dataProvider getGetAttributeTests
277 public function testGetAttributeDefined($defined, $value, $object, $item, $arguments, $type)
279 $template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
281 $this->assertEquals($defined, $template->getAttribute($object, $item, $arguments, $type, true));
285 * @dataProvider getGetAttributeTests
287 public function testGetAttributeDefinedStrict($defined, $value, $object, $item, $arguments, $type)
289 $template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('strict_variables' => true)));
291 $this->assertEquals($defined, $template->getAttribute($object, $item, $arguments, $type, true));
294 public function testGetAttributeCallExceptions()
296 $template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
298 $object = new Twig_TemplateMagicMethodExceptionObject();
300 $this->assertNull($template->getAttribute($object, 'foo'));
303 public function getGetAttributeTests()
306 'defined' => 'defined',
316 $objectArray = new Twig_TemplateArrayAccessObject();
317 $stdObject = (object) $array;
318 $magicPropertyObject = new Twig_TemplateMagicPropertyObject();
319 $propertyObject = new Twig_TemplatePropertyObject();
320 $propertyObject1 = new Twig_TemplatePropertyObjectAndIterator();
321 $propertyObject2 = new Twig_TemplatePropertyObjectAndArrayAccess();
322 $propertyObject3 = new Twig_TemplatePropertyObjectDefinedWithUndefinedValue();
323 $methodObject = new Twig_TemplateMethodObject();
324 $magicMethodObject = new Twig_TemplateMagicMethodObject();
326 $anyType = Twig_Template::ANY_CALL;
327 $methodType = Twig_Template::METHOD_CALL;
328 $arrayType = Twig_Template::ARRAY_CALL;
331 // array(defined, value, property to fetch)
332 array(true, 'defined', 'defined'),
333 array(false, null, 'undefined'),
334 array(false, null, 'protected'),
335 array(true, 0, 'zero'),
338 array(true, null, 'null'),
339 array(true, true, 'bar'),
340 array(true, 'baz', 'baz'),
341 array(true, '09', '09'),
342 array(true, '+4', '+4'),
344 $testObjects = array(
345 // array(object, type of fetch)
346 array($array, $arrayType),
347 array($objectArray, $arrayType),
348 array($stdObject, $anyType),
349 array($magicPropertyObject, $anyType),
350 array($methodObject, $methodType),
351 array($methodObject, $anyType),
352 array($propertyObject, $anyType),
353 array($propertyObject1, $anyType),
354 array($propertyObject2, $anyType),
358 foreach ($testObjects as $testObject) {
359 foreach ($basicTests as $test) {
360 // properties cannot be numbers
361 if (($testObject[0] instanceof stdClass || $testObject[0] instanceof Twig_TemplatePropertyObject) && is_numeric($test[2])) {
365 if ('+4' === $test[2] && $methodObject === $testObject[0]) {
369 $tests[] = array($test[0], $test[1], $testObject[0], $test[2], array(), $testObject[1]);
373 // additional properties tests
374 $tests = array_merge($tests, array(
375 array(true, null, $propertyObject3, 'foo', array(), $anyType),
378 // additional method tests
379 $tests = array_merge($tests, array(
380 array(true, 'defined', $methodObject, 'defined', array(), $methodType),
381 array(true, 'defined', $methodObject, 'DEFINED', array(), $methodType),
382 array(true, 'defined', $methodObject, 'getDefined', array(), $methodType),
383 array(true, 'defined', $methodObject, 'GETDEFINED', array(), $methodType),
384 array(true, 'static', $methodObject, 'static', array(), $methodType),
385 array(true, 'static', $methodObject, 'getStatic', array(), $methodType),
387 array(true, '__call_undefined', $magicMethodObject, 'undefined', array(), $methodType),
388 array(true, '__call_UNDEFINED', $magicMethodObject, 'UNDEFINED', array(), $methodType),
391 // add the same tests for the any type
392 foreach ($tests as $test) {
393 if ($anyType !== $test[5]) {
399 $methodAndPropObject = new Twig_TemplateMethodAndPropObject();
401 // additional method tests
402 $tests = array_merge($tests, array(
403 array(true, 'a', $methodAndPropObject, 'a', array(), $anyType),
404 array(true, 'a', $methodAndPropObject, 'a', array(), $methodType),
405 array(false, null, $methodAndPropObject, 'a', array(), $arrayType),
407 array(true, 'b_prop', $methodAndPropObject, 'b', array(), $anyType),
408 array(true, 'b', $methodAndPropObject, 'B', array(), $anyType),
409 array(true, 'b', $methodAndPropObject, 'b', array(), $methodType),
410 array(true, 'b', $methodAndPropObject, 'B', array(), $methodType),
411 array(false, null, $methodAndPropObject, 'b', array(), $arrayType),
413 array(false, null, $methodAndPropObject, 'c', array(), $anyType),
414 array(false, null, $methodAndPropObject, 'c', array(), $methodType),
415 array(false, null, $methodAndPropObject, 'c', array(), $arrayType),
418 // tests when input is not an array or object
419 $tests = array_merge($tests, array(
420 array(false, null, 42, 'a', array(), $anyType, 'Impossible to access an attribute ("a") on a integer variable ("42") in "index.twig".'),
421 array(false, null, 'string', 'a', array(), $anyType, 'Impossible to access an attribute ("a") on a string variable ("string") in "index.twig".'),
422 array(false, null, array(), 'a', array(), $anyType, 'Key "a" does not exist as the array is empty in "index.twig".'),
429 * @expectedException Twig_Error_Runtime
431 public function testGetIsMethods()
433 $getIsObject = new Twig_TemplateGetIsMethods();
434 $template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('strict_variables' => true)));
435 // first time should not create a cache for "get"
436 $this->assertNull($template->getAttribute($getIsObject, 'get'));
437 // 0 should be in the method cache now, so this should fail
438 $this->assertNull($template->getAttribute($getIsObject, 0));
442 class Twig_TemplateTest extends Twig_Template
446 public function __construct(Twig_Environment $env, $name = 'index.twig')
448 parent::__construct($env);
449 self::$cache = array();
453 public function getZero()
458 public function getEmpty()
463 public function getString()
465 return 'some_string';
468 public function getTrue()
473 public function getTemplateName()
478 public function getDebugInfo()
483 protected function doGetParent(array $context)
488 protected function doDisplay(array $context, array $blocks = array())
492 public function getAttribute($object, $item, array $arguments = array(), $type = Twig_Template::ANY_CALL, $isDefinedTest = false, $ignoreStrictCheck = false)
494 if (function_exists('twig_template_get_attributes')) {
495 return twig_template_get_attributes($this, $object, $item, $arguments, $type, $isDefinedTest, $ignoreStrictCheck);
497 return parent::getAttribute($object, $item, $arguments, $type, $isDefinedTest, $ignoreStrictCheck);
501 public function block_name($context, array $blocks = array())
506 class Twig_TemplateArrayAccessObject implements ArrayAccess
508 protected $protected = 'protected';
510 public $attributes = array(
511 'defined' => 'defined',
521 public function offsetExists($name)
523 return array_key_exists($name, $this->attributes);
526 public function offsetGet($name)
528 return array_key_exists($name, $this->attributes) ? $this->attributes[$name] : null;
531 public function offsetSet($name, $value)
535 public function offsetUnset($name)
540 class Twig_TemplateMagicPropertyObject
542 public $defined = 'defined';
544 public $attributes = array(
554 protected $protected = 'protected';
556 public function __isset($name)
558 return array_key_exists($name, $this->attributes);
561 public function __get($name)
563 return array_key_exists($name, $this->attributes) ? $this->attributes[$name] : null;
567 class Twig_TemplateMagicPropertyObjectWithException
569 public function __isset($key)
571 throw new Exception('Hey! Don\'t try to isset me!');
575 class Twig_TemplatePropertyObject
577 public $defined = 'defined';
583 protected $protected = 'protected';
586 class Twig_TemplatePropertyObjectAndIterator extends Twig_TemplatePropertyObject implements IteratorAggregate
588 public function getIterator()
590 return new ArrayIterator(array('foo', 'bar'));
594 class Twig_TemplatePropertyObjectAndArrayAccess extends Twig_TemplatePropertyObject implements ArrayAccess
596 private $data = array(
597 'defined' => 'defined',
604 public function offsetExists($offset)
606 return array_key_exists($offset, $this->data);
609 public function offsetGet($offset)
611 return $this->offsetExists($offset) ? $this->data[$offset] : 'n/a';
614 public function offsetSet($offset, $value)
618 public function offsetUnset($offset)
623 class Twig_TemplatePropertyObjectDefinedWithUndefinedValue
627 public function __construct()
629 $this->foo = @$notExist;
633 class Twig_TemplateMethodObject
635 public function getDefined()
640 public function get1()
645 public function get09()
650 public function getZero()
655 public function getNull()
659 public function isBar()
664 public function isBaz()
666 return 'should never be returned';
669 public function getBaz()
674 protected function getProtected()
679 public static function getStatic()
685 class Twig_TemplateGetIsMethods
687 public function get()
696 class Twig_TemplateMethodAndPropObject
698 private $a = 'a_prop';
700 public function getA()
705 public $b = 'b_prop';
707 public function getB()
712 private $c = 'c_prop';
714 private function getC()
720 class Twig_TemplateMagicMethodObject
722 public function __call($method, $arguments)
724 return '__call_'.$method;
728 class Twig_TemplateMagicMethodExceptionObject
730 public function __call($method, $arguments)
732 throw new BadMethodCallException(sprintf('Unknown method "%s".', $method));
736 class CExtDisablingNodeVisitor implements Twig_NodeVisitorInterface
738 public function enterNode(Twig_NodeInterface $node, Twig_Environment $env)
740 if ($node instanceof Twig_Node_Expression_GetAttr) {
741 $node->setAttribute('disable_c_ext', true);
747 public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env)
752 public function getPriority()
758 // to be removed in 2.0
759 interface Twig_TemplateTestLoaderInterface extends Twig_LoaderInterface, Twig_SourceContextLoaderInterface