@@ -1333,7 +1333,7 @@ public function updateDocument(string $collection, string $id, Document $documen
13331333 /**
13341334 * @param string $collection
13351335 * @param string $attribute
1336- * @param array<Document> $documents
1336+ * @param array<string|int, array{old: Document, new: Document} > $documents
13371337 * @return array<Document>
13381338 * @throws DatabaseException
13391339 */
@@ -1379,6 +1379,9 @@ public function createOrUpdateDocuments(
13791379
13801380 $ columns = [];
13811381 foreach (\array_keys ($ attributes ) as $ key => $ attr ) {
1382+ /**
1383+ * @var string $attr
1384+ */
13821385 $ columns [$ key ] = "{$ this ->quote ($ this ->filter ($ attr ))}" ;
13831386 }
13841387 $ columns = '( ' . \implode (', ' , $ columns ) . ') ' ;
@@ -1425,6 +1428,9 @@ public function createOrUpdateDocuments(
14251428 // Update all columns
14261429 $ updateColumns = [];
14271430 foreach (\array_keys ($ attributes ) as $ attr ) {
1431+ /**
1432+ * @var string $attr
1433+ */
14281434 $ updateColumns [] = $ getUpdateClause ($ this ->filter ($ attr ));
14291435 }
14301436 }
@@ -1455,12 +1461,12 @@ public function createOrUpdateDocuments(
14551461
14561462 $ current = [];
14571463 foreach (Database::PERMISSIONS as $ type ) {
1458- $ current [$ type ] = $ old ->getPermissionsByType ($ type ) ?? [] ;
1464+ $ current [$ type ] = $ old ->getPermissionsByType ($ type );
14591465 }
14601466
14611467 // Calculate removals
14621468 foreach (Database::PERMISSIONS as $ type ) {
1463- $ toRemove = \array_diff ($ current [$ type ] ?? [] , $ document ->getPermissionsByType ($ type ));
1469+ $ toRemove = \array_diff ($ current [$ type ], $ document ->getPermissionsByType ($ type ));
14641470 if (!empty ($ toRemove )) {
14651471 $ removeQueries [] = "(
14661472 _document = :_uid_ {$ index }
@@ -1478,7 +1484,7 @@ public function createOrUpdateDocuments(
14781484
14791485 // Calculate additions
14801486 foreach (Database::PERMISSIONS as $ type ) {
1481- $ toAdd = \array_diff ($ document ->getPermissionsByType ($ type ), $ current [$ type ] ?? [] );
1487+ $ toAdd = \array_diff ($ document ->getPermissionsByType ($ type ), $ current [$ type ]);
14821488
14831489 foreach ($ toAdd as $ i => $ permission ) {
14841490 $ addQuery = "(:_uid_ {$ index }, ' {$ type }', :add_ {$ type }_ {$ index }_ {$ i }" ;
@@ -1533,7 +1539,7 @@ public function createOrUpdateDocuments(
15331539 throw $ this ->processException ($ e );
15341540 }
15351541
1536- return $ documents ;
1542+ return \array_map ( fn ( $ document ) => $ document [ ' new ' ], $ documents) ;
15371543 }
15381544
15391545 /**
0 commit comments