@@ -261,7 +261,7 @@ public static function getInvalidValueForType(string $type): DateTime | stdClass
261261 */
262262 private static function getValidValue (
263263 ?array $ meta ,
264- string $ type
264+ string $ type,
265265 ): mixed {
266266 $ meta ??= [];
267267
@@ -272,6 +272,16 @@ private static function getValidValue(
272272 /** @var class-string $class */
273273 $ class = $ meta !== [] && array_key_exists ('targetEntity ' , $ meta ) ? $ meta ['targetEntity ' ] : $ type ;
274274
275+ if (!class_exists ($ class )) {
276+ throw new LogicException (
277+ sprintf (
278+ "Cannot create valid value for type '%s' because class '%s' does not exist. " ,
279+ $ type ,
280+ $ class ,
281+ ),
282+ );
283+ }
284+
275285 $ type = self ::TYPE_CUSTOM_CLASS ;
276286
277287 if ((new ReflectionClass ($ class ))->isEnum ()) {
@@ -286,6 +296,7 @@ private static function getValidValue(
286296 }
287297 }
288298
299+ /** @var mixed $output */
289300 $ output = match ($ type ) {
290301 self ::TYPE_ENUM => current ($ class ::cases ()), // TODO: fix this
291302 self ::TYPE_CUSTOM_CLASS => new $ class (...$ params ),
@@ -299,6 +310,7 @@ private static function getValidValue(
299310 };
300311
301312 if (str_contains ($ type , '| ' )) {
313+ /** @var mixed $output */
302314 $ output = self ::getValidValueForType (explode ('| ' , $ type )[0 ], $ meta );
303315 } elseif (str_contains ($ type , '[] ' )) {
304316 /** @var array<mixed, object> $output */
0 commit comments