Skip to content

Commit

Permalink
minor #23241 [Serializer] Implement missing context aware interfaces …
Browse files Browse the repository at this point in the history
…(chalasr)

This PR was merged into the 4.0-dev branch.

Discussion
----------

[Serializer] Implement missing context aware interfaces

| Q             | A
| ------------- | ---
| Branch?       | 4.0
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #22743
| License       | MIT
| Doc PR        | n/a

Forgot in #22743

Commits
-------

61d796a [Serializer] Implement missing context aware interfaces
  • Loading branch information
fabpot committed Jun 21, 2017
2 parents e55c846 + 61d796a commit 407631c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
6 changes: 2 additions & 4 deletions src/Symfony/Component/Serializer/Encoder/ChainDecoder.php
Expand Up @@ -22,7 +22,7 @@
*
* @final since version 3.3.
*/
class ChainDecoder implements DecoderInterface /*, ContextAwareDecoderInterface*/
class ChainDecoder implements ContextAwareDecoderInterface
{
protected $decoders = array();
protected $decoderByFormat = array();
Expand All @@ -43,10 +43,8 @@ final public function decode($data, $format, array $context = array())
/**
* {@inheritdoc}
*/
public function supportsDecoding($format/*, array $context = array()*/)
public function supportsDecoding($format, array $context = array())
{
$context = func_num_args() > 1 ? func_get_arg(1) : array();

try {
$this->getDecoder($format, $context);
} catch (RuntimeException $e) {
Expand Down
9 changes: 3 additions & 6 deletions src/Symfony/Component/Serializer/Encoder/ChainEncoder.php
Expand Up @@ -22,7 +22,7 @@
*
* @final since version 3.3.
*/
class ChainEncoder implements EncoderInterface /*, ContextAwareEncoderInterface*/
class ChainEncoder implements ContextAwareEncoderInterface
{
protected $encoders = array();
protected $encoderByFormat = array();
Expand All @@ -43,10 +43,8 @@ final public function encode($data, $format, array $context = array())
/**
* {@inheritdoc}
*/
public function supportsEncoding($format/*, array $context = array()*/)
public function supportsEncoding($format, array $context = array())
{
$context = func_num_args() > 1 ? func_get_arg(1) : array();

try {
$this->getEncoder($format, $context);
} catch (RuntimeException $e) {
Expand All @@ -64,9 +62,8 @@ public function supportsEncoding($format/*, array $context = array()*/)
*
* @return bool
*/
public function needsNormalization($format/*, array $context = array()*/)
public function needsNormalization($format, array $context = array())
{
$context = func_num_args() > 1 ? func_get_arg(1) : array();
$encoder = $this->getEncoder($format, $context);

if (!$encoder instanceof NormalizationAwareInterface) {
Expand Down
Expand Up @@ -24,7 +24,7 @@
*
* @final since version 3.3.
*/
class ArrayDenormalizer implements DenormalizerInterface, SerializerAwareInterface
class ArrayDenormalizer implements ContextAwareDenormalizerInterface, SerializerAwareInterface
{
/**
* @var SerializerInterface|DenormalizerInterface
Expand Down Expand Up @@ -66,10 +66,8 @@ public function denormalize($data, $class, $format = null, array $context = arra
/**
* {@inheritdoc}
*/
public function supportsDenormalization($data, $type, $format = null/*, array $context = array()*/)
public function supportsDenormalization($data, $type, $format = null, array $context = array())
{
$context = func_num_args() > 3 ? func_get_arg(3) : array();

return substr($type, -2) === '[]'
&& $this->serializer->supportsDenormalization($data, substr($type, 0, -2), $format, $context);
}
Expand Down
6 changes: 5 additions & 1 deletion src/Symfony/Component/Serializer/Serializer.php
Expand Up @@ -13,8 +13,12 @@

use Symfony\Component\Serializer\Encoder\ChainDecoder;
use Symfony\Component\Serializer\Encoder\ChainEncoder;
use Symfony\Component\Serializer\Encoder\ContextAwareDecoderInterface;
use Symfony\Component\Serializer\Encoder\ContextAwareEncoderInterface;
use Symfony\Component\Serializer\Encoder\EncoderInterface;
use Symfony\Component\Serializer\Encoder\DecoderInterface;
use Symfony\Component\Serializer\Normalizer\ContextAwareDenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
Expand All @@ -37,7 +41,7 @@
* @author Lukas Kahwe Smith <smith@pooteeweet.org>
* @author Kévin Dunglas <dunglas@gmail.com>
*/
class Serializer implements SerializerInterface, NormalizerInterface, DenormalizerInterface, EncoderInterface, DecoderInterface
class Serializer implements SerializerInterface, ContextAwareNormalizerInterface, ContextAwareDenormalizerInterface, ContextAwareEncoderInterface, ContextAwareDecoderInterface
{
/**
* @var Encoder\ChainEncoder
Expand Down

0 comments on commit 407631c

Please sign in to comment.