@@ -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 | { |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | public function findOne($query = [], array $fields = [], array $options = []) |
| 133 | 133 | { |
| 134 | - if (! is_array($query)) { |
|
| 134 | + if ( ! is_array($query)) { |
|
| 135 | 135 | $query = ['filename' => (string) $query]; |
| 136 | 136 | } |
| 137 | 137 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | try { |
| 208 | 208 | $file = $this->insertFile($record, $options); |
| 209 | 209 | } catch (MongoException $e) { |
| 210 | - throw new MongoGridFSException('Could not store file: '. $e->getMessage(), $e->getCode(), $e); |
|
| 210 | + throw new MongoGridFSException('Could not store file: ' . $e->getMessage(), $e->getCode(), $e); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | try { |
@@ -244,10 +244,10 @@ discard block |
||
| 244 | 244 | ]; |
| 245 | 245 | |
| 246 | 246 | $handle = fopen($filename, 'r'); |
| 247 | - if (! $handle) { |
|
| 247 | + if ( ! $handle) { |
|
| 248 | 248 | throw new MongoGridFSException('could not open file: ' . $filename); |
| 249 | 249 | } |
| 250 | - } elseif (! is_resource($filename)) { |
|
| 250 | + } elseif ( ! is_resource($filename)) { |
|
| 251 | 251 | throw new \Exception('first argument must be a string or stream resource'); |
| 252 | 252 | } else { |
| 253 | 253 | $handle = $filename; |
@@ -270,10 +270,10 @@ discard block |
||
| 270 | 270 | |
| 271 | 271 | // Add length and MD5 if they were not present before |
| 272 | 272 | $update = []; |
| 273 | - if (! isset($record['length'])) { |
|
| 273 | + if ( ! isset($record['length'])) { |
|
| 274 | 274 | $update['length'] = $length; |
| 275 | 275 | } |
| 276 | - if (! isset($record['md5'])) { |
|
| 276 | + if ( ! isset($record['md5'])) { |
|
| 277 | 277 | try { |
| 278 | 278 | $update['md5'] = $md5; |
| 279 | 279 | } catch (MongoException $e) { |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | if (count($update)) { |
| 285 | 285 | try { |
| 286 | 286 | $result = $this->update(['_id' => $file['_id']], ['$set' => $update]); |
| 287 | - if (! $this->isOKResult($result)) { |
|
| 287 | + if ( ! $this->isOKResult($result)) { |
|
| 288 | 288 | throw new MongoGridFSException('Could not store file'); |
| 289 | 289 | } |
| 290 | 290 | } catch (MongoException $e) { |
@@ -307,10 +307,10 @@ discard block |
||
| 307 | 307 | */ |
| 308 | 308 | public function storeUpload($name, array $metadata = []) |
| 309 | 309 | { |
| 310 | - if (! isset($_FILES[$name]) || $_FILES[$name]['error'] !== UPLOAD_ERR_OK) { |
|
| 310 | + if ( ! isset($_FILES[$name]) || $_FILES[$name]['error'] !== UPLOAD_ERR_OK) { |
|
| 311 | 311 | throw new MongoGridFSException("Could not find uploaded file $name"); |
| 312 | 312 | } |
| 313 | - if (! isset($_FILES[$name]['tmp_name'])) { |
|
| 313 | + if ( ! isset($_FILES[$name]['tmp_name'])) { |
|
| 314 | 314 | throw new MongoGridFSException("Couldn't find tmp_name in the \$_FILES array. Are you sure the upload worked?"); |
| 315 | 315 | } |
| 316 | 316 | |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | |
| 361 | 361 | $result = $this->chunks->insert($chunk); |
| 362 | 362 | |
| 363 | - if (! $this->isOKResult($result)) { |
|
| 363 | + if ( ! $this->isOKResult($result)) { |
|
| 364 | 364 | throw new \MongoException('error inserting chunk'); |
| 365 | 365 | } |
| 366 | 366 | |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | $hash = hash_init('md5'); |
| 406 | 406 | |
| 407 | 407 | rewind($handle); |
| 408 | - while (! feof($handle)) { |
|
| 408 | + while ( ! feof($handle)) { |
|
| 409 | 409 | $data = stream_get_contents($handle, $chunkSize); |
| 410 | 410 | hash_update($hash, $data); |
| 411 | 411 | $this->insertChunk($fileId, $data, $i++); |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | |
| 436 | 436 | $result = $this->insert($record, $options); |
| 437 | 437 | |
| 438 | - if (! $this->isOKResult($result)) { |
|
| 438 | + if ( ! $this->isOKResult($result)) { |
|
| 439 | 439 | throw new \MongoException('error inserting file'); |
| 440 | 440 | } |
| 441 | 441 | |
@@ -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 | { |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | */ |
| 222 | 222 | public function hasNext() |
| 223 | 223 | { |
| 224 | - if (! $this->startedIterating) { |
|
| 224 | + if ( ! $this->startedIterating) { |
|
| 225 | 225 | $this->ensureIterator(); |
| 226 | 226 | $this->startedIterating = true; |
| 227 | 227 | $this->storeIteratorState(); |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | */ |
| 406 | 406 | protected function convertCursorType() |
| 407 | 407 | { |
| 408 | - if (! $this->tailable) { |
|
| 408 | + if ( ! $this->tailable) { |
|
| 409 | 409 | return null; |
| 410 | 410 | } |
| 411 | 411 | |
@@ -446,7 +446,7 @@ discard block |
||
| 446 | 446 | protected function wrapTraversable(\Traversable $traversable) |
| 447 | 447 | { |
| 448 | 448 | foreach ($traversable as $key => $value) { |
| 449 | - if (isset($value->_id) && ($value->_id instanceof \MongoDB\BSON\ObjectID || !is_object($value->_id))) { |
|
| 449 | + if (isset($value->_id) && ($value->_id instanceof \MongoDB\BSON\ObjectID || ! is_object($value->_id))) { |
|
| 450 | 450 | $key = (string) $value->_id; |
| 451 | 451 | } |
| 452 | 452 | yield $key => $value; |
@@ -21,7 +21,6 @@ |
||
| 21 | 21 | use Alcaeus\MongoDbAdapter\TypeConverter; |
| 22 | 22 | use Alcaeus\MongoDbAdapter\ExceptionConverter; |
| 23 | 23 | use MongoDB\Driver\Cursor; |
| 24 | -use MongoDB\Driver\ReadPreference; |
|
| 25 | 24 | use MongoDB\Operation\Find; |
| 26 | 25 | |
| 27 | 26 | /** |
@@ -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; |
@@ -1018,6 +1018,9 @@ discard block |
||
| 1018 | 1018 | return null; |
| 1019 | 1019 | } |
| 1020 | 1020 | |
| 1021 | + /** |
|
| 1022 | + * @param string $name |
|
| 1023 | + */ |
|
| 1021 | 1024 | private function checkCollectionName($name) |
| 1022 | 1025 | { |
| 1023 | 1026 | if (empty($name)) { |
@@ -1028,7 +1031,7 @@ discard block |
||
| 1028 | 1031 | } |
| 1029 | 1032 | |
| 1030 | 1033 | /** |
| 1031 | - * @return array |
|
| 1034 | + * @return string[] |
|
| 1032 | 1035 | */ |
| 1033 | 1036 | public function __sleep() |
| 1034 | 1037 | { |
@@ -139,7 +139,7 @@ |
||
| 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 | |
@@ -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 | |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | */ |
| 278 | 278 | public function insert(&$a, array $options = []) |
| 279 | 279 | { |
| 280 | - if (! $this->ensureDocumentHasMongoId($a)) { |
|
| 280 | + if ( ! $this->ensureDocumentHasMongoId($a)) { |
|
| 281 | 281 | trigger_error(sprintf('%s(): expects parameter %d to be an array or object, %s given', __METHOD__, 1, gettype($a)), E_USER_WARNING); |
| 282 | 282 | return; |
| 283 | 283 | } |
@@ -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 | |
@@ -888,14 +888,14 @@ discard block |
||
| 888 | 888 | $command = [ |
| 889 | 889 | 'group' => [ |
| 890 | 890 | 'ns' => $this->name, |
| 891 | - '$reduce' => (string)$reduce, |
|
| 891 | + '$reduce' => (string) $reduce, |
|
| 892 | 892 | 'initial' => $initial, |
| 893 | 893 | 'cond' => $condition, |
| 894 | 894 | ], |
| 895 | 895 | ]; |
| 896 | 896 | |
| 897 | 897 | if ($keys instanceof MongoCode) { |
| 898 | - $command['group']['$keyf'] = (string)$keys; |
|
| 898 | + $command['group']['$keyf'] = (string) $keys; |
|
| 899 | 899 | } else { |
| 900 | 900 | $command['group']['key'] = $keys; |
| 901 | 901 | } |
@@ -904,7 +904,7 @@ discard block |
||
| 904 | 904 | } |
| 905 | 905 | if (array_key_exists('finalize', $condition)) { |
| 906 | 906 | if ($condition['finalize'] instanceof MongoCode) { |
| 907 | - $condition['finalize'] = (string)$condition['finalize']; |
|
| 907 | + $condition['finalize'] = (string) $condition['finalize']; |
|
| 908 | 908 | } |
| 909 | 909 | $command['group']['finalize'] = $condition['finalize']; |
| 910 | 910 | } |
@@ -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)) { |
| 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 | } |
@@ -121,6 +121,9 @@ |
||
| 121 | 121 | return $handle; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | + /** |
|
| 125 | + * @param resource $handle |
|
| 126 | + */ |
|
| 124 | 127 | private function copyToResource($handle) |
| 125 | 128 | { |
| 126 | 129 | $written = 0; |
@@ -78,7 +78,7 @@ |
||
| 78 | 78 | $filename = 'file'; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if (! $handle = fopen($filename, 'w')) { |
|
| 81 | + if ( ! $handle = fopen($filename, 'w')) { |
|
| 82 | 82 | trigger_error('Can not open the destination file', E_USER_ERROR); |
| 83 | 83 | return 0; |
| 84 | 84 | } |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | $wstring = (int) $wstring; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - if (! is_string($wstring) && ! is_int($wstring)) { |
|
| 32 | + if ( ! is_string($wstring) && ! is_int($wstring)) { |
|
| 33 | 33 | trigger_error("w for WriteConcern must be a string or integer", E_USER_WARNING); |
| 34 | 34 | return false; |
| 35 | 35 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * Returns the address being used by this for slaveOkay reads |
| 53 | 53 | * |
| 54 | 54 | * @link http://php.net/manual/en/mongo.getslave.php |
| 55 | - * @return bool The address of the secondary this connection is using for |
|
| 55 | + * @return boolean|null The address of the secondary this connection is using for |
|
| 56 | 56 | * reads. This returns NULL if this is not connected to a replica set or not yet |
| 57 | 57 | * initialized. |
| 58 | 58 | */ |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * Get slaveOkay setting for this connection |
| 66 | 66 | * |
| 67 | 67 | * @link http://php.net/manual/en/mongo.getslaveokay.php |
| 68 | - * @return bool Returns the value of slaveOkay for this instance. |
|
| 68 | + * @return boolean|null Returns the value of slaveOkay for this instance. |
|
| 69 | 69 | */ |
| 70 | 70 | public function getSlaveOkay() |
| 71 | 71 | { |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * |
| 78 | 78 | * @link http://www.php.net/manual/en/mongo.pairconnect.php |
| 79 | 79 | * @throws MongoConnectionException |
| 80 | - * @return boolean |
|
| 80 | + * @return boolean|null |
|
| 81 | 81 | * |
| 82 | 82 | * @deprecated Pass a string of the form "mongodb://server1,server2" to the constructor instead of using this method. |
| 83 | 83 | */ |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @link http://php.net/manual/en/mongo.setslaveokay.php |
| 105 | 105 | * @param bool $ok |
| 106 | - * @return bool returns the former value of slaveOkay for this instance. |
|
| 106 | + * @return boolean|null returns the former value of slaveOkay for this instance. |
|
| 107 | 107 | */ |
| 108 | 108 | public function setSlaveOkay($ok) |
| 109 | 109 | { |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * |
| 116 | 116 | * @link http://php.net/manual/en/mongo.setpoolsize.php |
| 117 | 117 | * @param $size <p>The max number of connections future pools will be able to create. Negative numbers mean that the pool will spawn an infinite number of connections.</p> |
| 118 | - * @return bool Returns the former value of pool size. |
|
| 118 | + * @return boolean|null Returns the former value of pool size. |
|
| 119 | 119 | * @deprecated Relying on this feature is highly discouraged. Please use MongoPool::setSize() instead. |
| 120 | 120 | */ |
| 121 | 121 | public function setPoolSize($size) |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * @param string $username A username used to identify the connection. |
| 131 | 131 | * @param string $password A password used to identify the connection. |
| 132 | 132 | * @throws MongoConnectionException |
| 133 | - * @return boolean If the connection was successful. |
|
| 133 | + * @return boolean|null If the connection was successful. |
|
| 134 | 134 | * @deprecated Pass array("persist" => $id) to the constructor instead of using this method. |
| 135 | 135 | */ |
| 136 | 136 | public function persistConnect($username = "", $password = "") |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | * @param string $username A username used to identify the connection. |
| 146 | 146 | * @param string $password A password used to identify the connection. |
| 147 | 147 | * @throws MongoConnectionException |
| 148 | - * @return boolean If the connection was successful. |
|
| 148 | + * @return boolean|null If the connection was successful. |
|
| 149 | 149 | * @deprecated Pass "mongodb://server1,server2" and array("persist" => $id) to the constructor instead of using this method. |
| 150 | 150 | */ |
| 151 | 151 | public function pairPersistConnect($username = "", $password = "") |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * |
| 159 | 159 | * @link http://www.php.net/manual/en/mongo.connectutil.php |
| 160 | 160 | * @throws MongoConnectionException |
| 161 | - * @return boolean If the connection was successful. |
|
| 161 | + * @return boolean|null If the connection was successful. |
|
| 162 | 162 | */ |
| 163 | 163 | protected function connectUtil() |
| 164 | 164 | { |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | * Creates a database error on the database. |
| 218 | 218 | * |
| 219 | 219 | * @link http://www.php.net/manual/en/mongo.forceerror.php |
| 220 | - * @return boolean The database response. |
|
| 220 | + * @return boolean|null The database response. |
|
| 221 | 221 | * @deprecated Use MongoDB::forceError() instead. |
| 222 | 222 | */ |
| 223 | 223 | public function forceError() |
@@ -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) |
@@ -32,13 +32,13 @@ discard block |
||
| 32 | 32 | use Helper\WriteConcern; |
| 33 | 33 | |
| 34 | 34 | const VERSION = '1.6.12'; |
| 35 | - const DEFAULT_HOST = "localhost" ; |
|
| 36 | - const DEFAULT_PORT = 27017 ; |
|
| 37 | - const RP_PRIMARY = "primary" ; |
|
| 38 | - const RP_PRIMARY_PREFERRED = "primaryPreferred" ; |
|
| 39 | - const RP_SECONDARY = "secondary" ; |
|
| 40 | - const RP_SECONDARY_PREFERRED = "secondaryPreferred" ; |
|
| 41 | - const RP_NEAREST = "nearest" ; |
|
| 35 | + const DEFAULT_HOST = "localhost"; |
|
| 36 | + const DEFAULT_PORT = 27017; |
|
| 37 | + const RP_PRIMARY = "primary"; |
|
| 38 | + const RP_PRIMARY_PREFERRED = "primaryPreferred"; |
|
| 39 | + const RP_SECONDARY = "secondary"; |
|
| 40 | + const RP_SECONDARY_PREFERRED = "secondaryPreferred"; |
|
| 41 | + const RP_NEAREST = "nearest"; |
|
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * @var bool |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | $this->server = $server; |
| 92 | 92 | if (false === strpos($this->server, 'mongodb://')) { |
| 93 | - $this->server = 'mongodb://'.$this->server; |
|
| 93 | + $this->server = 'mongodb://' . $this->server; |
|
| 94 | 94 | } |
| 95 | 95 | $this->client = new Client($this->server, $options, $driverOptions); |
| 96 | 96 | $info = $this->client->__debugInfo(); |
@@ -110,7 +110,7 @@ |
||
| 110 | 110 | return false; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - if ($readPreference == \MongoClient::RP_PRIMARY && !empty($tags)) { |
|
| 113 | + if ($readPreference == \MongoClient::RP_PRIMARY && ! empty($tags)) { |
|
| 114 | 114 | trigger_error("You can't use read preference tags with a read preference of PRIMARY", E_USER_WARNING); |
| 115 | 115 | return false; |
| 116 | 116 | } |