Skip to content

Commit

Permalink
feature #22743 [Serializer] Remove support for deprecated signatures …
Browse files Browse the repository at this point in the history
…(dunglas)

This PR was merged into the 4.0-dev branch.

Discussion
----------

[Serializer] Remove support for deprecated signatures

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no <!-- don't forget updating src/**/CHANGELOG.md files -->
| BC breaks?    | no
| Deprecations? | no <!-- don't forget updating UPGRADE-*.md files -->
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

<!--
- Bug fixes must be submitted against the lowest branch where they apply
  (lowest branches are regularly merged to upper ones so they get the fixes too).
- Features and deprecations must be submitted against the master branch.
- Please fill in this template according to the PR you're about to submit.
- Replace this comment by a description of what your PR is solving.
-->

Commits
-------

894f99b [Serializer] Remove support for deprecated signatures
  • Loading branch information
nicolas-grekas committed May 29, 2017
2 parents 6f72b34 + 894f99b commit bf99da5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 71 deletions.
3 changes: 3 additions & 0 deletions src/Symfony/Component/Serializer/CHANGELOG.md
Expand Up @@ -8,6 +8,9 @@ CHANGELOG
use the `SerializerAwareTrait` instead
* removed the `Serializer::$normalizerCache` and `Serializer::$denormalizerCache`
properties
* added an optional `string $format = null` argument to `AbstractNormalizer::instantiateObject`
* added an optional `array $context = array()` to `Serializer::supportsNormalization`, `Serializer::supportsDenormalization`,
`Serializer::supportsEncoding` and `Serializer::supportsDecoding`

3.3.0
-----
Expand Down
Expand Up @@ -305,21 +305,8 @@ protected function getConstructor(array &$data, $class, array &$context, \Reflec
*
* @throws RuntimeException
*/
protected function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes/*, string $format = null*/)
protected function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes, string $format = null)
{
if (func_num_args() >= 6) {
$format = func_get_arg(5);
} else {
if (__CLASS__ !== get_class($this)) {
$r = new \ReflectionMethod($this, __FUNCTION__);
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
@trigger_error(sprintf('Method %s::%s() will have a 6th `string $format = null` argument in version 4.0. Not defining it is deprecated since 3.2.', get_class($this), __FUNCTION__), E_USER_DEPRECATED);
}
}

$format = null;
}

if (
isset($context[static::OBJECT_TO_POPULATE]) &&
is_object($context[static::OBJECT_TO_POPULATE]) &&
Expand Down
60 changes: 4 additions & 56 deletions src/Symfony/Component/Serializer/Serializer.php
Expand Up @@ -163,42 +163,16 @@ public function denormalize($data, $type, $format = null, array $context = array
/**
* {@inheritdoc}
*/
public function supportsNormalization($data, $format = null/*, array $context = array()*/)
public function supportsNormalization($data, $format = null, array $context = array())
{
if (func_num_args() > 2) {
$context = func_get_arg(2);
} else {
if (__CLASS__ !== get_class($this)) {
$r = new \ReflectionMethod($this, __FUNCTION__);
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
@trigger_error(sprintf('Method %s() will have a third `$context = array()` argument in version 4.0. Not defining it is deprecated since 3.3.', __METHOD__), E_USER_DEPRECATED);
}
}

$context = array();
}

return null !== $this->getNormalizer($data, $format, $context);
}

/**
* {@inheritdoc}
*/
public function supportsDenormalization($data, $type, $format = null/*, array $context = array()*/)
public function supportsDenormalization($data, $type, $format = null, array $context = array())
{
if (func_num_args() > 3) {
$context = func_get_arg(3);
} else {
if (__CLASS__ !== get_class($this)) {
$r = new \ReflectionMethod($this, __FUNCTION__);
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
@trigger_error(sprintf('Method %s() will have a fourth `$context = array()` argument in version 4.0. Not defining it is deprecated since 3.3.', __METHOD__), E_USER_DEPRECATED);
}
}

$context = array();
}

return null !== $this->getDenormalizer($data, $type, $format, $context);
}

Expand Down Expand Up @@ -284,42 +258,16 @@ private function denormalizeObject($data, $class, $format, array $context = arra
/**
* {@inheritdoc}
*/
public function supportsEncoding($format/*, array $context = array()*/)
public function supportsEncoding($format, array $context = array())
{
if (func_num_args() > 1) {
$context = func_get_arg(1);
} else {
if (__CLASS__ !== get_class($this)) {
$r = new \ReflectionMethod($this, __FUNCTION__);
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
@trigger_error(sprintf('Method %s() will have a second `$context = array()` argument in version 4.0. Not defining it is deprecated since 3.3.', __METHOD__), E_USER_DEPRECATED);
}
}

$context = array();
}

return $this->encoder->supportsEncoding($format, $context);
}

/**
* {@inheritdoc}
*/
public function supportsDecoding($format/*, array $context = array()*/)
public function supportsDecoding($format, array $context = array())
{
if (func_num_args() > 1) {
$context = func_get_arg(1);
} else {
if (__CLASS__ !== get_class($this)) {
$r = new \ReflectionMethod($this, __FUNCTION__);
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
@trigger_error(sprintf('Method %s() will have a second `$context = array()` argument in version 4.0. Not defining it is deprecated since 3.3.', __METHOD__), E_USER_DEPRECATED);
}
}

$context = array();
}

return $this->decoder->supportsDecoding($format, $context);
}
}
Expand Up @@ -73,7 +73,7 @@ protected function isAllowedAttribute($classOrObject, $attribute, $format = null
return in_array($attribute, array('foo', 'baz'));
}

public function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes, $format = null)
public function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes, string $format = null)
{
return parent::instantiateObject($data, $class, $context, $reflectionClass, $allowedAttributes, $format);
}
Expand Down

0 comments on commit bf99da5

Please sign in to comment.