@@ -65,6 +65,6 @@ |
||
65 | 65 | public function key() |
66 | 66 | { |
67 | 67 | $file = $this->current(); |
68 | - return ($file !== null) ? (string)$file->file['_id'] : null; |
|
68 | + return ($file !== null) ? (string) $file->file['_id'] : null; |
|
69 | 69 | } |
70 | 70 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | public function add($item) |
77 | 77 | { |
78 | 78 | if (is_object($item)) { |
79 | - $item = (array)$item; |
|
79 | + $item = (array) $item; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | $this->validate($item); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | final public function execute(array $writeOptions = []) |
96 | 96 | { |
97 | 97 | $writeOptions += $this->writeOptions; |
98 | - if (! count($this->items)) { |
|
98 | + if ( ! count($this->items)) { |
|
99 | 99 | return ['ok' => true]; |
100 | 100 | } |
101 | 101 | |
@@ -142,13 +142,13 @@ discard block |
||
142 | 142 | { |
143 | 143 | switch ($this->batchType) { |
144 | 144 | case self::COMMAND_UPDATE: |
145 | - if (! isset($item['q']) || ! isset($item['u'])) { |
|
145 | + if ( ! isset($item['q']) || ! isset($item['u'])) { |
|
146 | 146 | throw new Exception('invalid item'); |
147 | 147 | } |
148 | 148 | break; |
149 | 149 | |
150 | 150 | case self::COMMAND_DELETE: |
151 | - if (! isset($item['q']) || ! isset($item['limit'])) { |
|
151 | + if ( ! isset($item['q']) || ! isset($item['limit'])) { |
|
152 | 152 | throw new Exception('invalid item'); |
153 | 153 | } |
154 | 154 | break; |
@@ -55,7 +55,7 @@ |
||
55 | 55 | */ |
56 | 56 | protected function setWriteConcernFromParameters($wstring, $wtimeout = 0) |
57 | 57 | { |
58 | - if (! is_string($wstring) && ! is_int($wstring)) { |
|
58 | + if ( ! is_string($wstring) && ! is_int($wstring)) { |
|
59 | 59 | trigger_error("w for WriteConcern must be a string or integer", E_WARNING); |
60 | 60 | return false; |
61 | 61 | } |
@@ -127,14 +127,14 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function aggregate(array $pipeline, array $op = []) |
129 | 129 | { |
130 | - if (! TypeConverter::isNumericArray($pipeline)) { |
|
130 | + if ( ! TypeConverter::isNumericArray($pipeline)) { |
|
131 | 131 | $pipeline = []; |
132 | 132 | $options = []; |
133 | 133 | |
134 | 134 | $i = 0; |
135 | 135 | foreach (func_get_args() as $operator) { |
136 | 136 | $i++; |
137 | - if (! is_array($operator)) { |
|
137 | + if ( ! is_array($operator)) { |
|
138 | 138 | trigger_error("Argument $i is not an array", E_WARNING); |
139 | 139 | return; |
140 | 140 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | ]; |
178 | 178 | |
179 | 179 | // Convert cursor option |
180 | - if (! isset($options['cursor'])) { |
|
180 | + if ( ! isset($options['cursor'])) { |
|
181 | 181 | $options['cursor'] = true; |
182 | 182 | } |
183 | 183 | |
@@ -265,12 +265,12 @@ discard block |
||
265 | 265 | { |
266 | 266 | $this->validateDocument($a); |
267 | 267 | |
268 | - if (! $this->ensureDocumentHasMongoId($a)) { |
|
268 | + if ( ! $this->ensureDocumentHasMongoId($a)) { |
|
269 | 269 | trigger_error(sprintf('%s expects parameter %d to be an array or object, %s given', __METHOD__, 1, gettype($a)), E_WARNING); |
270 | 270 | return; |
271 | 271 | } |
272 | 272 | |
273 | - if (! count((array)$a)) { |
|
273 | + if ( ! count((array) $a)) { |
|
274 | 274 | throw new \MongoException('document must be an array or object'); |
275 | 275 | } |
276 | 276 | |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | ExceptionConverter::toLegacy($e); |
293 | 293 | } |
294 | 294 | |
295 | - if (! $result->isAcknowledged()) { |
|
295 | + if ( ! $result->isAcknowledged()) { |
|
296 | 296 | return true; |
297 | 297 | } |
298 | 298 | |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | ExceptionConverter::toLegacy($e); |
330 | 330 | } |
331 | 331 | |
332 | - if (! $result->isAcknowledged()) { |
|
332 | + if ( ! $result->isAcknowledged()) { |
|
333 | 333 | return true; |
334 | 334 | } |
335 | 335 | |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | * @throws MongoCursorException |
354 | 354 | * @return boolean |
355 | 355 | */ |
356 | - public function update(array $criteria , array $newobj, array $options = []) |
|
356 | + public function update(array $criteria, array $newobj, array $options = []) |
|
357 | 357 | { |
358 | 358 | $multiple = isset($options['multiple']) ? $options['multiple'] : false; |
359 | 359 | $method = $multiple ? 'updateMany' : 'updateOne'; |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | ExceptionConverter::toLegacy($e); |
382 | 382 | } |
383 | 383 | |
384 | - if (! $result->isAcknowledged()) { |
|
384 | + if ( ! $result->isAcknowledged()) { |
|
385 | 385 | return true; |
386 | 386 | } |
387 | 387 | |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | */ |
409 | 409 | public function remove(array $criteria = [], array $options = []) |
410 | 410 | { |
411 | - $multiple = isset($options['justOne']) ? !$options['justOne'] : true; |
|
411 | + $multiple = isset($options['justOne']) ? ! $options['justOne'] : true; |
|
412 | 412 | $method = $multiple ? 'deleteMany' : 'deleteOne'; |
413 | 413 | |
414 | 414 | try { |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | ExceptionConverter::toLegacy($e); |
422 | 422 | } |
423 | 423 | |
424 | - if (! $result->isAcknowledged()) { |
|
424 | + if ( ! $result->isAcknowledged()) { |
|
425 | 425 | return true; |
426 | 426 | } |
427 | 427 | |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | */ |
546 | 546 | public function createIndex(array $keys, array $options = []) |
547 | 547 | { |
548 | - if (! is_array($keys) || ! count($keys)) { |
|
548 | + if ( ! is_array($keys) || ! count($keys)) { |
|
549 | 549 | throw new MongoException('keys cannot be empty'); |
550 | 550 | } |
551 | 551 | |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | $indexes = $this->collection->listIndexes(); |
556 | 556 | foreach ($indexes as $index) { |
557 | 557 | |
558 | - if (! empty($options['name']) && $index->getName() === $options['name']) { |
|
558 | + if ( ! empty($options['name']) && $index->getName() === $options['name']) { |
|
559 | 559 | throw new \MongoDuplicateKeyException(); |
560 | 560 | } |
561 | 561 | |
@@ -718,13 +718,13 @@ discard block |
||
718 | 718 | if ($document_or_id instanceof \MongoId) { |
719 | 719 | $id = $document_or_id; |
720 | 720 | } elseif (is_object($document_or_id)) { |
721 | - if (! isset($document_or_id->_id)) { |
|
721 | + if ( ! isset($document_or_id->_id)) { |
|
722 | 722 | return null; |
723 | 723 | } |
724 | 724 | |
725 | 725 | $id = $document_or_id->_id; |
726 | 726 | } elseif (is_array($document_or_id)) { |
727 | - if (! isset($document_or_id['_id'])) { |
|
727 | + if ( ! isset($document_or_id['_id'])) { |
|
728 | 728 | return null; |
729 | 729 | } |
730 | 730 | |
@@ -767,14 +767,14 @@ discard block |
||
767 | 767 | $command = [ |
768 | 768 | 'group' => [ |
769 | 769 | 'ns' => $this->name, |
770 | - '$reduce' => (string)$reduce, |
|
770 | + '$reduce' => (string) $reduce, |
|
771 | 771 | 'initial' => $initial, |
772 | 772 | 'cond' => $condition, |
773 | 773 | ], |
774 | 774 | ]; |
775 | 775 | |
776 | 776 | if ($keys instanceof MongoCode) { |
777 | - $command['group']['$keyf'] = (string)$keys; |
|
777 | + $command['group']['$keyf'] = (string) $keys; |
|
778 | 778 | } else { |
779 | 779 | $command['group']['key'] = $keys; |
780 | 780 | } |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | } |
784 | 784 | if (array_key_exists('finalize', $condition)) { |
785 | 785 | if ($condition['finalize'] instanceof MongoCode) { |
786 | - $condition['finalize'] = (string)$condition['finalize']; |
|
786 | + $condition['finalize'] = (string) $condition['finalize']; |
|
787 | 787 | } |
788 | 788 | $command['group']['finalize'] = $condition['finalize']; |
789 | 789 | } |
@@ -837,11 +837,11 @@ discard block |
||
837 | 837 | $options['w'] = ($options['safe']) ? 1 : 0; |
838 | 838 | } |
839 | 839 | |
840 | - if (isset($options['wtimeout']) && !isset($options['wTimeoutMS'])) { |
|
840 | + if (isset($options['wtimeout']) && ! isset($options['wTimeoutMS'])) { |
|
841 | 841 | $options['wTimeoutMS'] = $options['wtimeout']; |
842 | 842 | } |
843 | 843 | |
844 | - if (isset($options['w']) || !isset($options['wTimeoutMS'])) { |
|
844 | + if (isset($options['w']) || ! isset($options['wTimeoutMS'])) { |
|
845 | 845 | $collectionWriteConcern = $this->getWriteConcern(); |
846 | 846 | $writeConcern = $this->createWriteConcernFromParameters( |
847 | 847 | isset($options['w']) ? $options['w'] : $collectionWriteConcern['w'], |
@@ -866,13 +866,13 @@ discard block |
||
866 | 866 | private function ensureDocumentHasMongoId(&$document) |
867 | 867 | { |
868 | 868 | if (is_array($document)) { |
869 | - if (! isset($document['_id'])) { |
|
869 | + if ( ! isset($document['_id'])) { |
|
870 | 870 | $document['_id'] = new \MongoId(); |
871 | 871 | } |
872 | 872 | |
873 | 873 | return $document['_id']; |
874 | 874 | } elseif (is_object($document)) { |
875 | - if (! isset($document->_id)) { |
|
875 | + if ( ! isset($document->_id)) { |
|
876 | 876 | $document->_id = new \MongoId(); |
877 | 877 | } |
878 | 878 | |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | |
885 | 885 | private function validateDocument(&$document) |
886 | 886 | { |
887 | - if (! is_array($document) && ! is_object($document)) { |
|
887 | + if ( ! is_array($document) && ! is_object($document)) { |
|
888 | 888 | throw new \MongoException('document must be an array or object'); |
889 | 889 | } |
890 | 890 | $array = (array) $document; |