merged branch duplabe/customnormalizer-fix (PR #4273)

Commits
-------

e647eaa [Serializer] Fix CustomNormalizer supportsDenormalization interface check.

Discussion
----------

[Serializer] Fix CustomNormalizer supportsDenormalization interface check.

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: -
License of the code: MIT
Documentation PR: -

Fixes the previous PR: https://github.com/symfony/symfony/pull/4257

---------------------------------------------------------------------------

by travisbot at 2012-05-13T20:57:00Z

This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1322002) (merged e647eaa6 into 459942b4).
This commit is contained in:
Fabien Potencier 2012-05-14 13:29:22 +02:00
commit 6fba6d7389
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'));
}
}