Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik committed Oct 25, 2023
1 parent 2a19ae0 commit 0095636
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/TypeCaster/HydratorTypeCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Yiisoft\Hydrator\TypeCaster;

use ReflectionClass;
use ReflectionNamedType;
use ReflectionUnionType;
use Yiisoft\Hydrator\Exception\NonInstantiableException;
Expand Down Expand Up @@ -57,16 +56,12 @@ private function castInternal(array $value, ReflectionNamedType $type, HydratorI

$class = $type->getName();

$reflection = new ReflectionClass($class);
if ($reflection->isInstantiable()) {
try {
$object = $hydrator->create($class, $value);
} catch (NonInstantiableException) {
return Result::fail();
}
return Result::success($object);
try {
$object = $hydrator->create($class, $value);
} catch (NonInstantiableException) {
return Result::fail();
}

return Result::fail();
return Result::success($object);
}
}

0 comments on commit 0095636

Please sign in to comment.