@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function aggregate(array $pipeline, array $op = []) |
132 | 132 | { |
133 | - if (! TypeConverter::isNumericArray($pipeline)) { |
|
133 | + if ( ! TypeConverter::isNumericArray($pipeline)) { |
|
134 | 134 | $operators = func_get_args(); |
135 | 135 | $pipeline = []; |
136 | 136 | $options = []; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $i = 0; |
139 | 139 | foreach ($operators as $operator) { |
140 | 140 | $i++; |
141 | - if (! is_array($operator)) { |
|
141 | + if ( ! is_array($operator)) { |
|
142 | 142 | trigger_error("Argument $i is not an array", E_USER_WARNING); |
143 | 143 | return; |
144 | 144 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | ]; |
192 | 192 | |
193 | 193 | // Convert cursor option |
194 | - if (! isset($options['cursor'])) { |
|
194 | + if ( ! isset($options['cursor'])) { |
|
195 | 195 | $options['cursor'] = new \stdClass(); |
196 | 196 | } |
197 | 197 | |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | throw ExceptionConverter::toLegacy($e); |
294 | 294 | } |
295 | 295 | |
296 | - if (! $result->isAcknowledged()) { |
|
296 | + if ( ! $result->isAcknowledged()) { |
|
297 | 297 | return true; |
298 | 298 | } |
299 | 299 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | |
325 | 325 | foreach ($a as $key => $item) { |
326 | 326 | try { |
327 | - if (! $this->ensureDocumentHasMongoId($a[$key])) { |
|
327 | + if ( ! $this->ensureDocumentHasMongoId($a[$key])) { |
|
328 | 328 | if ($continueOnError) { |
329 | 329 | unset($a[$key]); |
330 | 330 | } else { |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | } |
334 | 334 | } |
335 | 335 | } catch (MongoException $e) { |
336 | - if (! $continueOnError) { |
|
336 | + if ( ! $continueOnError) { |
|
337 | 337 | throw $e; |
338 | 338 | } |
339 | 339 | } |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | throw ExceptionConverter::toLegacy($e, 'MongoResultException'); |
349 | 349 | } |
350 | 350 | |
351 | - if (! $result->isAcknowledged()) { |
|
351 | + if ( ! $result->isAcknowledged()) { |
|
352 | 352 | return true; |
353 | 353 | } |
354 | 354 | |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | throw ExceptionConverter::toLegacy($e); |
403 | 403 | } |
404 | 404 | |
405 | - if (! $result->isAcknowledged()) { |
|
405 | + if ( ! $result->isAcknowledged()) { |
|
406 | 406 | return true; |
407 | 407 | } |
408 | 408 | |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | */ |
430 | 430 | public function remove(array $criteria = [], array $options = []) |
431 | 431 | { |
432 | - $multiple = isset($options['justOne']) ? !$options['justOne'] : true; |
|
432 | + $multiple = isset($options['justOne']) ? ! $options['justOne'] : true; |
|
433 | 433 | $method = $multiple ? 'deleteMany' : 'deleteOne'; |
434 | 434 | |
435 | 435 | try { |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | throw ExceptionConverter::toLegacy($e); |
443 | 443 | } |
444 | 444 | |
445 | - if (! $result->isAcknowledged()) { |
|
445 | + if ( ! $result->isAcknowledged()) { |
|
446 | 446 | return true; |
447 | 447 | } |
448 | 448 | |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | |
521 | 521 | $options['projection'] = TypeConverter::convertProjection($fields); |
522 | 522 | |
523 | - if (! \MongoDB\is_first_key_operator($update)) { |
|
523 | + if ( ! \MongoDB\is_first_key_operator($update)) { |
|
524 | 524 | $document = $this->collection->findOneAndReplace($query, $update, $options); |
525 | 525 | } else { |
526 | 526 | $document = $this->collection->findOneAndUpdate($query, $update, $options); |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | public function findOne($query = [], array $fields = [], array $options = []) |
552 | 552 | { |
553 | 553 | // Can't typehint for array since MongoGridFS extends and accepts strings |
554 | - if (! is_array($query)) { |
|
554 | + if ( ! is_array($query)) { |
|
555 | 555 | trigger_error(sprintf('MongoCollection::findOne(): expects parameter 1 to be an array or object, %s given', gettype($query)), E_USER_WARNING); |
556 | 556 | return; |
557 | 557 | } |
@@ -591,11 +591,11 @@ discard block |
||
591 | 591 | $keys = (array) $keys; |
592 | 592 | } |
593 | 593 | |
594 | - if (! is_array($keys) || ! count($keys)) { |
|
594 | + if ( ! is_array($keys) || ! count($keys)) { |
|
595 | 595 | throw new MongoException('index specification has no elements'); |
596 | 596 | } |
597 | 597 | |
598 | - if (! isset($options['name'])) { |
|
598 | + if ( ! isset($options['name'])) { |
|
599 | 599 | $options['name'] = \MongoDB\generate_index_name($keys); |
600 | 600 | } |
601 | 601 | |
@@ -630,14 +630,14 @@ discard block |
||
630 | 630 | } |
631 | 631 | |
632 | 632 | $result = [ |
633 | - 'createdCollectionAutomatically' => !$collectionExists, |
|
633 | + 'createdCollectionAutomatically' => ! $collectionExists, |
|
634 | 634 | 'numIndexesBefore' => $indexCount, |
635 | 635 | 'numIndexesAfter' => $indexCount, |
636 | 636 | 'note' => 'all indexes already exist', |
637 | 637 | 'ok' => 1.0, |
638 | 638 | ]; |
639 | 639 | |
640 | - if (! $indexExists) { |
|
640 | + if ( ! $indexExists) { |
|
641 | 641 | $result['numIndexesAfter']++; |
642 | 642 | unset($result['note']); |
643 | 643 | } |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | { |
671 | 671 | if (is_string($keys)) { |
672 | 672 | $indexName = $keys; |
673 | - if (! preg_match('#_-?1$#', $indexName)) { |
|
673 | + if ( ! preg_match('#_-?1$#', $indexName)) { |
|
674 | 674 | $indexName .= '_1'; |
675 | 675 | } |
676 | 676 | } elseif (is_array($keys)) { |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | */ |
710 | 710 | public function getIndexInfo() |
711 | 711 | { |
712 | - $convertIndex = function (\MongoDB\Model\IndexInfo $indexInfo) { |
|
712 | + $convertIndex = function(\MongoDB\Model\IndexInfo $indexInfo) { |
|
713 | 713 | $infos = [ |
714 | 714 | 'v' => $indexInfo->getVersion(), |
715 | 715 | 'key' => $indexInfo->getKey(), |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | ]; |
734 | 734 | |
735 | 735 | foreach ($additionalKeys as $key) { |
736 | - if (! isset($indexInfo[$key])) { |
|
736 | + if ( ! isset($indexInfo[$key])) { |
|
737 | 737 | continue; |
738 | 738 | } |
739 | 739 | |
@@ -758,7 +758,7 @@ discard block |
||
758 | 758 | { |
759 | 759 | try { |
760 | 760 | // Handle legacy mode - limit and skip as second and third parameters, respectively |
761 | - if (! is_array($options)) { |
|
761 | + if ( ! is_array($options)) { |
|
762 | 762 | $limit = $options; |
763 | 763 | $options = []; |
764 | 764 | |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | $this->convertWriteConcernOptions($options) |
806 | 806 | ); |
807 | 807 | |
808 | - if (! $result->isAcknowledged()) { |
|
808 | + if ( ! $result->isAcknowledged()) { |
|
809 | 809 | return true; |
810 | 810 | } |
811 | 811 | |
@@ -839,13 +839,13 @@ discard block |
||
839 | 839 | if ($document_or_id instanceof \MongoId) { |
840 | 840 | $id = $document_or_id; |
841 | 841 | } elseif (is_object($document_or_id)) { |
842 | - if (! isset($document_or_id->_id)) { |
|
842 | + if ( ! isset($document_or_id->_id)) { |
|
843 | 843 | return null; |
844 | 844 | } |
845 | 845 | |
846 | 846 | $id = $document_or_id->_id; |
847 | 847 | } elseif (is_array($document_or_id)) { |
848 | - if (! isset($document_or_id['_id'])) { |
|
848 | + if ( ! isset($document_or_id['_id'])) { |
|
849 | 849 | return null; |
850 | 850 | } |
851 | 851 | |
@@ -958,11 +958,11 @@ discard block |
||
958 | 958 | $options['w'] = ($options['safe']) ? 1 : 0; |
959 | 959 | } |
960 | 960 | |
961 | - if (isset($options['wtimeout']) && !isset($options['wTimeoutMS'])) { |
|
961 | + if (isset($options['wtimeout']) && ! isset($options['wTimeoutMS'])) { |
|
962 | 962 | $options['wTimeoutMS'] = $options['wtimeout']; |
963 | 963 | } |
964 | 964 | |
965 | - if (isset($options['w']) || !isset($options['wTimeoutMS'])) { |
|
965 | + if (isset($options['w']) || ! isset($options['wTimeoutMS'])) { |
|
966 | 966 | $collectionWriteConcern = $this->getWriteConcern(); |
967 | 967 | $writeConcern = $this->createWriteConcernFromParameters( |
968 | 968 | isset($options['w']) ? $options['w'] : $collectionWriteConcern['w'], |
@@ -1000,7 +1000,7 @@ discard block |
||
1000 | 1000 | private function ensureDocumentHasMongoId(&$document) |
1001 | 1001 | { |
1002 | 1002 | if (is_array($document) || $document instanceof ArrayObject) { |
1003 | - if (! isset($document['_id'])) { |
|
1003 | + if ( ! isset($document['_id'])) { |
|
1004 | 1004 | $document['_id'] = new \MongoId(); |
1005 | 1005 | } |
1006 | 1006 | |
@@ -1010,12 +1010,12 @@ discard block |
||
1010 | 1010 | } elseif (is_object($document)) { |
1011 | 1011 | $reflectionObject = new \ReflectionObject($document); |
1012 | 1012 | foreach ($reflectionObject->getProperties() as $property) { |
1013 | - if (! $property->isPublic()) { |
|
1013 | + if ( ! $property->isPublic()) { |
|
1014 | 1014 | throw new \MongoException('zero-length keys are not allowed, did you use $ with double quotes?'); |
1015 | 1015 | } |
1016 | 1016 | } |
1017 | 1017 | |
1018 | - if (! isset($document->_id)) { |
|
1018 | + if ( ! isset($document->_id)) { |
|
1019 | 1019 | $document->_id = new \MongoId(); |
1020 | 1020 | } |
1021 | 1021 | |
@@ -1046,7 +1046,7 @@ discard block |
||
1046 | 1046 | |
1047 | 1047 | private function mustBeArrayOrObject($a) |
1048 | 1048 | { |
1049 | - if (!is_array($a) && !is_object($a)) { |
|
1049 | + if ( ! is_array($a) && ! is_object($a)) { |
|
1050 | 1050 | throw new \MongoException('document must be an array or object'); |
1051 | 1051 | } |
1052 | 1052 | } |