@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | */ |
132 | 132 | public function findOne($query = [], array $fields = [], array $options = []) |
133 | 133 | { |
134 | - if (! is_array($query)) { |
|
134 | + if ( ! is_array($query)) { |
|
135 | 135 | $query = ['filename' => (string) $query]; |
136 | 136 | } |
137 | 137 | |
@@ -244,10 +244,10 @@ discard block |
||
244 | 244 | ]; |
245 | 245 | |
246 | 246 | $handle = fopen($filename, 'r'); |
247 | - if (! $handle) { |
|
247 | + if ( ! $handle) { |
|
248 | 248 | throw new MongoGridFSException('could not open file: ' . $filename); |
249 | 249 | } |
250 | - } elseif (! is_resource($filename)) { |
|
250 | + } elseif ( ! is_resource($filename)) { |
|
251 | 251 | throw new \Exception('first argument must be a string or stream resource'); |
252 | 252 | } else { |
253 | 253 | $handle = $filename; |
@@ -270,10 +270,10 @@ discard block |
||
270 | 270 | |
271 | 271 | // Add length and MD5 if they were not present before |
272 | 272 | $update = []; |
273 | - if (! isset($record['length'])) { |
|
273 | + if ( ! isset($record['length'])) { |
|
274 | 274 | $update['length'] = $length; |
275 | 275 | } |
276 | - if (! isset($record['md5'])) { |
|
276 | + if ( ! isset($record['md5'])) { |
|
277 | 277 | try { |
278 | 278 | $update['md5'] = $md5; |
279 | 279 | } catch (MongoException $e) { |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | if (count($update)) { |
285 | 285 | try { |
286 | 286 | $result = $this->update(['_id' => $file['_id']], ['$set' => $update]); |
287 | - if (! $this->isOKResult($result)) { |
|
287 | + if ( ! $this->isOKResult($result)) { |
|
288 | 288 | throw new MongoGridFSException('Could not store file'); |
289 | 289 | } |
290 | 290 | } catch (MongoException $e) { |
@@ -307,10 +307,10 @@ discard block |
||
307 | 307 | */ |
308 | 308 | public function storeUpload($name, array $metadata = []) |
309 | 309 | { |
310 | - if (! isset($_FILES[$name]) || $_FILES[$name]['error'] !== UPLOAD_ERR_OK) { |
|
310 | + if ( ! isset($_FILES[$name]) || $_FILES[$name]['error'] !== UPLOAD_ERR_OK) { |
|
311 | 311 | throw new MongoGridFSException("Could not find uploaded file $name"); |
312 | 312 | } |
313 | - if (! isset($_FILES[$name]['tmp_name'])) { |
|
313 | + if ( ! isset($_FILES[$name]['tmp_name'])) { |
|
314 | 314 | throw new MongoGridFSException("Couldn't find tmp_name in the \$_FILES array. Are you sure the upload worked?"); |
315 | 315 | } |
316 | 316 | |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | |
361 | 361 | $result = $this->chunks->insert($chunk); |
362 | 362 | |
363 | - if (! $this->isOKResult($result)) { |
|
363 | + if ( ! $this->isOKResult($result)) { |
|
364 | 364 | throw new \MongoException('error inserting chunk'); |
365 | 365 | } |
366 | 366 | |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | $hash = hash_init('md5'); |
406 | 406 | |
407 | 407 | rewind($handle); |
408 | - while (! feof($handle)) { |
|
408 | + while ( ! feof($handle)) { |
|
409 | 409 | $data = stream_get_contents($handle, $chunkSize); |
410 | 410 | hash_update($hash, $data); |
411 | 411 | $this->insertChunk($fileId, $data, $i++); |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | |
436 | 436 | $result = $this->insert($record, $options); |
437 | 437 | |
438 | - if (! $this->isOKResult($result)) { |
|
438 | + if ( ! $this->isOKResult($result)) { |
|
439 | 439 | throw new \MongoException('error inserting file'); |
440 | 440 | } |
441 | 441 |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | throw ExceptionConverter::toLegacy($e); |
143 | 143 | } |
144 | 144 | |
145 | - $getCollectionInfo = function (CollectionInfo $collectionInfo) { |
|
145 | + $getCollectionInfo = function(CollectionInfo $collectionInfo) { |
|
146 | 146 | // @todo do away with __debugInfo once https://jira.mongodb.org/browse/PHPLIB-226 is fixed |
147 | 147 | $info = $collectionInfo->__debugInfo(); |
148 | 148 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | 'info' => isset($info['info']) ? (array) $info['info'] : null, |
155 | 155 | 'idIndex' => isset($info['idIndex']) ? (array) $info['idIndex'] : null, |
156 | 156 | ], |
157 | - function ($item) { |
|
157 | + function($item) { |
|
158 | 158 | return $item !== null; |
159 | 159 | } |
160 | 160 | ); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | throw ExceptionConverter::toLegacy($e); |
191 | 191 | } |
192 | 192 | |
193 | - $getCollectionName = function (CollectionInfo $collectionInfo) { |
|
193 | + $getCollectionName = function(CollectionInfo $collectionInfo) { |
|
194 | 194 | return $collectionInfo->getName(); |
195 | 195 | }; |
196 | 196 | |
@@ -359,13 +359,13 @@ discard block |
||
359 | 359 | if ($document_or_id instanceof \MongoId) { |
360 | 360 | $id = $document_or_id; |
361 | 361 | } elseif (is_object($document_or_id)) { |
362 | - if (! isset($document_or_id->_id)) { |
|
362 | + if ( ! isset($document_or_id->_id)) { |
|
363 | 363 | $id = $document_or_id; |
364 | 364 | } else { |
365 | 365 | $id = $document_or_id->_id; |
366 | 366 | } |
367 | 367 | } elseif (is_array($document_or_id)) { |
368 | - if (! isset($document_or_id['_id'])) { |
|
368 | + if ( ! isset($document_or_id['_id'])) { |
|
369 | 369 | return null; |
370 | 370 | } |
371 | 371 | |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | */ |
554 | 554 | private function getSystemCollectionFilterClosure($includeSystemCollections = false) |
555 | 555 | { |
556 | - return function (CollectionInfo $collectionInfo) use ($includeSystemCollections) { |
|
556 | + return function(CollectionInfo $collectionInfo) use ($includeSystemCollections) { |
|
557 | 557 | return $includeSystemCollections || ! preg_match('#^system\.#', $collectionInfo->getName()); |
558 | 558 | }; |
559 | 559 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | final public function execute(array $writeOptions = []) |
103 | 103 | { |
104 | 104 | $writeOptions += $this->writeOptions; |
105 | - if (! count($this->items)) { |
|
105 | + if ( ! count($this->items)) { |
|
106 | 106 | return ['ok' => true]; |
107 | 107 | } |
108 | 108 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | break; |
168 | 168 | } |
169 | 169 | |
170 | - if (! $ok) { |
|
170 | + if ( ! $ok) { |
|
171 | 171 | // Exception code is hardcoded to the value in ext-mongo, see |
172 | 172 | // https://github.com/mongodb/mongo-php-driver-legacy/blob/ab4bc0d90e93b3f247f6bcb386d0abc8d2fa7d74/batch/write.c#L428 |
173 | 173 | throw new \MongoWriteConcernException('Failed write', 911, null, $resultDocument); |
@@ -180,19 +180,19 @@ discard block |
||
180 | 180 | { |
181 | 181 | switch ($this->batchType) { |
182 | 182 | case self::COMMAND_UPDATE: |
183 | - if (! isset($item['q'])) { |
|
183 | + if ( ! isset($item['q'])) { |
|
184 | 184 | throw new Exception("Expected \$item to contain 'q' key"); |
185 | 185 | } |
186 | - if (! isset($item['u'])) { |
|
186 | + if ( ! isset($item['u'])) { |
|
187 | 187 | throw new Exception("Expected \$item to contain 'u' key"); |
188 | 188 | } |
189 | 189 | break; |
190 | 190 | |
191 | 191 | case self::COMMAND_DELETE: |
192 | - if (! isset($item['q'])) { |
|
192 | + if ( ! isset($item['q'])) { |
|
193 | 193 | throw new Exception("Expected \$item to contain 'q' key"); |
194 | 194 | } |
195 | - if (! isset($item['limit'])) { |
|
195 | + if ( ! isset($item['limit'])) { |
|
196 | 196 | throw new Exception("Expected \$item to contain 'limit' key"); |
197 | 197 | } |
198 | 198 | break; |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | public function analyticalStore() |
6 | 6 | { |
7 | 7 | static $redis; |
8 | - if (!$redis) { |
|
8 | + if ( ! $redis) { |
|
9 | 9 | $redis = new Predis\Client(); |
10 | 10 | } |
11 | 11 | return $redis; |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | public function eavesdrop($opts = ['criteria' => 0, 'options' => 1], $fnc, $args = []) |
15 | 15 | { |
16 | - if (isset($opts['readArgs']) && !$opts['readArgs']) { |
|
16 | + if (isset($opts['readArgs']) && ! $opts['readArgs']) { |
|
17 | 17 | $criteria = $opts['criteria'] ?? []; |
18 | 18 | $options = $opts['options'] ?? []; |
19 | 19 | $op = $opts['operation'] ?: null; |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | } else { |
22 | 22 | $criteria = isset($opts['criteria']) ? $args[$opts['criteria']] ?? [] : []; |
23 | 23 | $options = isset($opts['options']) ? ($args[$opts['options']] ?? []) : []; |
24 | - $op = is_array($fnc) && !isset($opts['operation']) ? |
|
24 | + $op = is_array($fnc) && ! isset($opts['operation']) ? |
|
25 | 25 | ($fnc[1] ?? null) : (isset($opts['operation']) ? ($opts['operation'] ?? null) : null); |
26 | 26 | $name = $opts['name'] ?? $this->name; |
27 | 27 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | private function analyticalNormalization(&$criteria) |
33 | 33 | { |
34 | 34 | if (is_array($criteria)) { |
35 | - array_walk($criteria, function (&$ref) { |
|
35 | + array_walk($criteria, function(&$ref) { |
|
36 | 36 | if (is_array($ref)) { |
37 | 37 | $this->analyticalNormalization($ref); |
38 | 38 | return; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $serialized = json_encode($payload); |
54 | 54 | $redisKey = sprintf("mongodb/%s/%s/%s", $name ?: $this->name, $op, md5($serialized)); |
55 | 55 | |
56 | - $onEnd = function () use ($serialized, $redisKey, $init) { |
|
56 | + $onEnd = function() use ($serialized, $redisKey, $init) { |
|
57 | 57 | $diff = ceil((microtime(true) - $init) * 1000); |
58 | 58 | if ($diff < 10) return; |
59 | 59 |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | 'criteria' => 0, |
143 | 143 | 'options' => 1, |
144 | 144 | 'operation' => 'aggregate' |
145 | - ], function () use ($pipeline, $op) { |
|
146 | - if (! TypeConverter::isNumericArray($pipeline)) { |
|
145 | + ], function() use ($pipeline, $op) { |
|
146 | + if ( ! TypeConverter::isNumericArray($pipeline)) { |
|
147 | 147 | $operators = func_get_args(); |
148 | 148 | $pipeline = []; |
149 | 149 | $options = []; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | $i = 0; |
152 | 152 | foreach ($operators as $operator) { |
153 | 153 | $i++; |
154 | - if (! is_array($operator)) { |
|
154 | + if ( ! is_array($operator)) { |
|
155 | 155 | trigger_error("Argument $i is not an array", E_USER_WARNING); |
156 | 156 | return; |
157 | 157 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | ]; |
206 | 206 | |
207 | 207 | // Convert cursor option |
208 | - if (! isset($options['cursor'])) { |
|
208 | + if ( ! isset($options['cursor'])) { |
|
209 | 209 | $options['cursor'] = new \stdClass(); |
210 | 210 | } |
211 | 211 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | */ |
292 | 292 | public function insert(&$a, array $options = []) |
293 | 293 | { |
294 | - if (! $this->ensureDocumentHasMongoId($a)) { |
|
294 | + if ( ! $this->ensureDocumentHasMongoId($a)) { |
|
295 | 295 | trigger_error(sprintf('%s(): expects parameter %d to be an array or object, %s given', __METHOD__, 1, gettype($a)), E_USER_WARNING); |
296 | 296 | return; |
297 | 297 | } |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | throw ExceptionConverter::toLegacy($e); |
308 | 308 | } |
309 | 309 | |
310 | - if (! $result->isAcknowledged()) { |
|
310 | + if ( ! $result->isAcknowledged()) { |
|
311 | 311 | return true; |
312 | 312 | } |
313 | 313 | |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | |
339 | 339 | foreach ($a as $key => $item) { |
340 | 340 | try { |
341 | - if (! $this->ensureDocumentHasMongoId($a[$key])) { |
|
341 | + if ( ! $this->ensureDocumentHasMongoId($a[$key])) { |
|
342 | 342 | if ($continueOnError) { |
343 | 343 | unset($a[$key]); |
344 | 344 | } else { |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | } |
348 | 348 | } |
349 | 349 | } catch (MongoException $e) { |
350 | - if (! $continueOnError) { |
|
350 | + if ( ! $continueOnError) { |
|
351 | 351 | throw $e; |
352 | 352 | } |
353 | 353 | } |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | throw ExceptionConverter::toLegacy($e, 'MongoResultException'); |
363 | 363 | } |
364 | 364 | |
365 | - if (! $result->isAcknowledged()) { |
|
365 | + if ( ! $result->isAcknowledged()) { |
|
366 | 366 | return true; |
367 | 367 | } |
368 | 368 | |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | 'criteria' => 0, |
394 | 394 | 'options' => 2, |
395 | 395 | 'operation' => 'update' |
396 | - ], function () use ($criteria, $newobj, $options) { |
|
396 | + ], function() use ($criteria, $newobj, $options) { |
|
397 | 397 | $this->mustBeArrayOrObject($criteria); |
398 | 398 | $this->mustBeArrayOrObject($newobj); |
399 | 399 | |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | throw ExceptionConverter::toLegacy($e); |
422 | 422 | } |
423 | 423 | |
424 | - if (! $result->isAcknowledged()) { |
|
424 | + if ( ! $result->isAcknowledged()) { |
|
425 | 425 | return true; |
426 | 426 | } |
427 | 427 | |
@@ -453,8 +453,8 @@ discard block |
||
453 | 453 | 'criteria' => 0, |
454 | 454 | 'options' => 1, |
455 | 455 | 'operation' => 'remove' |
456 | - ], function () use ($criteria, $options) { |
|
457 | - $multiple = isset($options['justOne']) ? !$options['justOne'] : true; |
|
456 | + ], function() use ($criteria, $options) { |
|
457 | + $multiple = isset($options['justOne']) ? ! $options['justOne'] : true; |
|
458 | 458 | $method = $multiple ? 'deleteMany' : 'deleteOne'; |
459 | 459 | |
460 | 460 | try { |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | throw ExceptionConverter::toLegacy($e); |
468 | 468 | } |
469 | 469 | |
470 | - if (! $result->isAcknowledged()) { |
|
470 | + if ( ! $result->isAcknowledged()) { |
|
471 | 471 | return true; |
472 | 472 | } |
473 | 473 | |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | 'criteria' => 1, |
511 | 511 | 'options' => 0, |
512 | 512 | 'operation' => 'distinct' |
513 | - ], function () use ($key, $query) { |
|
513 | + ], function() use ($key, $query) { |
|
514 | 514 | try { |
515 | 515 | return array_map([TypeConverter::class, 'toLegacy'], $this->collection->distinct($key, TypeConverter::fromLegacy($query))); |
516 | 516 | } catch (\MongoDB\Driver\Exception\Exception $e) { |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | 'criteria' => 0, |
536 | 536 | 'options' => 3, |
537 | 537 | 'operation' => 'findAndModify' |
538 | - ], function () use ($query, $update, $fields, $options) { |
|
538 | + ], function() use ($query, $update, $fields, $options) { |
|
539 | 539 | $query = TypeConverter::fromLegacy($query); |
540 | 540 | try { |
541 | 541 | if (isset($options['remove'])) { |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | |
558 | 558 | $options['projection'] = TypeConverter::convertProjection($fields); |
559 | 559 | |
560 | - if (! \MongoDB\is_first_key_operator($update)) { |
|
560 | + if ( ! \MongoDB\is_first_key_operator($update)) { |
|
561 | 561 | $document = $this->collection->findOneAndReplace($query, $update, $options); |
562 | 562 | } else { |
563 | 563 | $document = $this->collection->findOneAndUpdate($query, $update, $options); |
@@ -592,9 +592,9 @@ discard block |
||
592 | 592 | 'criteria' => 0, |
593 | 593 | 'options' => 2, |
594 | 594 | 'operation' => 'findOne' |
595 | - ], function () use ($query, $fields, $options) { |
|
595 | + ], function() use ($query, $fields, $options) { |
|
596 | 596 | // Can't typehint for array since MongoGridFS extends and accepts strings |
597 | - if (! is_array($query)) { |
|
597 | + if ( ! is_array($query)) { |
|
598 | 598 | trigger_error(sprintf('MongoCollection::findOne(): expects parameter 1 to be an array or object, %s given', gettype($query)), E_USER_WARNING); |
599 | 599 | return; |
600 | 600 | } |
@@ -635,11 +635,11 @@ discard block |
||
635 | 635 | $keys = (array) $keys; |
636 | 636 | } |
637 | 637 | |
638 | - if (! is_array($keys) || ! count($keys)) { |
|
638 | + if ( ! is_array($keys) || ! count($keys)) { |
|
639 | 639 | throw new MongoException('index specification has no elements'); |
640 | 640 | } |
641 | 641 | |
642 | - if (! isset($options['name'])) { |
|
642 | + if ( ! isset($options['name'])) { |
|
643 | 643 | $options['name'] = \MongoDB\generate_index_name($keys); |
644 | 644 | } |
645 | 645 | |
@@ -674,14 +674,14 @@ discard block |
||
674 | 674 | } |
675 | 675 | |
676 | 676 | $result = [ |
677 | - 'createdCollectionAutomatically' => !$collectionExists, |
|
677 | + 'createdCollectionAutomatically' => ! $collectionExists, |
|
678 | 678 | 'numIndexesBefore' => $indexCount, |
679 | 679 | 'numIndexesAfter' => $indexCount, |
680 | 680 | 'note' => 'all indexes already exist', |
681 | 681 | 'ok' => 1.0, |
682 | 682 | ]; |
683 | 683 | |
684 | - if (! $indexExists) { |
|
684 | + if ( ! $indexExists) { |
|
685 | 685 | $result['numIndexesAfter']++; |
686 | 686 | unset($result['note']); |
687 | 687 | } |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | { |
715 | 715 | if (is_string($keys)) { |
716 | 716 | $indexName = $keys; |
717 | - if (! preg_match('#_-?1$#', $indexName)) { |
|
717 | + if ( ! preg_match('#_-?1$#', $indexName)) { |
|
718 | 718 | $indexName .= '_1'; |
719 | 719 | } |
720 | 720 | } elseif (is_array($keys)) { |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | */ |
754 | 754 | public function getIndexInfo() |
755 | 755 | { |
756 | - $convertIndex = function (\MongoDB\Model\IndexInfo $indexInfo) { |
|
756 | + $convertIndex = function(\MongoDB\Model\IndexInfo $indexInfo) { |
|
757 | 757 | $infos = [ |
758 | 758 | 'v' => $indexInfo->getVersion(), |
759 | 759 | 'key' => $indexInfo->getKey(), |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | ]; |
778 | 778 | |
779 | 779 | foreach ($additionalKeys as $key) { |
780 | - if (! isset($indexInfo[$key])) { |
|
780 | + if ( ! isset($indexInfo[$key])) { |
|
781 | 781 | continue; |
782 | 782 | } |
783 | 783 | |
@@ -804,10 +804,10 @@ discard block |
||
804 | 804 | 'criteria' => 0, |
805 | 805 | 'options' => 1, |
806 | 806 | 'operation' => 'count' |
807 | - ], function () use ($query, $options) { |
|
807 | + ], function() use ($query, $options) { |
|
808 | 808 | try { |
809 | 809 | // Handle legacy mode - limit and skip as second and third parameters, respectively |
810 | - if (! is_array($options)) { |
|
810 | + if ( ! is_array($options)) { |
|
811 | 811 | $limit = $options; |
812 | 812 | $options = []; |
813 | 813 | |
@@ -855,7 +855,7 @@ discard block |
||
855 | 855 | $this->convertWriteConcernOptions($options) |
856 | 856 | ); |
857 | 857 | |
858 | - if (! $result->isAcknowledged()) { |
|
858 | + if ( ! $result->isAcknowledged()) { |
|
859 | 859 | return true; |
860 | 860 | } |
861 | 861 | |
@@ -889,13 +889,13 @@ discard block |
||
889 | 889 | if ($document_or_id instanceof \MongoId) { |
890 | 890 | $id = $document_or_id; |
891 | 891 | } elseif (is_object($document_or_id)) { |
892 | - if (! isset($document_or_id->_id)) { |
|
892 | + if ( ! isset($document_or_id->_id)) { |
|
893 | 893 | return null; |
894 | 894 | } |
895 | 895 | |
896 | 896 | $id = $document_or_id->_id; |
897 | 897 | } elseif (is_array($document_or_id)) { |
898 | - if (! isset($document_or_id['_id'])) { |
|
898 | + if ( ! isset($document_or_id['_id'])) { |
|
899 | 899 | return null; |
900 | 900 | } |
901 | 901 | |
@@ -1008,11 +1008,11 @@ discard block |
||
1008 | 1008 | $options['w'] = ($options['safe']) ? 1 : 0; |
1009 | 1009 | } |
1010 | 1010 | |
1011 | - if (isset($options['wtimeout']) && !isset($options['wTimeoutMS'])) { |
|
1011 | + if (isset($options['wtimeout']) && ! isset($options['wTimeoutMS'])) { |
|
1012 | 1012 | $options['wTimeoutMS'] = $options['wtimeout']; |
1013 | 1013 | } |
1014 | 1014 | |
1015 | - if (isset($options['w']) || !isset($options['wTimeoutMS'])) { |
|
1015 | + if (isset($options['w']) || ! isset($options['wTimeoutMS'])) { |
|
1016 | 1016 | $collectionWriteConcern = $this->getWriteConcern(); |
1017 | 1017 | $writeConcern = $this->createWriteConcernFromParameters( |
1018 | 1018 | isset($options['w']) ? $options['w'] : $collectionWriteConcern['w'], |
@@ -1050,7 +1050,7 @@ discard block |
||
1050 | 1050 | private function ensureDocumentHasMongoId(&$document) |
1051 | 1051 | { |
1052 | 1052 | if (is_array($document)) { |
1053 | - if (! isset($document['_id'])) { |
|
1053 | + if ( ! isset($document['_id'])) { |
|
1054 | 1054 | $document['_id'] = new \MongoId(); |
1055 | 1055 | } |
1056 | 1056 | |
@@ -1060,12 +1060,12 @@ discard block |
||
1060 | 1060 | } elseif (is_object($document)) { |
1061 | 1061 | $reflectionObject = new \ReflectionObject($document); |
1062 | 1062 | foreach ($reflectionObject->getProperties() as $property) { |
1063 | - if (! $property->isPublic()) { |
|
1063 | + if ( ! $property->isPublic()) { |
|
1064 | 1064 | throw new \MongoException('zero-length keys are not allowed, did you use $ with double quotes?'); |
1065 | 1065 | } |
1066 | 1066 | } |
1067 | 1067 | |
1068 | - if (! isset($document->_id)) { |
|
1068 | + if ( ! isset($document->_id)) { |
|
1069 | 1069 | $document->_id = new \MongoId(); |
1070 | 1070 | } |
1071 | 1071 | |
@@ -1096,7 +1096,7 @@ discard block |
||
1096 | 1096 | |
1097 | 1097 | private function mustBeArrayOrObject($a) |
1098 | 1098 | { |
1099 | - if (!is_array($a) && !is_object($a)) { |
|
1099 | + if ( ! is_array($a) && ! is_object($a)) { |
|
1100 | 1100 | throw new \MongoException('document must be an array or object'); |
1101 | 1101 | } |
1102 | 1102 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | 'options' => array_merge(['foundOnly'=> $foundOnly], $this->options), |
144 | 144 | 'operation' => 'count', |
145 | 145 | 'name' => $this->collection->getCollectionName() |
146 | - ], function () use ($foundOnly) { |
|
146 | + ], function() use ($foundOnly) { |
|
147 | 147 | $optionNames = ['hint', 'maxTimeMS']; |
148 | 148 | if ($foundOnly) { |
149 | 149 | $optionNames = array_merge($optionNames, ['limit', 'skip']); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | 'options' => $this->options, |
174 | 174 | 'operation' => 'count', |
175 | 175 | 'name' => $this->collection->getCollectionName() |
176 | - ], function () { |
|
176 | + ], function() { |
|
177 | 177 | // MongoDB\Driver\Cursor needs to be wrapped into a \Generator so that a valid \Iterator with working implementations of |
178 | 178 | // next, current, valid, key and rewind is returned. These methods don't work if we wrap the Cursor inside an \IteratorIterator |
179 | 179 | if ($this->iterator === null) { |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | */ |
272 | 272 | public function hasNext() |
273 | 273 | { |
274 | - if (! $this->startedIterating) { |
|
274 | + if ( ! $this->startedIterating) { |
|
275 | 275 | $this->ensureIterator(); |
276 | 276 | $this->startedIterating = true; |
277 | 277 | $this->storeIteratorState(); |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | */ |
457 | 457 | protected function convertCursorType() |
458 | 458 | { |
459 | - if (! $this->tailable) { |
|
459 | + if ( ! $this->tailable) { |
|
460 | 460 | return null; |
461 | 461 | } |
462 | 462 | |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | protected function wrapTraversable(\Traversable $traversable) |
511 | 511 | { |
512 | 512 | foreach ($traversable as $key => $value) { |
513 | - if (isset($value->_id) && ($value->_id instanceof \MongoDB\BSON\ObjectID || !is_object($value->_id))) { |
|
513 | + if (isset($value->_id) && ($value->_id instanceof \MongoDB\BSON\ObjectID || ! is_object($value->_id))) { |
|
514 | 514 | $key = (string) $value->_id; |
515 | 515 | } |
516 | 516 | yield $key => $value; |