Skip to content

Commit 98bcb91

Browse files
authored
Merge pull request #1 from dunglas/theofidry-feature/param-object
Prevent BC in instantiateObject
2 parents e437e04 + 7b5d55d commit 98bcb91

File tree

3 files changed

+5
-14
lines changed

3 files changed

+5
-14
lines changed

src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php

+3-12
Original file line numberDiff line numberDiff line change
@@ -268,17 +268,6 @@ protected function getConstructor(array &$data, $class, array &$context, \Reflec
268268
return $reflectionClass->getConstructor();
269269
}
270270

271-
/**
272-
* @see instantiateComplexObject
273-
* @deprecated Since 3.1, will be removed in 4.0. Use instantiateComplexObject instead.
274-
*/
275-
protected function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes)
276-
{
277-
@trigger_error(sprintf('"%s()" has been deprecated since Symfony 3.1 and will be removed in version 4.0. Use "%s::instantiateComplexObject()" instead.', __METHOD__, __CLASS__), E_USER_DEPRECATED);
278-
279-
return $this->instantiateComplexObject($data, $class, $context, $reflectionClass, $allowedAttributes);
280-
}
281-
282271
/**
283272
* Instantiates an object using constructor parameters when needed.
284273
*
@@ -298,8 +287,10 @@ protected function instantiateObject(array &$data, $class, array &$context, \Ref
298287
*
299288
* @throws RuntimeException
300289
*/
301-
protected function instantiateComplexObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes, $format = null)
290+
protected function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes/*, $format = null*/)
302291
{
292+
$format = func_num_args() >= 6 ? func_get_arg(5) : null;
293+
303294
if (
304295
isset($context[static::OBJECT_TO_POPULATE]) &&
305296
is_object($context[static::OBJECT_TO_POPULATE]) &&

src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public function denormalize($data, $class, $format = null, array $context = arra
175175
$normalizedData = $this->prepareForDenormalization($data);
176176

177177
$reflectionClass = new \ReflectionClass($class);
178-
$object = $this->instantiateComplexObject($normalizedData, $class, $context, $reflectionClass, $allowedAttributes, $format);
178+
$object = $this->instantiateObject($normalizedData, $class, $context, $reflectionClass, $allowedAttributes, $format);
179179

180180
foreach ($normalizedData as $attribute => $value) {
181181
if ($this->nameConverter) {

src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function denormalize($data, $class, $format = null, array $context = arra
4747
$normalizedData = $this->prepareForDenormalization($data);
4848

4949
$reflectionClass = new \ReflectionClass($class);
50-
$object = $this->instantiateComplexObject($normalizedData, $class, $context, $reflectionClass, $allowedAttributes, $format);
50+
$object = $this->instantiateObject($normalizedData, $class, $context, $reflectionClass, $allowedAttributes, $format);
5151

5252
$classMethods = get_class_methods($object);
5353
foreach ($normalizedData as $attribute => $value) {

0 commit comments

Comments
 (0)