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