Completed
Pull Request — final (#446)
by Georges
02:18
created
src/phpFastCache/Drivers/Wincache/Driver.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -132,9 +132,9 @@
 block discarded – undo
132 132
         $date = (new \DateTime())->setTimestamp(time() - $info[ 'total_cache_uptime' ]);
133 133
 
134 134
         return (new driverStatistic())
135
-          ->setInfo(sprintf("The Wincache daemon is up since %s.\n For more information see RawData.", $date->format(DATE_RFC2822)))
136
-          ->setSize($memInfo[ 'memory_free' ] - $memInfo[ 'memory_total' ])
137
-          ->setData(implode(', ', array_keys($this->itemInstances)))
138
-          ->setRawData($memInfo);
135
+            ->setInfo(sprintf("The Wincache daemon is up since %s.\n For more information see RawData.", $date->format(DATE_RFC2822)))
136
+            ->setSize($memInfo[ 'memory_free' ] - $memInfo[ 'memory_total' ])
137
+            ->setData(implode(', ', array_keys($this->itemInstances)))
138
+            ->setRawData($memInfo);
139 139
     }
140 140
 }
141 141
\ 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
@@ -129,11 +129,11 @@
 block discarded – undo
129 129
     {
130 130
         $memInfo = wincache_ucache_meminfo();
131 131
         $info = wincache_ucache_info();
132
-        $date = (new \DateTime())->setTimestamp(time() - $info[ 'total_cache_uptime' ]);
132
+        $date = (new \DateTime())->setTimestamp(time() - $info['total_cache_uptime']);
133 133
 
134 134
         return (new driverStatistic())
135 135
           ->setInfo(sprintf("The Wincache daemon is up since %s.\n For more information see RawData.", $date->format(DATE_RFC2822)))
136
-          ->setSize($memInfo[ 'memory_free' ] - $memInfo[ 'memory_total' ])
136
+          ->setSize($memInfo['memory_free'] - $memInfo['memory_total'])
137 137
           ->setData(implode(', ', array_keys($this->itemInstances)))
138 138
           ->setRawData($memInfo);
139 139
     }
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,6 @@
 block discarded – undo
15 15
 namespace phpFastCache\Drivers\Wincache;
16 16
 
17 17
 use phpFastCache\Core\DriverAbstract;
18
-use phpFastCache\Core\StandardPsr6StructureTrait;
19 18
 use phpFastCache\Entities\driverStatistic;
20 19
 use phpFastCache\Exceptions\phpFastCacheDriverCheckException;
21 20
 use phpFastCache\Exceptions\phpFastCacheDriverException;
Please login to merge, or discard this patch.
src/phpFastCache/Drivers/Couchbase/Driver.php 4 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -142,10 +142,10 @@  discard block
 block discarded – undo
142 142
             $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : '';
143 143
             $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : '';
144 144
             $buckets = isset($this->config[ 'buckets' ]) ? $this->config[ 'buckets' ] : [
145
-              [
145
+                [
146 146
                 'bucket' => 'default',
147 147
                 'password' => '',
148
-              ],
148
+                ],
149 149
             ];
150 150
 
151 151
             $this->instance = $this->instance ?: new CouchbaseClient("couchbase://{$host}", $username, $password);
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
         $info = $this->getBucket()->manager()->info();
194 194
 
195 195
         return (new driverStatistic())
196
-          ->setSize($info[ 'basicStats' ][ 'diskUsed' ])
197
-          ->setRawData($info)
198
-          ->setData(implode(', ', array_keys($this->itemInstances)))
199
-          ->setInfo('CouchBase version ' . $info[ 'nodes' ][ 0 ][ 'version' ] . ', Uptime (in days): ' . round($info[ 'nodes' ][ 0 ][ 'uptime' ] / 86400, 1) . "\n For more information see RawData.");
196
+            ->setSize($info[ 'basicStats' ][ 'diskUsed' ])
197
+            ->setRawData($info)
198
+            ->setData(implode(', ', array_keys($this->itemInstances)))
199
+            ->setInfo('CouchBase version ' . $info[ 'nodes' ][ 0 ][ 'version' ] . ', Uptime (in days): ' . round($info[ 'nodes' ][ 0 ][ 'uptime' ] / 86400, 1) . "\n For more information see RawData.");
200 200
     }
201 201
 }
202 202
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -137,11 +137,11 @@  discard block
 block discarded – undo
137 137
         } else {
138 138
 
139 139
 
140
-            $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1';
140
+            $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1';
141 141
             //$port = isset($server[ 'port' ]) ? $server[ 'port' ] : '11211';
142
-            $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : '';
143
-            $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : '';
144
-            $buckets = isset($this->config[ 'buckets' ]) ? $this->config[ 'buckets' ] : [
142
+            $password = isset($this->config['password']) ? $this->config['password'] : '';
143
+            $username = isset($this->config['username']) ? $this->config['username'] : '';
144
+            $buckets = isset($this->config['buckets']) ? $this->config['buckets'] : [
145 145
               [
146 146
                 'bucket' => 'default',
147 147
                 'password' => '',
@@ -151,8 +151,8 @@  discard block
 block discarded – undo
151 151
             $this->instance = $this->instance ?: new CouchbaseClient("couchbase://{$host}", $username, $password);
152 152
 
153 153
             foreach ($buckets as $bucket) {
154
-                $this->bucketCurrent = $this->bucketCurrent ?: $bucket[ 'bucket' ];
155
-                $this->setBucket($bucket[ 'bucket' ], $this->instance->openBucket($bucket[ 'bucket' ], $bucket[ 'password' ]));
154
+                $this->bucketCurrent = $this->bucketCurrent ?: $bucket['bucket'];
155
+                $this->setBucket($bucket['bucket'], $this->instance->openBucket($bucket['bucket'], $bucket['password']));
156 156
             }
157 157
         }
158 158
     }
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
      */
163 163
     protected function getBucket()
164 164
     {
165
-        return $this->bucketInstances[ $this->bucketCurrent ];
165
+        return $this->bucketInstances[$this->bucketCurrent];
166 166
     }
167 167
 
168 168
     /**
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
     protected function setBucket($bucketName, \CouchbaseBucket $CouchbaseBucket)
174 174
     {
175 175
         if (!array_key_exists($bucketName, $this->bucketInstances)) {
176
-            $this->bucketInstances[ $bucketName ] = $CouchbaseBucket;
176
+            $this->bucketInstances[$bucketName] = $CouchbaseBucket;
177 177
         } else {
178 178
             throw new \LogicException('A bucket instance with this name already exists.');
179 179
         }
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
         $info = $this->getBucket()->manager()->info();
194 194
 
195 195
         return (new driverStatistic())
196
-          ->setSize($info[ 'basicStats' ][ 'diskUsed' ])
196
+          ->setSize($info['basicStats']['diskUsed'])
197 197
           ->setRawData($info)
198 198
           ->setData(implode(', ', array_keys($this->itemInstances)))
199
-          ->setInfo('CouchBase version ' . $info[ 'nodes' ][ 0 ][ 'version' ] . ', Uptime (in days): ' . round($info[ 'nodes' ][ 0 ][ 'uptime' ] / 86400, 1) . "\n For more information see RawData.");
199
+          ->setInfo('CouchBase version ' . $info['nodes'][0]['version'] . ', Uptime (in days): ' . round($info['nodes'][0]['uptime'] / 86400, 1) . "\n For more information see RawData.");
200 200
     }
201 201
 }
202 202
\ No newline at end of file
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,6 @@
 block discarded – undo
16 16
 
17 17
 use CouchbaseCluster as CouchbaseClient;
18 18
 use phpFastCache\Core\DriverAbstract;
19
-use phpFastCache\Core\StandardPsr6StructureTrait;
20 19
 use phpFastCache\Entities\driverStatistic;
21 20
 use phpFastCache\Exceptions\phpFastCacheDriverCheckException;
22 21
 use phpFastCache\Exceptions\phpFastCacheDriverException;
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@
 block discarded – undo
126 126
     }
127 127
 
128 128
     /**
129
-     * @return bool
129
+     * @return boolean|null
130 130
      */
131 131
     protected function driverConnect()
132 132
     {
Please login to merge, or discard this patch.
src/phpFastCache/Drivers/Xcache/Driver.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -136,10 +136,10 @@
 block discarded – undo
136 136
             $info = xcache_info(XC_TYPE_VAR, 0);
137 137
 
138 138
             return (new driverStatistic())
139
-              ->setSize(abs($info[ 'size' ] - $info[ 'avail' ]))
140
-              ->setData(implode(', ', array_keys($this->itemInstances)))
141
-              ->setInfo(sprintf("Xcache v%s with following modules loaded:\n %s", XCACHE_VERSION, str_replace(' ', ', ', XCACHE_MODULES)))
142
-              ->setRawData($info);
139
+                ->setSize(abs($info[ 'size' ] - $info[ 'avail' ]))
140
+                ->setData(implode(', ', array_keys($this->itemInstances)))
141
+                ->setInfo(sprintf("Xcache v%s with following modules loaded:\n %s", XCACHE_VERSION, str_replace(' ', ', ', XCACHE_MODULES)))
142
+                ->setRawData($info);
143 143
         } else {
144 144
             throw new \RuntimeException("PhpFastCache is not able to read Xcache configuration. Please put this to your php.ini:\n
145 145
             [xcache.admin]
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@
 block discarded – undo
136 136
             $info = xcache_info(XC_TYPE_VAR, 0);
137 137
 
138 138
             return (new driverStatistic())
139
-              ->setSize(abs($info[ 'size' ] - $info[ 'avail' ]))
139
+              ->setSize(abs($info['size'] - $info['avail']))
140 140
               ->setData(implode(', ', array_keys($this->itemInstances)))
141 141
               ->setInfo(sprintf("Xcache v%s with following modules loaded:\n %s", XCACHE_VERSION, str_replace(' ', ', ', XCACHE_MODULES)))
142 142
               ->setRawData($info);
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
@@ -136,10 +136,10 @@
 block discarded – undo
136 136
         $date = (new \DateTime())->setTimestamp($stats[ 'start_time' ]);
137 137
 
138 138
         return (new driverStatistic())
139
-          ->setData(implode(', ', array_keys($this->itemInstances)))
140
-          ->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),
139
+            ->setData(implode(', ', array_keys($this->itemInstances)))
140
+            ->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),
141 141
             $stats[ 'num_entries' ]))
142
-          ->setRawData($stats)
143
-          ->setSize($stats[ 'mem_size' ]);
142
+            ->setRawData($stats)
143
+            ->setSize($stats[ 'mem_size' ]);
144 144
     }
145 145
 }
146 146
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -133,13 +133,13 @@
 block discarded – undo
133 133
     public function getStats()
134 134
     {
135 135
         $stats = (array) apc_cache_info('user');
136
-        $date = (new \DateTime())->setTimestamp($stats[ 'start_time' ]);
136
+        $date = (new \DateTime())->setTimestamp($stats['start_time']);
137 137
 
138 138
         return (new driverStatistic())
139 139
           ->setData(implode(', ', array_keys($this->itemInstances)))
140 140
           ->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),
141
-            $stats[ 'num_entries' ]))
141
+            $stats['num_entries']))
142 142
           ->setRawData($stats)
143
-          ->setSize($stats[ 'mem_size' ]);
143
+          ->setSize($stats['mem_size']);
144 144
     }
145 145
 }
146 146
\ 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
@@ -138,17 +138,17 @@  discard block
 block discarded – undo
138 138
     protected function driverConnect()
139 139
     {
140 140
         try {
141
-            $server = isset($this->config[ 'ssdb' ]) ? $this->config[ 'ssdb' ] : [
141
+            $server = isset($this->config['ssdb']) ? $this->config['ssdb'] : [
142 142
               'host' => "127.0.0.1",
143 143
               'port' => 8888,
144 144
               'password' => '',
145 145
               'timeout' => 2000,
146 146
             ];
147 147
 
148
-            $host = $server[ 'host' ];
149
-            $port = isset($server[ 'port' ]) ? (int) $server[ 'port' ] : 8888;
150
-            $password = isset($server[ 'password' ]) ? $server[ 'password' ] : '';
151
-            $timeout = !empty($server[ 'timeout' ]) ? (int) $server[ 'timeout' ] : 2000;
148
+            $host = $server['host'];
149
+            $port = isset($server['port']) ? (int) $server['port'] : 8888;
150
+            $password = isset($server['password']) ? $server['password'] : '';
151
+            $timeout = !empty($server['timeout']) ? (int) $server['timeout'] : 2000;
152 152
             $this->instance = new SimpleSSDB($host, $port, $timeout);
153 153
             if (!empty($password)) {
154 154
                 $this->instance->auth($password);
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
          * Data returned by Ssdb are very poorly formatted
183 183
          * using hardcoded offset of pair key-value :-(
184 184
          */
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 ]))
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 186
           ->setRawData($info)
187 187
           ->setData(implode(', ', array_keys($this->itemInstances)))
188 188
           ->setSize($this->instance->dbsize());
Please login to merge, or discard this patch.
src/phpFastCache/Proxy/phpFastCacheAbstractProxy.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -74,9 +74,9 @@
 block discarded – undo
74 74
      */
75 75
     public function __call($name, $args)
76 76
     {
77
-        if(method_exists($this->instance, $name)){
77
+        if (method_exists($this->instance, $name)) {
78 78
             return call_user_func_array([$this->instance, $name], $args);
79
-        }else{
79
+        } else {
80 80
             throw new \BadMethodCallException(sprintf('Method %s does not exists', $name));
81 81
         }
82 82
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@
 block discarded – undo
76 76
     {
77 77
         if(method_exists($this->instance, $name)){
78 78
             return call_user_func_array([$this->instance, $name], $args);
79
-        }else{
79
+        } else{
80 80
             throw new \BadMethodCallException(sprintf('Method %s does not exists', $name));
81 81
         }
82 82
     }
Please login to merge, or discard this patch.
src/phpFastCache/CacheManager.php 3 patches
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
             $class = self::getNamespacePath() . $driver . '\Driver';
96 96
             try{
97 97
                 self::$instances[ $instance ] = new $class($config);
98
-            }catch(phpFastCacheDriverCheckException $e){
98
+            } catch(phpFastCacheDriverCheckException $e){
99 99
                 $fallback = self::standardizeDriverName($config['fallback']);
100 100
                 if($fallback && $fallback !== $driver){
101 101
                     $class = self::getNamespacePath() . $fallback . '\Driver';
102 102
                     self::$instances[ $instance ] = new $class($config);
103 103
                     trigger_error(sprintf('The "%s" driver is unavailable at the moment, the fallback driver "%s" has been used instead.', $driver, $fallback), E_USER_WARNING);
104
-                }else{
104
+                } else{
105 105
                     throw new phpFastCacheDriverCheckException($e->getMessage(), $e->getCode(), $e);
106 106
                 }
107 107
             }
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
             self::$config = array_merge(self::$config, $name);
199 199
         } else if (is_string($name)){
200 200
             self::$config[ $name ] = $value;
201
-        }else{
201
+        } else{
202 202
             throw new \InvalidArgumentException('Invalid variable type: $name');
203 203
         }
204 204
     }
Please login to merge, or discard this patch.
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -57,15 +57,15 @@  discard block
 block discarded – undo
57 57
      * @var array
58 58
      */
59 59
     protected static $config = [
60
-      'securityKey' => 'auto', // The securityKey that will be used to create the sub-directory
61
-      'ignoreSymfonyNotice' => false, // Ignore Symfony notices for Symfony projects that do not makes use of PhpFastCache's Symfony Bundle
62
-      'defaultTtl' => 900, // Default time-to-live in seconds
63
-      'htaccess' => true, // Auto-generate .htaccess if it is missing
64
-      'default_chmod' => 0777, // 0777 is recommended
65
-      'path' => '', // If not set will be the value of sys_get_temp_dir()
66
-      'fallback' => false, // Fall back when old driver is not supported
67
-      'limited_memory_each_object' => 4096, // Maximum size (bytes) of object store in memory
68
-      'compress_data' => false, // Compress stored data if the backend supports it
60
+        'securityKey' => 'auto', // The securityKey that will be used to create the sub-directory
61
+        'ignoreSymfonyNotice' => false, // Ignore Symfony notices for Symfony projects that do not makes use of PhpFastCache's Symfony Bundle
62
+        'defaultTtl' => 900, // Default time-to-live in seconds
63
+        'htaccess' => true, // Auto-generate .htaccess if it is missing
64
+        'default_chmod' => 0777, // 0777 is recommended
65
+        'path' => '', // If not set will be the value of sys_get_temp_dir()
66
+        'fallback' => false, // Fall back when old driver is not supported
67
+        'limited_memory_each_object' => 4096, // Maximum size (bytes) of object store in memory
68
+        'compress_data' => false, // Compress stored data if the backend supports it
69 69
     ];
70 70
 
71 71
     /**
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
                 }
117 117
             }
118 118
         } else if(++$badPracticeOmeter[$driver] >= 5){
119
-           trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances.
119
+            trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances.
120 120
            See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F');
121 121
         }
122 122
 
@@ -227,23 +227,23 @@  discard block
 block discarded – undo
227 227
     public static function getStaticSystemDrivers()
228 228
     {
229 229
         return [
230
-          'Sqlite',
231
-          'Files',
232
-          'Apc',
233
-          'Apcu',
234
-          'Memcache',
235
-          'Memcached',
236
-          'Couchbase',
237
-          'Mongodb',
238
-          'Predis',
239
-          'Redis',
240
-          'Ssdb',
241
-          'Leveldb',
242
-          'Wincache',
243
-          'Xcache',
244
-          'Zenddisk',
245
-          'Zendshm',
246
-          'Devnull',
230
+            'Sqlite',
231
+            'Files',
232
+            'Apc',
233
+            'Apcu',
234
+            'Memcache',
235
+            'Memcached',
236
+            'Couchbase',
237
+            'Mongodb',
238
+            'Predis',
239
+            'Redis',
240
+            'Ssdb',
241
+            'Leveldb',
242
+            'Wincache',
243
+            'Xcache',
244
+            'Zenddisk',
245
+            'Zendshm',
246
+            'Devnull',
247 247
         ];
248 248
     }
249 249
 
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -97,30 +97,30 @@  discard block
 block discarded – undo
97 97
         }
98 98
 
99 99
         $instance = crc32($driver . serialize($config));
100
-        if (!isset(self::$instances[ $instance ])) {
100
+        if (!isset(self::$instances[$instance])) {
101 101
             $badPracticeOmeter[$driver] = 1;
102
-            if(!$config['ignoreSymfonyNotice'] && interface_exists('Symfony\Component\HttpKernel\KernelInterface') && !class_exists('phpFastCache\Bundle\phpFastCacheBundle')){
102
+            if (!$config['ignoreSymfonyNotice'] && interface_exists('Symfony\Component\HttpKernel\KernelInterface') && !class_exists('phpFastCache\Bundle\phpFastCacheBundle')) {
103 103
                 trigger_error('A Symfony Bundle to make the PhpFastCache integration more easier is now available here: https://github.com/PHPSocialNetwork/phpfastcache-bundle', E_USER_NOTICE);
104 104
             }
105 105
             $class = self::getNamespacePath() . $driver . '\Driver';
106
-            try{
107
-                self::$instances[ $instance ] = new $class($config);
108
-            }catch(phpFastCacheDriverCheckException $e){
106
+            try {
107
+                self::$instances[$instance] = new $class($config);
108
+            } catch (phpFastCacheDriverCheckException $e) {
109 109
                 $fallback = self::standardizeDriverName($config['fallback']);
110
-                if($fallback && $fallback !== $driver){
110
+                if ($fallback && $fallback !== $driver) {
111 111
                     $class = self::getNamespacePath() . $fallback . '\Driver';
112
-                    self::$instances[ $instance ] = new $class($config);
112
+                    self::$instances[$instance] = new $class($config);
113 113
                     trigger_error(sprintf('The "%s" driver is unavailable at the moment, the fallback driver "%s" has been used instead.', $driver, $fallback), E_USER_WARNING);
114
-                }else{
114
+                } else {
115 115
                     throw new phpFastCacheDriverCheckException($e->getMessage(), $e->getCode(), $e);
116 116
                 }
117 117
             }
118
-        } else if(++$badPracticeOmeter[$driver] >= 5){
118
+        } else if (++$badPracticeOmeter[$driver] >= 5) {
119 119
            trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances.
120 120
            See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F');
121 121
         }
122 122
 
123
-        return self::$instances[ $instance ];
123
+        return self::$instances[$instance];
124 124
     }
125 125
 
126 126
     /**
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
      */
154 154
     public static function __callStatic($name, $arguments)
155 155
     {
156
-        $options = (array_key_exists(0, $arguments) && is_array($arguments) ? $arguments[ 0 ] : []);
156
+        $options = (array_key_exists(0, $arguments) && is_array($arguments) ? $arguments[0] : []);
157 157
 
158 158
         return self::getInstance($name, $options);
159 159
     }
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
     {
207 207
         if (is_array($name)) {
208 208
             self::$config = array_merge(self::$config, $name);
209
-        } else if (is_string($name)){
210
-            self::$config[ $name ] = $value;
211
-        }else{
209
+        } else if (is_string($name)) {
210
+            self::$config[$name] = $value;
211
+        } else {
212 212
             throw new \InvalidArgumentException('Invalid variable type: $name');
213 213
         }
214 214
     }
Please login to merge, or discard this patch.
src/phpFastCache/Core/PathSeekerTrait.php 4 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -185,9 +185,9 @@
 block discarded – undo
185 185
     protected static function cleanFileName($filename)
186 186
     {
187 187
         $regex = [
188
-          '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/',
189
-          '/\.$/',
190
-          '/^\./',
188
+            '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/',
189
+            '/\.$/',
190
+            '/^\./',
191 191
         ];
192 192
         $replace = ['-', '', ''];
193 193
 
Please login to merge, or discard this patch.
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
     }
142 142
 
143 143
     /**
144
-     * @param $keyword
144
+     * @param string|false $keyword
145 145
      * @param bool $skip
146 146
      * @return string
147 147
      * @throws phpFastCacheDriverException
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 
188 188
     /**
189 189
      * @param $filename
190
-     * @return mixed
190
+     * @return string
191 191
      */
192 192
     protected static function cleanFileName($filename)
193 193
     {
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
     }
203 203
 
204 204
     /**
205
-     * @param $path
205
+     * @param string $path
206 206
      * @param bool $create
207 207
      * @throws \Exception
208 208
      */
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -78,11 +78,11 @@
 block discarded – undo
78 78
                 return $full_path_tmp;
79 79
             }
80 80
             return $full_path;
81
-        }else{
81
+        } else{
82 82
             if (!isset($this->tmp[ $full_path_hash ]) || (!@file_exists($full_path) || !@is_writable($full_path))) {
83 83
                 if (!@file_exists($full_path)) {
84 84
                     @mkdir($full_path, $this->setChmodAuto(), true);
85
-                }elseif (!@is_writable($full_path)) {
85
+                } elseif (!@is_writable($full_path)) {
86 86
                     if (!@chmod($full_path, $this->setChmodAuto()))
87 87
                     {
88 88
                         /**
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -45,10 +45,10 @@  discard block
 block discarded – undo
45 45
          * Calculate the security key
46 46
          */
47 47
         {
48
-            $securityKey = array_key_exists('securityKey', $this->config) ? $this->config[ 'securityKey' ] : '';
48
+            $securityKey = array_key_exists('securityKey', $this->config) ? $this->config['securityKey'] : '';
49 49
             if (!$securityKey || $securityKey === 'auto') {
50
-                if (isset($_SERVER[ 'HTTP_HOST' ])) {
51
-                    $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER[ 'HTTP_HOST' ])));
50
+                if (isset($_SERVER['HTTP_HOST'])) {
51
+                    $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER['HTTP_HOST'])));
52 52
                 } else {
53 53
                     $securityKey = ($this->isPHPModule() ? 'web' : 'cli');
54 54
                 }
@@ -63,10 +63,10 @@  discard block
 block discarded – undo
63 63
          * with the security key and the driver name
64 64
          */
65 65
         $tmp_dir = rtrim($tmp_dir, '/') . DIRECTORY_SEPARATOR;
66
-        if (empty($this->config[ 'path' ]) || !is_string($this->config[ 'path' ])) {
66
+        if (empty($this->config['path']) || !is_string($this->config['path'])) {
67 67
             $path = $tmp_dir;
68 68
         } else {
69
-            $path = rtrim($this->config[ 'path' ], '/') . DIRECTORY_SEPARATOR;
69
+            $path = rtrim($this->config['path'], '/') . DIRECTORY_SEPARATOR;
70 70
         }
71 71
         $path_suffix = $securityKey . DIRECTORY_SEPARATOR . $this->getDriverName();
72 72
         $full_path = Directory::getAbsolutePath($path . $path_suffix);
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
          * return the temp dir
80 80
          */
81 81
         if ($readonly === true) {
82
-            if(!@file_exists($full_path) || !@is_writable($full_path)){
82
+            if (!@file_exists($full_path) || !@is_writable($full_path)) {
83 83
                 return $full_path_tmp;
84 84
             }
85 85
             return $full_path;
86
-        }else{
87
-            if (!isset($this->tmp[ $full_path_hash ]) || (!@file_exists($full_path) || !@is_writable($full_path))) {
86
+        } else {
87
+            if (!isset($this->tmp[$full_path_hash]) || (!@file_exists($full_path) || !@is_writable($full_path))) {
88 88
                 if (!@file_exists($full_path)) {
89 89
                     @mkdir($full_path, $this->setChmodAuto(), true);
90 90
                 }elseif (!@is_writable($full_path)) {
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
                 if (!@file_exists($full_path) || !@is_writable($full_path)) {
110 110
                     throw new phpFastCacheDriverException('PLEASE CREATE OR CHMOD ' . $full_path . ' - 0777 OR ANY WRITABLE PERMISSION!');
111 111
                 }
112
-                $this->tmp[ $full_path_hash ] = $full_path;
113
-                $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config[ 'htaccess' ] : false);
112
+                $this->tmp[$full_path_hash] = $full_path;
113
+                $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config['htaccess'] : false);
114 114
             }
115 115
         }
116 116
         return realpath($full_path);
@@ -184,10 +184,10 @@  discard block
 block discarded – undo
184 184
      */
185 185
     public function setChmodAuto()
186 186
     {
187
-        if (!isset($this->config[ 'default_chmod' ]) || $this->config[ 'default_chmod' ] == '' || is_null($this->config[ 'default_chmod' ])) {
187
+        if (!isset($this->config['default_chmod']) || $this->config['default_chmod'] == '' || is_null($this->config['default_chmod'])) {
188 188
             return 0777;
189 189
         } else {
190
-            return $this->config[ 'default_chmod' ];
190
+            return $this->config['default_chmod'];
191 191
         }
192 192
     }
193 193
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
         if ($create === true) {
218 218
             if (!is_writable($path)) {
219 219
                 try {
220
-                    if(!chmod($path, 0777)){
220
+                    if (!chmod($path, 0777)) {
221 221
                         throw new phpFastCacheDriverException('Chmod failed on : ' . $path);
222 222
                     }
223 223
                 } catch (phpFastCacheDriverException $e) {
Please login to merge, or discard this patch.
src/phpFastCache/Drivers/Sqlite/Driver.php 4 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.
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -16,10 +16,8 @@
 block discarded – undo
16 16
 
17 17
 use PDO;
18 18
 use PDOException;
19
-use phpFastCache\Cache\ExtendedCacheItemInterface;
20 19
 use phpFastCache\Core\DriverAbstract;
21 20
 use phpFastCache\Core\PathSeekerTrait;
22
-use phpFastCache\Core\StandardPsr6StructureTrait;
23 21
 use phpFastCache\Entities\driverStatistic;
24 22
 use phpFastCache\Exceptions\phpFastCacheDriverCheckException;
25 23
 use phpFastCache\Exceptions\phpFastCacheDriverException;
Please login to merge, or discard this patch.
Indentation   +22 added lines, -22 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,18 +308,18 @@  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 LIMIT 1");
311
+                ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword LIMIT 1");
312 312
             $stm->execute([
313
-              ':keyword' => $item->getKey(),
313
+                ':keyword' => $item->getKey(),
314 314
             ]);
315 315
             $row = $stm->fetch(PDO::FETCH_ASSOC);
316 316
 
317 317
         } catch (PDOException $e) {
318 318
             try {
319 319
                 $stm = $this->getDb($item->getKey(), true)
320
-                  ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword LIMIT 1");
320
+                    ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword LIMIT 1");
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;
@@ -414,9 +414,9 @@  discard block
 block discarded – undo
414 414
         }
415 415
 
416 416
         $stat->setData(implode(', ', array_keys($this->itemInstances)))
417
-          ->setRawData([])
418
-          ->setSize(Directory::dirSize($path))
419
-          ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path));
417
+            ->setRawData([])
418
+            ->setSize(Directory::dirSize($path))
419
+            ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path));
420 420
 
421 421
         return $stat;
422 422
     }
Please login to merge, or discard this patch.
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
     }
208 208
 
209 209
     /**
210
-     * @param $keyword
210
+     * @param string $keyword
211 211
      * @param bool $reset
212 212
      * @return PDO
213 213
      */
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 
245 245
     /**
246 246
      * @param \Psr\Cache\CacheItemInterface $item
247
-     * @return mixed
247
+     * @return boolean
248 248
      * @throws \InvalidArgumentException
249 249
      */
250 250
     protected function driverWrite(CacheItemInterface $item)
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
     }
382 382
 
383 383
     /**
384
-     * @return bool
384
+     * @return boolean|null
385 385
      */
386 386
     protected function driverConnect()
387 387
     {
Please login to merge, or discard this patch.