@@ -161,7 +161,7 @@ protected function callableCallbackFromArrayValue(array $value, $key, $argDefini
161161 return $ default ;
162162 }
163163
164- $ code = $ this -> getSkeletonContent ( ' ResolverClosure ' ) ;
164+ $ code = ' function (%s) <closureUseStatements>{ return %s; } ' ;
165165
166166 if (is_callable ($ value [$ key ])) {
167167 $ func = $ value [$ key ];
@@ -205,6 +205,11 @@ protected function generateConfig(array $config)
205205 return $ code ;
206206 }
207207
208+ protected function generateClosureUseStatements (array $ config )
209+ {
210+ return null ;
211+ }
212+
208213 protected function typeAlias2String ($ alias )
209214 {
210215 // Non-Null
@@ -235,6 +240,17 @@ protected function resolveTypeCode($alias)
235240 return $ alias . 'Type::getInstance() ' ;
236241 }
237242
243+ protected function resolveTypesCode (array $ values , $ key )
244+ {
245+ if (isset ($ values [$ key ])) {
246+ $ types = sprintf ('function () <closureUseStatements>{ return %s; } ' , $ this ->types2String ($ values [$ key ]));
247+ } else {
248+ $ types = '[] ' ;
249+ }
250+
251+ return $ types ;
252+ }
253+
238254 protected function types2String (array $ types )
239255 {
240256 $ types = array_map (__CLASS__ . '::typeAlias2String ' , $ types );
@@ -279,7 +295,7 @@ public function generateClasses(array $configs, $outputDirectory, $regenerateIfE
279295
280296 public function generateClass (array $ config , $ outputDirectory , $ regenerateIfExists = false )
281297 {
282- static $ treatLater = ['useStatement ' , 'spaces ' ];
298+ static $ treatLater = ['useStatement ' , 'spaces ' , ' closureUseStatements ' ];
283299 $ this ->clearInternalUseStatements ();
284300 $ code = $ this ->processTemplatePlaceHoldersReplacements ('TypeSystem ' , $ config , $ treatLater );
285301 $ code = $ this ->processPlaceHoldersReplacements ($ treatLater , $ code , $ config ) . "\n" ;
0 commit comments