Completed
Pull Request — final (#461)
by Georges
02:36
created
src/phpFastCache/Drivers/Devtrue/Driver.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
 
63 63
     /**
64 64
      * @param \Psr\Cache\CacheItemInterface $item
65
-     * @return mixed
65
+     * @return boolean
66 66
      * @throws phpFastCacheInvalidArgumentException
67 67
      */
68 68
     protected function driverWrite(CacheItemInterface $item)
Please login to merge, or discard this 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/Helper/TestHelper.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
      */
96 96
     public function printNewLine($count = 1)
97 97
     {
98
-        for($i = 0; $i < $count; $i++){
98
+        for ($i = 0; $i < $count; $i++) {
99 99
             print PHP_EOL;
100 100
         }
101 101
 
@@ -109,9 +109,9 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public function printText($string, $strtoupper = false)
111 111
     {
112
-        if(!$strtoupper){
112
+        if (!$strtoupper) {
113 113
             print trim($string) . PHP_EOL;
114
-        }else{
114
+        } else {
115 115
             print strtoupper(trim($string) . PHP_EOL);
116 116
         }
117 117
 
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
      */
124 124
     public function runAsyncProcess($cmd)
125 125
     {
126
-        if (substr(php_uname(), 0, 7) === 'Windows'){
127
-            pclose(popen('start /B '. $cmd, 'r'));
126
+        if (substr(php_uname(), 0, 7) === 'Windows') {
127
+            pclose(popen('start /B ' . $cmd, 'r'));
128 128
         }
129 129
         else {
130 130
             exec($cmd . ' > /dev/null &');
Please login to merge, or discard this patch.
Braces   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
     {
112 112
         if(!$strtoupper){
113 113
             print trim($string) . PHP_EOL;
114
-        }else{
114
+        } else{
115 115
             print strtoupper(trim($string) . PHP_EOL);
116 116
         }
117 117
 
@@ -125,8 +125,7 @@  discard block
 block discarded – undo
125 125
     {
126 126
         if (substr(php_uname(), 0, 7) === 'Windows'){
127 127
             pclose(popen('start /B '. $cmd, 'r'));
128
-        }
129
-        else {
128
+        } else {
130 129
             exec($cmd . ' > /dev/null &');
131 130
         }
132 131
     }
Please login to merge, or discard this patch.
src/phpFastCache/Entities/ItemBatch.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,10 +39,10 @@
 block discarded – undo
39 39
      */
40 40
     public function __construct($itemKey, \DateTime $itemDate)
41 41
     {
42
-        if(is_string($itemKey)){
42
+        if (is_string($itemKey)) {
43 43
             $this->itemKey = $itemKey;
44 44
             $this->itemDate = $itemDate;
45
-        }else{
45
+        } else {
46 46
             throw new phpFastCacheInvalidArgumentException(sprintf('$itemKey must be a string, got "%s" instead', gettype($itemKey)));
47 47
         }
48 48
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
         if(is_string($itemKey)){
43 43
             $this->itemKey = $itemKey;
44 44
             $this->itemDate = $itemDate;
45
-        }else{
45
+        } else{
46 46
             throw new phpFastCacheInvalidArgumentException(sprintf('$itemKey must be a string, got "%s" instead', gettype($itemKey)));
47 47
         }
48 48
     }
Please login to merge, or discard this patch.
src/phpFastCache/Drivers/Mongodb/Driver.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@
 block discarded – undo
76 76
 
77 77
     /**
78 78
      * @param \Psr\Cache\CacheItemInterface $item
79
-     * @return mixed
79
+     * @return boolean
80 80
      * @throws phpFastCacheInvalidArgumentException
81 81
      * @throws phpFastCacheDriverException
82 82
      */
Please login to merge, or discard this patch.
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -88,15 +88,15 @@  discard block
 block discarded – undo
88 88
         if ($item instanceof Item) {
89 89
             try {
90 90
                 $result = (array) $this->getCollection()->updateOne(
91
-                  ['_id' => $item->getEncodedKey()],
92
-                  [
91
+                    ['_id' => $item->getEncodedKey()],
92
+                    [
93 93
                     '$set' => [
94
-                      self::DRIVER_DATA_WRAPPER_INDEX => new Binary($this->encode($item->get()), Binary::TYPE_GENERIC),
95
-                      self::DRIVER_TAGS_WRAPPER_INDEX => new Binary($this->encode($item->getTags()), Binary::TYPE_GENERIC),
96
-                      self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((time() + $item->getTtl()) * 1000) : new UTCDateTime(time()*1000)),
94
+                        self::DRIVER_DATA_WRAPPER_INDEX => new Binary($this->encode($item->get()), Binary::TYPE_GENERIC),
95
+                        self::DRIVER_TAGS_WRAPPER_INDEX => new Binary($this->encode($item->getTags()), Binary::TYPE_GENERIC),
96
+                        self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((time() + $item->getTtl()) * 1000) : new UTCDateTime(time()*1000)),
97 97
                     ],
98
-                  ],
99
-                  ['upsert' => true, 'multiple' => false]
98
+                    ],
99
+                    ['upsert' => true, 'multiple' => false]
100 100
                 );
101 101
             } catch (MongoDBException $e) {
102 102
                 throw new phpFastCacheDriverException('Got an exception while trying to write data to MongoDB server', null, $e);
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
 
119 119
         if ($document) {
120 120
             return [
121
-              self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->getData()),
122
-              self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->getData()),
123
-              self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()),
121
+                self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->getData()),
122
+                self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->getData()),
123
+                self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()),
124 124
             ];
125 125
         } else {
126 126
             return null;
@@ -191,10 +191,10 @@  discard block
 block discarded – undo
191 191
              * @todo make an url builder
192 192
              */
193 193
             $this->instance = $this->instance ?: (new MongodbManager('mongodb://' .
194
-              ($username ?: '') .
195
-              ($password ? ":{$password}" : '') .
196
-              ($username ? '@' : '') . "{$host}" .
197
-              ($port != '27017' ? ":{$port}" : ''), ['connectTimeoutMS' => $timeout * 1000]));
194
+                ($username ?: '') .
195
+                ($password ? ":{$password}" : '') .
196
+                ($username ? '@' : '') . "{$host}" .
197
+                ($port != '27017' ? ":{$port}" : ''), ['connectTimeoutMS' => $timeout * 1000]));
198 198
             $this->collection = $this->collection ?: new Collection($this->instance,$databaseName, $collectionName);
199 199
 
200 200
             return true;
@@ -222,15 +222,15 @@  discard block
 block discarded – undo
222 222
     public function getStats()
223 223
     {
224 224
         $serverStats = $this->instance->executeCommand('phpFastCache', new Command([
225
-          'serverStatus' => 1,
226
-          'recordStats' => 0,
227
-          'repl' => 0,
228
-          'metrics' => 0,
225
+            'serverStatus' => 1,
226
+            'recordStats' => 0,
227
+            'repl' => 0,
228
+            'metrics' => 0,
229 229
         ]))->toArray()[0];
230 230
 
231 231
         $collectionStats = $this->instance->executeCommand('phpFastCache', new Command([
232
-          'collStats' => (isset($this->config[ 'collectionName' ]) ? $this->config[ 'collectionName' ] : 'Cache'),
233
-          'verbose' => true,
232
+            'collStats' => (isset($this->config[ 'collectionName' ]) ? $this->config[ 'collectionName' ] : 'Cache'),
233
+            'verbose' => true,
234 234
         ]))->toArray()[0];
235 235
 
236 236
         $array_filter_recursive = function( $array, callable $callback = null ) use(&$array_filter_recursive) {
@@ -260,13 +260,13 @@  discard block
 block discarded – undo
260 260
         $collectionStats = $array_filter_recursive($collectionStats, $callback);
261 261
 
262 262
         $stats = (new DriverStatistic())
263
-          ->setInfo('MongoDB version ' . $serverStats->version . ', Uptime (in days): ' . round($serverStats->uptime / 86400, 1) . "\n For more information see RawData.")
264
-          ->setSize($collectionStats->size)
265
-          ->setData(implode(', ', array_keys($this->itemInstances)))
266
-          ->setRawData([
263
+            ->setInfo('MongoDB version ' . $serverStats->version . ', Uptime (in days): ' . round($serverStats->uptime / 86400, 1) . "\n For more information see RawData.")
264
+            ->setSize($collectionStats->size)
265
+            ->setData(implode(', ', array_keys($this->itemInstances)))
266
+            ->setRawData([
267 267
             'serverStatus' => $serverStats,
268 268
             'collStats' => $collectionStats,
269
-          ]);
269
+            ]);
270 270
 
271 271
         return $stats;
272 272
     }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      */
67 67
     public function driverCheck()
68 68
     {
69
-        if(!class_exists('MongoDB\Driver\Manager') && class_exists('MongoClient')){
69
+        if (!class_exists('MongoDB\Driver\Manager') && class_exists('MongoClient')) {
70 70
             trigger_error('This driver is used to support the pecl MongoDb extension with mongo-php-library.
71 71
             For MongoDb with Mongo PECL support use Mongo Driver.', E_USER_ERROR);
72 72
         }
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
                     '$set' => [
94 94
                       self::DRIVER_DATA_WRAPPER_INDEX => new Binary($this->encode($item->get()), Binary::TYPE_GENERIC),
95 95
                       self::DRIVER_TAGS_WRAPPER_INDEX => new Binary($this->encode($item->getTags()), Binary::TYPE_GENERIC),
96
-                      self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((time() + $item->getTtl()) * 1000) : new UTCDateTime(time()*1000)),
96
+                      self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((time() + $item->getTtl()) * 1000) : new UTCDateTime(time() * 1000)),
97 97
                     ],
98 98
                   ],
99 99
                   ['upsert' => true, 'multiple' => false]
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
                 throw new phpFastCacheDriverException('Got an exception while trying to write data to MongoDB server', null, $e);
103 103
             }
104 104
 
105
-            return isset($result[ 'ok' ]) ? $result[ 'ok' ] == 1 : true;
105
+            return isset($result['ok']) ? $result['ok'] == 1 : true;
106 106
         } else {
107 107
             throw new phpFastCacheInvalidArgumentException('Cross-Driver type confusion detected');
108 108
         }
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
 
119 119
         if ($document) {
120 120
             return [
121
-              self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->getData()),
122
-              self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->getData()),
123
-              self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()),
121
+              self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[self::DRIVER_DATA_WRAPPER_INDEX]->getData()),
122
+              self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[self::DRIVER_TAGS_WRAPPER_INDEX]->getData()),
123
+              self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_EDATE_WRAPPER_INDEX]->toDateTime()->getTimestamp()),
124 124
             ];
125 125
         } else {
126 126
             return null;
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
          * @var \MongoDB\Model\BSONDocument $result
159 159
          */
160 160
         $result = $this->getCollection()->drop()->getArrayCopy();
161
-        $this->collection = new Collection($this->instance,'phpFastCache','Cache');
161
+        $this->collection = new Collection($this->instance, 'phpFastCache', 'Cache');
162 162
 
163 163
         /**
164 164
          * This will rebuild automatically the Collection indexes
@@ -178,13 +178,13 @@  discard block
 block discarded – undo
178 178
         if ($this->instance instanceof \MongoDB\Driver\Manager) {
179 179
             throw new LogicException('Already connected to Mongodb server');
180 180
         } else {
181
-            $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1';
182
-            $port = isset($this->config[ 'port' ]) ? $this->config[ 'port' ] : '27017';
183
-            $timeout = isset($this->config[ 'timeout' ]) ? $this->config[ 'timeout' ] : 3;
184
-            $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : '';
185
-            $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : '';
186
-            $collectionName = isset($this->config[ 'collectionName' ]) ? $this->config[ 'collectionName' ] : 'Cache';
187
-            $databaseName = isset($this->config[ 'databaseName' ]) ? $this->config[ 'databaseName' ] : 'phpFastCache';
181
+            $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1';
182
+            $port = isset($this->config['port']) ? $this->config['port'] : '27017';
183
+            $timeout = isset($this->config['timeout']) ? $this->config['timeout'] : 3;
184
+            $password = isset($this->config['password']) ? $this->config['password'] : '';
185
+            $username = isset($this->config['username']) ? $this->config['username'] : '';
186
+            $collectionName = isset($this->config['collectionName']) ? $this->config['collectionName'] : 'Cache';
187
+            $databaseName = isset($this->config['databaseName']) ? $this->config['databaseName'] : 'phpFastCache';
188 188
 
189 189
 
190 190
             /**
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
               ($password ? ":{$password}" : '') .
196 196
               ($username ? '@' : '') . "{$host}" .
197 197
               ($port != '27017' ? ":{$port}" : ''), ['connectTimeoutMS' => $timeout * 1000]));
198
-            $this->collection = $this->collection ?: new Collection($this->instance,$databaseName, $collectionName);
198
+            $this->collection = $this->collection ?: new Collection($this->instance, $databaseName, $collectionName);
199 199
 
200 200
             return true;
201 201
         }
@@ -229,16 +229,16 @@  discard block
 block discarded – undo
229 229
         ]))->toArray()[0];
230 230
 
231 231
         $collectionStats = $this->instance->executeCommand('phpFastCache', new Command([
232
-          'collStats' => (isset($this->config[ 'collectionName' ]) ? $this->config[ 'collectionName' ] : 'Cache'),
232
+          'collStats' => (isset($this->config['collectionName']) ? $this->config['collectionName'] : 'Cache'),
233 233
           'verbose' => true,
234 234
         ]))->toArray()[0];
235 235
 
236
-        $array_filter_recursive = function( $array, callable $callback = null ) use(&$array_filter_recursive) {
236
+        $array_filter_recursive = function($array, callable $callback = null) use(&$array_filter_recursive) {
237 237
             $array = $callback($array);
238 238
 
239
-            if(is_object($array) ||is_array($array)){
240
-                foreach ( $array as &$value ) {
241
-                    $value = call_user_func( $array_filter_recursive, $value, $callback );
239
+            if (is_object($array) || is_array($array)) {
240
+                foreach ($array as &$value) {
241
+                    $value = call_user_func($array_filter_recursive, $value, $callback);
242 242
                 }
243 243
             }
244 244
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
             /**
251 251
              * Remove unserializable properties
252 252
              */
253
-            if($item instanceof \MongoDB\BSON\UTCDateTime){
253
+            if ($item instanceof \MongoDB\BSON\UTCDateTime) {
254 254
                 return (string) $item;
255 255
             }
256 256
             return $item;
Please login to merge, or discard this patch.
src/phpFastCache/CacheManager.php 4 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -64,95 +64,95 @@  discard block
 block discarded – undo
64 64
         /**
65 65
          * Specify if the item must provide detailed creation/modification dates
66 66
          */
67
-      'itemDetailedDate' => false,
67
+        'itemDetailedDate' => false,
68 68
 
69 69
         /**
70 70
          * Automatically attempt to fallback to temporary directory
71 71
          * if the cache fails to write on the specified directory
72 72
          */
73
-      'autoTmpFallback' => false,
73
+        'autoTmpFallback' => false,
74 74
 
75 75
         /**
76 76
          * Provide a secure file manipulation mechanism,
77 77
          * on intensive usage the performance can be affected.
78 78
          */
79
-      'secureFileManipulation' => false,
79
+        'secureFileManipulation' => false,
80 80
 
81 81
         /**
82 82
          * Ignore Symfony notice for Symfony project which
83 83
          * do not makes use of PhpFastCache's Symfony Bundle
84 84
          */
85
-      'ignoreSymfonyNotice' => false,
85
+        'ignoreSymfonyNotice' => false,
86 86
 
87 87
         /**
88 88
          * Default time-to-live in second
89 89
          */
90
-      'defaultTtl' => 900,
90
+        'defaultTtl' => 900,
91 91
 
92 92
         /**
93 93
          * Default key hash function
94 94
          * (md5 by default)
95 95
          */
96
-      'defaultKeyHashFunction' => '',
96
+        'defaultKeyHashFunction' => '',
97 97
 
98 98
         /**
99 99
          * The securityKey that will be used
100 100
          * to create sub-directory
101 101
          * (Files-based drivers only)
102 102
          */
103
-      'securityKey' => 'auto',
103
+        'securityKey' => 'auto',
104 104
 
105 105
         /**
106 106
          * Auto-generate .htaccess if it's missing
107 107
          * (Files-based drivers only)
108 108
          */
109
-      'htaccess' => true,
109
+        'htaccess' => true,
110 110
 
111 111
         /**
112 112
          * Default files chmod
113 113
          * 0777 recommended
114 114
          * (Files-based drivers only)
115 115
          */
116
-      'default_chmod' => 0777,
116
+        'default_chmod' => 0777,
117 117
 
118 118
         /**
119 119
          * The path where we will writecache files
120 120
          * default value if empty: sys_get_temp_dir()
121 121
          * (Files-based drivers only)
122 122
          */
123
-      'path' => '',
123
+        'path' => '',
124 124
 
125 125
         /**
126 126
          * Driver fallback in case of failure.
127 127
          * Caution, in case of failure an E_WARNING
128 128
          * error will always be raised
129 129
          */
130
-      'fallback' => false,
130
+        'fallback' => false,
131 131
 
132 132
         /**
133 133
          * Maximum size (bytes) of object store in memory
134 134
          * (Memcache(d) drivers only)
135 135
          */
136
-      'limited_memory_each_object' => 4096,
136
+        'limited_memory_each_object' => 4096,
137 137
 
138 138
         /**
139 139
          * Compress stored data, if the backend supports it
140 140
          * (Memcache(d) drivers only)
141 141
          */
142
-      'compress_data' => false,
142
+        'compress_data' => false,
143 143
 
144 144
         /**
145 145
          * Prevent cache slams when
146 146
          * making use of heavy cache
147 147
          * items
148 148
          */
149
-      'preventCacheSlams' => false,
149
+        'preventCacheSlams' => false,
150 150
 
151 151
         /**
152 152
          * Cache slams timeout
153 153
          * in seconds
154 154
          */
155
-      'cacheSlamsTimeout' => 15,
155
+        'cacheSlamsTimeout' => 15,
156 156
 
157 157
     ];
158 158
 
@@ -335,24 +335,24 @@  discard block
 block discarded – undo
335 335
     public static function getStaticSystemDrivers()
336 336
     {
337 337
         return [
338
-          'Apc',
339
-          'Apcu',
340
-          'Cassandra',
341
-          'Couchbase',
342
-          'Couchdb',
343
-          'Devnull',
344
-          'Files',
345
-          'Leveldb',
346
-          'Memcache',
347
-          'Memcached',
348
-          'Memstatic',
349
-          'Mongodb',
350
-          'Predis',
351
-          'Redis',
352
-          'Ssdb',
353
-          'Sqlite',
354
-          'Wincache',
355
-          'Xcache',
338
+            'Apc',
339
+            'Apcu',
340
+            'Cassandra',
341
+            'Couchbase',
342
+            'Couchdb',
343
+            'Devnull',
344
+            'Files',
345
+            'Leveldb',
346
+            'Memcache',
347
+            'Memcached',
348
+            'Memstatic',
349
+            'Mongodb',
350
+            'Predis',
351
+            'Redis',
352
+            'Ssdb',
353
+            'Sqlite',
354
+            'Wincache',
355
+            'Xcache',
356 356
         ];
357 357
     }
358 358
 
@@ -362,9 +362,9 @@  discard block
 block discarded – undo
362 362
     public static function getStaticAllDrivers()
363 363
     {
364 364
         return array_merge(self::getStaticSystemDrivers(), [
365
-          'Devtrue',
366
-          'Devfalse',
367
-          'Cookie',
365
+            'Devtrue',
366
+            'Devfalse',
367
+            'Cookie',
368 368
         ]);
369 369
     }
370 370
 
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -188,42 +188,42 @@  discard block
 block discarded – undo
188 188
         }
189 189
 
190 190
         $instance = crc32($driver . serialize($config));
191
-        if (!isset(self::$instances[ $instance ])) {
191
+        if (!isset(self::$instances[$instance])) {
192 192
             $badPracticeOmeter[$driver] = 1;
193
-            if(!$config['ignoreSymfonyNotice'] && interface_exists('Symfony\Component\HttpKernel\KernelInterface') && !class_exists('phpFastCache\Bundle\phpFastCacheBundle')){
193
+            if (!$config['ignoreSymfonyNotice'] && interface_exists('Symfony\Component\HttpKernel\KernelInterface') && !class_exists('phpFastCache\Bundle\phpFastCacheBundle')) {
194 194
                 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);
195 195
             }
196 196
             $class = self::getNamespacePath() . $driver . '\Driver';
197
-            try{
198
-                self::$instances[ $instance ] = new $class($config);
199
-                self::$instances[ $instance ]->setEventManager(EventManager::getInstance());
200
-            }catch(phpFastCacheDriverCheckException $e){
201
-                if($config['fallback']){
202
-                    try{
197
+            try {
198
+                self::$instances[$instance] = new $class($config);
199
+                self::$instances[$instance]->setEventManager(EventManager::getInstance());
200
+            } catch (phpFastCacheDriverCheckException $e) {
201
+                if ($config['fallback']) {
202
+                    try {
203 203
                         $fallback = self::standardizeDriverName($config['fallback']);
204
-                        if($fallback !== $driver){
204
+                        if ($fallback !== $driver) {
205 205
                             $class = self::getNamespacePath() . $fallback . '\Driver';
206
-                            self::$instances[ $instance ] = new $class($config);
207
-                            self::$instances[ $instance ]->setEventManager(EventManager::getInstance());
206
+                            self::$instances[$instance] = new $class($config);
207
+                            self::$instances[$instance]->setEventManager(EventManager::getInstance());
208 208
                             trigger_error(sprintf('The "%s" driver is unavailable at the moment, the fallback driver "%s" has been used instead.', $driver, $fallback), E_USER_WARNING);
209
-                        }else{
209
+                        } else {
210 210
                             throw new phpFastCacheInvalidConfigurationException('The fallback driver cannot be the same than the default driver', 0, $e);
211 211
                         }
212
-                    }catch (phpFastCacheInvalidArgumentException $e){
212
+                    } catch (phpFastCacheInvalidArgumentException $e) {
213 213
                         throw new phpFastCacheInvalidConfigurationException('Invalid fallback driver configuration', 0, $e);
214 214
                     }
215
-                }else{
215
+                } else {
216 216
                     throw new phpFastCacheDriverCheckException($e->getMessage(), $e->getCode(), $e);
217 217
                 }
218 218
             }
219
-        } else if($badPracticeOmeter[$driver] >= 5){
219
+        } else if ($badPracticeOmeter[$driver] >= 5) {
220 220
             trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances.
221 221
            See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F');
222 222
         }
223 223
 
224 224
         $badPracticeOmeter[$driver]++;
225 225
 
226
-        return self::$instances[ $instance ];
226
+        return self::$instances[$instance];
227 227
     }
228 228
 
229 229
     /**
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
      */
285 285
     public static function __callStatic($name, $arguments)
286 286
     {
287
-        $options = (array_key_exists(0, $arguments) && is_array($arguments) ? $arguments[ 0 ] : []);
287
+        $options = (array_key_exists(0, $arguments) && is_array($arguments) ? $arguments[0] : []);
288 288
 
289 289
         return self::getInstance($name, $options);
290 290
     }
@@ -325,9 +325,9 @@  discard block
 block discarded – undo
325 325
     {
326 326
         if (is_array($name)) {
327 327
             self::$config = array_merge(self::$config, $name);
328
-        } else if (is_string($name)){
329
-            self::$config[ $name ] = $value;
330
-        }else{
328
+        } else if (is_string($name)) {
329
+            self::$config[$name] = $value;
330
+        } else {
331 331
             throw new phpFastCacheInvalidArgumentException('Invalid variable type: $name');
332 332
         }
333 333
     }
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
      */
387 387
     public static function standardizeDriverName($driverName)
388 388
     {
389
-        if(!is_string($driverName)){
389
+        if (!is_string($driverName)) {
390 390
             throw new phpFastCacheInvalidArgumentException(sprintf('Expected $driverName to be a string got "%s" instead', gettype($driverName)));
391 391
         }
392 392
         return ucfirst(strtolower(trim($driverName)));
@@ -401,70 +401,70 @@  discard block
 block discarded – undo
401 401
     protected static function validateConfig(array $config)
402 402
     {
403 403
         foreach ($config as $configName => $configValue) {
404
-            switch($configName)
404
+            switch ($configName)
405 405
             {
406 406
                 case 'itemDetailedDate':
407
-                    if(!is_bool($configValue)){
407
+                    if (!is_bool($configValue)) {
408 408
                         throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean");
409 409
                     }
410 410
                     break;
411 411
                 case 'autoTmpFallback':
412
-                    if(!is_bool($configValue)){
412
+                    if (!is_bool($configValue)) {
413 413
                         throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean");
414 414
                     }
415 415
                     break;
416 416
                 case 'secureFileManipulation':
417
-                    if(!is_bool($configValue)){
417
+                    if (!is_bool($configValue)) {
418 418
                         throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean");
419 419
                     }
420 420
                     break;
421 421
                 case 'ignoreSymfonyNotice':
422
-                    if(!is_bool($configValue)){
422
+                    if (!is_bool($configValue)) {
423 423
                         throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean");
424 424
                     }
425 425
                     break;
426 426
                 case 'defaultTtl':
427
-                    if(!is_numeric($configValue)){
427
+                    if (!is_numeric($configValue)) {
428 428
                         throw new phpFastCacheInvalidConfigurationException("{$configName} must be numeric");
429 429
                     }
430 430
                     break;
431 431
                 case 'defaultKeyHashFunction':
432
-                    if(!is_string($configValue) && !function_exists($configValue)){
432
+                    if (!is_string($configValue) && !function_exists($configValue)) {
433 433
                         throw new phpFastCacheInvalidConfigurationException("{$configName} must be a valid function name string");
434 434
                     }
435 435
                     break;
436 436
                 case 'securityKey':
437
-                    if(!is_string($configValue)){
437
+                    if (!is_string($configValue)) {
438 438
                         throw new phpFastCacheInvalidConfigurationException("{$configName} must be a string");
439 439
                     }
440 440
                     break;
441 441
                 case 'htaccess':
442
-                    if(!is_bool($configValue)){
442
+                    if (!is_bool($configValue)) {
443 443
                         throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean");
444 444
                     }
445 445
                     break;
446 446
                 case 'default_chmod':
447
-                    if(!is_int($configValue)){
447
+                    if (!is_int($configValue)) {
448 448
                         throw new phpFastCacheInvalidConfigurationException("{$configName} must be an integer");
449 449
                     }
450 450
                     break;
451 451
                 case 'path':
452
-                    if(!is_string($configValue)){
452
+                    if (!is_string($configValue)) {
453 453
                         throw new phpFastCacheInvalidConfigurationException("{$configName} must be a string");
454 454
                     }
455 455
                     break;
456 456
                 case 'fallback':
457
-                    if(!is_bool($configValue)){
457
+                    if (!is_bool($configValue)) {
458 458
                         throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean");
459 459
                     }
460 460
                     break;
461 461
                 case 'limited_memory_each_object':
462
-                    if(!is_int($configValue)){
462
+                    if (!is_int($configValue)) {
463 463
                         throw new phpFastCacheInvalidConfigurationException("{$configName} must be an integer");
464 464
                     }
465 465
                     break;
466 466
                 case 'compress_data':
467
-                    if(!is_bool($configValue)){
467
+                    if (!is_bool($configValue)) {
468 468
                         throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean");
469 469
                     }
470 470
                     break;
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
             try{
198 198
                 self::$instances[ $instance ] = new $class($config);
199 199
                 self::$instances[ $instance ]->setEventManager(EventManager::getInstance());
200
-            }catch(phpFastCacheDriverCheckException $e){
200
+            } catch(phpFastCacheDriverCheckException $e){
201 201
                 if($config['fallback']){
202 202
                     try{
203 203
                         $fallback = self::standardizeDriverName($config['fallback']);
@@ -206,13 +206,13 @@  discard block
 block discarded – undo
206 206
                             self::$instances[ $instance ] = new $class($config);
207 207
                             self::$instances[ $instance ]->setEventManager(EventManager::getInstance());
208 208
                             trigger_error(sprintf('The "%s" driver is unavailable at the moment, the fallback driver "%s" has been used instead.', $driver, $fallback), E_USER_WARNING);
209
-                        }else{
209
+                        } else{
210 210
                             throw new phpFastCacheInvalidConfigurationException('The fallback driver cannot be the same than the default driver', 0, $e);
211 211
                         }
212
-                    }catch (phpFastCacheInvalidArgumentException $e){
212
+                    } catch (phpFastCacheInvalidArgumentException $e){
213 213
                         throw new phpFastCacheInvalidConfigurationException('Invalid fallback driver configuration', 0, $e);
214 214
                     }
215
-                }else{
215
+                } else{
216 216
                     throw new phpFastCacheDriverCheckException($e->getMessage(), $e->getCode(), $e);
217 217
                 }
218 218
             }
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
             self::$config = array_merge(self::$config, $name);
328 328
         } else if (is_string($name)){
329 329
             self::$config[ $name ] = $value;
330
-        }else{
330
+        } else{
331 331
             throw new phpFastCacheInvalidArgumentException('Invalid variable type: $name');
332 332
         }
333 333
     }
Please login to merge, or discard this patch.
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 
346 346
 
347 347
     /**
348
-     * @return array
348
+     * @return ExtendedCacheItemPoolInterface[]
349 349
      */
350 350
     public static function getDefaultConfig()
351 351
     {
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
     }
354 354
 
355 355
     /**
356
-     * @return array
356
+     * @return string[]
357 357
      */
358 358
     public static function getStaticSystemDrivers()
359 359
     {
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
     }
381 381
 
382 382
     /**
383
-     * @return array
383
+     * @return string[]
384 384
      */
385 385
     public static function getStaticAllDrivers()
386 386
     {
Please login to merge, or discard this patch.
src/phpFastCache/Core/Item/ItemExtendedTrait.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
     {
51 51
         $keyHashFunction = $this->driver->getConfigOption('defaultKeyHashFunction');
52 52
 
53
-        if($keyHashFunction){
53
+        if ($keyHashFunction) {
54 54
             return $keyHashFunction($this->getKey());
55
-        }else{
55
+        } else {
56 56
             return md5($this->getKey());
57 57
         }
58 58
     }
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
      */
97 97
     public function getCreationDate()
98 98
     {
99
-        if($this->driver->getConfig()['itemDetailedDate']){
99
+        if ($this->driver->getConfig()['itemDetailedDate']) {
100 100
             return $this->creationDate;
101
-        }else{
101
+        } else {
102 102
             throw new phpFastCacheLogicException('Cannot access to the creation date when the "itemDetailedDate" configuration is disabled.');
103 103
         }
104 104
     }
@@ -110,10 +110,10 @@  discard block
 block discarded – undo
110 110
      */
111 111
     public function setCreationDate(\DateTimeInterface $date)
112 112
     {
113
-        if($this->driver->getConfig()['itemDetailedDate']){
113
+        if ($this->driver->getConfig()['itemDetailedDate']) {
114 114
             $this->creationDate = $date;
115 115
             return $this;
116
-        }else{
116
+        } else {
117 117
             throw new phpFastCacheLogicException('Cannot access to the creation date when the "itemDetailedDate" configuration is disabled.');
118 118
         }
119 119
     }
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
      */
125 125
     public function getModificationDate()
126 126
     {
127
-        if($this->driver->getConfig()['itemDetailedDate']){
127
+        if ($this->driver->getConfig()['itemDetailedDate']) {
128 128
             return $this->modificationDate;
129
-        }else{
129
+        } else {
130 130
             throw new phpFastCacheLogicException('Cannot access to the modification date when the "itemDetailedDate" configuration is disabled.');
131 131
         }
132 132
     }
@@ -138,10 +138,10 @@  discard block
 block discarded – undo
138 138
      */
139 139
     public function setModificationDate(\DateTimeInterface $date)
140 140
     {
141
-        if($this->driver->getConfig()['itemDetailedDate']){
141
+        if ($this->driver->getConfig()['itemDetailedDate']) {
142 142
             $this->modificationDate = $date;
143 143
             return $this;
144
-        }else{
144
+        } else {
145 145
             throw new phpFastCacheLogicException('Cannot access to the modification date when the "itemDetailedDate" configuration is disabled.');
146 146
         }
147 147
     }
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
     public function removeTag($tagName)
310 310
     {
311 311
         if (($key = array_search($tagName, $this->tags)) !== false) {
312
-            unset($this->tags[ $key ]);
312
+            unset($this->tags[$key]);
313 313
             $this->removedTags[] = $tagName;
314 314
         }
315 315
 
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
     final public function __debugInfo()
389 389
     {
390 390
         $info = get_object_vars($this);
391
-        $info[ 'driver' ] = 'object(' . get_class($info[ 'driver' ]) . ')';
391
+        $info['driver'] = 'object(' . get_class($info['driver']) . ')';
392 392
 
393 393
         return (array) $info;
394 394
     }
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
         if($keyHashFunction){
54 54
             return $keyHashFunction($this->getKey());
55
-        }else{
55
+        } else{
56 56
             return md5($this->getKey());
57 57
         }
58 58
     }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     {
99 99
         if($this->driver->getConfig()['itemDetailedDate']){
100 100
             return $this->creationDate;
101
-        }else{
101
+        } else{
102 102
             throw new phpFastCacheLogicException('Cannot access to the creation date when the "itemDetailedDate" configuration is disabled.');
103 103
         }
104 104
     }
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
         if($this->driver->getConfig()['itemDetailedDate']){
114 114
             $this->creationDate = $date;
115 115
             return $this;
116
-        }else{
116
+        } else{
117 117
             throw new phpFastCacheLogicException('Cannot access to the creation date when the "itemDetailedDate" configuration is disabled.');
118 118
         }
119 119
     }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     {
127 127
         if($this->driver->getConfig()['itemDetailedDate']){
128 128
             return $this->modificationDate;
129
-        }else{
129
+        } else{
130 130
             throw new phpFastCacheLogicException('Cannot access to the modification date when the "itemDetailedDate" configuration is disabled.');
131 131
         }
132 132
     }
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
         if($this->driver->getConfig()['itemDetailedDate']){
142 142
             $this->modificationDate = $date;
143 143
             return $this;
144
-        }else{
144
+        } else{
145 145
             throw new phpFastCacheLogicException('Cannot access to the modification date when the "itemDetailedDate" configuration is disabled.');
146 146
         }
147 147
     }
Please login to merge, or discard this patch.
src/phpFastCache/Entities/DriverStatistic.php 1 patch
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     }
53 53
 
54 54
     /**
55
-     * @return int|bool Return size in octet or false if no information available
55
+     * @return string Return size in octet or false if no information available
56 56
      */
57 57
     public function getSize()
58 58
     {
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     }
61 61
 
62 62
     /**
63
-     * @return mixed
63
+     * @return string
64 64
      */
65 65
     public function getData()
66 66
     {
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     }
69 69
 
70 70
     /**
71
-     * @param $info
71
+     * @param string $info
72 72
      * @return $this
73 73
      */
74 74
     public function setInfo($info)
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/Zendshm/Driver.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -147,8 +147,8 @@
 block discarded – undo
147 147
         $stats = (array) zend_shm_cache_info();
148 148
         return (new DriverStatistic())
149 149
             ->setData(implode(', ', array_keys($this->namespaces)))
150
-            ->setInfo(sprintf("The Zend memory have %d item(s) in cache.\n For more information see RawData.",$stats[ 'items_total' ]))
150
+            ->setInfo(sprintf("The Zend memory have %d item(s) in cache.\n For more information see RawData.", $stats['items_total']))
151 151
             ->setRawData($stats)
152
-            ->setSize($stats[ 'memory_total' ]);
152
+            ->setSize($stats['memory_total']);
153 153
     }
154 154
 }
155 155
\ No newline at end of file
Please login to merge, or discard this patch.