Skip to content

Commit f25e8c1

Browse files
[DI][Serializer] Add missing deprecations
1 parent 9ad3020 commit f25e8c1

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

Normalizer/AbstractNormalizer.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,18 @@ protected function getConstructor(array &$data, $class, array &$context, \Reflec
289289
*/
290290
protected function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes/*, $format = null*/)
291291
{
292-
$format = func_num_args() >= 6 ? func_get_arg(5) : null;
292+
if (func_num_args() >= 6) {
293+
$format = func_get_arg(5);
294+
} else {
295+
if (__CLASS__ !== get_class($this)) {
296+
$r = new \ReflectionMethod($this, __FUNCTION__);
297+
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
298+
@trigger_error(sprintf('Method %s() will have a 6th `$format = null` argument in version 4.0. Not defining it is deprecated since 3.2.', get_class($this), __FUNCTION__), E_USER_DEPRECATED);
299+
}
300+
}
301+
302+
$format = null;
303+
}
293304

294305
if (
295306
isset($context[static::OBJECT_TO_POPULATE]) &&

Tests/Normalizer/AbstractObjectNormalizerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ protected function isAllowedAttribute($classOrObject, $attribute, $format = null
5959
return in_array($attribute, array('foo', 'baz'));
6060
}
6161

62-
public function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes)
62+
public function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes, $format = null)
6363
{
64-
return parent::instantiateObject($data, $class, $context, $reflectionClass, $allowedAttributes);
64+
return parent::instantiateObject($data, $class, $context, $reflectionClass, $allowedAttributes, $format);
6565
}
6666
}
6767

0 commit comments

Comments
 (0)