@@ -161,7 +161,7 @@ protected function callableCallbackFromArrayValue(array $value, $key, $argDefini
161
161
return $ default ;
162
162
}
163
163
164
- $ code = $ this -> getSkeletonContent ( ' ResolverClosure ' ) ;
164
+ $ code = ' function (%s) <closureUseStatements>{ return %s; } ' ;
165
165
166
166
if (is_callable ($ value [$ key ])) {
167
167
$ func = $ value [$ key ];
@@ -205,6 +205,11 @@ protected function generateConfig(array $config)
205
205
return $ code ;
206
206
}
207
207
208
+ protected function generateClosureUseStatements (array $ config )
209
+ {
210
+ return null ;
211
+ }
212
+
208
213
protected function typeAlias2String ($ alias )
209
214
{
210
215
// Non-Null
@@ -235,6 +240,17 @@ protected function resolveTypeCode($alias)
235
240
return $ alias . 'Type::getInstance() ' ;
236
241
}
237
242
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
+
238
254
protected function types2String (array $ types )
239
255
{
240
256
$ types = array_map (__CLASS__ . '::typeAlias2String ' , $ types );
@@ -279,7 +295,7 @@ public function generateClasses(array $configs, $outputDirectory, $regenerateIfE
279
295
280
296
public function generateClass (array $ config , $ outputDirectory , $ regenerateIfExists = false )
281
297
{
282
- static $ treatLater = ['useStatement ' , 'spaces ' ];
298
+ static $ treatLater = ['useStatement ' , 'spaces ' , ' closureUseStatements ' ];
283
299
$ this ->clearInternalUseStatements ();
284
300
$ code = $ this ->processTemplatePlaceHoldersReplacements ('TypeSystem ' , $ config , $ treatLater );
285
301
$ code = $ this ->processPlaceHoldersReplacements ($ treatLater , $ code , $ config ) . "\n" ;
0 commit comments