-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 0.2.0
-
Component/s: None
-
None
When php_phongo_bson_visit_document() and php_phongo_bson_visit_array() iterate on the keys within objects and arrays, respectively, the class name picked up by php_phongo_bson_visit_binary() is used for hydration and the unserialize method (i.e. BSON_UNSERIALIZE_FUNC_NAME) is invoked directly. From what I can tell, this code doesn't appear to check if the class itself implements the required interface.
It also means that BSON arrays might get hydrated as classes iff they contain an appropriate binary data element. Unlike objects, I don't think we should rely on arrays containing elements, given that update operators are prone to removing elements from an array (see: $push with $slice). Also, this would mean that size checks done on the array during queries or in other drivers would differ from the size of the hydrated array in the PHP driver.
If the user would like a BSON array to be hydrated as a PHP class, that is best done in the parent document classe that contains the array/collection field.