@@ -43,7 +43,7 @@ |
||
| 43 | 43 | return; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - if (! preg_match('#^/(.*)/([imxslu]*)$#', $regex, $matches)) { |
|
| 46 | + if ( ! preg_match('#^/(.*)/([imxslu]*)$#', $regex, $matches)) { |
|
| 47 | 47 | throw new MongoException('invalid regex', 9); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -17,11 +17,14 @@ |
||
| 17 | 17 | * <p>(PECL mongo >= 1.5.0)</p> |
| 18 | 18 | * @link http://php.net/manual/en/class.mongowriteconcernexception.php#class.mongowriteconcernexception |
| 19 | 19 | */ |
| 20 | -class MongoWriteConcernException extends MongoCursorException { |
|
| 20 | +class MongoWriteConcernException extends MongoCursorException |
|
| 21 | +{ |
|
| 21 | 22 | /** |
| 22 | 23 | * Get the error document |
| 23 | 24 | * @link http://php.net/manual/en/mongowriteconcernexception.getdocument.php |
| 24 | 25 | * @return array <p>A MongoDB document, if available, as an array.</p> |
| 25 | 26 | */ |
| 26 | - public function getDocument() {} |
|
| 27 | + public function getDocument() |
|
| 28 | + { |
|
| 29 | +} |
|
| 27 | 30 | } |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | * |
| 36 | 36 | * @link http://php.net/manual/en/mongopool.setsize.php |
| 37 | 37 | * @param int $size |
| 38 | - * @return boolean Returns the former value of pool size |
|
| 38 | + * @return integer Returns the former value of pool size |
|
| 39 | 39 | */ |
| 40 | 40 | public static function setSize($size) |
| 41 | 41 | { |
@@ -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; |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * Delete a file from the database |
| 81 | 81 | * |
| 82 | 82 | * @link http://php.net/manual/en/mongogridfs.delete.php |
| 83 | - * @param mixed $id _id of the file to remove |
|
| 83 | + * @param MongoId $id _id of the file to remove |
|
| 84 | 84 | * @return boolean Returns true if the remove was successfully sent to the database. |
| 85 | 85 | */ |
| 86 | 86 | public function delete($id) |
@@ -106,7 +106,6 @@ discard block |
||
| 106 | 106 | * @link http://php.net/manual/en/mongogridfs.find.php |
| 107 | 107 | * @param array $query The query |
| 108 | 108 | * @param array $fields Fields to return |
| 109 | - * @param array $options Options for the find command |
|
| 110 | 109 | * @return MongoGridFSCursor A MongoGridFSCursor |
| 111 | 110 | */ |
| 112 | 111 | public function find(array $query = [], array $fields = []) |
@@ -155,7 +154,7 @@ discard block |
||
| 155 | 154 | * @param string $filename The name of the file |
| 156 | 155 | * @param array $extra Other metadata to add to the file saved |
| 157 | 156 | * @param array $options An array of options for the insert operations executed against the chunks and files collections. |
| 158 | - * @return mixed Returns the _id of the saved object |
|
| 157 | + * @return MongoId Returns the _id of the saved object |
|
| 159 | 158 | */ |
| 160 | 159 | public function put($filename, array $extra = [], array $options = []) |
| 161 | 160 | { |
@@ -190,7 +189,7 @@ discard block |
||
| 190 | 189 | * @param string $bytes A string of bytes to store |
| 191 | 190 | * @param array $extra Other metadata to add to the file saved |
| 192 | 191 | * @param array $options Options for the store. "safe": Check that this store succeeded |
| 193 | - * @return mixed The _id of the object saved |
|
| 192 | + * @return MongoId The _id of the object saved |
|
| 194 | 193 | */ |
| 195 | 194 | public function storeBytes($bytes, array $extra = [], array $options = []) |
| 196 | 195 | { |
@@ -224,7 +223,7 @@ discard block |
||
| 224 | 223 | * @param string $filename The name of the file |
| 225 | 224 | * @param array $extra Other metadata to add to the file saved |
| 226 | 225 | * @param array $options Options for the store. "safe": Check that this store succeeded |
| 227 | - * @return mixed Returns the _id of the saved object |
|
| 226 | + * @return MongoId Returns the _id of the saved object |
|
| 228 | 227 | * @throws MongoGridFSException |
| 229 | 228 | * @throws Exception |
| 230 | 229 | */ |
@@ -299,7 +298,7 @@ discard block |
||
| 299 | 298 | * @link http://www.php.net/manual/en/mongogridfs.storeupload.php |
| 300 | 299 | * @param string $name The name attribute of the uploaded file, from <input type="file" name="something"/>. |
| 301 | 300 | * @param array $metadata An array of extra fields for the uploaded file. |
| 302 | - * @return mixed Returns the _id of the uploaded file. |
|
| 301 | + * @return null|MongoId Returns the _id of the uploaded file. |
|
| 303 | 302 | * @throws MongoGridFSException |
| 304 | 303 | */ |
| 305 | 304 | public function storeUpload($name, array $metadata = []) |
@@ -436,7 +435,7 @@ discard block |
||
| 436 | 435 | /** |
| 437 | 436 | * Returns the MD5 string for a file previously stored to the database |
| 438 | 437 | * |
| 439 | - * @param $id |
|
| 438 | + * @param MongoId $id |
|
| 440 | 439 | * @return string |
| 441 | 440 | */ |
| 442 | 441 | private function getMd5ForFile($id) |
@@ -241,10 +241,10 @@ discard block |
||
| 241 | 241 | ]; |
| 242 | 242 | |
| 243 | 243 | $handle = fopen($filename, 'r'); |
| 244 | - if (! $handle) { |
|
| 244 | + if ( ! $handle) { |
|
| 245 | 245 | throw new MongoGridFSException('could not open file: ' . $filename); |
| 246 | 246 | } |
| 247 | - } elseif (! is_resource($filename)) { |
|
| 247 | + } elseif ( ! is_resource($filename)) { |
|
| 248 | 248 | throw new \Exception('first argument must be a string or stream resource'); |
| 249 | 249 | } else { |
| 250 | 250 | $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'] = $this->getMd5ForFile($file['_id']); |
| 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('Error updating file record'); |
| 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 | |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | $chunkSize = $record['chunkSize']; |
| 400 | 400 | |
| 401 | 401 | rewind($handle); |
| 402 | - while (! feof($handle)) { |
|
| 402 | + while ( ! feof($handle)) { |
|
| 403 | 403 | $data = stream_get_contents($handle, $chunkSize); |
| 404 | 404 | $this->insertChunk($fileId, $data, $i++); |
| 405 | 405 | $written += strlen($data); |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | |
| 427 | 427 | $result = $this->insert($record, $options); |
| 428 | 428 | |
| 429 | - if (! $this->isOKResult($result)) { |
|
| 429 | + if ( ! $this->isOKResult($result)) { |
|
| 430 | 430 | throw new \MongoException('error inserting file'); |
| 431 | 431 | } |
| 432 | 432 | |
@@ -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 | } |