@@ -55,8 +55,6 @@ public function __construct(?ContainerInterface $container = null)
5555 * @param class-string<T>|T $object
5656 * @param array|object $data
5757 *
58- * @throws InvalidArgumentException
59- * If the data isn't valid.
6058 * @throws Exception\UntypedPropertyException
6159 * If one of the object properties isn't typed.
6260 * @throws Exception\UnsupportedPropertyTypeException
@@ -67,6 +65,8 @@ public function __construct(?ContainerInterface $container = null)
6765 * If the given data contains an invalid value.
6866 * @throws Exception\HydrationException
6967 * If the object cannot be hydrated.
68+ * @throws InvalidArgumentException
69+ * If the data isn't valid.
7070 *
7171 * @return T
7272 *
@@ -150,10 +150,10 @@ public function hydrate(string|object $object, array|object $data): object
150150 * @param string $json
151151 * @param ?int $flags
152152 *
153- * @throws InvalidArgumentException
154- * If the JSON cannot be decoded.
155153 * @throws Exception\HydrationException
156154 * If the object cannot be hydrated.
155+ * @throws InvalidArgumentException
156+ * If the JSON cannot be decoded.
157157 *
158158 * @return T
159159 *
@@ -179,14 +179,26 @@ public function hydrateWithJson(string|object $object, string $json, ?int $flags
179179 return $ this ->hydrate ($ object , $ data );
180180 }
181181
182+ /**
183+ * @param class-string|object $object
184+ *
185+ * @throws \ReflectionException
186+ *
187+ * @return object|null
188+ */
189+ public function getConcreteResolverFor (string |object $ object ): ?ConcreteResolver
190+ {
191+ return $ this ->getAttributeInstance (new ReflectionClass ($ object ), ConcreteResolver::class, ReflectionAttribute::IS_INSTANCEOF );
192+ }
193+
182194 /**
183195 * Initializes the given object.
184196 *
185197 * @param class-string<T>|T $object
186198 *
199+ * @throws InvalidArgumentException
187200 * @throws ContainerExceptionInterface
188201 * If the object cannot be initialized.
189- * @throws InvalidArgumentException
190202 *
191203 * @return T
192204 *
@@ -218,7 +230,7 @@ private function initializeObject(string|object $object, array|object $data): ob
218230 ));
219231 }
220232
221- return $ this ->initializeObject ($ attribute ->getConcreteClass ($ data ), $ data );
233+ return $ this ->initializeObject ($ attribute ->concreteFor ($ data ), $ data );
222234 }
223235
224236 // if we have a container, get the instance through it
@@ -268,10 +280,10 @@ private function getAttributeInstance(ReflectionProperty|ReflectionClass $target
268280 * @param ReflectionNamedType $type
269281 * @param mixed $value
270282 *
271- * @throws Exception\UnsupportedPropertyTypeException
272- * If the given property contains an unsupported type.
273283 * @throws Exception\InvalidValueException
274284 * If the given value isn't valid.
285+ * @throws Exception\UnsupportedPropertyTypeException
286+ * If the given property contains an unsupported type.
275287 *
276288 * @return void
277289 */
0 commit comments