@@ -126,14 +126,14 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function aggregate(array $pipeline, array $op = []) |
| 128 | 128 | { |
| 129 | - if (! TypeConverter::isNumericArray($pipeline)) { |
|
| 129 | + if ( ! TypeConverter::isNumericArray($pipeline)) { |
|
| 130 | 130 | $pipeline = []; |
| 131 | 131 | $options = []; |
| 132 | 132 | |
| 133 | 133 | $i = 0; |
| 134 | 134 | foreach (func_get_args() as $operator) { |
| 135 | 135 | $i++; |
| 136 | - if (! is_array($operator)) { |
|
| 136 | + if ( ! is_array($operator)) { |
|
| 137 | 137 | trigger_error("Argument $i is not an array", E_WARNING); |
| 138 | 138 | return; |
| 139 | 139 | } |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | ]; |
| 181 | 181 | |
| 182 | 182 | // Convert cursor option |
| 183 | - if (! isset($options['cursor'])) { |
|
| 183 | + if ( ! isset($options['cursor'])) { |
|
| 184 | 184 | $options['cursor'] = new \stdClass(); |
| 185 | 185 | } |
| 186 | 186 | |
@@ -266,12 +266,12 @@ discard block |
||
| 266 | 266 | */ |
| 267 | 267 | public function insert(&$a, array $options = []) |
| 268 | 268 | { |
| 269 | - if (! $this->ensureDocumentHasMongoId($a)) { |
|
| 269 | + if ( ! $this->ensureDocumentHasMongoId($a)) { |
|
| 270 | 270 | trigger_error(sprintf('%s(): expects parameter %d to be an array or object, %s given', __METHOD__, 1, gettype($a)), E_USER_WARNING); |
| 271 | 271 | return; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - if (! count((array)$a)) { |
|
| 274 | + if ( ! count((array) $a)) { |
|
| 275 | 275 | throw new \MongoException('document must be an array or object'); |
| 276 | 276 | } |
| 277 | 277 | |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | throw ExceptionConverter::toLegacy($e); |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - if (! $result->isAcknowledged()) { |
|
| 287 | + if ( ! $result->isAcknowledged()) { |
|
| 288 | 288 | return true; |
| 289 | 289 | } |
| 290 | 290 | |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | |
| 316 | 316 | foreach ($a as $key => $item) { |
| 317 | 317 | try { |
| 318 | - if (! $this->ensureDocumentHasMongoId($a[$key])) { |
|
| 318 | + if ( ! $this->ensureDocumentHasMongoId($a[$key])) { |
|
| 319 | 319 | if ($continueOnError) { |
| 320 | 320 | unset($a[$key]); |
| 321 | 321 | } else { |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | throw ExceptionConverter::toLegacy($e, 'MongoResultException'); |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - if (! $result->isAcknowledged()) { |
|
| 342 | + if ( ! $result->isAcknowledged()) { |
|
| 343 | 343 | return true; |
| 344 | 344 | } |
| 345 | 345 | |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | * @throws MongoCursorException |
| 364 | 364 | * @return boolean |
| 365 | 365 | */ |
| 366 | - public function update(array $criteria , array $newobj, array $options = []) |
|
| 366 | + public function update(array $criteria, array $newobj, array $options = []) |
|
| 367 | 367 | { |
| 368 | 368 | $multiple = isset($options['multiple']) ? $options['multiple'] : false; |
| 369 | 369 | $isReplace = ! \MongoDB\is_first_key_operator($newobj); |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | throw ExceptionConverter::toLegacy($e); |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - if (! $result->isAcknowledged()) { |
|
| 390 | + if ( ! $result->isAcknowledged()) { |
|
| 391 | 391 | return true; |
| 392 | 392 | } |
| 393 | 393 | |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | */ |
| 415 | 415 | public function remove(array $criteria = [], array $options = []) |
| 416 | 416 | { |
| 417 | - $multiple = isset($options['justOne']) ? !$options['justOne'] : true; |
|
| 417 | + $multiple = isset($options['justOne']) ? ! $options['justOne'] : true; |
|
| 418 | 418 | $method = $multiple ? 'deleteMany' : 'deleteOne'; |
| 419 | 419 | |
| 420 | 420 | try { |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | throw ExceptionConverter::toLegacy($e); |
| 428 | 428 | } |
| 429 | 429 | |
| 430 | - if (! $result->isAcknowledged()) { |
|
| 430 | + if ( ! $result->isAcknowledged()) { |
|
| 431 | 431 | return true; |
| 432 | 432 | } |
| 433 | 433 | |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | |
| 500 | 500 | $options['projection'] = is_array($fields) ? TypeConverter::fromLegacy($fields) : []; |
| 501 | 501 | |
| 502 | - if (! \MongoDB\is_first_key_operator($update)) { |
|
| 502 | + if ( ! \MongoDB\is_first_key_operator($update)) { |
|
| 503 | 503 | $document = $this->collection->findOneAndReplace($query, $update, $options); |
| 504 | 504 | } else { |
| 505 | 505 | $document = $this->collection->findOneAndUpdate($query, $update, $options); |
@@ -564,11 +564,11 @@ discard block |
||
| 564 | 564 | $keys = (array) $keys; |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | - if (! is_array($keys) || ! count($keys)) { |
|
| 567 | + if ( ! is_array($keys) || ! count($keys)) { |
|
| 568 | 568 | throw new MongoException('index specification has no elements'); |
| 569 | 569 | } |
| 570 | 570 | |
| 571 | - if (! isset($options['name'])) { |
|
| 571 | + if ( ! isset($options['name'])) { |
|
| 572 | 572 | $options['name'] = \MongoDB\generate_index_name($keys); |
| 573 | 573 | } |
| 574 | 574 | |
@@ -642,7 +642,7 @@ discard block |
||
| 642 | 642 | { |
| 643 | 643 | if (is_string($keys)) { |
| 644 | 644 | $indexName = $keys; |
| 645 | - if (! preg_match('#_-?1$#', $indexName)) { |
|
| 645 | + if ( ! preg_match('#_-?1$#', $indexName)) { |
|
| 646 | 646 | $indexName .= '_1'; |
| 647 | 647 | } |
| 648 | 648 | } elseif (is_array($keys)) { |
@@ -738,7 +738,7 @@ discard block |
||
| 738 | 738 | $this->convertWriteConcernOptions($options) |
| 739 | 739 | ); |
| 740 | 740 | |
| 741 | - if (! $result->isAcknowledged()) { |
|
| 741 | + if ( ! $result->isAcknowledged()) { |
|
| 742 | 742 | return true; |
| 743 | 743 | } |
| 744 | 744 | |
@@ -772,13 +772,13 @@ discard block |
||
| 772 | 772 | if ($document_or_id instanceof \MongoId) { |
| 773 | 773 | $id = $document_or_id; |
| 774 | 774 | } elseif (is_object($document_or_id)) { |
| 775 | - if (! isset($document_or_id->_id)) { |
|
| 775 | + if ( ! isset($document_or_id->_id)) { |
|
| 776 | 776 | return null; |
| 777 | 777 | } |
| 778 | 778 | |
| 779 | 779 | $id = $document_or_id->_id; |
| 780 | 780 | } elseif (is_array($document_or_id)) { |
| 781 | - if (! isset($document_or_id['_id'])) { |
|
| 781 | + if ( ! isset($document_or_id['_id'])) { |
|
| 782 | 782 | return null; |
| 783 | 783 | } |
| 784 | 784 | |
@@ -821,14 +821,14 @@ discard block |
||
| 821 | 821 | $command = [ |
| 822 | 822 | 'group' => [ |
| 823 | 823 | 'ns' => $this->name, |
| 824 | - '$reduce' => (string)$reduce, |
|
| 824 | + '$reduce' => (string) $reduce, |
|
| 825 | 825 | 'initial' => $initial, |
| 826 | 826 | 'cond' => $condition, |
| 827 | 827 | ], |
| 828 | 828 | ]; |
| 829 | 829 | |
| 830 | 830 | if ($keys instanceof MongoCode) { |
| 831 | - $command['group']['$keyf'] = (string)$keys; |
|
| 831 | + $command['group']['$keyf'] = (string) $keys; |
|
| 832 | 832 | } else { |
| 833 | 833 | $command['group']['key'] = $keys; |
| 834 | 834 | } |
@@ -837,7 +837,7 @@ discard block |
||
| 837 | 837 | } |
| 838 | 838 | if (array_key_exists('finalize', $condition)) { |
| 839 | 839 | if ($condition['finalize'] instanceof MongoCode) { |
| 840 | - $condition['finalize'] = (string)$condition['finalize']; |
|
| 840 | + $condition['finalize'] = (string) $condition['finalize']; |
|
| 841 | 841 | } |
| 842 | 842 | $command['group']['finalize'] = $condition['finalize']; |
| 843 | 843 | } |
@@ -891,11 +891,11 @@ discard block |
||
| 891 | 891 | $options['w'] = ($options['safe']) ? 1 : 0; |
| 892 | 892 | } |
| 893 | 893 | |
| 894 | - if (isset($options['wtimeout']) && !isset($options['wTimeoutMS'])) { |
|
| 894 | + if (isset($options['wtimeout']) && ! isset($options['wTimeoutMS'])) { |
|
| 895 | 895 | $options['wTimeoutMS'] = $options['wtimeout']; |
| 896 | 896 | } |
| 897 | 897 | |
| 898 | - if (isset($options['w']) || !isset($options['wTimeoutMS'])) { |
|
| 898 | + if (isset($options['w']) || ! isset($options['wTimeoutMS'])) { |
|
| 899 | 899 | $collectionWriteConcern = $this->getWriteConcern(); |
| 900 | 900 | $writeConcern = $this->createWriteConcernFromParameters( |
| 901 | 901 | isset($options['w']) ? $options['w'] : $collectionWriteConcern['w'], |
@@ -928,7 +928,7 @@ discard block |
||
| 928 | 928 | }; |
| 929 | 929 | |
| 930 | 930 | if (is_array($document)) { |
| 931 | - if (! isset($document['_id'])) { |
|
| 931 | + if ( ! isset($document['_id'])) { |
|
| 932 | 932 | $document['_id'] = new \MongoId(); |
| 933 | 933 | } |
| 934 | 934 | |
@@ -938,12 +938,12 @@ discard block |
||
| 938 | 938 | } elseif (is_object($document)) { |
| 939 | 939 | $reflectionObject = new \ReflectionObject($document); |
| 940 | 940 | foreach ($reflectionObject->getProperties() as $property) { |
| 941 | - if (! $property->isPublic()) { |
|
| 941 | + if ( ! $property->isPublic()) { |
|
| 942 | 942 | throw new \MongoException('zero-length keys are not allowed, did you use $ with double quotes?'); |
| 943 | 943 | } |
| 944 | 944 | } |
| 945 | 945 | |
| 946 | - if (! isset($document->_id)) { |
|
| 946 | + if ( ! isset($document->_id)) { |
|
| 947 | 947 | $document->_id = new \MongoId(); |
| 948 | 948 | } |
| 949 | 949 | |