mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 03:16:34 +00:00
Fix regression in defined test for GetAttr. Fixes #319
This commit is contained in:
@@ -33,8 +33,9 @@ class Twig_Node_Expression_Test extends Twig_Node_Expression
|
||||
} elseif ($this->getNode('node') instanceof Twig_Node_Expression_GetAttr) {
|
||||
$this->getNode('node')->setAttribute('is_defined_test', true);
|
||||
$compiler
|
||||
->raw('null !== ')
|
||||
->raw('(null !== ')
|
||||
->subcompile($this->getNode('node'))
|
||||
->raw(')')
|
||||
;
|
||||
} else {
|
||||
throw new Twig_Error_Syntax('The "defined" test only works with simple variables', $this->getLine());
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
{{ foobar is not defined ? 'ok' : 'ko' }}
|
||||
{{ zero is defined ? 'ok' : 'ko' }}
|
||||
{{ nested.foo is defined ? 'ok' : 'ko' }}
|
||||
{{ nested.foo is not defined ? 'ok' : 'ko' }}
|
||||
{{ nested.bar is not defined ? 'ok' : 'ko' }}
|
||||
{{ nested.zero is defined ? 'ok' : 'ko' }}
|
||||
--DATA--
|
||||
@@ -16,5 +17,6 @@ ok
|
||||
ok
|
||||
ok
|
||||
ok
|
||||
ko
|
||||
ok
|
||||
ok
|
||||
|
||||
Reference in New Issue
Block a user