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

Skip to content

[Serializer] Implement missing context aware interfaces #23241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/Symfony/Component/Serializer/Encoder/ChainDecoder.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 <[email protected]>
* @author Kévin Dunglas <[email protected]>
*/
class Serializer implements SerializerInterface, NormalizerInterface, DenormalizerInterface, EncoderInterface, DecoderInterface
class Serializer implements SerializerInterface, ContextAwareNormalizerInterface, ContextAwareDenormalizerInterface, ContextAwareEncoderInterface, ContextAwareDecoderInterface
{
/**
* @var Encoder\ChainEncoder
Expand Down