File tree Expand file tree Collapse file tree 2 files changed +42
-6
lines changed 
src/Symfony/Bundle/TwigBundle 
Tests/DependencyInjection Expand file tree Collapse file tree 2 files changed +42
-6
lines changed Original file line number Diff line number Diff line change @@ -78,12 +78,21 @@ private function addGlobalsSection(NodeBuilder $rootNode)
7878 ->useAttributeAsKey ('key ' )
7979 ->prototype ('array ' )
8080 ->beforeNormalization ()
81-  ->ifTrue (function ($ vreturn  is_scalar ($ v
82-  ->then (function ($ v
83-  return  ('@ '  === substr ($ v0 , 1 ))
84-  ? array ('id '  => substr ($ v1 ), 'type '  => 'service ' )
85-  : array ('value '  => $ v
81+  ->ifTrue (function ($ vreturn  is_string ($ v'@ '  === substr ($ v0 , 1 ); })
82+  ->then (function ($ vreturn  array ('id '  => substr ($ v1 ), 'type '  => 'service ' ); })
83+  ->end ()
84+  ->beforeNormalization ()
85+  ->ifTrue (function ($ v
86+  if  (is_array ($ v
87+  $ keysarray_keys ($ v
88+  sort ($ keys
89+ 
90+  return  $ keysarray ('id ' , 'type ' ) && $ keysarray ('value ' );
91+  }
92+ 
93+  return  true ;
8694 })
95+  ->then (function ($ vreturn  array ('value '  => $ v
8796 ->end ()
8897 ->scalarNode ('id ' )->end ()
8998 ->scalarNode ('type ' )
@@ -92,7 +101,7 @@ private function addGlobalsSection(NodeBuilder $rootNode)
92101 ->thenInvalid ('The %s type is not supported ' )
93102 ->end ()
94103 ->end ()
95-  ->scalarNode ('value ' )->end ()
104+  ->variableNode ('value ' )->end ()
96105 ->end ()
97106 ->end ()
98107 ;
Original file line number Diff line number Diff line change @@ -86,6 +86,33 @@ public function testLoadFullConfiguration($format)
8686 $ this assertTrue ($ options'strict_variables ' ], '->load() sets the strict_variables option ' );
8787 }
8888
89+  public  function  testGlobalsWithDifferentTypesAndValues ()
90+  {
91+  $ globalsarray (
92+  'array '  => array (),
93+  'false '  => false ,
94+  'float '  => 2.0 ,
95+  'integer '  => 3 ,
96+  'null '  => null ,
97+  'object '  => new  \stdClass (),
98+  'string '  => 'foo ' ,
99+  'true '  => true ,
100+  );
101+ 
102+  $ container$ this createContainer ();
103+  $ containerregisterExtension (new  TwigExtension ());
104+  $ containerloadFromExtension ('twig ' , array ('globals '  => $ globals
105+  $ this compileContainer ($ container
106+ 
107+  $ calls$ containergetDefinition ('twig ' )->getMethodCalls ();
108+ 
109+  foreach  ($ callsas  $ call
110+  list ($ name$ valueeach ($ globals
111+  $ this assertEquals ($ name$ call1 ][0 ]);
112+  $ this assertSame ($ value$ call1 ][1 ]);
113+  }
114+  }
115+ 
89116 public  function  getFormats ()
90117 {
91118 return  array (
                         You can’t perform that action at this time. 
           
                  
0 commit comments