Browse Source

Don't traverse arrays in ensureCorrectType

Andreas Braun 10 years ago
parent
commit
c0fbc2c3e6
1 changed files with 4 additions and 3 deletions
  1. 4 3
      lib/Alcaeus/MongoDbAdapter/TypeConverter.php

+ 4 - 3
lib/Alcaeus/MongoDbAdapter/TypeConverter.php

@@ -22,14 +22,14 @@ class TypeConverter
 {
     public static function convertLegacyArrayToObject($array)
     {
-        // TODO: provide actual class
+        // TODO: provide actual class once mongodb/mongo-php-library#78 has been merged
         $result = [];
 
         foreach ($array as $key => $value) {
             $result[$key] = (is_array($value)) ? static::convertLegacyArrayToObject($value) : static::convertToBSONType($value);
         }
 
-        return static::ensureCorrectType($result);
+        return self::ensureCorrectType($result);
     }
 
     public static function convertObjectToLegacyArray($object)
@@ -37,6 +37,7 @@ class TypeConverter
         $result = [];
 
         foreach ($object as $key => $value) {
+            // TODO: use actual class instead of \stdClass once mongodb/mongo-php-library#78 has been merged
             $result[$key] = ($value instanceof \stdClass || is_array($value)) ? static::convertObjectToLegacyArray($value) : static::convertToLegacyType($value);
         }
 
@@ -90,7 +91,7 @@ class TypeConverter
         // Can convert array to stdClass
         $object = new \stdClass();
         foreach ($array as $key => $value) {
-            $object->$key = is_array($value) ? static::ensureCorrectType($value) : $value;
+            $object->$key = $value;
         }
 
         return $object;