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

Skip to content

Commit 61d796a

Browse files
committed
[Serializer] Implement missing context aware interfaces
1 parent 3bbb657 commit 61d796a

File tree

4 files changed

+12
-15
lines changed

4 files changed

+12
-15
lines changed

src/Symfony/Component/Serializer/Encoder/ChainDecoder.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*
2323
* @final since version 3.3.
2424
*/
25-
class ChainDecoder implements DecoderInterface /*, ContextAwareDecoderInterface*/
25+
class ChainDecoder implements ContextAwareDecoderInterface
2626
{
2727
protected $decoders = array();
2828
protected $decoderByFormat = array();
@@ -43,10 +43,8 @@ final public function decode($data, $format, array $context = array())
4343
/**
4444
* {@inheritdoc}
4545
*/
46-
public function supportsDecoding($format/*, array $context = array()*/)
46+
public function supportsDecoding($format, array $context = array())
4747
{
48-
$context = func_num_args() > 1 ? func_get_arg(1) : array();
49-
5048
try {
5149
$this->getDecoder($format, $context);
5250
} catch (RuntimeException $e) {

src/Symfony/Component/Serializer/Encoder/ChainEncoder.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*
2323
* @final since version 3.3.
2424
*/
25-
class ChainEncoder implements EncoderInterface /*, ContextAwareEncoderInterface*/
25+
class ChainEncoder implements ContextAwareEncoderInterface
2626
{
2727
protected $encoders = array();
2828
protected $encoderByFormat = array();
@@ -43,10 +43,8 @@ final public function encode($data, $format, array $context = array())
4343
/**
4444
* {@inheritdoc}
4545
*/
46-
public function supportsEncoding($format/*, array $context = array()*/)
46+
public function supportsEncoding($format, array $context = array())
4747
{
48-
$context = func_num_args() > 1 ? func_get_arg(1) : array();
49-
5048
try {
5149
$this->getEncoder($format, $context);
5250
} catch (RuntimeException $e) {
@@ -64,9 +62,8 @@ public function supportsEncoding($format/*, array $context = array()*/)
6462
*
6563
* @return bool
6664
*/
67-
public function needsNormalization($format/*, array $context = array()*/)
65+
public function needsNormalization($format, array $context = array())
6866
{
69-
$context = func_num_args() > 1 ? func_get_arg(1) : array();
7067
$encoder = $this->getEncoder($format, $context);
7168

7269
if (!$encoder instanceof NormalizationAwareInterface) {

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*
2525
* @final since version 3.3.
2626
*/
27-
class ArrayDenormalizer implements DenormalizerInterface, SerializerAwareInterface
27+
class ArrayDenormalizer implements ContextAwareDenormalizerInterface, SerializerAwareInterface
2828
{
2929
/**
3030
* @var SerializerInterface|DenormalizerInterface
@@ -66,10 +66,8 @@ public function denormalize($data, $class, $format = null, array $context = arra
6666
/**
6767
* {@inheritdoc}
6868
*/
69-
public function supportsDenormalization($data, $type, $format = null/*, array $context = array()*/)
69+
public function supportsDenormalization($data, $type, $format = null, array $context = array())
7070
{
71-
$context = func_num_args() > 3 ? func_get_arg(3) : array();
72-
7371
return substr($type, -2) === '[]'
7472
&& $this->serializer->supportsDenormalization($data, substr($type, 0, -2), $format, $context);
7573
}

src/Symfony/Component/Serializer/Serializer.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@
1313

1414
use Symfony\Component\Serializer\Encoder\ChainDecoder;
1515
use Symfony\Component\Serializer\Encoder\ChainEncoder;
16+
use Symfony\Component\Serializer\Encoder\ContextAwareDecoderInterface;
17+
use Symfony\Component\Serializer\Encoder\ContextAwareEncoderInterface;
1618
use Symfony\Component\Serializer\Encoder\EncoderInterface;
1719
use Symfony\Component\Serializer\Encoder\DecoderInterface;
20+
use Symfony\Component\Serializer\Normalizer\ContextAwareDenormalizerInterface;
21+
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
1822
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
1923
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
2024
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
@@ -37,7 +41,7 @@
3741
* @author Lukas Kahwe Smith <[email protected]>
3842
* @author Kévin Dunglas <[email protected]>
3943
*/
40-
class Serializer implements SerializerInterface, NormalizerInterface, DenormalizerInterface, EncoderInterface, DecoderInterface
44+
class Serializer implements SerializerInterface, ContextAwareNormalizerInterface, ContextAwareDenormalizerInterface, ContextAwareEncoderInterface, ContextAwareDecoderInterface
4145
{
4246
/**
4347
* @var Encoder\ChainEncoder

0 commit comments

Comments
 (0)