Skip to content

Commit

Permalink
minor performance tweak to reduce performance lost by previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lsmith77 committed Jun 7, 2011
1 parent 854f8c8 commit 6212c59
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Serializer/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function __construct(NormalizerInterface $nativePhpNormalizer, Normalizer
*/
public final function normalize($data, $format = null)
{
if ($this->customObjectNormalizers) {
if (is_object($data) && $this->customObjectNormalizers) {
foreach ($this->customObjectNormalizers as $normalizer) {
if ($normalizer->supportsNormalization($data, $format)) {
return $normalizer->normalize($data, $format);
Expand Down
5 changes: 4 additions & 1 deletion Tests/Serializer/SerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ public function testNormalize()

$list = new AuthorList();
$list->add(new Author('Bar'));
$normalized = $serializer->normalize($list);

$normalized = $serializer->normalize($list);
$this->assertEquals(array(), $normalized);

$normalized = $serializer->normalize(array('foo'));
$this->assertEquals(array('foo'), $normalized);
}

public function testDenormalize()
Expand Down

0 comments on commit 6212c59

Please sign in to comment.