Passed
Pull Request — v6 (#816)
by Georges
53s
created
src/autoload.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,9 +17,9 @@
 block discarded – undo
17 17
 /**
18 18
  * Register Autoload
19 19
  */
20
-spl_autoload_register(function ($entity) {
20
+spl_autoload_register(function($entity) {
21 21
     $module = explode('\\', $entity, 2);
22
-    if (!in_array($module[ 0 ], ['phpFastCache', 'Psr'])) {
22
+    if (!in_array($module[0], ['phpFastCache', 'Psr'])) {
23 23
         /**
24 24
          * Not a part of phpFastCache file
25 25
          * then we return here.
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,5 +56,5 @@
 block discarded – undo
56 56
 
57 57
 if ((!defined('PFC_IGNORE_COMPOSER_WARNING') || !PFC_IGNORE_COMPOSER_WARNING) && class_exists('Composer\Autoload\ClassLoader')) {
58 58
     trigger_error('Your project already makes use of Composer. You SHOULD use the composer dependency "phpfastcache/phpfastcache" instead of hard-autoloading.',
59
-      E_USER_WARNING);
59
+        E_USER_WARNING);
60 60
 }
61 61
\ No newline at end of file
Please login to merge, or discard this patch.
src/phpFastCache/Util/Directory.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -83,8 +83,8 @@
 block discarded – undo
83 83
 
84 84
         $files = new RecursiveIteratorIterator
85 85
         (
86
-          new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS),
87
-          RecursiveIteratorIterator::CHILD_FIRST
86
+            new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS),
87
+            RecursiveIteratorIterator::CHILD_FIRST
88 88
         );
89 89
         
90 90
         foreach ($files as $fileinfo) {
Please login to merge, or discard this patch.
Spacing   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -86,8 +86,7 @@  discard block
 block discarded – undo
86 86
             return unlink($source);
87 87
         }
88 88
 
89
-        $files = new RecursiveIteratorIterator
90
-        (
89
+        $files = new RecursiveIteratorIterator(
91 90
           new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS),
92 91
           RecursiveIteratorIterator::CHILD_FIRST
93 92
         );
@@ -137,8 +136,8 @@  discard block
 block discarded – undo
137 136
         /**
138 137
          * Allows to dereference char
139 138
          */
140
-        $__FILE__ = preg_replace('~^(([a-z0-9\-]+)://)~', '', __FILE__);// remove file protocols such as "phar://" etc.
141
-        $prefix = $__FILE__[ 0 ] === DIRECTORY_SEPARATOR ? DIRECTORY_SEPARATOR : '';
139
+        $__FILE__ = preg_replace('~^(([a-z0-9\-]+)://)~', '', __FILE__); // remove file protocols such as "phar://" etc.
140
+        $prefix = $__FILE__[0] === DIRECTORY_SEPARATOR ? DIRECTORY_SEPARATOR : '';
142 141
         return $prefix . implode(DIRECTORY_SEPARATOR, $absolutes);
143 142
     }
144 143
 }
145 144
\ No newline at end of file
Please login to merge, or discard this patch.
src/phpFastCache/Drivers/Ssdb/Driver.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -139,10 +139,10 @@  discard block
 block discarded – undo
139 139
     {
140 140
         try {
141 141
             $server = isset($this->config[ 'ssdb' ]) ? $this->config[ 'ssdb' ] : [
142
-              'host' => "127.0.0.1",
143
-              'port' => 8888,
144
-              'password' => '',
145
-              'timeout' => 2000,
142
+                'host' => "127.0.0.1",
143
+                'port' => 8888,
144
+                'password' => '',
145
+                'timeout' => 2000,
146 146
             ];
147 147
 
148 148
             $host = $server[ 'host' ];
@@ -183,9 +183,9 @@  discard block
 block discarded – undo
183 183
          * using hardcoded offset of pair key-value :-(
184 184
          */
185 185
         $stat->setInfo(sprintf("Ssdb-server v%s with a total of %s call(s).\n For more information see RawData.", $info[ 2 ], $info[ 6 ]))
186
-          ->setRawData($info)
187
-          ->setData(implode(', ', array_keys($this->itemInstances)))
188
-          ->setSize($this->instance->dbsize());
186
+            ->setRawData($info)
187
+            ->setData(implode(', ', array_keys($this->itemInstances)))
188
+            ->setSize($this->instance->dbsize());
189 189
 
190 190
         return $stat;
191 191
     }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -125,17 +125,17 @@  discard block
 block discarded – undo
125 125
     protected function driverConnect()
126 126
     {
127 127
         try {
128
-            $server = isset($this->config[ 'ssdb' ]) ? $this->config[ 'ssdb' ] : [
128
+            $server = isset($this->config['ssdb']) ? $this->config['ssdb'] : [
129 129
               'host' => "127.0.0.1",
130 130
               'port' => 8888,
131 131
               'password' => '',
132 132
               'timeout' => 2000,
133 133
             ];
134 134
 
135
-            $host = $server[ 'host' ];
136
-            $port = isset($server[ 'port' ]) ? (int)$server[ 'port' ] : 8888;
137
-            $password = isset($server[ 'password' ]) ? $server[ 'password' ] : '';
138
-            $timeout = !empty($server[ 'timeout' ]) ? (int)$server[ 'timeout' ] : 2000;
135
+            $host = $server['host'];
136
+            $port = isset($server['port']) ? (int) $server['port'] : 8888;
137
+            $password = isset($server['password']) ? $server['password'] : '';
138
+            $timeout = !empty($server['timeout']) ? (int) $server['timeout'] : 2000;
139 139
             $this->instance = new SimpleSSDB($host, $port, $timeout);
140 140
             if (!empty($password)) {
141 141
                 $this->instance->auth($password);
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
          * Data returned by Ssdb are very poorly formatted
170 170
          * using hardcoded offset of pair key-value :-(
171 171
          */
172
-        $stat->setInfo(sprintf("Ssdb-server v%s with a total of %s call(s).\n For more information see RawData.", $info[ 2 ], $info[ 6 ]))
172
+        $stat->setInfo(sprintf("Ssdb-server v%s with a total of %s call(s).\n For more information see RawData.", $info[2], $info[6]))
173 173
           ->setRawData($info)
174 174
           ->setData(implode(', ', array_keys($this->itemInstances)))
175 175
           ->setSize($this->instance->dbsize());
Please login to merge, or discard this patch.
src/phpFastCache/Util/MemcacheDriverCollisionDetectorTrait.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
                 return true;
28 28
             } else if (constant($CONSTANT_NAME) !== $driverName) {
29 29
                 trigger_error('Memcache collision detected, you used both Memcache and Memcached driver in your script, this may leads to unexpected behaviours',
30
-                  E_USER_WARNING);
30
+                    E_USER_WARNING);
31 31
 
32 32
                 return false;
33 33
             }
Please login to merge, or discard this patch.
src/phpFastCache/Drivers/Sqlite/Driver.php 2 patches
Spacing   +11 added lines, -11 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,8 +329,8 @@  discard block
 block discarded – undo
329 329
             }
330 330
         }
331 331
 
332
-        if (isset($row[ 'object' ])) {
333
-            return $this->decode($row[ 'object' ]);
332
+        if (isset($row['object'])) {
333
+            return $this->decode($row['object']);
334 334
         }
335 335
 
336 336
         return null;
Please login to merge, or discard this patch.
Indentation   +19 added lines, -19 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
 
@@ -271,22 +271,22 @@  discard block
 block discarded – undo
271 271
                 $sql = "INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)";
272 272
                 try {
273 273
                     $stm = $this->getDb($item->getKey())
274
-                      ->prepare($sql);
274
+                        ->prepare($sql);
275 275
                     $stm->execute([
276
-                      ':keyword' => $item->getKey(),
277
-                      ':object' => $this->encode($this->driverPreWrap($item)),
278
-                      ':exp' => $item->getExpirationDate()->getTimestamp(),
276
+                        ':keyword' => $item->getKey(),
277
+                        ':object' => $this->encode($this->driverPreWrap($item)),
278
+                        ':exp' => $item->getExpirationDate()->getTimestamp(),
279 279
                     ]);
280 280
 
281 281
                     return true;
282 282
                 } catch (\PDOException $e) {
283 283
                     try {
284 284
                         $stm = $this->getDb($item->getKey(), true)
285
-                          ->prepare($sql);
285
+                            ->prepare($sql);
286 286
                         $stm->execute([
287
-                          ':keyword' => $item->getKey(),
288
-                          ':object' => $this->encode($this->driverPreWrap($item)),
289
-                          ':exp' => $item->getExpirationDate()->getTimestamp(),
287
+                            ':keyword' => $item->getKey(),
288
+                            ':object' => $this->encode($this->driverPreWrap($item)),
289
+                            ':exp' => $item->getExpirationDate()->getTimestamp(),
290 290
                         ]);
291 291
                     } catch (PDOException $e) {
292 292
                         return false;
@@ -309,17 +309,17 @@  discard block
 block discarded – undo
309 309
         $sql = "SELECT * FROM `caching` WHERE `keyword`=:keyword LIMIT 1";
310 310
         try {
311 311
             $stm = $this->getDb($item->getKey())
312
-              ->prepare($sql);
312
+                ->prepare($sql);
313 313
             $stm->execute([
314
-              ':keyword' => $item->getKey(),
314
+                ':keyword' => $item->getKey(),
315 315
             ]);
316 316
             $row = $stm->fetch(PDO::FETCH_ASSOC);
317 317
         } catch (PDOException $e) {
318 318
             try {
319 319
                 $stm = $this->getDb($item->getKey(), true)
320
-                  ->prepare($sql);
320
+                    ->prepare($sql);
321 321
                 $stm->execute([
322
-                  ':keyword' => $item->getKey(),
322
+                    ':keyword' => $item->getKey(),
323 323
                 ]);
324 324
                 $row = $stm->fetch(PDO::FETCH_ASSOC);
325 325
             } catch (PDOException $e) {
@@ -347,11 +347,11 @@  discard block
 block discarded – undo
347 347
         if ($item instanceof Item) {
348 348
             try {
349 349
                 $stm = $this->getDb($item->getKey())
350
-                  ->prepare("DELETE FROM `caching` WHERE (`exp` <= :U) OR (`keyword`=:keyword) ");
350
+                    ->prepare("DELETE FROM `caching` WHERE (`exp` <= :U) OR (`keyword`=:keyword) ");
351 351
 
352 352
                 return $stm->execute([
353
-                  ':keyword' => $item->getKey(),
354
-                  ':U' => time(),
353
+                    ':keyword' => $item->getKey(),
354
+                    ':U' => time(),
355 355
                 ]);
356 356
             } catch (PDOException $e) {
357 357
                 return false;
Please login to merge, or discard this patch.
src/phpFastCache/Drivers/Cookie/Item.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
             $this->driver->setItem($this);
44 44
         } else {
45 45
             throw new phpFastCacheInvalidArgumentException(sprintf('$key must be a string, got type "%s" instead.',
46
-              gettype($key)));
46
+                gettype($key)));
47 47
         }
48 48
     }
49 49
 
Please login to merge, or discard this patch.
src/phpFastCache/Drivers/Devtrue/Driver.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
     protected function driverRead(CacheItemInterface $item)
81 81
     {
82 82
         return [
83
-          self::DRIVER_DATA_WRAPPER_INDEX => true,
84
-          self::DRIVER_TAGS_WRAPPER_INDEX => [],
85
-          self::DRIVER_EDATE_WRAPPER_INDEX => new \DateTime(),
83
+            self::DRIVER_DATA_WRAPPER_INDEX => true,
84
+            self::DRIVER_TAGS_WRAPPER_INDEX => [],
85
+            self::DRIVER_EDATE_WRAPPER_INDEX => new \DateTime(),
86 86
         ];
87 87
     }
88 88
 
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
     {
133 133
         $stat = new DriverStatistic();
134 134
         $stat->setInfo('[Devtrue] A void info string')
135
-          ->setSize(0)
136
-          ->setData(implode(', ', array_keys($this->itemInstances)))
137
-          ->setRawData(true);
135
+            ->setSize(0)
136
+            ->setData(implode(', ', array_keys($this->itemInstances)))
137
+            ->setRawData(true);
138 138
 
139 139
         return $stat;
140 140
     }
Please login to merge, or discard this patch.
src/phpFastCache/Drivers/Wincache/Driver.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -133,9 +133,9 @@
 block discarded – undo
133 133
         $date = (new \DateTime())->setTimestamp(time() - $info[ 'total_cache_uptime' ]);
134 134
 
135 135
         return (new DriverStatistic())
136
-          ->setInfo(sprintf("The Wincache daemon is up since %s.\n For more information see RawData.", $date->format(DATE_RFC2822)))
137
-          ->setSize($memInfo[ 'memory_free' ] - $memInfo[ 'memory_total' ])
138
-          ->setData(implode(', ', array_keys($this->itemInstances)))
139
-          ->setRawData($memInfo);
136
+            ->setInfo(sprintf("The Wincache daemon is up since %s.\n For more information see RawData.", $date->format(DATE_RFC2822)))
137
+            ->setSize($memInfo[ 'memory_free' ] - $memInfo[ 'memory_total' ])
138
+            ->setData(implode(', ', array_keys($this->itemInstances)))
139
+            ->setRawData($memInfo);
140 140
     }
141 141
 }
142 142
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -130,11 +130,11 @@
 block discarded – undo
130 130
     {
131 131
         $memInfo = wincache_ucache_meminfo();
132 132
         $info = wincache_ucache_info();
133
-        $date = (new \DateTime())->setTimestamp(time() - $info[ 'total_cache_uptime' ]);
133
+        $date = (new \DateTime())->setTimestamp(time() - $info['total_cache_uptime']);
134 134
 
135 135
         return (new DriverStatistic())
136 136
           ->setInfo(sprintf("The Wincache daemon is up since %s.\n For more information see RawData.", $date->format(DATE_RFC2822)))
137
-          ->setSize($memInfo[ 'memory_free' ] - $memInfo[ 'memory_total' ])
137
+          ->setSize($memInfo['memory_free'] - $memInfo['memory_total'])
138 138
           ->setData(implode(', ', array_keys($this->itemInstances)))
139 139
           ->setRawData($memInfo);
140 140
     }
Please login to merge, or discard this patch.
src/phpFastCache/Drivers/Apc/Driver.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -137,10 +137,10 @@
 block discarded – undo
137 137
         $date = (new \DateTime())->setTimestamp($stats[ 'start_time' ]);
138 138
 
139 139
         return (new DriverStatistic())
140
-          ->setData(implode(', ', array_keys($this->itemInstances)))
141
-          ->setInfo(sprintf("The APC cache is up since %s, and have %d item(s) in cache.\n For more information see RawData.", $date->format(DATE_RFC2822),
140
+            ->setData(implode(', ', array_keys($this->itemInstances)))
141
+            ->setInfo(sprintf("The APC cache is up since %s, and have %d item(s) in cache.\n For more information see RawData.", $date->format(DATE_RFC2822),
142 142
             $stats[ 'num_entries' ]))
143
-          ->setRawData($stats)
144
-          ->setSize($stats[ 'mem_size' ]);
143
+            ->setRawData($stats)
144
+            ->setSize($stats[ 'mem_size' ]);
145 145
     }
146 146
 }
147 147
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -133,14 +133,14 @@
 block discarded – undo
133 133
      */
134 134
     public function getStats()
135 135
     {
136
-        $stats = (array)apc_cache_info('user');
137
-        $date = (new \DateTime())->setTimestamp($stats[ 'start_time' ]);
136
+        $stats = (array) apc_cache_info('user');
137
+        $date = (new \DateTime())->setTimestamp($stats['start_time']);
138 138
 
139 139
         return (new DriverStatistic())
140 140
           ->setData(implode(', ', array_keys($this->itemInstances)))
141 141
           ->setInfo(sprintf("The APC cache is up since %s, and have %d item(s) in cache.\n For more information see RawData.", $date->format(DATE_RFC2822),
142
-            $stats[ 'num_entries' ]))
142
+            $stats['num_entries']))
143 143
           ->setRawData($stats)
144
-          ->setSize($stats[ 'mem_size' ]);
144
+          ->setSize($stats['mem_size']);
145 145
     }
146 146
 }
147 147
\ No newline at end of file
Please login to merge, or discard this patch.