[Serializer] fixed CS (refs #7971)
This commit is contained in:
parent
a5ab1aa3f7
commit
e3187590c0
@ -173,9 +173,7 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz
|
||||
private function getNormalizer($data, $format = null)
|
||||
{
|
||||
foreach ($this->normalizers as $normalizer) {
|
||||
if ($normalizer instanceof NormalizerInterface
|
||||
&& $normalizer->supportsNormalization($data, $format)
|
||||
) {
|
||||
if ($normalizer instanceof NormalizerInterface && $normalizer->supportsNormalization($data, $format)) {
|
||||
return $normalizer;
|
||||
}
|
||||
}
|
||||
@ -189,9 +187,7 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz
|
||||
private function getDenormalizer($data, $type, $format = null)
|
||||
{
|
||||
foreach ($this->normalizers as $normalizer) {
|
||||
if ($normalizer instanceof DenormalizerInterface
|
||||
&& $normalizer->supportsDenormalization($data, $type, $format)
|
||||
) {
|
||||
if ($normalizer instanceof DenormalizerInterface && $normalizer->supportsDenormalization($data, $type, $format)) {
|
||||
return $normalizer;
|
||||
}
|
||||
}
|
||||
|
@ -20,19 +20,18 @@ use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
*/
|
||||
class TestDenormalizer implements DenormalizerInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function denormalize($data, $class, $format = null, array $context = array())
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function denormalize($data, $class, $format = null, array $context = array())
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supportsDenormalization($data, $type, $format = null)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supportsDenormalization($data, $type, $format = null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -20,19 +20,18 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
*/
|
||||
class TestNormalizer implements NormalizerInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function normalize($object, $format = null, array $context = array())
|
||||
{
|
||||
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function normalize($object, $format = null, array $context = array())
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supportsNormalization($data, $format = null)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supportsNormalization($data, $format = null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -50,8 +50,8 @@ class SerializerTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testNormalizeOnDenormalizer()
|
||||
{
|
||||
$this->serializer = new Serializer(array(new TestDenormalizer()), array());
|
||||
$this->assertTrue($this->serializer->normalize(new \stdClass, 'json'));
|
||||
$this->serializer = new Serializer(array(new TestDenormalizer()), array());
|
||||
$this->assertTrue($this->serializer->normalize(new \stdClass, 'json'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -68,9 +68,9 @@ class SerializerTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testDenormalizeOnNormalizer()
|
||||
{
|
||||
$this->serializer = new Serializer(array(new TestNormalizer()), array());
|
||||
$data = array('title' => 'foo', 'numbers' => array(5, 3));
|
||||
$this->assertTrue($this->serializer->denormalize(json_encode($data), 'stdClass', 'json'));
|
||||
$this->serializer = new Serializer(array(new TestNormalizer()), array());
|
||||
$data = array('title' => 'foo', 'numbers' => array(5, 3));
|
||||
$this->assertTrue($this->serializer->denormalize(json_encode($data), 'stdClass', 'json'));
|
||||
}
|
||||
|
||||
public function testSerialize()
|
||||
@ -244,5 +244,4 @@ class Model
|
||||
{
|
||||
return array('title' => $this->title, 'numbers' => $this->numbers);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user