1919use OpenCodeModeling \JsonSchemaToPhp \Type \ArrayType ;
2020use OpenCodeModeling \JsonSchemaToPhp \Type \ReferenceType ;
2121use OpenCodeModeling \JsonSchemaToPhp \Type \ScalarType ;
22+ use OpenCodeModeling \JsonSchemaToPhp \Type \StringType ;
2223use OpenCodeModeling \JsonSchemaToPhp \Type \TypeDefinition ;
2324use OpenCodeModeling \JsonSchemaToPhp \Type \TypeSet ;
2425use OpenCodeModeling \JsonSchemaToPhpAst \Common \IteratorFactory ;
@@ -219,14 +220,15 @@ private function determineType(string $name, TypeSet ...$typeSets): TypeDefiniti
219220 $ resolvedTypeSet = $ type ->resolvedType ();
220221
221222 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+ );
223226 }
224-
225227 if (\count ($ resolvedTypeSet ) !== 1 ) {
226228 throw new \RuntimeException ('Can only handle one JSON type ' );
227229 }
228- $ type = $ typeSet ->first ();
229- break ;
230+ $ type = $ resolvedTypeSet ->first ();
231+ // no break
230232 case $ type instanceof ScalarType:
231233 break ;
232234 default :
@@ -365,7 +367,7 @@ public function methodRemove(
365367 $copy->%s = array_values(
366368 array_filter(
367369 $copy->%s,
368- static function($v) { return !$v->equals($%s); }
370+ static function($v) use ($%s) { return !$v->equals($%s); }
369371 )
370372 );
371373 return $copy;
@@ -377,7 +379,7 @@ static function($v) { return !$v->equals($%s); }
377379 (new ParameterGenerator (($ this ->propertyNameFilter )($ argumentType ), ($ this ->classNameFilter )($ argumentType ))),
378380 ],
379381 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 ) ))
381383 );
382384 $ method ->setTyped ($ this ->typed );
383385 $ method ->setReturnType ('self ' );
@@ -466,7 +468,7 @@ public function methodFilter(
466468 ...array_values(
467469 array_filter(
468470 $this->%s,
469- static function($%s) { return $filter($%s); }
471+ static function($%s) use ($filter) { return $filter($%s); }
470472 )
471473 )
472474 );
0 commit comments