Completed
Push — v5 ( a234cb...4f37c0 )
by Georges
02:54
created
src/phpFastCache/Drivers/Devnull/Driver.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
 
58 58
     /**
59 59
      * @param \Psr\Cache\CacheItemInterface $item
60
-     * @return mixed
60
+     * @return boolean
61 61
      * @throws \InvalidArgumentException
62 62
      */
63 63
     public function driverWrite(CacheItemInterface $item)
Please login to merge, or discard this patch.
src/phpFastCache/Drivers/Mongodb/Driver.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
                 return false;
93 93
             }
94 94
 
95
-            return isset($result[ 'ok' ]) ? $result[ 'ok' ] == 1 : true;
95
+            return isset($result['ok']) ? $result['ok'] == 1 : true;
96 96
         } else {
97 97
             throw new \InvalidArgumentException('Cross-Driver type confusion detected');
98 98
         }
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
 
109 109
         if ($document) {
110 110
             return [
111
-              self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->bin),
112
-              self::DRIVER_TIME_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_TIME_WRAPPER_INDEX ]->sec),
113
-              self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->bin),
111
+              self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[self::DRIVER_DATA_WRAPPER_INDEX]->bin),
112
+              self::DRIVER_TIME_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_TIME_WRAPPER_INDEX]->sec),
113
+              self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[self::DRIVER_TAGS_WRAPPER_INDEX]->bin),
114 114
             ];
115 115
         } else {
116 116
             return null;
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
         if ($item instanceof Item) {
131 131
             $deletionResult = (array) $this->getCollection()->remove(['_id' => $item->getKey()], ["w" => 1]);
132 132
 
133
-            return (int) $deletionResult[ 'ok' ] === 1 && !$deletionResult[ 'err' ];
133
+            return (int) $deletionResult['ok'] === 1 && !$deletionResult['err'];
134 134
         } else {
135 135
             throw new \InvalidArgumentException('Cross-Driver type confusion detected');
136 136
         }
@@ -154,11 +154,11 @@  discard block
 block discarded – undo
154 154
         if ($this->instance instanceof MongodbClient) {
155 155
             throw new LogicException('Already connected to Mongodb server');
156 156
         } else {
157
-            $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1';
158
-            $port = isset($server[ 'port' ]) ? $server[ 'port' ] : '27017';
159
-            $timeout = isset($server[ 'timeout' ]) ? $server[ 'timeout' ] : 3;
160
-            $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : '';
161
-            $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : '';
157
+            $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1';
158
+            $port = isset($server['port']) ? $server['port'] : '27017';
159
+            $timeout = isset($server['timeout']) ? $server['timeout'] : 3;
160
+            $password = isset($this->config['password']) ? $this->config['password'] : '';
161
+            $username = isset($this->config['username']) ? $this->config['username'] : '';
162 162
 
163 163
 
164 164
             /**
@@ -206,8 +206,8 @@  discard block
 block discarded – undo
206 206
         ]);
207 207
 
208 208
         $stats = (new driverStatistic())
209
-          ->setInfo('MongoDB version ' . $serverStatus[ 'version' ] . ', Uptime (in days): ' . round($serverStatus[ 'uptime' ] / 86400, 1) . "\n For more information see RawData.")
210
-          ->setSize((int) $collStats[ 'size' ])
209
+          ->setInfo('MongoDB version ' . $serverStatus['version'] . ', Uptime (in days): ' . round($serverStatus['uptime'] / 86400, 1) . "\n For more information see RawData.")
210
+          ->setSize((int) $collStats['size'])
211 211
           ->setData(implode(', ', array_keys($this->itemInstances)))
212 212
           ->setRawData([
213 213
             'serverStatus' => $serverStatus,
Please login to merge, or discard this patch.
src/phpFastCache/Drivers/Sqlite/Driver.php 2 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 
152 152
             $PDO = new PDO("sqlite:" . $this->SqliteDir . '/' . self::INDEXING_FILE);
153 153
             $PDO->setAttribute(PDO::ATTR_ERRMODE,
154
-              PDO::ERRMODE_EXCEPTION);
154
+                PDO::ERRMODE_EXCEPTION);
155 155
 
156 156
             if ($createTable == true) {
157 157
                 $this->initIndexing($PDO);
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         // look for keyword
187 187
         $stm = $this->indexing->prepare("SELECT * FROM `balancing` WHERE `keyword`=:keyword LIMIT 1");
188 188
         $stm->execute([
189
-          ':keyword' => $keyword,
189
+            ':keyword' => $keyword,
190 190
         ]);
191 191
         $row = $stm->fetch(PDO::FETCH_ASSOC);
192 192
         if (isset($row[ 'db' ]) && $row[ 'db' ] != '') {
@@ -198,8 +198,8 @@  discard block
 block discarded – undo
198 198
             $db = $this->currentDB;
199 199
             $stm = $this->indexing->prepare("INSERT INTO `balancing` (`keyword`,`db`) VALUES(:keyword, :db)");
200 200
             $stm->execute([
201
-              ':keyword' => $keyword,
202
-              ':db' => $db,
201
+                ':keyword' => $keyword,
202
+                ':db' => $db,
203 203
             ]);
204 204
         }
205 205
 
@@ -270,11 +270,11 @@  discard block
 block discarded – undo
270 270
             if ($toWrite == true) {
271 271
                 try {
272 272
                     $stm = $this->getDb($item->getKey())
273
-                      ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)");
273
+                        ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)");
274 274
                     $stm->execute([
275
-                      ':keyword' => $item->getKey(),
276
-                      ':object' => $this->encode($this->driverPreWrap($item)),
277
-                      ':exp' => time() + $item->getTtl(),
275
+                        ':keyword' => $item->getKey(),
276
+                        ':object' => $this->encode($this->driverPreWrap($item)),
277
+                        ':exp' => time() + $item->getTtl(),
278 278
                     ]);
279 279
 
280 280
                     return true;
@@ -282,11 +282,11 @@  discard block
 block discarded – undo
282 282
 
283 283
                     try {
284 284
                         $stm = $this->getDb($item->getKey(), true)
285
-                          ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)");
285
+                            ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)");
286 286
                         $stm->execute([
287
-                          ':keyword' => $item->getKey(),
288
-                          ':object' => $this->encode($this->driverPreWrap($item)),
289
-                          ':exp' => time() + $item->getTtl(),
287
+                            ':keyword' => $item->getKey(),
288
+                            ':object' => $this->encode($this->driverPreWrap($item)),
289
+                            ':exp' => time() + $item->getTtl(),
290 290
                         ]);
291 291
                     } catch (PDOException $e) {
292 292
                         return false;
@@ -308,20 +308,20 @@  discard block
 block discarded – undo
308 308
     {
309 309
         try {
310 310
             $stm = $this->getDb($item->getKey())
311
-              ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U)  LIMIT 1");
311
+                ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U)  LIMIT 1");
312 312
             $stm->execute([
313
-              ':keyword' => $item->getKey(),
314
-              ':U' => time(),
313
+                ':keyword' => $item->getKey(),
314
+                ':U' => time(),
315 315
             ]);
316 316
             $row = $stm->fetch(PDO::FETCH_ASSOC);
317 317
 
318 318
         } catch (PDOException $e) {
319 319
             try {
320 320
                 $stm = $this->getDb($item->getKey(), true)
321
-                  ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U)  LIMIT 1");
321
+                    ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U)  LIMIT 1");
322 322
                 $stm->execute([
323
-                  ':keyword' => $item->getKey(),
324
-                  ':U' => time(),
323
+                    ':keyword' => $item->getKey(),
324
+                    ':U' => time(),
325 325
                 ]);
326 326
                 $row = $stm->fetch(PDO::FETCH_ASSOC);
327 327
             } catch (PDOException $e) {
@@ -359,13 +359,13 @@  discard block
 block discarded – undo
359 359
         if ($item instanceof Item) {
360 360
             try {
361 361
                 $stm = $this->getDb($item->getKey())
362
-                  //->prepare("DELETE FROM `caching` WHERE (`id`=:id) OR (`exp` <= :U) ");
363
-                  ->prepare("DELETE FROM `caching` WHERE (`exp` <= :U) OR (`keyword`=:keyword) ");
362
+                    //->prepare("DELETE FROM `caching` WHERE (`id`=:id) OR (`exp` <= :U) ");
363
+                    ->prepare("DELETE FROM `caching` WHERE (`exp` <= :U) OR (`keyword`=:keyword) ");
364 364
 
365 365
                 return $stm->execute([
366 366
                     // ':id' => $row[ 'id' ],
367
-                  ':keyword' => $item->getKey(),
368
-                  ':U' => time(),
367
+                    ':keyword' => $item->getKey(),
368
+                    ':U' => time(),
369 369
                 ]);
370 370
             } catch (PDOException $e) {
371 371
                 return false;
@@ -428,9 +428,9 @@  discard block
 block discarded – undo
428 428
         }
429 429
 
430 430
         $stat->setData(implode(', ', array_keys($this->itemInstances)))
431
-          ->setRawData([])
432
-          ->setSize(Directory::dirSize($path))
433
-          ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path));
431
+            ->setRawData([])
432
+            ->setSize(Directory::dirSize($path))
433
+            ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path));
434 434
 
435 435
         return $stat;
436 436
     }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -162,12 +162,12 @@  discard block
 block discarded – undo
162 162
             $stm = $this->indexing->prepare("SELECT MAX(`db`) as `db` FROM `balancing`");
163 163
             $stm->execute();
164 164
             $row = $stm->fetch(PDO::FETCH_ASSOC);
165
-            if (!isset($row[ 'db' ])) {
165
+            if (!isset($row['db'])) {
166 166
                 $db = 1;
167
-            } elseif ($row[ 'db' ] <= 1) {
167
+            } elseif ($row['db'] <= 1) {
168 168
                 $db = 1;
169 169
             } else {
170
-                $db = $row[ 'db' ];
170
+                $db = $row['db'];
171 171
             }
172 172
 
173 173
             // check file size
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
           ':keyword' => $keyword,
190 190
         ]);
191 191
         $row = $stm->fetch(PDO::FETCH_ASSOC);
192
-        if (isset($row[ 'db' ]) && $row[ 'db' ] != '') {
193
-            $db = $row[ 'db' ];
192
+        if (isset($row['db']) && $row['db'] != '') {
193
+            $db = $row['db'];
194 194
         } else {
195 195
             /*
196 196
              * Insert new to Indexing
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
         /**
222 222
          * init instant
223 223
          */
224
-        if (!isset($this->instance[ $instant ])) {
224
+        if (!isset($this->instance[$instant])) {
225 225
             // check DB Files ready or not
226 226
             $createTable = false;
227 227
             if (!file_exists($this->SqliteDir . '/db' . $instant) || $reset == true) {
@@ -234,12 +234,12 @@  discard block
 block discarded – undo
234 234
                 $this->initDB($PDO);
235 235
             }
236 236
 
237
-            $this->instance[ $instant ] = $PDO;
237
+            $this->instance[$instant] = $PDO;
238 238
             unset($PDO);
239 239
 
240 240
         }
241 241
 
242
-        return $this->instance[ $instant ];
242
+        return $this->instance[$instant];
243 243
     }
244 244
 
245 245
     /**
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
          * Check for Cross-Driver type confusion
254 254
          */
255 255
         if ($item instanceof Item) {
256
-            $skipExisting = isset($this->config[ 'skipExisting' ]) ? $this->config[ 'skipExisting' ] : false;
256
+            $skipExisting = isset($this->config['skipExisting']) ? $this->config['skipExisting'] : false;
257 257
             $toWrite = true;
258 258
 
259 259
             // check in cache first
@@ -329,18 +329,18 @@  discard block
 block discarded – undo
329 329
             }
330 330
         }
331 331
 
332
-        if (isset($row[ 'id' ])) {
332
+        if (isset($row['id'])) {
333 333
             /**
334 334
              * @var $item ExtendedCacheItemInterface
335 335
              */
336
-            $item = $this->decode($row[ 'object' ]);
336
+            $item = $this->decode($row['object']);
337 337
             if ($item instanceof ExtendedCacheItemInterface && $item->isExpired()) {
338 338
                 $this->driverDelete($item);
339 339
 
340 340
                 return null;
341 341
             }
342 342
 
343
-            return $this->decode($row[ 'object' ]);
343
+            return $this->decode($row['object']);
344 344
         }
345 345
 
346 346
         return null;
Please login to merge, or discard this patch.
src/phpFastCache/Cache/ItemBaseTrait.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
      */
115 115
     public function setHit($isHit)
116 116
     {
117
-        if(is_bool($isHit)){
117
+        if (is_bool($isHit)) {
118 118
             $this->isHit = $isHit;
119 119
             return $this;
120
-        }else{
120
+        } else {
121 121
             throw new \InvalidArgumentException('$isHit must be a boolean');
122 122
         }
123 123
     }
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
     public function removeTag($tagName)
370 370
     {
371 371
         if (($key = array_search($tagName, $this->tags)) !== false) {
372
-            unset($this->tags[ $key ]);
372
+            unset($this->tags[$key]);
373 373
             $this->removedTags[] = $tagName;
374 374
         }
375 375
 
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
     final public function __debugInfo()
416 416
     {
417 417
         $info = get_object_vars($this);
418
-        $info[ 'driver' ] = 'object(' . get_class($info[ 'driver' ]) . ')';
418
+        $info['driver'] = 'object(' . get_class($info['driver']) . ')';
419 419
 
420 420
         return (array) $info;
421 421
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -273,7 +273,7 @@
 block discarded – undo
273 273
         
274 274
         if (!is_dir($path)) {
275 275
             throw new phpFastCacheDriverException("Can't read PATH:" . $path, 94);
276
-        }else{
276
+        } else{
277 277
             $size = Directory::dirSize($path);
278 278
         }
279 279
 
Please login to merge, or discard this patch.
src/phpFastCache/Core/StandardPsr6StructureTrait.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
                          * getItem() call in delete() method
66 66
                          */
67 67
                         $this->driverDelete($item);
68
-                    }else{
68
+                    } else {
69 69
                         $item->setHit(true);
70 70
                     }
71 71
                 }
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
             throw new \InvalidArgumentException(sprintf('$key must be a string, got type "%s" instead.', gettype($key)));
76 76
         }
77 77
 
78
-        return $this->itemInstances[ $key ];
78
+        return $this->itemInstances[$key];
79 79
     }
80 80
 
81 81
     /**
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
     public function setItem(CacheItemInterface $item)
87 87
     {
88 88
         if ($this->getClassNamespace() . '\\Item' === get_class($item)) {
89
-            $this->itemInstances[ $item->getKey() ] = $item;
89
+            $this->itemInstances[$item->getKey()] = $item;
90 90
 
91 91
             return $this;
92 92
         } else {
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
     {
104 104
         $collection = [];
105 105
         foreach ($keys as $key) {
106
-            $collection[ $key ] = $this->getItem($key);
106
+            $collection[$key] = $this->getItem($key);
107 107
         }
108 108
 
109 109
         return $collection;
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
         if ($this->hasItem($key) && $this->driverDelete($item)) {
147 147
             $item->setHit(false);
148 148
             CacheManager::$WriteHits++;
149
-            unset($this->itemInstances[ $key ]);
149
+            unset($this->itemInstances[$key]);
150 150
 
151 151
             return true;
152 152
         }
@@ -183,9 +183,9 @@  discard block
 block discarded – undo
183 183
          * @var ExtendedCacheItemInterface $item
184 184
          */
185 185
         if (!array_key_exists($item->getKey(), $this->itemInstances)) {
186
-            $this->itemInstances[ $item->getKey() ] = $item;
186
+            $this->itemInstances[$item->getKey()] = $item;
187 187
         }
188
-        if($this->driverWrite($item) && $this->driverWriteTags($item))
188
+        if ($this->driverWrite($item) && $this->driverWriteTags($item))
189 189
         {
190 190
             $item->setHit(true);
191 191
             CacheManager::$WriteHits++;
@@ -202,10 +202,10 @@  discard block
 block discarded – undo
202 202
     public function saveDeferred(CacheItemInterface $item)
203 203
     {
204 204
         if (!array_key_exists($item->getKey(), $this->itemInstances)) {
205
-            $this->itemInstances[ $item->getKey() ] = $item;
205
+            $this->itemInstances[$item->getKey()] = $item;
206 206
         }
207 207
 
208
-        return $this->deferredList[ $item->getKey() ] = $item;
208
+        return $this->deferredList[$item->getKey()] = $item;
209 209
     }
210 210
 
211 211
     /**
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
         foreach ($this->deferredList as $key => $item) {
219 219
             $result = $this->save($item);
220 220
             if ($return !== false) {
221
-                unset($this->deferredList[ $key ]);
221
+                unset($this->deferredList[$key]);
222 222
                 $return = $result;
223 223
             }
224 224
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@
 block discarded – undo
65 65
                          * getItem() call in delete() method
66 66
                          */
67 67
                         $this->driverDelete($item);
68
-                    }else{
68
+                    } else{
69 69
                         $item->setHit(true);
70 70
                     }
71 71
                 }
Please login to merge, or discard this patch.