@@ -84,7 +84,7 @@ public static function getWrappedType($name)
8484 {
8585 return isset (self ::$ wrappedTypes [$ name ]) ? self ::$ wrappedTypes [$ name ] : null ;
8686 }
87-
87+
8888 protected function generateParentClassName (array $ config )
8989 {
9090 return $ this ->shortenClassName (self ::$ typeSystems [$ config ['type ' ]]);
@@ -109,18 +109,18 @@ protected function generateClassDocBlock(array $config)
109109EOF ;
110110 }
111111
112- protected function varExportFromArrayValue (array $ values , $ key , $ default = 'null ' )
112+ protected function varExportFromArrayValue (array $ values , $ key , $ default = 'null ' , array $ compilerNames = [] )
113113 {
114114 if (!isset ($ values [$ key ])) {
115115 return $ default ;
116116 }
117117
118- $ code = $ this ->varExport ($ values [$ key ], $ default );
118+ $ code = $ this ->varExport ($ values [$ key ], $ default, $ compilerNames );
119119
120120 return $ code ;
121121 }
122122
123- protected function varExport ($ var , $ default = null )
123+ protected function varExport ($ var , $ default = null , array $ compilerNames = [] )
124124 {
125125 switch (true ) {
126126 case is_array ($ var ):
@@ -133,7 +133,7 @@ protected function varExport($var, $default = null)
133133 return "[ " . implode (", " , $ r ) . "] " ;
134134
135135 case $ this ->isExpression ($ var ):
136- return $ code = $ this ->getExpressionLanguage ()->compile ($ var );
136+ return $ code = $ this ->getExpressionLanguage ()->compile ($ var, $ compilerNames );
137137
138138 case is_object ($ var ):
139139 return $ default ;
@@ -155,7 +155,7 @@ protected function processFromArray(array $values, $templatePrefix)
155155 return '[ ' . $ this ->prefixCodeWithSpaces ($ code , 2 ) . "\n<spaces>] " ;
156156 }
157157
158- protected function callableCallbackFromArrayValue (array $ value , $ key , $ argDefinitions = null , $ default = 'null ' )
158+ protected function callableCallbackFromArrayValue (array $ value , $ key , $ argDefinitions = null , $ default = 'null ' , array $ compilerNames = null )
159159 {
160160 if (!isset ($ value [$ key ])) {
161161 return $ default ;
@@ -177,13 +177,14 @@ protected function callableCallbackFromArrayValue(array $value, $key, $argDefini
177177 return $ code ;
178178 }
179179 } elseif ($ this ->isExpression ($ value [$ key ])) {
180- preg_match_all ('@\$([a-z_][a-z0-9_]+)@i ' , $ argDefinitions , $ matches );
181-
182- $ argNames = isset ($ matches [1 ]) ? $ matches [1 ] : [];
180+ if (null === $ compilerNames ) {
181+ preg_match_all ('@\$([a-z_][a-z0-9_]+)@i ' , $ argDefinitions , $ matches );
182+ $ compilerNames = isset ($ matches [1 ]) ? $ matches [1 ] : [];
183+ }
183184 $ code = sprintf (
184185 $ code ,
185186 $ this ->shortenClassFromCode ($ argDefinitions ),
186- $ this ->getExpressionLanguage ()->compile ($ value [$ key ], $ argNames )
187+ $ this ->getExpressionLanguage ()->compile ($ value [$ key ], $ compilerNames )
187188 );
188189
189190 return $ code ;
0 commit comments