@@ -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 | * |
@@ -141,7 +141,7 @@ |
||
| 141 | 141 | */ |
| 142 | 142 | public function next() |
| 143 | 143 | { |
| 144 | - if (!$this->startedIterating) { |
|
| 144 | + if ( ! $this->startedIterating) { |
|
| 145 | 145 | $this->ensureIterator(); |
| 146 | 146 | $this->startedIterating = true; |
| 147 | 147 | } else { |
@@ -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 | |
@@ -263,12 +263,12 @@ discard block |
||
| 263 | 263 | */ |
| 264 | 264 | public function insert(&$a, array $options = []) |
| 265 | 265 | { |
| 266 | - if (! $this->ensureDocumentHasMongoId($a)) { |
|
| 266 | + if ( ! $this->ensureDocumentHasMongoId($a)) { |
|
| 267 | 267 | trigger_error(sprintf('%s expects parameter %d to be an array or object, %s given', __METHOD__, 1, gettype($a)), E_USER_WARNING); |
| 268 | 268 | return; |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - if (! count((array)$a)) { |
|
| 271 | + if ( ! count((array) $a)) { |
|
| 272 | 272 | throw new \MongoException('document must be an array or object'); |
| 273 | 273 | } |
| 274 | 274 | |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | ExceptionConverter::toLegacy($e); |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - if (! $result->isAcknowledged()) { |
|
| 293 | + if ( ! $result->isAcknowledged()) { |
|
| 294 | 294 | return true; |
| 295 | 295 | } |
| 296 | 296 | |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | |
| 322 | 322 | foreach ($a as $key => $item) { |
| 323 | 323 | try { |
| 324 | - if (! $this->ensureDocumentHasMongoId($a[$key])) { |
|
| 324 | + if ( ! $this->ensureDocumentHasMongoId($a[$key])) { |
|
| 325 | 325 | if ($continueOnError) { |
| 326 | 326 | unset($a[$key]); |
| 327 | 327 | } else { |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | ExceptionConverter::toLegacy($e); |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | - if (! $result->isAcknowledged()) { |
|
| 348 | + if ( ! $result->isAcknowledged()) { |
|
| 349 | 349 | return true; |
| 350 | 350 | } |
| 351 | 351 | |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | * @throws MongoCursorException |
| 370 | 370 | * @return boolean |
| 371 | 371 | */ |
| 372 | - public function update(array $criteria , array $newobj, array $options = []) |
|
| 372 | + public function update(array $criteria, array $newobj, array $options = []) |
|
| 373 | 373 | { |
| 374 | 374 | $multiple = isset($options['multiple']) ? $options['multiple'] : false; |
| 375 | 375 | $method = $multiple ? 'updateMany' : 'updateOne'; |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | 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 | ExceptionConverter::toLegacy($e); |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - if (! $result->isAcknowledged()) { |
|
| 440 | + if ( ! $result->isAcknowledged()) { |
|
| 441 | 441 | return true; |
| 442 | 442 | } |
| 443 | 443 | |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | $keys = (array) $keys; |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - if (! is_array($keys) || ! count($keys)) { |
|
| 575 | + if ( ! is_array($keys) || ! count($keys)) { |
|
| 576 | 576 | throw new MongoException('keys cannot be empty'); |
| 577 | 577 | } |
| 578 | 578 | |
@@ -582,7 +582,7 @@ discard block |
||
| 582 | 582 | $indexes = $this->collection->listIndexes(); |
| 583 | 583 | foreach ($indexes as $index) { |
| 584 | 584 | |
| 585 | - if (! empty($options['name']) && $index->getName() === $options['name']) { |
|
| 585 | + if ( ! empty($options['name']) && $index->getName() === $options['name']) { |
|
| 586 | 586 | throw new \MongoResultException(sprintf('index with name: %s already exists', $index->getName())); |
| 587 | 587 | } |
| 588 | 588 | |
@@ -733,7 +733,7 @@ discard block |
||
| 733 | 733 | ExceptionConverter::toLegacy($e); |
| 734 | 734 | } |
| 735 | 735 | |
| 736 | - if (!$result->isAcknowledged()) { |
|
| 736 | + if ( ! $result->isAcknowledged()) { |
|
| 737 | 737 | return true; |
| 738 | 738 | } |
| 739 | 739 | |
@@ -759,13 +759,13 @@ discard block |
||
| 759 | 759 | if ($document_or_id instanceof \MongoId) { |
| 760 | 760 | $id = $document_or_id; |
| 761 | 761 | } elseif (is_object($document_or_id)) { |
| 762 | - if (! isset($document_or_id->_id)) { |
|
| 762 | + if ( ! isset($document_or_id->_id)) { |
|
| 763 | 763 | return null; |
| 764 | 764 | } |
| 765 | 765 | |
| 766 | 766 | $id = $document_or_id->_id; |
| 767 | 767 | } elseif (is_array($document_or_id)) { |
| 768 | - if (! isset($document_or_id['_id'])) { |
|
| 768 | + if ( ! isset($document_or_id['_id'])) { |
|
| 769 | 769 | return null; |
| 770 | 770 | } |
| 771 | 771 | |
@@ -808,14 +808,14 @@ discard block |
||
| 808 | 808 | $command = [ |
| 809 | 809 | 'group' => [ |
| 810 | 810 | 'ns' => $this->name, |
| 811 | - '$reduce' => (string)$reduce, |
|
| 811 | + '$reduce' => (string) $reduce, |
|
| 812 | 812 | 'initial' => $initial, |
| 813 | 813 | 'cond' => $condition, |
| 814 | 814 | ], |
| 815 | 815 | ]; |
| 816 | 816 | |
| 817 | 817 | if ($keys instanceof MongoCode) { |
| 818 | - $command['group']['$keyf'] = (string)$keys; |
|
| 818 | + $command['group']['$keyf'] = (string) $keys; |
|
| 819 | 819 | } else { |
| 820 | 820 | $command['group']['key'] = $keys; |
| 821 | 821 | } |
@@ -824,7 +824,7 @@ discard block |
||
| 824 | 824 | } |
| 825 | 825 | if (array_key_exists('finalize', $condition)) { |
| 826 | 826 | if ($condition['finalize'] instanceof MongoCode) { |
| 827 | - $condition['finalize'] = (string)$condition['finalize']; |
|
| 827 | + $condition['finalize'] = (string) $condition['finalize']; |
|
| 828 | 828 | } |
| 829 | 829 | $command['group']['finalize'] = $condition['finalize']; |
| 830 | 830 | } |
@@ -878,11 +878,11 @@ discard block |
||
| 878 | 878 | $options['w'] = ($options['safe']) ? 1 : 0; |
| 879 | 879 | } |
| 880 | 880 | |
| 881 | - if (isset($options['wtimeout']) && !isset($options['wTimeoutMS'])) { |
|
| 881 | + if (isset($options['wtimeout']) && ! isset($options['wTimeoutMS'])) { |
|
| 882 | 882 | $options['wTimeoutMS'] = $options['wtimeout']; |
| 883 | 883 | } |
| 884 | 884 | |
| 885 | - if (isset($options['w']) || !isset($options['wTimeoutMS'])) { |
|
| 885 | + if (isset($options['w']) || ! isset($options['wTimeoutMS'])) { |
|
| 886 | 886 | $collectionWriteConcern = $this->getWriteConcern(); |
| 887 | 887 | $writeConcern = $this->createWriteConcernFromParameters( |
| 888 | 888 | isset($options['w']) ? $options['w'] : $collectionWriteConcern['w'], |
@@ -918,7 +918,7 @@ discard block |
||
| 918 | 918 | if (empty($document)) { |
| 919 | 919 | throw new \MongoException('document cannot be empty'); |
| 920 | 920 | } |
| 921 | - if (! isset($document['_id'])) { |
|
| 921 | + if ( ! isset($document['_id'])) { |
|
| 922 | 922 | $document['_id'] = new \MongoId(); |
| 923 | 923 | } |
| 924 | 924 | |
@@ -929,7 +929,7 @@ discard block |
||
| 929 | 929 | if (empty((array) $document)) { |
| 930 | 930 | throw new \MongoException('document cannot be empty'); |
| 931 | 931 | } |
| 932 | - if (! isset($document->_id)) { |
|
| 932 | + if ( ! isset($document->_id)) { |
|
| 933 | 933 | $document->_id = new \MongoId(); |
| 934 | 934 | } |
| 935 | 935 | |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | */ |
| 395 | 395 | protected function convertCursorType() |
| 396 | 396 | { |
| 397 | - if (! $this->tailable) { |
|
| 397 | + if ( ! $this->tailable) { |
|
| 398 | 398 | return null; |
| 399 | 399 | } |
| 400 | 400 | |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | protected function wrapTraversable(\Traversable $traversable) |
| 436 | 436 | { |
| 437 | 437 | foreach ($traversable as $key => $value) { |
| 438 | - if (isset($value->_id) && ($value->_id instanceof \MongoDB\BSON\ObjectID || !is_object($value->_id))) { |
|
| 438 | + if (isset($value->_id) && ($value->_id instanceof \MongoDB\BSON\ObjectID || ! is_object($value->_id))) { |
|
| 439 | 439 | $key = (string) $value->_id; |
| 440 | 440 | } |
| 441 | 441 | yield $key => $value; |
@@ -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 | |
@@ -152,19 +152,19 @@ discard block |
||
| 152 | 152 | { |
| 153 | 153 | switch ($this->batchType) { |
| 154 | 154 | case self::COMMAND_UPDATE: |
| 155 | - if (! isset($item['q'])) { |
|
| 155 | + if ( ! isset($item['q'])) { |
|
| 156 | 156 | throw new Exception("Expected $item to contain 'q' key"); |
| 157 | 157 | } |
| 158 | - if (! isset($item['u'])) { |
|
| 158 | + if ( ! isset($item['u'])) { |
|
| 159 | 159 | throw new Exception("Expected $item to contain 'u' key"); |
| 160 | 160 | } |
| 161 | 161 | break; |
| 162 | 162 | |
| 163 | 163 | case self::COMMAND_DELETE: |
| 164 | - if (! isset($item['q'])) { |
|
| 164 | + if ( ! isset($item['q'])) { |
|
| 165 | 165 | throw new Exception("Expected $item to contain 'q' key"); |
| 166 | 166 | } |
| 167 | - if (! isset($item['limit'])) { |
|
| 167 | + if ( ! isset($item['limit'])) { |
|
| 168 | 168 | throw new Exception("Expected $item to contain 'limit' key"); |
| 169 | 169 | } |
| 170 | 170 | break; |