Просмотр исходного кода

switch condition order, added small comment

Johannes M. Schmitt 14 лет назад
Родитель
Сommit
b1ee7dbb89
1 измененных файлов с 3 добавлено и 1 удалено
  1. 3 1
      Serializer/Serializer.php

+ 3 - 1
Serializer/Serializer.php

@@ -73,7 +73,9 @@ class Serializer implements SerializerInterface
      */
     public final function normalize($data, $format = null)
     {
-        if (is_object($data) && $this->customObjectNormalizers) {
+        // needs to run first so that users can override the behavior for built-in
+        // interface like \Traversable, see #10
+        if ($this->customObjectNormalizers && is_object($data)) {
             foreach ($this->customObjectNormalizers as $normalizer) {
                 if ($normalizer->supportsNormalization($data, $format)) {
                     return $normalizer->normalize($data, $format);