@@ -265,7 +265,7 @@ public static function getInvalidValueForType(string $type): DateTime | stdClass
265265 */
266266 private static function getValidValue (
267267 ?array $ meta ,
268- string $ type
268+ string $ type,
269269 ): mixed {
270270 $ meta ??= [];
271271
@@ -276,6 +276,16 @@ private static function getValidValue(
276276 /** @var class-string $class */
277277 $ class = $ meta !== [] && array_key_exists ('targetEntity ' , $ meta ) ? $ meta ['targetEntity ' ] : $ type ;
278278
279+ if (!class_exists ($ class )) {
280+ throw new LogicException (
281+ sprintf (
282+ "Cannot create valid value for type '%s' because class '%s' does not exist. " ,
283+ $ type ,
284+ $ class ,
285+ ),
286+ );
287+ }
288+
279289 $ type = self ::TYPE_CUSTOM_CLASS ;
280290
281291 if ((new ReflectionClass ($ class ))->isEnum ()) {
@@ -290,6 +300,7 @@ private static function getValidValue(
290300 }
291301 }
292302
303+ /** @var mixed $output */
293304 $ output = match ($ type ) {
294305 self ::TYPE_ENUM => current ($ class ::cases ()), // TODO: fix this
295306 self ::TYPE_CUSTOM_CLASS => new $ class (...$ params ),
@@ -303,6 +314,7 @@ private static function getValidValue(
303314 };
304315
305316 if (str_contains ($ type , '| ' )) {
317+ /** @var mixed $output */
306318 $ output = self ::getValidValueForType (explode ('| ' , $ type )[0 ], $ meta );
307319 } elseif (str_contains ($ type , '[] ' )) {
308320 /** @var array<mixed, object> $output */
0 commit comments