@@ -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; |
@@ -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 | { |
@@ -214,7 +213,7 @@ discard block |
||
| 214 | 213 | * @param string $filename The name of the file |
| 215 | 214 | * @param array $extra Other metadata to add to the file saved |
| 216 | 215 | * @param array $options Options for the store. "safe": Check that this store succeeded |
| 217 | - * @return mixed Returns the _id of the saved object |
|
| 216 | + * @return MongoId Returns the _id of the saved object |
|
| 218 | 217 | * @throws MongoGridFSException |
| 219 | 218 | * @throws Exception |
| 220 | 219 | */ |
@@ -265,7 +264,7 @@ discard block |
||
| 265 | 264 | * @link http://www.php.net/manual/en/mongogridfs.storeupload.php |
| 266 | 265 | * @param string $name The name attribute of the uploaded file, from <input type="file" name="something"/>. |
| 267 | 266 | * @param array $metadata An array of extra fields for the uploaded file. |
| 268 | - * @return mixed Returns the _id of the uploaded file. |
|
| 267 | + * @return null|MongoId Returns the _id of the uploaded file. |
|
| 269 | 268 | * @throws MongoGridFSException |
| 270 | 269 | */ |
| 271 | 270 | public function storeUpload($name, array $metadata = []) |
@@ -388,7 +387,7 @@ discard block |
||
| 388 | 387 | /** |
| 389 | 388 | * Returns the MD5 string for a file previously stored to the database |
| 390 | 389 | * |
| 391 | - * @param $id |
|
| 390 | + * @param MongoId $id |
|
| 392 | 391 | * @return string |
| 393 | 392 | */ |
| 394 | 393 | private function getMd5ForFile($id) |
@@ -231,10 +231,10 @@ discard block |
||
| 231 | 231 | ]; |
| 232 | 232 | |
| 233 | 233 | $handle = fopen($filename, 'r'); |
| 234 | - if (! $handle) { |
|
| 234 | + if ( ! $handle) { |
|
| 235 | 235 | throw new MongoGridFSException('could not open file: ' . $filename); |
| 236 | 236 | } |
| 237 | - } elseif (! is_resource($filename)) { |
|
| 237 | + } elseif ( ! is_resource($filename)) { |
|
| 238 | 238 | throw new \Exception('first argument must be a string or stream resource'); |
| 239 | 239 | } else { |
| 240 | 240 | $handle = $filename; |
@@ -245,10 +245,10 @@ discard block |
||
| 245 | 245 | |
| 246 | 246 | // Add length and MD5 if they were not present before |
| 247 | 247 | $update = []; |
| 248 | - if (! isset($record['length'])) { |
|
| 248 | + if ( ! isset($record['length'])) { |
|
| 249 | 249 | $update['length'] = $length; |
| 250 | 250 | } |
| 251 | - if (! isset($record['md5'])) { |
|
| 251 | + if ( ! isset($record['md5'])) { |
|
| 252 | 252 | $update['md5'] = $this->getMd5ForFile($file['_id']); |
| 253 | 253 | } |
| 254 | 254 | |
@@ -270,10 +270,10 @@ discard block |
||
| 270 | 270 | */ |
| 271 | 271 | public function storeUpload($name, array $metadata = []) |
| 272 | 272 | { |
| 273 | - if (! isset($_FILES[$name]) || $_FILES[$name]['error'] !== UPLOAD_ERR_OK) { |
|
| 273 | + if ( ! isset($_FILES[$name]) || $_FILES[$name]['error'] !== UPLOAD_ERR_OK) { |
|
| 274 | 274 | throw new MongoGridFSException("Could not find uploaded file $name"); |
| 275 | 275 | } |
| 276 | - if (! isset($_FILES[$name]['tmp_name'])) { |
|
| 276 | + if ( ! isset($_FILES[$name]['tmp_name'])) { |
|
| 277 | 277 | throw new MongoGridFSException("Couldn't find tmp_name in the \$_FILES array. Are you sure the upload worked?"); |
| 278 | 278 | } |
| 279 | 279 | |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | $chunkSize = $record['chunkSize']; |
| 356 | 356 | |
| 357 | 357 | rewind($handle); |
| 358 | - while (! feof($handle)) { |
|
| 358 | + while ( ! feof($handle)) { |
|
| 359 | 359 | $data = stream_get_contents($handle, $chunkSize); |
| 360 | 360 | $this->insertChunk($fileId, $data, $i++); |
| 361 | 361 | $written += strlen($data); |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | * |
| 27 | 27 | * @see http://php.net/manual/en/mongoupdatebatch.construct.php |
| 28 | 28 | * @param MongoCollection $collection |
| 29 | - * @param array $writeOptions |
|
| 29 | + * @param array $writeOption |
|
| 30 | 30 | */ |
| 31 | 31 | public function __construct(MongoCollection $collection, array $writeOption = []) |
| 32 | 32 | { |
@@ -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 | } |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | * |
| 27 | 27 | * @see http://php.net/manual/en/mongoupdatebatch.construct.php |
| 28 | 28 | * @param MongoCollection $collection |
| 29 | - * @param array $writeOptions |
|
| 29 | + * @param array $writeOption |
|
| 30 | 30 | */ |
| 31 | 31 | public function __construct(MongoCollection $collection, array $writeOption = []) |
| 32 | 32 | { |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | * |
| 27 | 27 | * @see http://php.net/manual/en/mongoupdatebatch.construct.php |
| 28 | 28 | * @param MongoCollection $collection |
| 29 | - * @param array $writeOptions |
|
| 29 | + * @param array $writeOption |
|
| 30 | 30 | */ |
| 31 | 31 | public function __construct(MongoCollection $collection, array $writeOption = []) |
| 32 | 32 | { |
@@ -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 | |
@@ -142,13 +142,13 @@ discard block |
||
| 142 | 142 | { |
| 143 | 143 | switch ($this->batchType) { |
| 144 | 144 | case self::COMMAND_UPDATE: |
| 145 | - if (! isset($item['q']) || ! isset($item['u'])) { |
|
| 145 | + if ( ! isset($item['q']) || ! isset($item['u'])) { |
|
| 146 | 146 | throw new Exception('invalid item'); |
| 147 | 147 | } |
| 148 | 148 | break; |
| 149 | 149 | |
| 150 | 150 | case self::COMMAND_DELETE: |
| 151 | - if (! isset($item['q']) || ! isset($item['limit'])) { |
|
| 151 | + if ( ! isset($item['q']) || ! isset($item['limit'])) { |
|
| 152 | 152 | throw new Exception('invalid item'); |
| 153 | 153 | } |
| 154 | 154 | break; |