Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bf99da5

Browse files
feature #22743 [Serializer] Remove support for deprecated signatures (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
2 parents 6f72b34 + 894f99b commit bf99da5

File tree

4 files changed

+9
-71
lines changed

4 files changed

+9
-71
lines changed

src/Symfony/Component/Serializer/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ CHANGELOG
88
use the `SerializerAwareTrait` instead
99
* removed the `Serializer::$normalizerCache` and `Serializer::$denormalizerCache`
1010
properties
11+
* added an optional `string $format = null` argument to `AbstractNormalizer::instantiateObject`
12+
* added an optional `array $context = array()` to `Serializer::supportsNormalization`, `Serializer::supportsDenormalization`,
13+
`Serializer::supportsEncoding` and `Serializer::supportsDecoding`
1114

1215
3.3.0
1316
-----

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -305,21 +305,8 @@ protected function getConstructor(array &$data, $class, array &$context, \Reflec
305305
*
306306
* @throws RuntimeException
307307
*/
308-
protected function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes/*, string $format = null*/)
308+
protected function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes, string $format = null)
309309
{
310-
if (func_num_args() >= 6) {
311-
$format = func_get_arg(5);
312-
} else {
313-
if (__CLASS__ !== get_class($this)) {
314-
$r = new \ReflectionMethod($this, __FUNCTION__);
315-
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
316-
@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);
317-
}
318-
}
319-
320-
$format = null;
321-
}
322-
323310
if (
324311
isset($context[static::OBJECT_TO_POPULATE]) &&
325312
is_object($context[static::OBJECT_TO_POPULATE]) &&

src/Symfony/Component/Serializer/Serializer.php

Lines changed: 4 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -163,42 +163,16 @@ public function denormalize($data, $type, $format = null, array $context = array
163163
/**
164164
* {@inheritdoc}
165165
*/
166-
public function supportsNormalization($data, $format = null/*, array $context = array()*/)
166+
public function supportsNormalization($data, $format = null, array $context = array())
167167
{
168-
if (func_num_args() > 2) {
169-
$context = func_get_arg(2);
170-
} else {
171-
if (__CLASS__ !== get_class($this)) {
172-
$r = new \ReflectionMethod($this, __FUNCTION__);
173-
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
174-
@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);
175-
}
176-
}
177-
178-
$context = array();
179-
}
180-
181168
return null !== $this->getNormalizer($data, $format, $context);
182169
}
183170

184171
/**
185172
* {@inheritdoc}
186173
*/
187-
public function supportsDenormalization($data, $type, $format = null/*, array $context = array()*/)
174+
public function supportsDenormalization($data, $type, $format = null, array $context = array())
188175
{
189-
if (func_num_args() > 3) {
190-
$context = func_get_arg(3);
191-
} else {
192-
if (__CLASS__ !== get_class($this)) {
193-
$r = new \ReflectionMethod($this, __FUNCTION__);
194-
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
195-
@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);
196-
}
197-
}
198-
199-
$context = array();
200-
}
201-
202176
return null !== $this->getDenormalizer($data, $type, $format, $context);
203177
}
204178

@@ -284,42 +258,16 @@ private function denormalizeObject($data, $class, $format, array $context = arra
284258
/**
285259
* {@inheritdoc}
286260
*/
287-
public function supportsEncoding($format/*, array $context = array()*/)
261+
public function supportsEncoding($format, array $context = array())
288262
{
289-
if (func_num_args() > 1) {
290-
$context = func_get_arg(1);
291-
} else {
292-
if (__CLASS__ !== get_class($this)) {
293-
$r = new \ReflectionMethod($this, __FUNCTION__);
294-
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
295-
@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);
296-
}
297-
}
298-
299-
$context = array();
300-
}
301-
302263
return $this->encoder->supportsEncoding($format, $context);
303264
}
304265

305266
/**
306267
* {@inheritdoc}
307268
*/
308-
public function supportsDecoding($format/*, array $context = array()*/)
269+
public function supportsDecoding($format, array $context = array())
309270
{
310-
if (func_num_args() > 1) {
311-
$context = func_get_arg(1);
312-
} else {
313-
if (__CLASS__ !== get_class($this)) {
314-
$r = new \ReflectionMethod($this, __FUNCTION__);
315-
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
316-
@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);
317-
}
318-
}
319-
320-
$context = array();
321-
}
322-
323271
return $this->decoder->supportsDecoding($format, $context);
324272
}
325273
}

src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ protected function isAllowedAttribute($classOrObject, $attribute, $format = null
7373
return in_array($attribute, array('foo', 'baz'));
7474
}
7575

76-
public function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes, $format = null)
76+
public function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes, string $format = null)
7777
{
7878
return parent::instantiateObject($data, $class, $context, $reflectionClass, $allowedAttributes, $format);
7979
}

0 commit comments

Comments
 (0)