Explorar el Código

Fix method signature of MongoCollection::update

Both $criteria and $newobj may be objects (see https://github.com/mongodb/mongo-php-driver-legacy/blob/16c9a1e49d3db59aaa84c6efd5f6fde84b7a3a85/collection.c#L1600..L1605), even though the docs state array for both types.
Andreas Braun hace 8 años
padre
commit
c5712ed51f
Se han modificado 1 ficheros con 7 adiciones y 4 borrados
  1. 7 4
      lib/Mongo/MongoCollection.php

+ 7 - 4
lib/Mongo/MongoCollection.php

@@ -366,16 +366,19 @@ class MongoCollection
      * Update records based on a given criteria
      *
      * @link http://www.php.net/manual/en/mongocollection.update.php
-     * @param array $criteria Description of the objects to update.
-     * @param array $newobj The object with which to update the matching records.
+     * @param array|object $criteria Description of the objects to update.
+     * @param array|object $newobj The object with which to update the matching records.
      * @param array $options
      * @return bool|array
      * @throws MongoException
      * @throws MongoWriteConcernException
      */
-    public function update(array $criteria, array $newobj, array $options = [])
+    public function update($criteria, $newobj, array $options = [])
     {
-        $this->checkKeys($newobj);
+        $this->mustBeArrayOrObject($criteria);
+        $this->mustBeArrayOrObject($newobj);
+
+        $this->checkKeys((array) $newobj);
 
         $multiple = isset($options['multiple']) ? $options['multiple'] : false;
         $isReplace = ! \MongoDB\is_first_key_operator($newobj);