@@ -55,8 +55,6 @@ public function __construct(?ContainerInterface $container = null)
55
55
* @param class-string<T>|T $object
56
56
* @param array|object $data
57
57
*
58
- * @throws InvalidArgumentException
59
- * If the data isn't valid.
60
58
* @throws Exception\UntypedPropertyException
61
59
* If one of the object properties isn't typed.
62
60
* @throws Exception\UnsupportedPropertyTypeException
@@ -67,6 +65,8 @@ public function __construct(?ContainerInterface $container = null)
67
65
* If the given data contains an invalid value.
68
66
* @throws Exception\HydrationException
69
67
* If the object cannot be hydrated.
68
+ * @throws InvalidArgumentException
69
+ * If the data isn't valid.
70
70
*
71
71
* @return T
72
72
*
@@ -150,10 +150,10 @@ public function hydrate(string|object $object, array|object $data): object
150
150
* @param string $json
151
151
* @param ?int $flags
152
152
*
153
- * @throws InvalidArgumentException
154
- * If the JSON cannot be decoded.
155
153
* @throws Exception\HydrationException
156
154
* If the object cannot be hydrated.
155
+ * @throws InvalidArgumentException
156
+ * If the JSON cannot be decoded.
157
157
*
158
158
* @return T
159
159
*
@@ -179,14 +179,26 @@ public function hydrateWithJson(string|object $object, string $json, ?int $flags
179
179
return $ this ->hydrate ($ object , $ data );
180
180
}
181
181
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
+
182
194
/**
183
195
* Initializes the given object.
184
196
*
185
197
* @param class-string<T>|T $object
186
198
*
199
+ * @throws InvalidArgumentException
187
200
* @throws ContainerExceptionInterface
188
201
* If the object cannot be initialized.
189
- * @throws InvalidArgumentException
190
202
*
191
203
* @return T
192
204
*
@@ -218,7 +230,7 @@ private function initializeObject(string|object $object, array|object $data): ob
218
230
));
219
231
}
220
232
221
- return $ this ->initializeObject ($ attribute ->getConcreteClass ($ data ), $ data );
233
+ return $ this ->initializeObject ($ attribute ->concreteFor ($ data ), $ data );
222
234
}
223
235
224
236
// if we have a container, get the instance through it
@@ -268,10 +280,10 @@ private function getAttributeInstance(ReflectionProperty|ReflectionClass $target
268
280
* @param ReflectionNamedType $type
269
281
* @param mixed $value
270
282
*
271
- * @throws Exception\UnsupportedPropertyTypeException
272
- * If the given property contains an unsupported type.
273
283
* @throws Exception\InvalidValueException
274
284
* If the given value isn't valid.
285
+ * @throws Exception\UnsupportedPropertyTypeException
286
+ * If the given property contains an unsupported type.
275
287
*
276
288
* @return void
277
289
*/
0 commit comments