19
19
use OpenCodeModeling \JsonSchemaToPhp \Type \ArrayType ;
20
20
use OpenCodeModeling \JsonSchemaToPhp \Type \ReferenceType ;
21
21
use OpenCodeModeling \JsonSchemaToPhp \Type \ScalarType ;
22
+ use OpenCodeModeling \JsonSchemaToPhp \Type \StringType ;
22
23
use OpenCodeModeling \JsonSchemaToPhp \Type \TypeDefinition ;
23
24
use OpenCodeModeling \JsonSchemaToPhp \Type \TypeSet ;
24
25
use OpenCodeModeling \JsonSchemaToPhpAst \Common \IteratorFactory ;
@@ -219,14 +220,15 @@ private function determineType(string $name, TypeSet ...$typeSets): TypeDefiniti
219
220
$ resolvedTypeSet = $ type ->resolvedType ();
220
221
221
222
if ($ resolvedTypeSet === null ) {
222
- throw new \RuntimeException (\sprintf ('Reference has no resolved type for "%s". ' , $ name ));
223
+ $ resolvedTypeSet = new TypeSet (
224
+ StringType::fromDefinition (['type ' => StringType::type (), 'name ' => $ type ->name ()])
225
+ );
223
226
}
224
-
225
227
if (\count ($ resolvedTypeSet ) !== 1 ) {
226
228
throw new \RuntimeException ('Can only handle one JSON type ' );
227
229
}
228
- $ type = $ typeSet ->first ();
229
- break ;
230
+ $ type = $ resolvedTypeSet ->first ();
231
+ // no break
230
232
case $ type instanceof ScalarType:
231
233
break ;
232
234
default :
@@ -365,7 +367,7 @@ public function methodRemove(
365
367
$copy->%s = array_values(
366
368
array_filter(
367
369
$copy->%s,
368
- static function($v) { return !$v->equals($%s); }
370
+ static function($v) use ($%s) { return !$v->equals($%s); }
369
371
)
370
372
);
371
373
return $copy;
@@ -377,7 +379,7 @@ static function($v) { return !$v->equals($%s); }
377
379
(new ParameterGenerator (($ this ->propertyNameFilter )($ argumentType ), ($ this ->classNameFilter )($ argumentType ))),
378
380
],
379
381
MethodGenerator::FLAG_PUBLIC ,
380
- new BodyGenerator ($ this ->parser , \sprintf ($ body , $ propertyName , $ propertyName , ($ this ->propertyNameFilter )($ argumentType )))
382
+ new BodyGenerator ($ this ->parser , \sprintf ($ body , $ propertyName , $ propertyName , ($ this ->propertyNameFilter )($ argumentType ), ( $ this -> propertyNameFilter )( $ argumentType ) ))
381
383
);
382
384
$ method ->setTyped ($ this ->typed );
383
385
$ method ->setReturnType ('self ' );
@@ -466,7 +468,7 @@ public function methodFilter(
466
468
...array_values(
467
469
array_filter(
468
470
$this->%s,
469
- static function($%s) { return $filter($%s); }
471
+ static function($%s) use ($filter) { return $filter($%s); }
470
472
)
471
473
)
472
474
);
0 commit comments