@@ -119,7 +119,7 @@ |
||
| 119 | 119 | * <ul> |
| 120 | 120 | * @return boolean Returns <b>TRUE</b> on success or <b>FALSE</b> on failure. |
| 121 | 121 | */ |
| 122 | - public static function setCallback(callable $log_function ) |
|
| 122 | + public static function setCallback(callable $log_function) |
|
| 123 | 123 | { |
| 124 | 124 | self::$callback = $log_function; |
| 125 | 125 | return true; |
@@ -65,6 +65,6 @@ |
||
| 65 | 65 | public function key() |
| 66 | 66 | { |
| 67 | 67 | $file = $this->current(); |
| 68 | - return ($file !== null) ? (string)$file->file['_id'] : null; |
|
| 68 | + return ($file !== null) ? (string) $file->file['_id'] : null; |
|
| 69 | 69 | } |
| 70 | 70 | } |
@@ -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 | * |
@@ -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; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | public function current() |
| 120 | 120 | { |
| 121 | - if (! $this->startedIterating) { |
|
| 121 | + if ( ! $this->startedIterating) { |
|
| 122 | 122 | return null; |
| 123 | 123 | } |
| 124 | 124 | |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | public function key() |
| 139 | 139 | { |
| 140 | - if (! $this->startedIterating) { |
|
| 140 | + if ( ! $this->startedIterating) { |
|
| 141 | 141 | return null; |
| 142 | 142 | } |
| 143 | 143 | |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | public function next() |
| 155 | 155 | { |
| 156 | - if (! $this->startedIterating) { |
|
| 156 | + if ( ! $this->startedIterating) { |
|
| 157 | 157 | $this->ensureIterator(); |
| 158 | 158 | $this->startedIterating = true; |
| 159 | 159 | } else { |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | */ |
| 187 | 187 | public function valid() |
| 188 | 188 | { |
| 189 | - if (! $this->startedIterating) { |
|
| 189 | + if ( ! $this->startedIterating) { |
|
| 190 | 190 | return false; |
| 191 | 191 | } |
| 192 | 192 | |
@@ -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 | { |
@@ -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 | } |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | * @link http://www.php.net/manual/en/mongoclient.killcursor.php |
| 229 | 229 | * @param string $server_hash The server hash that has the cursor. |
| 230 | 230 | * @param int|MongoInt64 $id The ID of the cursor to kill. |
| 231 | - * @return bool |
|
| 231 | + * @return boolean|null |
|
| 232 | 232 | */ |
| 233 | 233 | public function killCursor($server_hash , $id) |
| 234 | 234 | { |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | /** |
| 339 | - * @return array |
|
| 339 | + * @return string[] |
|
| 340 | 340 | */ |
| 341 | 341 | function __sleep() |
| 342 | 342 | { |
@@ -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 | |