@@ -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); |
@@ -530,7 +530,7 @@ discard block |
||
| 530 | 530 | public function findOne($query = [], array $fields = [], array $options = []) |
| 531 | 531 | { |
| 532 | 532 | // Can't typehint for array since MongoGridFS extends and accepts strings |
| 533 | - if (! is_array($query)) { |
|
| 533 | + if ( ! is_array($query)) { |
|
| 534 | 534 | trigger_error(sprintf('MongoCollection::findOne(): expects parameter 1 to be an array or object, %s given', gettype($query)), E_WARNING); |
| 535 | 535 | return; |
| 536 | 536 | } |
@@ -570,11 +570,11 @@ discard block |
||
| 570 | 570 | $keys = (array) $keys; |
| 571 | 571 | } |
| 572 | 572 | |
| 573 | - if (! is_array($keys) || ! count($keys)) { |
|
| 573 | + if ( ! is_array($keys) || ! count($keys)) { |
|
| 574 | 574 | throw new MongoException('index specification has no elements'); |
| 575 | 575 | } |
| 576 | 576 | |
| 577 | - if (! isset($options['name'])) { |
|
| 577 | + if ( ! isset($options['name'])) { |
|
| 578 | 578 | $options['name'] = \MongoDB\generate_index_name($keys); |
| 579 | 579 | } |
| 580 | 580 | |
@@ -609,14 +609,14 @@ discard block |
||
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | $result = [ |
| 612 | - 'createdCollectionAutomatically' => !$collectionExists, |
|
| 612 | + 'createdCollectionAutomatically' => ! $collectionExists, |
|
| 613 | 613 | 'numIndexesBefore' => $indexCount, |
| 614 | 614 | 'numIndexesAfter' => $indexCount, |
| 615 | 615 | 'note' => 'all indexes already exist', |
| 616 | 616 | 'ok' => 1.0, |
| 617 | 617 | ]; |
| 618 | 618 | |
| 619 | - if (! $indexExists) { |
|
| 619 | + if ( ! $indexExists) { |
|
| 620 | 620 | $result['numIndexesAfter']++; |
| 621 | 621 | unset($result['note']); |
| 622 | 622 | } |
@@ -649,7 +649,7 @@ discard block |
||
| 649 | 649 | { |
| 650 | 650 | if (is_string($keys)) { |
| 651 | 651 | $indexName = $keys; |
| 652 | - if (! preg_match('#_-?1$#', $indexName)) { |
|
| 652 | + if ( ! preg_match('#_-?1$#', $indexName)) { |
|
| 653 | 653 | $indexName .= '_1'; |
| 654 | 654 | } |
| 655 | 655 | } elseif (is_array($keys)) { |
@@ -745,7 +745,7 @@ discard block |
||
| 745 | 745 | $this->convertWriteConcernOptions($options) |
| 746 | 746 | ); |
| 747 | 747 | |
| 748 | - if (! $result->isAcknowledged()) { |
|
| 748 | + if ( ! $result->isAcknowledged()) { |
|
| 749 | 749 | return true; |
| 750 | 750 | } |
| 751 | 751 | |
@@ -779,13 +779,13 @@ discard block |
||
| 779 | 779 | if ($document_or_id instanceof \MongoId) { |
| 780 | 780 | $id = $document_or_id; |
| 781 | 781 | } elseif (is_object($document_or_id)) { |
| 782 | - if (! isset($document_or_id->_id)) { |
|
| 782 | + if ( ! isset($document_or_id->_id)) { |
|
| 783 | 783 | return null; |
| 784 | 784 | } |
| 785 | 785 | |
| 786 | 786 | $id = $document_or_id->_id; |
| 787 | 787 | } elseif (is_array($document_or_id)) { |
| 788 | - if (! isset($document_or_id['_id'])) { |
|
| 788 | + if ( ! isset($document_or_id['_id'])) { |
|
| 789 | 789 | return null; |
| 790 | 790 | } |
| 791 | 791 | |
@@ -828,14 +828,14 @@ discard block |
||
| 828 | 828 | $command = [ |
| 829 | 829 | 'group' => [ |
| 830 | 830 | 'ns' => $this->name, |
| 831 | - '$reduce' => (string)$reduce, |
|
| 831 | + '$reduce' => (string) $reduce, |
|
| 832 | 832 | 'initial' => $initial, |
| 833 | 833 | 'cond' => $condition, |
| 834 | 834 | ], |
| 835 | 835 | ]; |
| 836 | 836 | |
| 837 | 837 | if ($keys instanceof MongoCode) { |
| 838 | - $command['group']['$keyf'] = (string)$keys; |
|
| 838 | + $command['group']['$keyf'] = (string) $keys; |
|
| 839 | 839 | } else { |
| 840 | 840 | $command['group']['key'] = $keys; |
| 841 | 841 | } |
@@ -844,7 +844,7 @@ discard block |
||
| 844 | 844 | } |
| 845 | 845 | if (array_key_exists('finalize', $condition)) { |
| 846 | 846 | if ($condition['finalize'] instanceof MongoCode) { |
| 847 | - $condition['finalize'] = (string)$condition['finalize']; |
|
| 847 | + $condition['finalize'] = (string) $condition['finalize']; |
|
| 848 | 848 | } |
| 849 | 849 | $command['group']['finalize'] = $condition['finalize']; |
| 850 | 850 | } |
@@ -898,11 +898,11 @@ discard block |
||
| 898 | 898 | $options['w'] = ($options['safe']) ? 1 : 0; |
| 899 | 899 | } |
| 900 | 900 | |
| 901 | - if (isset($options['wtimeout']) && !isset($options['wTimeoutMS'])) { |
|
| 901 | + if (isset($options['wtimeout']) && ! isset($options['wTimeoutMS'])) { |
|
| 902 | 902 | $options['wTimeoutMS'] = $options['wtimeout']; |
| 903 | 903 | } |
| 904 | 904 | |
| 905 | - if (isset($options['w']) || !isset($options['wTimeoutMS'])) { |
|
| 905 | + if (isset($options['w']) || ! isset($options['wTimeoutMS'])) { |
|
| 906 | 906 | $collectionWriteConcern = $this->getWriteConcern(); |
| 907 | 907 | $writeConcern = $this->createWriteConcernFromParameters( |
| 908 | 908 | isset($options['w']) ? $options['w'] : $collectionWriteConcern['w'], |
@@ -935,7 +935,7 @@ discard block |
||
| 935 | 935 | }; |
| 936 | 936 | |
| 937 | 937 | if (is_array($document)) { |
| 938 | - if (! isset($document['_id'])) { |
|
| 938 | + if ( ! isset($document['_id'])) { |
|
| 939 | 939 | $document['_id'] = new \MongoId(); |
| 940 | 940 | } |
| 941 | 941 | |
@@ -945,12 +945,12 @@ discard block |
||
| 945 | 945 | } elseif (is_object($document)) { |
| 946 | 946 | $reflectionObject = new \ReflectionObject($document); |
| 947 | 947 | foreach ($reflectionObject->getProperties() as $property) { |
| 948 | - if (! $property->isPublic()) { |
|
| 948 | + if ( ! $property->isPublic()) { |
|
| 949 | 949 | throw new \MongoException('zero-length keys are not allowed, did you use $ with double quotes?'); |
| 950 | 950 | } |
| 951 | 951 | } |
| 952 | 952 | |
| 953 | - if (! isset($document->_id)) { |
|
| 953 | + if ( ! isset($document->_id)) { |
|
| 954 | 954 | $document->_id = new \MongoId(); |
| 955 | 955 | } |
| 956 | 956 | |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function findOne($query = [], array $fields = [], array $options = []) |
| 129 | 129 | { |
| 130 | - if (! is_array($query)) { |
|
| 130 | + if ( ! is_array($query)) { |
|
| 131 | 131 | $query = ['filename' => (string) $query]; |
| 132 | 132 | } |
| 133 | 133 | |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | try { |
| 204 | 204 | $file = $this->insertFile($record, $options); |
| 205 | 205 | } catch (MongoException $e) { |
| 206 | - throw new MongoGridFSException('Could not store file: '. $e->getMessage(), 0, $e); |
|
| 206 | + throw new MongoGridFSException('Could not store file: ' . $e->getMessage(), 0, $e); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | try { |
@@ -240,10 +240,10 @@ discard block |
||
| 240 | 240 | ]; |
| 241 | 241 | |
| 242 | 242 | $handle = fopen($filename, 'r'); |
| 243 | - if (! $handle) { |
|
| 243 | + if ( ! $handle) { |
|
| 244 | 244 | throw new MongoGridFSException('could not open file: ' . $filename); |
| 245 | 245 | } |
| 246 | - } elseif (! is_resource($filename)) { |
|
| 246 | + } elseif ( ! is_resource($filename)) { |
|
| 247 | 247 | throw new \Exception('first argument must be a string or stream resource'); |
| 248 | 248 | } else { |
| 249 | 249 | $handle = $filename; |
@@ -266,10 +266,10 @@ discard block |
||
| 266 | 266 | |
| 267 | 267 | // Add length and MD5 if they were not present before |
| 268 | 268 | $update = []; |
| 269 | - if (! isset($record['length'])) { |
|
| 269 | + if ( ! isset($record['length'])) { |
|
| 270 | 270 | $update['length'] = $length; |
| 271 | 271 | } |
| 272 | - if (! isset($record['md5'])) { |
|
| 272 | + if ( ! isset($record['md5'])) { |
|
| 273 | 273 | try { |
| 274 | 274 | $update['md5'] = $md5; |
| 275 | 275 | } catch (MongoException $e) { |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | if (count($update)) { |
| 281 | 281 | try { |
| 282 | 282 | $result = $this->update(['_id' => $file['_id']], ['$set' => $update]); |
| 283 | - if (! $this->isOKResult($result)) { |
|
| 283 | + if ( ! $this->isOKResult($result)) { |
|
| 284 | 284 | throw new MongoGridFSException('Could not store file'); |
| 285 | 285 | } |
| 286 | 286 | } catch (MongoException $e) { |
@@ -304,10 +304,10 @@ discard block |
||
| 304 | 304 | */ |
| 305 | 305 | public function storeUpload($name, array $metadata = []) |
| 306 | 306 | { |
| 307 | - if (! isset($_FILES[$name]) || $_FILES[$name]['error'] !== UPLOAD_ERR_OK) { |
|
| 307 | + if ( ! isset($_FILES[$name]) || $_FILES[$name]['error'] !== UPLOAD_ERR_OK) { |
|
| 308 | 308 | throw new MongoGridFSException("Could not find uploaded file $name"); |
| 309 | 309 | } |
| 310 | - if (! isset($_FILES[$name]['tmp_name'])) { |
|
| 310 | + if ( ! isset($_FILES[$name]['tmp_name'])) { |
|
| 311 | 311 | throw new MongoGridFSException("Couldn't find tmp_name in the \$_FILES array. Are you sure the upload worked?"); |
| 312 | 312 | } |
| 313 | 313 | |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | |
| 358 | 358 | $result = $this->chunks->insert($chunk); |
| 359 | 359 | |
| 360 | - if (! $this->isOKResult($result)) { |
|
| 360 | + if ( ! $this->isOKResult($result)) { |
|
| 361 | 361 | throw new \MongoException('error inserting chunk'); |
| 362 | 362 | } |
| 363 | 363 | |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | $hash = hash_init('md5'); |
| 403 | 403 | |
| 404 | 404 | rewind($handle); |
| 405 | - while (! feof($handle)) { |
|
| 405 | + while ( ! feof($handle)) { |
|
| 406 | 406 | $data = stream_get_contents($handle, $chunkSize); |
| 407 | 407 | hash_update($hash, $data); |
| 408 | 408 | $this->insertChunk($fileId, $data, $i++); |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | |
| 433 | 433 | $result = $this->insert($record, $options); |
| 434 | 434 | |
| 435 | - if (! $this->isOKResult($result)) { |
|
| 435 | + if ( ! $this->isOKResult($result)) { |
|
| 436 | 436 | throw new \MongoException('error inserting file'); |
| 437 | 437 | } |
| 438 | 438 | |