Completed
Push — V6 ( ddfc29...839d12 )
by Georges
03:14
created
src/phpFastCache/Drivers/Sqlite/Driver.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 
154 154
             $PDO = new PDO("sqlite:" . $this->SqliteDir . '/' . self::INDEXING_FILE);
155 155
             $PDO->setAttribute(PDO::ATTR_ERRMODE,
156
-              PDO::ERRMODE_EXCEPTION);
156
+                PDO::ERRMODE_EXCEPTION);
157 157
 
158 158
             if ($createTable == true) {
159 159
                 $this->initIndexing($PDO);
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
         // look for keyword
189 189
         $stm = $this->indexing->prepare("SELECT * FROM `balancing` WHERE `keyword`=:keyword LIMIT 1");
190 190
         $stm->execute([
191
-          ':keyword' => $keyword,
191
+            ':keyword' => $keyword,
192 192
         ]);
193 193
         $row = $stm->fetch(PDO::FETCH_ASSOC);
194 194
         if (isset($row[ 'db' ]) && $row[ 'db' ] != '') {
@@ -200,8 +200,8 @@  discard block
 block discarded – undo
200 200
             $db = $this->currentDB;
201 201
             $stm = $this->indexing->prepare("INSERT INTO `balancing` (`keyword`,`db`) VALUES(:keyword, :db)");
202 202
             $stm->execute([
203
-              ':keyword' => $keyword,
204
-              ':db' => $db,
203
+                ':keyword' => $keyword,
204
+                ':db' => $db,
205 205
             ]);
206 206
         }
207 207
 
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
             if ($toWrite == true) {
273 273
                 try {
274 274
                     $stm = $this->getDb($item->getKey())
275
-                      ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)");
275
+                        ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)");
276 276
                     $stm->execute([
277
-                      ':keyword' => $item->getKey(),
278
-                      ':object' => $this->encode($this->driverPreWrap($item)),
279
-                      ':exp' => time() + $item->getTtl(),
277
+                        ':keyword' => $item->getKey(),
278
+                        ':object' => $this->encode($this->driverPreWrap($item)),
279
+                        ':exp' => time() + $item->getTtl(),
280 280
                     ]);
281 281
 
282 282
                     return true;
@@ -284,11 +284,11 @@  discard block
 block discarded – undo
284 284
 
285 285
                     try {
286 286
                         $stm = $this->getDb($item->getKey(), true)
287
-                          ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)");
287
+                            ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)");
288 288
                         $stm->execute([
289
-                          ':keyword' => $item->getKey(),
290
-                          ':object' => $this->encode($this->driverPreWrap($item)),
291
-                          ':exp' => time() + $item->getTtl(),
289
+                            ':keyword' => $item->getKey(),
290
+                            ':object' => $this->encode($this->driverPreWrap($item)),
291
+                            ':exp' => time() + $item->getTtl(),
292 292
                         ]);
293 293
                     } catch (PDOException $e) {
294 294
                         return false;
@@ -310,20 +310,20 @@  discard block
 block discarded – undo
310 310
     {
311 311
         try {
312 312
             $stm = $this->getDb($item->getKey())
313
-              ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U)  LIMIT 1");
313
+                ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U)  LIMIT 1");
314 314
             $stm->execute([
315
-              ':keyword' => $item->getKey(),
316
-              ':U' => time(),
315
+                ':keyword' => $item->getKey(),
316
+                ':U' => time(),
317 317
             ]);
318 318
             $row = $stm->fetch(PDO::FETCH_ASSOC);
319 319
 
320 320
         } catch (PDOException $e) {
321 321
             try {
322 322
                 $stm = $this->getDb($item->getKey(), true)
323
-                  ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U)  LIMIT 1");
323
+                    ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U)  LIMIT 1");
324 324
                 $stm->execute([
325
-                  ':keyword' => $item->getKey(),
326
-                  ':U' => time(),
325
+                    ':keyword' => $item->getKey(),
326
+                    ':U' => time(),
327 327
                 ]);
328 328
                 $row = $stm->fetch(PDO::FETCH_ASSOC);
329 329
             } catch (PDOException $e) {
@@ -351,13 +351,13 @@  discard block
 block discarded – undo
351 351
         if ($item instanceof Item) {
352 352
             try {
353 353
                 $stm = $this->getDb($item->getKey())
354
-                  //->prepare("DELETE FROM `caching` WHERE (`id`=:id) OR (`exp` <= :U) ");
355
-                  ->prepare("DELETE FROM `caching` WHERE (`exp` <= :U) OR (`keyword`=:keyword) ");
354
+                    //->prepare("DELETE FROM `caching` WHERE (`id`=:id) OR (`exp` <= :U) ");
355
+                    ->prepare("DELETE FROM `caching` WHERE (`exp` <= :U) OR (`keyword`=:keyword) ");
356 356
 
357 357
                 return $stm->execute([
358 358
                     // ':id' => $row[ 'id' ],
359
-                  ':keyword' => $item->getKey(),
360
-                  ':U' => time(),
359
+                    ':keyword' => $item->getKey(),
360
+                    ':U' => time(),
361 361
                 ]);
362 362
             } catch (PDOException $e) {
363 363
                 return false;
@@ -420,11 +420,11 @@  discard block
 block discarded – undo
420 420
         }
421 421
 
422 422
         $stat->setData(implode(', ', array_keys($this->itemInstances)))
423
-          ->setRawData([
423
+            ->setRawData([
424 424
             'tmp' => $this->tmp
425
-          ])
426
-          ->setSize(Directory::dirSize($path))
427
-          ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path));
425
+            ])
426
+            ->setSize(Directory::dirSize($path))
427
+            ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path));
428 428
 
429 429
         return $stat;
430 430
     }
Please login to merge, or discard this patch.
src/phpFastCache/Drivers/Files/Driver.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -215,11 +215,11 @@
 block discarded – undo
215 215
         }
216 216
 
217 217
         $stat->setData(implode(', ', array_keys($this->itemInstances)))
218
-          ->setRawData([
218
+            ->setRawData([
219 219
             'tmp' => $this->tmp
220
-          ])
221
-          ->setSize(Directory::dirSize($path))
222
-          ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path));
220
+            ])
221
+            ->setSize(Directory::dirSize($path))
222
+            ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path));
223 223
 
224 224
         return $stat;
225 225
     }
Please login to merge, or discard this patch.
src/phpFastCache/Core/Pool/IO/IOHelperTrait.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
         }
81 81
 
82 82
         $full_path = rtrim($path, '/')
83
-          . DIRECTORY_SEPARATOR
84
-          . $securityKey
85
-          . DIRECTORY_SEPARATOR
86
-          . $this->getDriverName();
83
+            . DIRECTORY_SEPARATOR
84
+            . $securityKey
85
+            . DIRECTORY_SEPARATOR
86
+            . $this->getDriverName();
87 87
         $full_path_hash = md5($full_path);
88 88
 
89 89
         /**
@@ -207,9 +207,9 @@  discard block
 block discarded – undo
207 207
     protected static function cleanFileName($filename)
208 208
     {
209 209
         $regex = [
210
-          '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/',
211
-          '/\.$/',
212
-          '/^\./',
210
+            '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/',
211
+            '/\.$/',
212
+            '/^\./',
213 213
         ];
214 214
         $replace = ['-', '', ''];
215 215
 
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
             $tmpFilename = Directory::getAbsolutePath(dirname($file) . '/tmp_' . md5(
302 302
                 str_shuffle(uniqid($this->getDriverName(), false))
303 303
                 . str_shuffle(uniqid($this->getDriverName(), false))
304
-              ));
304
+                ));
305 305
 
306 306
             $f = fopen($tmpFilename, 'w+');
307 307
             flock($f, LOCK_EX);
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -41,10 +41,10 @@  discard block
 block discarded – undo
41 41
          * Calculate the security key
42 42
          */
43 43
         {
44
-            $securityKey = array_key_exists('securityKey', $this->config) ? $this->config[ 'securityKey' ] : '';
44
+            $securityKey = array_key_exists('securityKey', $this->config) ? $this->config['securityKey'] : '';
45 45
             if (!$securityKey || $securityKey === 'auto') {
46
-                if (isset($_SERVER[ 'HTTP_HOST' ])) {
47
-                    $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER[ 'HTTP_HOST' ])));
46
+                if (isset($_SERVER['HTTP_HOST'])) {
47
+                    $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER['HTTP_HOST'])));
48 48
                 } else {
49 49
                     $securityKey = ($this->isPHPModule() ? 'web' : 'cli');
50 50
                 }
@@ -63,20 +63,20 @@  discard block
 block discarded – undo
63 63
          */
64 64
         $tmp_dir = rtrim($tmp_dir, '/') . DIRECTORY_SEPARATOR;
65 65
 
66
-        if (empty($this->config[ 'path' ]) || !is_string($this->config[ 'path' ])) {
66
+        if (empty($this->config['path']) || !is_string($this->config['path'])) {
67 67
             if (self::isPHPModule()) {
68 68
                 $path = $tmp_dir;
69 69
             } else {
70
-                $document_root_path = rtrim($_SERVER[ 'DOCUMENT_ROOT' ], '/') . '/../';
71
-                $path = isset($_SERVER[ 'DOCUMENT_ROOT' ]) && is_writable($document_root_path) ? $document_root_path : rtrim(__DIR__, '/') . DIRECTORY_SEPARATOR;
70
+                $document_root_path = rtrim($_SERVER['DOCUMENT_ROOT'], '/') . '/../';
71
+                $path = isset($_SERVER['DOCUMENT_ROOT']) && is_writable($document_root_path) ? $document_root_path : rtrim(__DIR__, '/') . DIRECTORY_SEPARATOR;
72 72
             }
73 73
 
74
-            if ($this->config[ 'path' ] != '') {
75
-                $path = $this->config[ 'path' ];
74
+            if ($this->config['path'] != '') {
75
+                $path = $this->config['path'];
76 76
             }
77 77
 
78 78
         } else {
79
-            $path = $this->config[ 'path' ];
79
+            $path = $this->config['path'];
80 80
         }
81 81
 
82 82
         $full_path = rtrim($path, '/')
@@ -93,19 +93,19 @@  discard block
 block discarded – undo
93 93
          * return the temp dir
94 94
          */
95 95
         if ($readonly === true) {
96
-            if($this->config[ 'autoTmpFallback' ] && (@file_exists($full_path) || !@is_writable($full_path))){
96
+            if ($this->config['autoTmpFallback'] && (@file_exists($full_path) || !@is_writable($full_path))) {
97 97
                 return $tmp_dir;
98 98
             }
99 99
             return $full_path;
100
-        }else{
101
-            if (!isset($this->tmp[ $full_path_hash ]) || (!@file_exists($full_path) || !@is_writable($full_path))) {
100
+        } else {
101
+            if (!isset($this->tmp[$full_path_hash]) || (!@file_exists($full_path) || !@is_writable($full_path))) {
102 102
                 if (!@file_exists($full_path)) {
103 103
                     @mkdir($full_path, $this->setChmodAuto(), true);
104
-                }else if (!@is_writable($full_path)) {
104
+                } else if (!@is_writable($full_path)) {
105 105
                     @chmod($full_path, $this->setChmodAuto());
106 106
                 }
107 107
 
108
-                if ($this->config[ 'autoTmpFallback' ] && !@is_writable($full_path)) {
108
+                if ($this->config['autoTmpFallback'] && !@is_writable($full_path)) {
109 109
                     /**
110 110
                      * Switch back to tmp dir
111 111
                      * again if the path is not writable
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
                     throw new phpFastCacheIOException('PLEASE CREATE OR CHMOD ' . $full_path . ' - 0777 OR ANY WRITABLE PERMISSION!');
126 126
                 }
127 127
 
128
-                $this->tmp[ $full_path_hash ] = $full_path;
129
-                $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config[ 'htaccess' ] : false);
128
+                $this->tmp[$full_path_hash] = $full_path;
129
+                $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config['htaccess'] : false);
130 130
             }
131 131
         }
132 132
 
@@ -193,10 +193,10 @@  discard block
 block discarded – undo
193 193
      */
194 194
     public function setChmodAuto()
195 195
     {
196
-        if (!isset($this->config[ 'default_chmod' ]) || $this->config[ 'default_chmod' ] == '' || is_null($this->config[ 'default_chmod' ])) {
196
+        if (!isset($this->config['default_chmod']) || $this->config['default_chmod'] == '' || is_null($this->config['default_chmod'])) {
197 197
             return 0777;
198 198
         } else {
199
-            return $this->config[ 'default_chmod' ];
199
+            return $this->config['default_chmod'];
200 200
         }
201 201
     }
202 202
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
         if ($create === true) {
227 227
             if (!is_writable($path)) {
228 228
                 try {
229
-                    if(!chmod($path, 0777)){
229
+                    if (!chmod($path, 0777)) {
230 230
                         throw new phpFastCacheIOException('Chmod failed on : ' . $path);
231 231
                     }
232 232
                 } catch (phpFastCacheIOException $e) {
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
          */
298 298
         $this->eventManager->dispatch('CacheWriteFileOnDisk', $this, $file, $secureFileManipulation);
299 299
 
300
-        if($secureFileManipulation){
300
+        if ($secureFileManipulation) {
301 301
             $tmpFilename = Directory::getAbsolutePath(dirname($file) . '/tmp_' . md5(
302 302
                 str_shuffle(uniqid($this->getDriverName(), false))
303 303
                 . str_shuffle(uniqid($this->getDriverName(), false))
@@ -309,10 +309,10 @@  discard block
 block discarded – undo
309 309
             flock($f, LOCK_UN);
310 310
             fclose($f);
311 311
 
312
-            if(!rename($tmpFilename, $file)){
312
+            if (!rename($tmpFilename, $file)) {
313 313
                 throw new phpFastCacheIOException(sprintf('Failed to rename %s to %s', $tmpFilename, $file));
314 314
             }
315
-        }else{
315
+        } else {
316 316
             $f = fopen($file, 'w+');
317 317
             $octetWritten = fwrite($f, $data);
318 318
             fclose($f);
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
                 return $tmp_dir;
98 98
             }
99 99
             return $full_path;
100
-        }else{
100
+        } else{
101 101
             if (!isset($this->tmp[ $full_path_hash ]) || (!@file_exists($full_path) || !@is_writable($full_path))) {
102 102
                 if (!@file_exists($full_path)) {
103 103
                     @mkdir($full_path, $this->setChmodAuto(), true);
104
-                }else if (!@is_writable($full_path)) {
104
+                } else if (!@is_writable($full_path)) {
105 105
                     @chmod($full_path, $this->setChmodAuto());
106 106
                 }
107 107
 
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
             if(!rename($tmpFilename, $file)){
313 313
                 throw new phpFastCacheIOException(sprintf('Failed to rename %s to %s', $tmpFilename, $file));
314 314
             }
315
-        }else{
315
+        } else{
316 316
             $f = fopen($file, 'w+');
317 317
             $octetWritten = fwrite($f, $data);
318 318
             fclose($f);
Please login to merge, or discard this patch.