[Serializer] Fix CustomNormalizer supportsDenormalization interface check.

This commit is contained in:
duplabe 2012-05-11 10:16:14 +02:00
parent 459942b456
commit e647eaa646
5 changed files with 31 additions and 3 deletions

View File

@ -59,6 +59,6 @@ class CustomNormalizer extends SerializerAwareNormalizer implements NormalizerIn
{
$class = new \ReflectionClass($type);
return $class->isSubclassOf('Symfony\Component\Serializer\Normalizer\NormalizableInterface');
return $class->isSubclassOf('Symfony\Component\Serializer\Normalizer\DenormalizableInterface');
}
}

View File

@ -0,0 +1,25 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Serializer\Tests\Fixtures;
use Symfony\Component\Serializer\Normalizer\DenormalizableInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
class DenormalizableDummy implements DenormalizableInterface
{
function denormalize(DenormalizerInterface $denormalizer, $data, $format = null)
{
}
}

View File

@ -12,10 +12,11 @@
namespace Symfony\Component\Serializer\Tests\Fixtures;
use Symfony\Component\Serializer\Normalizer\NormalizableInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizableInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
class Dummy implements NormalizableInterface
class Dummy implements NormalizableInterface, DenormalizableInterface
{
public $foo;
public $bar;

View File

@ -12,10 +12,11 @@
namespace Symfony\Component\Serializer\Tests\Fixtures;
use Symfony\Component\Serializer\Normalizer\NormalizableInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizableInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
class NormalizableTraversableDummy extends TraversableDummy implements NormalizableInterface
class NormalizableTraversableDummy extends TraversableDummy implements NormalizableInterface, DenormalizableInterface
{
public function normalize(NormalizerInterface $normalizer, $format = null)
{

View File

@ -53,5 +53,6 @@ class CustomNormalizerTest extends \PHPUnit_Framework_TestCase
{
$this->assertTrue($this->normalizer->supportsDenormalization(array(), 'Symfony\Component\Serializer\Tests\Fixtures\ScalarDummy'));
$this->assertFalse($this->normalizer->supportsDenormalization(array(), 'stdClass'));
$this->assertTrue($this->normalizer->supportsDenormalization(array(), 'Symfony\Component\Serializer\Tests\Fixtures\DenormalizableDummy'));
}
}