@@ -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 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | use Alcaeus\MongoDbAdapter\TypeConverter; |
| 17 | 17 | |
| 18 | -if (! function_exists('bson_decode')) { |
|
| 18 | +if ( ! function_exists('bson_decode')) { |
|
| 19 | 19 | /** |
| 20 | 20 | * Deserializes a BSON object into a PHP array |
| 21 | 21 | * |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | -if (! function_exists('bson_encode')) { |
|
| 31 | +if ( ! function_exists('bson_encode')) { |
|
| 32 | 32 | /** |
| 33 | 33 | * Serializes a PHP variable into a BSON string |
| 34 | 34 | * |
@@ -28,13 +28,13 @@ discard block |
||
| 28 | 28 | use Helper\WriteConcern; |
| 29 | 29 | |
| 30 | 30 | const VERSION = '1.6.12'; |
| 31 | - const DEFAULT_HOST = "localhost" ; |
|
| 32 | - const DEFAULT_PORT = 27017 ; |
|
| 33 | - const RP_PRIMARY = "primary" ; |
|
| 34 | - const RP_PRIMARY_PREFERRED = "primaryPreferred" ; |
|
| 35 | - const RP_SECONDARY = "secondary" ; |
|
| 36 | - const RP_SECONDARY_PREFERRED = "secondaryPreferred" ; |
|
| 37 | - const RP_NEAREST = "nearest" ; |
|
| 31 | + const DEFAULT_HOST = "localhost"; |
|
| 32 | + const DEFAULT_PORT = 27017; |
|
| 33 | + const RP_PRIMARY = "primary"; |
|
| 34 | + const RP_PRIMARY_PREFERRED = "primaryPreferred"; |
|
| 35 | + const RP_SECONDARY = "secondary"; |
|
| 36 | + const RP_SECONDARY_PREFERRED = "secondaryPreferred"; |
|
| 37 | + const RP_NEAREST = "nearest"; |
|
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * @var bool |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | $this->server = $server; |
| 86 | 86 | if (false === strpos($this->server, 'mongodb://')) { |
| 87 | - $this->server = 'mongodb://'.$this->server; |
|
| 87 | + $this->server = 'mongodb://' . $this->server; |
|
| 88 | 88 | } |
| 89 | 89 | $this->client = new Client($this->server, $options, $driverOptions); |
| 90 | 90 | $info = $this->client->__debugInfo(); |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | * @param int|MongoInt64 $id The ID of the cursor to kill. |
| 231 | 231 | * @return bool |
| 232 | 232 | */ |
| 233 | - public function killCursor($server_hash , $id) |
|
| 233 | + public function killCursor($server_hash, $id) |
|
| 234 | 234 | { |
| 235 | 235 | $this->notImplemented(); |
| 236 | 236 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | * @link http://www.php.net/manual/en/mongoclient.killcursor.php |
| 235 | 235 | * @param string $server_hash The server hash that has the cursor. |
| 236 | 236 | * @param int|MongoInt64 $id The ID of the cursor to kill. |
| 237 | - * @return bool |
|
| 237 | + * @return boolean|null |
|
| 238 | 238 | */ |
| 239 | 239 | public function killCursor($server_hash , $id) |
| 240 | 240 | { |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | /** |
| 345 | - * @return array |
|
| 345 | + * @return string[] |
|
| 346 | 346 | */ |
| 347 | 347 | function __sleep() |
| 348 | 348 | { |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | /** |
| 355 | - * @param $server |
|
| 355 | + * @param string $server |
|
| 356 | 356 | * @return array |
| 357 | 357 | */ |
| 358 | 358 | private function extractUrlOptions($server) |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | ]; |
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | - * @return Cursor |
|
| 83 | + * @return \Traversable |
|
| 84 | 84 | */ |
| 85 | 85 | abstract protected function ensureCursor(); |
| 86 | 86 | |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | /** |
| 380 | - * @return array |
|
| 380 | + * @return string[] |
|
| 381 | 381 | */ |
| 382 | 382 | public function __sleep() |
| 383 | 383 | { |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | public function next() |
| 162 | 162 | { |
| 163 | - if (! $this->startedIterating) { |
|
| 163 | + if ( ! $this->startedIterating) { |
|
| 164 | 164 | $this->ensureIterator(); |
| 165 | 165 | $this->startedIterating = true; |
| 166 | 166 | } else { |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | */ |
| 403 | 403 | private function storeIteratorState() |
| 404 | 404 | { |
| 405 | - if (! $this->startedIterating) { |
|
| 405 | + if ( ! $this->startedIterating) { |
|
| 406 | 406 | $this->current = null; |
| 407 | 407 | $this->key = null; |
| 408 | 408 | $this->valid = false; |
@@ -102,7 +102,7 @@ |
||
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
| 105 | - * @return array |
|
| 105 | + * @return string[] |
|
| 106 | 106 | */ |
| 107 | 107 | public function __sleep() |
| 108 | 108 | { |
@@ -105,7 +105,6 @@ discard block |
||
| 105 | 105 | * @link http://php.net/manual/en/mongogridfs.find.php |
| 106 | 106 | * @param array $query The query |
| 107 | 107 | * @param array $fields Fields to return |
| 108 | - * @param array $options Options for the find command |
|
| 109 | 108 | * @return MongoGridFSCursor A MongoGridFSCursor |
| 110 | 109 | */ |
| 111 | 110 | public function find(array $query = [], array $fields = []) |
@@ -446,7 +445,7 @@ discard block |
||
| 446 | 445 | } |
| 447 | 446 | |
| 448 | 447 | /** |
| 449 | - * @return array |
|
| 448 | + * @return string[] |
|
| 450 | 449 | */ |
| 451 | 450 | public function __sleep() |
| 452 | 451 | { |
@@ -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 | |
@@ -511,6 +511,9 @@ discard block |
||
| 511 | 511 | } |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | + /** |
|
| 515 | + * @param string $name |
|
| 516 | + */ |
|
| 514 | 517 | private function checkDatabaseName($name) |
| 515 | 518 | { |
| 516 | 519 | if (empty($name)) { |
@@ -543,7 +546,7 @@ discard block |
||
| 543 | 546 | } |
| 544 | 547 | |
| 545 | 548 | /** |
| 546 | - * @return array |
|
| 549 | + * @return string[] |
|
| 547 | 550 | */ |
| 548 | 551 | public function __sleep() |
| 549 | 552 | { |
@@ -130,14 +130,14 @@ 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 | $pipeline = []; |
| 135 | 135 | $options = []; |
| 136 | 136 | |
| 137 | 137 | $i = 0; |
| 138 | 138 | foreach (func_get_args() as $operator) { |
| 139 | 139 | $i++; |
| 140 | - if (! is_array($operator)) { |
|
| 140 | + if ( ! is_array($operator)) { |
|
| 141 | 141 | trigger_error("Argument $i is not an array", E_WARNING); |
| 142 | 142 | return; |
| 143 | 143 | } |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | 'waitedMS' => 0, |
| 170 | 170 | ]; |
| 171 | 171 | } catch (\MongoDB\Driver\Exception\Exception $e) { |
| 172 | - throw ExceptionConverter::toLegacy($e,'MongoResultException'); |
|
| 172 | + throw ExceptionConverter::toLegacy($e, 'MongoResultException'); |
|
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | ]; |
| 191 | 191 | |
| 192 | 192 | // Convert cursor option |
| 193 | - if (! isset($options['cursor'])) { |
|
| 193 | + if ( ! isset($options['cursor'])) { |
|
| 194 | 194 | $options['cursor'] = new \stdClass(); |
| 195 | 195 | } |
| 196 | 196 | |
@@ -276,12 +276,12 @@ discard block |
||
| 276 | 276 | */ |
| 277 | 277 | public function insert(&$a, array $options = []) |
| 278 | 278 | { |
| 279 | - if (! $this->ensureDocumentHasMongoId($a)) { |
|
| 279 | + if ( ! $this->ensureDocumentHasMongoId($a)) { |
|
| 280 | 280 | trigger_error(sprintf('%s(): expects parameter %d to be an array or object, %s given', __METHOD__, 1, gettype($a)), E_USER_WARNING); |
| 281 | 281 | return; |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - if (! count((array)$a)) { |
|
| 284 | + if ( ! count((array) $a)) { |
|
| 285 | 285 | throw new \MongoException('document must be an array or object'); |
| 286 | 286 | } |
| 287 | 287 | |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | throw ExceptionConverter::toLegacy($e); |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | - if (! $result->isAcknowledged()) { |
|
| 297 | + if ( ! $result->isAcknowledged()) { |
|
| 298 | 298 | return true; |
| 299 | 299 | } |
| 300 | 300 | |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | |
| 326 | 326 | foreach ($a as $key => $item) { |
| 327 | 327 | try { |
| 328 | - if (! $this->ensureDocumentHasMongoId($a[$key])) { |
|
| 328 | + if ( ! $this->ensureDocumentHasMongoId($a[$key])) { |
|
| 329 | 329 | if ($continueOnError) { |
| 330 | 330 | unset($a[$key]); |
| 331 | 331 | } else { |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | throw ExceptionConverter::toLegacy($e, 'MongoResultException'); |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - if (! $result->isAcknowledged()) { |
|
| 352 | + if ( ! $result->isAcknowledged()) { |
|
| 353 | 353 | return true; |
| 354 | 354 | } |
| 355 | 355 | |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | * @throws MongoCursorException |
| 374 | 374 | * @return boolean |
| 375 | 375 | */ |
| 376 | - public function update(array $criteria , array $newobj, array $options = []) |
|
| 376 | + public function update(array $criteria, array $newobj, array $options = []) |
|
| 377 | 377 | { |
| 378 | 378 | $multiple = isset($options['multiple']) ? $options['multiple'] : false; |
| 379 | 379 | $isReplace = ! \MongoDB\is_first_key_operator($newobj); |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | throw ExceptionConverter::toLegacy($e); |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | - if (! $result->isAcknowledged()) { |
|
| 400 | + if ( ! $result->isAcknowledged()) { |
|
| 401 | 401 | return true; |
| 402 | 402 | } |
| 403 | 403 | |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | */ |
| 425 | 425 | public function remove(array $criteria = [], array $options = []) |
| 426 | 426 | { |
| 427 | - $multiple = isset($options['justOne']) ? !$options['justOne'] : true; |
|
| 427 | + $multiple = isset($options['justOne']) ? ! $options['justOne'] : true; |
|
| 428 | 428 | $method = $multiple ? 'deleteMany' : 'deleteOne'; |
| 429 | 429 | |
| 430 | 430 | try { |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | throw ExceptionConverter::toLegacy($e); |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - if (! $result->isAcknowledged()) { |
|
| 440 | + if ( ! $result->isAcknowledged()) { |
|
| 441 | 441 | return true; |
| 442 | 442 | } |
| 443 | 443 | |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | |
| 516 | 516 | $options['projection'] = is_array($fields) ? TypeConverter::fromLegacy($fields) : []; |
| 517 | 517 | |
| 518 | - if (! \MongoDB\is_first_key_operator($update)) { |
|
| 518 | + if ( ! \MongoDB\is_first_key_operator($update)) { |
|
| 519 | 519 | $document = $this->collection->findOneAndReplace($query, $update, $options); |
| 520 | 520 | } else { |
| 521 | 521 | $document = $this->collection->findOneAndUpdate($query, $update, $options); |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | public function findOne($query = [], array $fields = [], array $options = []) |
| 547 | 547 | { |
| 548 | 548 | // Can't typehint for array since MongoGridFS extends and accepts strings |
| 549 | - if (! is_array($query)) { |
|
| 549 | + if ( ! is_array($query)) { |
|
| 550 | 550 | trigger_error(sprintf('MongoCollection::findOne(): expects parameter 1 to be an array or object, %s given', gettype($query)), E_WARNING); |
| 551 | 551 | return; |
| 552 | 552 | } |
@@ -586,11 +586,11 @@ discard block |
||
| 586 | 586 | $keys = (array) $keys; |
| 587 | 587 | } |
| 588 | 588 | |
| 589 | - if (! is_array($keys) || ! count($keys)) { |
|
| 589 | + if ( ! is_array($keys) || ! count($keys)) { |
|
| 590 | 590 | throw new MongoException('index specification has no elements'); |
| 591 | 591 | } |
| 592 | 592 | |
| 593 | - if (! isset($options['name'])) { |
|
| 593 | + if ( ! isset($options['name'])) { |
|
| 594 | 594 | $options['name'] = \MongoDB\generate_index_name($keys); |
| 595 | 595 | } |
| 596 | 596 | |
@@ -625,14 +625,14 @@ discard block |
||
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | $result = [ |
| 628 | - 'createdCollectionAutomatically' => !$collectionExists, |
|
| 628 | + 'createdCollectionAutomatically' => ! $collectionExists, |
|
| 629 | 629 | 'numIndexesBefore' => $indexCount, |
| 630 | 630 | 'numIndexesAfter' => $indexCount, |
| 631 | 631 | 'note' => 'all indexes already exist', |
| 632 | 632 | 'ok' => 1.0, |
| 633 | 633 | ]; |
| 634 | 634 | |
| 635 | - if (! $indexExists) { |
|
| 635 | + if ( ! $indexExists) { |
|
| 636 | 636 | $result['numIndexesAfter']++; |
| 637 | 637 | unset($result['note']); |
| 638 | 638 | } |
@@ -665,7 +665,7 @@ discard block |
||
| 665 | 665 | { |
| 666 | 666 | if (is_string($keys)) { |
| 667 | 667 | $indexName = $keys; |
| 668 | - if (! preg_match('#_-?1$#', $indexName)) { |
|
| 668 | + if ( ! preg_match('#_-?1$#', $indexName)) { |
|
| 669 | 669 | $indexName .= '_1'; |
| 670 | 670 | } |
| 671 | 671 | } elseif (is_array($keys)) { |
@@ -728,7 +728,7 @@ discard block |
||
| 728 | 728 | { |
| 729 | 729 | try { |
| 730 | 730 | // Handle legacy mode - limit and skip as second and third parameters, respectively |
| 731 | - if (! is_array($options)) { |
|
| 731 | + if ( ! is_array($options)) { |
|
| 732 | 732 | $limit = $options; |
| 733 | 733 | $options = []; |
| 734 | 734 | |
@@ -775,7 +775,7 @@ discard block |
||
| 775 | 775 | $this->convertWriteConcernOptions($options) |
| 776 | 776 | ); |
| 777 | 777 | |
| 778 | - if (! $result->isAcknowledged()) { |
|
| 778 | + if ( ! $result->isAcknowledged()) { |
|
| 779 | 779 | return true; |
| 780 | 780 | } |
| 781 | 781 | |
@@ -809,13 +809,13 @@ discard block |
||
| 809 | 809 | if ($document_or_id instanceof \MongoId) { |
| 810 | 810 | $id = $document_or_id; |
| 811 | 811 | } elseif (is_object($document_or_id)) { |
| 812 | - if (! isset($document_or_id->_id)) { |
|
| 812 | + if ( ! isset($document_or_id->_id)) { |
|
| 813 | 813 | return null; |
| 814 | 814 | } |
| 815 | 815 | |
| 816 | 816 | $id = $document_or_id->_id; |
| 817 | 817 | } elseif (is_array($document_or_id)) { |
| 818 | - if (! isset($document_or_id['_id'])) { |
|
| 818 | + if ( ! isset($document_or_id['_id'])) { |
|
| 819 | 819 | return null; |
| 820 | 820 | } |
| 821 | 821 | |
@@ -858,14 +858,14 @@ discard block |
||
| 858 | 858 | $command = [ |
| 859 | 859 | 'group' => [ |
| 860 | 860 | 'ns' => $this->name, |
| 861 | - '$reduce' => (string)$reduce, |
|
| 861 | + '$reduce' => (string) $reduce, |
|
| 862 | 862 | 'initial' => $initial, |
| 863 | 863 | 'cond' => $condition, |
| 864 | 864 | ], |
| 865 | 865 | ]; |
| 866 | 866 | |
| 867 | 867 | if ($keys instanceof MongoCode) { |
| 868 | - $command['group']['$keyf'] = (string)$keys; |
|
| 868 | + $command['group']['$keyf'] = (string) $keys; |
|
| 869 | 869 | } else { |
| 870 | 870 | $command['group']['key'] = $keys; |
| 871 | 871 | } |
@@ -874,7 +874,7 @@ discard block |
||
| 874 | 874 | } |
| 875 | 875 | if (array_key_exists('finalize', $condition)) { |
| 876 | 876 | if ($condition['finalize'] instanceof MongoCode) { |
| 877 | - $condition['finalize'] = (string)$condition['finalize']; |
|
| 877 | + $condition['finalize'] = (string) $condition['finalize']; |
|
| 878 | 878 | } |
| 879 | 879 | $command['group']['finalize'] = $condition['finalize']; |
| 880 | 880 | } |
@@ -928,11 +928,11 @@ discard block |
||
| 928 | 928 | $options['w'] = ($options['safe']) ? 1 : 0; |
| 929 | 929 | } |
| 930 | 930 | |
| 931 | - if (isset($options['wtimeout']) && !isset($options['wTimeoutMS'])) { |
|
| 931 | + if (isset($options['wtimeout']) && ! isset($options['wTimeoutMS'])) { |
|
| 932 | 932 | $options['wTimeoutMS'] = $options['wtimeout']; |
| 933 | 933 | } |
| 934 | 934 | |
| 935 | - if (isset($options['w']) || !isset($options['wTimeoutMS'])) { |
|
| 935 | + if (isset($options['w']) || ! isset($options['wTimeoutMS'])) { |
|
| 936 | 936 | $collectionWriteConcern = $this->getWriteConcern(); |
| 937 | 937 | $writeConcern = $this->createWriteConcernFromParameters( |
| 938 | 938 | isset($options['w']) ? $options['w'] : $collectionWriteConcern['w'], |
@@ -965,7 +965,7 @@ discard block |
||
| 965 | 965 | }; |
| 966 | 966 | |
| 967 | 967 | if (is_array($document)) { |
| 968 | - if (! isset($document['_id'])) { |
|
| 968 | + if ( ! isset($document['_id'])) { |
|
| 969 | 969 | $document['_id'] = new \MongoId(); |
| 970 | 970 | } |
| 971 | 971 | |
@@ -975,12 +975,12 @@ discard block |
||
| 975 | 975 | } elseif (is_object($document)) { |
| 976 | 976 | $reflectionObject = new \ReflectionObject($document); |
| 977 | 977 | foreach ($reflectionObject->getProperties() as $property) { |
| 978 | - if (! $property->isPublic()) { |
|
| 978 | + if ( ! $property->isPublic()) { |
|
| 979 | 979 | throw new \MongoException('zero-length keys are not allowed, did you use $ with double quotes?'); |
| 980 | 980 | } |
| 981 | 981 | } |
| 982 | 982 | |
| 983 | - if (! isset($document->_id)) { |
|
| 983 | + if ( ! isset($document->_id)) { |
|
| 984 | 984 | $document->_id = new \MongoId(); |
| 985 | 985 | } |
| 986 | 986 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | /** |
| 38 | 38 | * @var MongoDB |
| 39 | 39 | */ |
| 40 | - public $db = NULL; |
|
| 40 | + public $db = null; |
|
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * @var string |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | foreach ($operators as $operator) { |
| 140 | 140 | $i++; |
| 141 | 141 | if (! is_array($operator)) { |
| 142 | - trigger_error("Argument $i is not an array", E_USER_WARNING); |
|
| 142 | + trigger_error("argument $i is not an array", E_USER_WARNING); |
|
| 143 | 143 | return; |
| 144 | 144 | } |
| 145 | 145 | |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | * @param bool $scan_data Only validate indices, not the base collection. |
| 255 | 255 | * @return array Returns the database's evaluation of this object. |
| 256 | 256 | */ |
| 257 | - public function validate($scan_data = FALSE) |
|
| 257 | + public function validate($scan_data = false) |
|
| 258 | 258 | { |
| 259 | 259 | $command = [ |
| 260 | 260 | 'validate' => $this->name, |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | public function add($item) |
| 84 | 84 | { |
| 85 | 85 | if (is_object($item)) { |
| 86 | - $item = (array)$item; |
|
| 86 | + $item = (array) $item; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | $this->validate($item); |
@@ -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; |