Completed
Push — V6 ( 6f3726...b362d7 )
by Georges
02:31
created
tests/NewCacheInstance.test.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 if (!class_exists('phpFastCache\CacheManager')) {
16 16
     echo "[FAIL] Autoload failed to find the CacheManager\n";
17 17
     $status = 255;
18
-}else{
18
+} else {
19 19
     echo "[PASS] Autoload successfully found the CacheManager\n";
20 20
 }
21 21
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 if (!class_exists('phpFastCache\CacheManager')) {
16 16
     echo "[FAIL] Autoload failed to find the CacheManager\n";
17 17
     $status = 255;
18
-}else{
18
+} else{
19 19
     echo "[PASS] Autoload successfully found the CacheManager\n";
20 20
 }
21 21
 
Please login to merge, or discard this patch.
tests/EventManager.test.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 $status = 0;
17 17
 echo "Testing EventManager\n";
18 18
 
19
-EventManager::getInstance()->onCacheSaveItem(function(ExtendedCacheItemPoolInterface $itemPool, ExtendedCacheItemInterface $item){
20
-    if($item->get() === 1000){
19
+EventManager::getInstance()->onCacheSaveItem(function(ExtendedCacheItemPoolInterface $itemPool, ExtendedCacheItemInterface $item) {
20
+    if ($item->get() === 1000) {
21 21
         $item->increment(337);
22 22
     }
23 23
 });
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
 $cacheInstance->save($item);
31 31
 
32 32
 
33
-if($cacheInstance->getItem($cacheKey)->get() === 1337){
33
+if ($cacheInstance->getItem($cacheKey)->get() === 1337) {
34 34
     echo "[PASS] The dispatched event executed the custom callback to alter to item.\n";
35
-}else{
35
+} else {
36 36
     echo "[FAIL] The dispatched event did not worked well, the expected value '1337', got '" . (int) $cacheInstance->getItem($cacheKey)->get() . "'\n";
37 37
     $status = 1;
38 38
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 if (!class_exists('phpFastCache\CacheManager')) {
16 16
     echo "[FAIL] Autoload failed to find the CacheManager\n";
17 17
     $status = 255;
18
-}else{
18
+} else{
19 19
     echo "[PASS] Autoload successfully found the CacheManager\n";
20 20
 }
21 21
 
Please login to merge, or discard this patch.
src/phpFastCache/Drivers/Files/Driver.php 1 patch
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 
61 61
     /**
62 62
      * @param \Psr\Cache\CacheItemInterface $item
63
-     * @return mixed
63
+     * @return boolean
64 64
      * @throws \InvalidArgumentException
65 65
      */
66 66
     protected function driverWrite(CacheItemInterface $item)
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
     /**
147 147
      * @param string $optionName
148 148
      * @param mixed $optionValue
149
-     * @return bool
149
+     * @return boolean|null
150 150
      * @throws \InvalidArgumentException
151 151
      */
152 152
     public static function isValidOption($optionName, $optionValue)
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
     }
175 175
 
176 176
     /**
177
-     * @return array
177
+     * @return string[]
178 178
      */
179 179
     public static function getValidOptions()
180 180
     {
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
     }
183 183
 
184 184
     /**
185
-     * @return array
185
+     * @return string[]
186 186
      */
187 187
     public static function getRequiredOptions()
188 188
     {
Please login to merge, or discard this patch.
src/phpFastCache/Core/Pool/IO/IOHelperTrait.php 4 patches
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
                 return $tmp_dir;
98 98
             }
99 99
             return $full_path;
100
-        }else{
100
+        } else{
101 101
             if (!isset($this->tmp[ $full_path_hash ]) || (!@file_exists($full_path) || !@is_writable($full_path))) {
102 102
                 if (!@file_exists($full_path)) {
103 103
                     @mkdir($full_path, $this->setChmodAuto(), true);
104
-                }else if (!@is_writable($full_path)) {
104
+                } else if (!@is_writable($full_path)) {
105 105
                     @chmod($full_path, $this->setChmodAuto());
106 106
                 }
107 107
 
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
             if(!rename($tmpFilename, $file)){
313 313
                 throw new phpFastCacheIOException(sprintf('Failed to rename %s to %s', $tmpFilename, $file));
314 314
             }
315
-        }else{
315
+        } else{
316 316
             $f = fopen($file, 'w+');
317 317
             $octetWritten = fwrite($f, $data);
318 318
             fclose($f);
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -41,10 +41,10 @@  discard block
 block discarded – undo
41 41
          * Calculate the security key
42 42
          */
43 43
         {
44
-            $securityKey = array_key_exists('securityKey', $this->config) ? $this->config[ 'securityKey' ] : '';
44
+            $securityKey = array_key_exists('securityKey', $this->config) ? $this->config['securityKey'] : '';
45 45
             if (!$securityKey || $securityKey === 'auto') {
46
-                if (isset($_SERVER[ 'HTTP_HOST' ])) {
47
-                    $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER[ 'HTTP_HOST' ])));
46
+                if (isset($_SERVER['HTTP_HOST'])) {
47
+                    $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER['HTTP_HOST'])));
48 48
                 } else {
49 49
                     $securityKey = ($this->isPHPModule() ? 'web' : 'cli');
50 50
                 }
@@ -63,10 +63,10 @@  discard block
 block discarded – undo
63 63
          */
64 64
         $tmp_dir = rtrim($tmp_dir, '/') . DIRECTORY_SEPARATOR;
65 65
 
66
-        if (empty($this->config[ 'path' ]) || !is_string($this->config[ 'path' ])) {
66
+        if (empty($this->config['path']) || !is_string($this->config['path'])) {
67 67
             $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
 
72 72
         $path_suffix = $securityKey . DIRECTORY_SEPARATOR . $this->getDriverName();
@@ -81,16 +81,16 @@  discard block
 block discarded – undo
81 81
          * return the temp dir
82 82
          */
83 83
         if ($readonly === true) {
84
-            if($this->config[ 'autoTmpFallback' ] && (!@file_exists($full_path) || !@is_writable($full_path))){
84
+            if ($this->config['autoTmpFallback'] && (!@file_exists($full_path) || !@is_writable($full_path))) {
85 85
                 return $full_path_tmp;
86 86
             }
87 87
             return $full_path;
88
-        }else{
89
-            if (!isset($this->tmp[ $full_path_hash ]) || (!@file_exists($full_path) || !@is_writable($full_path))) {
88
+        } else {
89
+            if (!isset($this->tmp[$full_path_hash]) || (!@file_exists($full_path) || !@is_writable($full_path))) {
90 90
                 if (!@file_exists($full_path)) {
91 91
                     @mkdir($full_path, $this->setChmodAuto(), true);
92
-                }else if (!@is_writable($full_path)) {
93
-                    if (!@chmod($full_path, $this->setChmodAuto()) && $this->config[ 'autoTmpFallback' ])
92
+                } else if (!@is_writable($full_path)) {
93
+                    if (!@chmod($full_path, $this->setChmodAuto()) && $this->config['autoTmpFallback'])
94 94
                     {
95 95
                         /**
96 96
                          * Switch back to tmp dir
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
                     throw new phpFastCacheIOException('PLEASE CREATE OR CHMOD ' . $full_path . ' - 0777 OR ANY WRITABLE PERMISSION!');
113 113
                 }
114 114
 
115
-                $this->tmp[ $full_path_hash ] = $full_path;
116
-                $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config[ 'htaccess' ] : false);
115
+                $this->tmp[$full_path_hash] = $full_path;
116
+                $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config['htaccess'] : false);
117 117
             }
118 118
         }
119 119
 
@@ -180,10 +180,10 @@  discard block
 block discarded – undo
180 180
      */
181 181
     public function setChmodAuto()
182 182
     {
183
-        if (!isset($this->config[ 'default_chmod' ]) || $this->config[ 'default_chmod' ] == '' || is_null($this->config[ 'default_chmod' ])) {
183
+        if (!isset($this->config['default_chmod']) || $this->config['default_chmod'] == '' || is_null($this->config['default_chmod'])) {
184 184
             return 0777;
185 185
         } else {
186
-            return $this->config[ 'default_chmod' ];
186
+            return $this->config['default_chmod'];
187 187
         }
188 188
     }
189 189
 
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
         if ($create === true) {
214 214
             if (!is_writable($path)) {
215 215
                 try {
216
-                    if(!chmod($path, 0777)){
216
+                    if (!chmod($path, 0777)) {
217 217
                         throw new phpFastCacheIOException('Chmod failed on : ' . $path);
218 218
                     }
219 219
                 } catch (phpFastCacheIOException $e) {
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
          */
285 285
         $this->eventManager->dispatch('CacheWriteFileOnDisk', $this, $file, $secureFileManipulation);
286 286
 
287
-        if($secureFileManipulation){
287
+        if ($secureFileManipulation) {
288 288
             $tmpFilename = Directory::getAbsolutePath(dirname($file) . '/tmp_' . md5(
289 289
                 str_shuffle(uniqid($this->getDriverName(), false))
290 290
                 . str_shuffle(uniqid($this->getDriverName(), false))
@@ -296,10 +296,10 @@  discard block
 block discarded – undo
296 296
             flock($f, LOCK_UN);
297 297
             fclose($f);
298 298
 
299
-            if(!rename($tmpFilename, $file)){
299
+            if (!rename($tmpFilename, $file)) {
300 300
                 throw new phpFastCacheIOException(sprintf('Failed to rename %s to %s', $tmpFilename, $file));
301 301
             }
302
-        }else{
302
+        } else {
303 303
             $f = fopen($file, 'w+');
304 304
             $octetWritten = fwrite($f, $data);
305 305
             fclose($f);
Please login to merge, or discard this patch.
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 
131 131
 
132 132
     /**
133
-     * @param $keyword
133
+     * @param false|string $keyword
134 134
      * @param bool $skip
135 135
      * @return string
136 136
      * @throws phpFastCacheIOException
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 
198 198
     /**
199 199
      * @param $filename
200
-     * @return mixed
200
+     * @return string
201 201
      */
202 202
     protected static function cleanFileName($filename)
203 203
     {
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
     }
213 213
 
214 214
     /**
215
-     * @param $path
215
+     * @param string $path
216 216
      * @param bool $create
217 217
      * @throws phpFastCacheIOException
218 218
      */
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 
250 250
 
251 251
     /**
252
-     * @param $file
252
+     * @param string $file
253 253
      * @return string
254 254
      * @throws phpFastCacheIOException
255 255
      */
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -202,9 +202,9 @@  discard block
 block discarded – undo
202 202
     protected static function cleanFileName($filename)
203 203
     {
204 204
         $regex = [
205
-          '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/',
206
-          '/\.$/',
207
-          '/^\./',
205
+            '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/',
206
+            '/\.$/',
207
+            '/^\./',
208 208
         ];
209 209
         $replace = ['-', '', ''];
210 210
 
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
             $tmpFilename = Directory::getAbsolutePath(dirname($file) . '/tmp_' . md5(
297 297
                 str_shuffle(uniqid($this->getDriverName(), false))
298 298
                 . str_shuffle(uniqid($this->getDriverName(), false))
299
-              ));
299
+                ));
300 300
 
301 301
             $f = fopen($tmpFilename, 'w+');
302 302
             flock($f, LOCK_EX);
@@ -338,11 +338,11 @@  discard block
 block discarded – undo
338 338
         }
339 339
 
340 340
         $stat->setData(implode(', ', array_keys($this->itemInstances)))
341
-          ->setRawData([
341
+            ->setRawData([
342 342
             'tmp' => $this->tmp
343
-          ])
344
-          ->setSize(Directory::dirSize($path))
345
-          ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path));
343
+            ])
344
+            ->setSize(Directory::dirSize($path))
345
+            ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path));
346 346
 
347 347
         return $stat;
348 348
     }
Please login to merge, or discard this patch.
tests/ReadWriteOperations.test.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,9 +23,9 @@
 block discarded – undo
23 23
 $keys = [];
24 24
 
25 25
 $dirs = [
26
-  __DIR__ . '/../var/cache/IO-',
27
-  sys_get_temp_dir() . '/phpfastcache/IO-1',
28
-  sys_get_temp_dir() . '/phpfastcache/IO-2'
26
+    __DIR__ . '/../var/cache/IO-',
27
+    sys_get_temp_dir() . '/phpfastcache/IO-1',
28
+    sys_get_temp_dir() . '/phpfastcache/IO-2'
29 29
 ];
30 30
 
31 31
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
     {
40 40
         $cacheInstanceName = 'cacheInstance' . $i;
41 41
 
42
-        $instances[$dirIndex][$cacheInstanceName] = CacheManager::getInstance('Files',array('path' => $dir . str_pad($i, 3, '0', STR_PAD_LEFT)));
42
+        $instances[$dirIndex][$cacheInstanceName] = CacheManager::getInstance('Files', array('path' => $dir . str_pad($i, 3, '0', STR_PAD_LEFT)));
43 43
 
44
-        foreach($keys[$dirIndex] as $index => $key)
44
+        foreach ($keys[$dirIndex] as $index => $key)
45 45
         {
46 46
             $items[$dirIndex][$index] = $instances[$dirIndex][$cacheInstanceName]->getItem($key);
47 47
             $items[$dirIndex][$index]->set("test-$dirIndex-$index")->expiresAfter(600);
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
         $instances[$dirIndex][$cacheInstanceName]->detachAllItems();
52 52
     }
53 53
 
54
-    foreach($instances[$dirIndex] as $cacheInstanceName => $instance)
54
+    foreach ($instances[$dirIndex] as $cacheInstanceName => $instance)
55 55
     {
56
-        foreach($keys[$dirIndex] as $index => $key)
56
+        foreach ($keys[$dirIndex] as $index => $key)
57 57
         {
58
-            if($instances[$dirIndex][$cacheInstanceName]->getItem($key)->get() === "test-$dirIndex-$index")
58
+            if ($instances[$dirIndex][$cacheInstanceName]->getItem($key)->get() === "test-$dirIndex-$index")
59 59
             {
60 60
                 echo "[PASS] Item #{$key} of instance #{$cacheInstanceName} of dir #{$dirIndex} has returned the expected value (" . gettype("test-$dirIndex-$index") . ":'" . "test-$dirIndex-$index" . "')\n";
61 61
             }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,8 +58,7 @@
 block discarded – undo
58 58
             if($instances[$dirIndex][$cacheInstanceName]->getItem($key)->get() === "test-$dirIndex-$index")
59 59
             {
60 60
                 echo "[PASS] Item #{$key} of instance #{$cacheInstanceName} of dir #{$dirIndex} has returned the expected value (" . gettype("test-$dirIndex-$index") . ":'" . "test-$dirIndex-$index" . "')\n";
61
-            }
62
-            else
61
+            } else
63 62
             {
64 63
                 echo "[FAIL] Item #{$key} of instance #{$cacheInstanceName} of dir #{$dirIndex} returned an unexpected value (" . gettype($instances[$dirIndex][$cacheInstanceName]->getItem($key)->get()) . ":'" . $instances[$dirIndex][$cacheInstanceName]->getItem($key)->get() . "') expected (" . gettype("test-$dirIndex-$index") . ":'" . "test-$dirIndex-$index" . "') \n";
65 64
                 $status = 255;
Please login to merge, or discard this patch.
src/autoload.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,6 +46,6 @@
 block discarded – undo
46 46
 });
47 47
 
48 48
 if ((!defined('PFC_IGNORE_COMPOSER_WARNING') || !PFC_IGNORE_COMPOSER_WARNING) && class_exists('Composer\Autoload\ClassLoader')) {
49
-  trigger_error('Your project already makes use of Composer. You SHOULD use the composer dependency "phpfastcache/phpfastcache" instead of hard-autoloading.',
49
+    trigger_error('Your project already makes use of Composer. You SHOULD use the composer dependency "phpfastcache/phpfastcache" instead of hard-autoloading.',
50 50
     E_USER_WARNING);
51 51
 }
52 52
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,9 +18,9 @@  discard block
 block discarded – undo
18 18
 /**
19 19
  * Register Autoload
20 20
  */
21
-spl_autoload_register(function ($entity) {
21
+spl_autoload_register(function($entity) {
22 22
     $module = explode('\\', $entity, 2);
23
-    if (!in_array($module[ 0 ], ['phpFastCache', 'Psr'])) {
23
+    if (!in_array($module[0], ['phpFastCache', 'Psr'])) {
24 24
         /**
25 25
          * Not a part of phpFastCache file
26 26
          * then we return here.
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
         if (is_readable($path)) {
33 33
             require_once $path;
34
-        }else{
34
+        } else {
35 35
             trigger_error('Cannot locate the Psr/Cache files', E_USER_ERROR);
36 36
         }
37 37
         return;
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 
41 41
         if (is_readable($path)) {
42 42
             require_once $path;
43
-        }else{
43
+        } else {
44 44
             trigger_error('Cannot locate the Psr/SimpleCache files', E_USER_ERROR);
45 45
         }
46 46
         return;
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
             flock($f, LOCK_UN);
120 120
             fclose($f);
121 121
             rename($tmpFilename, $file);
122
-        }else{
122
+        } else{
123 123
             $f = fopen($file, 'w+');
124 124
             $octetWritten = fwrite($f, $data);
125 125
             fclose($f);
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
              * reuse it else set a new Date
209 209
              */
210 210
             $wrap[ self::DRIVER_CDATE_WRAPPER_INDEX ] = $item->getCreationDate() ?: new \DateTime();
211
-        }else{
211
+        } else{
212 212
             $wrap[ self::DRIVER_MDATE_WRAPPER_INDEX ] = null;
213 213
             $wrap[ self::DRIVER_CDATE_WRAPPER_INDEX ] = null;
214 214
         }
Please login to merge, or discard this patch.
src/phpFastCache/Drivers/Memstatic/Driver.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
 {
30 30
     use DriverBaseTrait;
31 31
 
32
-  /**
33
-   * @var array
34
-   */
32
+    /**
33
+     * @var array
34
+     */
35 35
     protected $staticStack = [];
36 36
 
37 37
     /**
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     {
86 86
         $key = md5($item->getKey());
87 87
         if(isset($this->staticStack[$key])){
88
-          return $this->staticStack[$key];
88
+            return $this->staticStack[$key];
89 89
         }
90 90
         return null;
91 91
     }
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
          * Check for Cross-Driver type confusion
102 102
          */
103 103
         if ($item instanceof Item) {
104
-          $key = md5($item->getKey());
105
-          if(isset($this->staticStack[$key])){
106
-              unset($this->staticStack[$key]);
107
-              return true;
108
-          }
109
-          return false;
104
+            $key = md5($item->getKey());
105
+            if(isset($this->staticStack[$key])){
106
+                unset($this->staticStack[$key]);
107
+                return true;
108
+            }
109
+            return false;
110 110
         } else {
111 111
             throw new \InvalidArgumentException('Cross-Driver type confusion detected');
112 112
         }
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
      */
118 118
     protected function driverClear()
119 119
     {
120
-      unset($this->staticStack);
121
-      $this->staticStack = [];
122
-      return true;
120
+        unset($this->staticStack);
121
+        $this->staticStack = [];
122
+        return true;
123 123
     }
124 124
 
125 125
     /**
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
     {
144 144
         $stat = new driverStatistic();
145 145
         $stat->setInfo('[Memstatic] A memory static driver')
146
-          ->setSize(mb_strlen(serialize($this->staticStack)))
147
-          ->setData(implode(', ', array_keys($this->itemInstances)))
148
-          ->setRawData($this->staticStack);
146
+            ->setSize(mb_strlen(serialize($this->staticStack)))
147
+            ->setData(implode(', ', array_keys($this->itemInstances)))
148
+            ->setRawData($this->staticStack);
149 149
 
150 150
         return $stat;
151 151
     }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     protected function driverRead(CacheItemInterface $item)
85 85
     {
86 86
         $key = md5($item->getKey());
87
-        if(isset($this->staticStack[$key])){
87
+        if (isset($this->staticStack[$key])) {
88 88
           return $this->staticStack[$key];
89 89
         }
90 90
         return null;
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
          */
103 103
         if ($item instanceof Item) {
104 104
           $key = md5($item->getKey());
105
-          if(isset($this->staticStack[$key])){
105
+          if (isset($this->staticStack[$key])) {
106 106
               unset($this->staticStack[$key]);
107 107
               return true;
108 108
           }
Please login to merge, or discard this patch.
src/phpFastCache/Core/Pool/ExtendedCacheItemPoolTrait.php 3 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,6 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 47
     /**
48 48
      * @inheritdoc
49
+     * @param string $tagName
49 50
      */
50 51
     public function getItemsByTag($tagName)
51 52
     {
@@ -416,7 +417,7 @@  discard block
 block discarded – undo
416 417
 
417 418
     /**
418 419
      * @internal This method de-register an item from $this->itemInstances
419
-     * @param CacheItemInterface|string $item
420
+     * @param CacheItemInterface $item
420 421
      * @throws \InvalidArgumentException
421 422
      */
422 423
     protected function deregisterItem($item)
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      */
39 39
     public function getItemsAsJsonString(array $keys = [], $option = 0, $depth = 512)
40 40
     {
41
-        $callback = function (CacheItemInterface $item) {
41
+        $callback = function(CacheItemInterface $item) {
42 42
             return $item->get();
43 43
         };
44 44
         return json_encode(array_map($callback, array_values($this->getItems($keys))), $option, $depth);
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
         if (is_string($tagName)) {
53 53
             $driverResponse = $this->getItem($this->getTagKey($tagName));
54 54
             if ($driverResponse->isHit()) {
55
-                $items = (array)$driverResponse->get();
55
+                $items = (array) $driverResponse->get();
56 56
 
57 57
                 /**
58 58
                  * getItems() may provides expired item(s)
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
                  *
65 65
                  * #headache
66 66
                  */
67
-                return array_filter($this->getItems(array_unique(array_keys($items))), function (ExtendedCacheItemInterface $item) {
67
+                return array_filter($this->getItems(array_unique(array_keys($items))), function(ExtendedCacheItemInterface $item) {
68 68
                     return $item->isHit();
69 69
                 });
70 70
             } else {
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
     {
83 83
         $items = [];
84 84
         foreach (array_unique($tagNames) as $tagName) {
85
-            if(is_string($tagName)){
85
+            if (is_string($tagName)) {
86 86
                 $items = array_merge($items, $this->getItemsByTag($tagName));
87
-            }else{
87
+            } else {
88 88
                 throw new InvalidArgumentException('$tagName must be a a string');
89 89
             }
90 90
         }
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 
103 103
         foreach ($items as $key => $item) {
104 104
             if (array_diff($tagNames, $item->getTags())) {
105
-                unset($items[ $key ]);
105
+                unset($items[$key]);
106 106
             }
107 107
         }
108 108
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
      */
116 116
     public function getItemsByTagsAsJsonString(array $tagNames, $option = 0, $depth = 512)
117 117
     {
118
-        $callback = function (CacheItemInterface $item) {
118
+        $callback = function(CacheItemInterface $item) {
119 119
             return $item->get();
120 120
         };
121 121
 
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
      */
387 387
     public function detachItem(CacheItemInterface $item)
388 388
     {
389
-        if (isset($this->itemInstances[ $item->getKey() ])) {
389
+        if (isset($this->itemInstances[$item->getKey()])) {
390 390
             $this->deregisterItem($item);
391 391
         }
392 392
     }
@@ -406,10 +406,10 @@  discard block
 block discarded – undo
406 406
      */
407 407
     public function attachItem(CacheItemInterface $item)
408 408
     {
409
-        if (isset($this->itemInstances[ $item->getKey() ]) && spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])) {
409
+        if (isset($this->itemInstances[$item->getKey()]) && spl_object_hash($item) !== spl_object_hash($this->itemInstances[$item->getKey()])) {
410 410
             throw new \LogicException('The item already exists and cannot be overwritten because the Spl object hash mismatches ! You probably tried to re-attach a detached item which has been already retrieved from cache.');
411 411
         } else {
412
-            $this->itemInstances[ $item->getKey() ] = $item;
412
+            $this->itemInstances[$item->getKey()] = $item;
413 413
         }
414 414
     }
415 415
 
@@ -422,10 +422,10 @@  discard block
 block discarded – undo
422 422
     protected function deregisterItem($item)
423 423
     {
424 424
         if ($item instanceof CacheItemInterface) {
425
-            unset($this->itemInstances[ $item->getKey() ]);
425
+            unset($this->itemInstances[$item->getKey()]);
426 426
 
427 427
         } else if (is_string($item)) {
428
-            unset($this->itemInstances[ $item ]);
428
+            unset($this->itemInstances[$item]);
429 429
         } else {
430 430
             throw new \InvalidArgumentException('Invalid type for $item variable');
431 431
         }
@@ -445,8 +445,8 @@  discard block
 block discarded – undo
445 445
      */
446 446
     public function isAttached(CacheItemInterface $item)
447 447
     {
448
-        if (isset($this->itemInstances[ $item->getKey() ])) {
449
-            return spl_object_hash($item) === spl_object_hash($this->itemInstances[ $item->getKey() ]);
448
+        if (isset($this->itemInstances[$item->getKey()])) {
449
+            return spl_object_hash($item) === spl_object_hash($this->itemInstances[$item->getKey()]);
450 450
         }
451 451
         return null;
452 452
     }
@@ -466,8 +466,8 @@  discard block
 block discarded – undo
466 466
      */
467 467
     public function saveMultiple(...$items)
468 468
     {
469
-        if (isset($items[ 0 ]) && is_array($items[ 0 ])) {
470
-            foreach ($items[ 0 ] as $item) {
469
+        if (isset($items[0]) && is_array($items[0])) {
470
+            foreach ($items[0] as $item) {
471 471
                 $this->save($item);
472 472
             }
473 473
             return true;
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@
 block discarded – undo
84 84
         foreach (array_unique($tagNames) as $tagName) {
85 85
             if(is_string($tagName)){
86 86
                 $items = array_merge($items, $this->getItemsByTag($tagName));
87
-            }else{
87
+            } else{
88 88
                 throw new InvalidArgumentException('$tagName must be a a string');
89 89
             }
90 90
         }
Please login to merge, or discard this patch.
tests/ItemTags.test.php 3 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -28,36 +28,36 @@
 block discarded – undo
28 28
     $item3 = $driverInstance->getItem('tag-test3');
29 29
 
30 30
     $item1->set('item-test_1')
31
-      ->expiresAfter(600)
32
-      ->addTag('tag-test_1')
33
-      ->addTag('tag-test_all')
34
-      ->addTag('tag-test_all2')
35
-      ->addTag('tag-test_all3');
31
+        ->expiresAfter(600)
32
+        ->addTag('tag-test_1')
33
+        ->addTag('tag-test_all')
34
+        ->addTag('tag-test_all2')
35
+        ->addTag('tag-test_all3');
36 36
 
37 37
     $item2->set('item-test_2')
38
-      ->expiresAfter(600)
39
-      ->addTag('tag-test_1')
40
-      ->addTag('tag-test_2')
41
-      ->addTag('tag-test_all')
42
-      ->addTag('tag-test_all2')
43
-      ->addTag('tag-test_all3');
38
+        ->expiresAfter(600)
39
+        ->addTag('tag-test_1')
40
+        ->addTag('tag-test_2')
41
+        ->addTag('tag-test_all')
42
+        ->addTag('tag-test_all2')
43
+        ->addTag('tag-test_all3');
44 44
 
45 45
     $item3->set('item-test_3')
46
-      ->expiresAfter(600)
47
-      ->addTag('tag-test_1')
48
-      ->addTag('tag-test_2')
49
-      ->addTag('tag-test_3')
50
-      ->addTag('tag-test_all')
51
-      ->addTag('tag-test_all2')
52
-      ->addTag('tag-test_all3')
53
-      ->addTag('tag-test_all4');
46
+        ->expiresAfter(600)
47
+        ->addTag('tag-test_1')
48
+        ->addTag('tag-test_2')
49
+        ->addTag('tag-test_3')
50
+        ->addTag('tag-test_all')
51
+        ->addTag('tag-test_all2')
52
+        ->addTag('tag-test_all3')
53
+        ->addTag('tag-test_all4');
54 54
 
55 55
     $driverInstance->saveMultiple($item1, $item2, $item3);
56 56
 
57 57
     return [
58
-      'item1' => $item1,
59
-      'item2' => $item2,
60
-      'item3' => $item3
58
+        'item1' => $item1,
59
+        'item2' => $item2,
60
+        'item3' => $item3
61 61
     ];
62 62
 };
63 63
 
Please login to merge, or discard this patch.
Braces   +14 added lines, -28 removed lines patch added patch discarded remove patch
@@ -82,15 +82,13 @@  discard block
 block discarded – undo
82 82
             }
83 83
         }
84 84
         echo "[PASS] STEP#1 // Successfully retrieved 3 tagged item keys\n";
85
-    }
86
-    else
85
+    } else
87 86
     {
88 87
         echo '[FAIL] STEP#1 //Got wrong count of item:' . count($tagsItems) .  "\n";
89 88
         $status = 1;
90 89
         goto itemTagTest2;
91 90
     }
92
-}
93
-else
91
+} else
94 92
 {
95 93
     echo '[FAIL] STEP#1 // Expected $tagsItems to be an array, got: ' . gettype($tagsItems) .  "\n";
96 94
     $status = 1;
@@ -120,15 +118,13 @@  discard block
 block discarded – undo
120 118
             }
121 119
         }
122 120
         echo "[PASS] STEP#2 // Successfully retrieved 3 tagged item key\n";
123
-    }
124
-    else
121
+    } else
125 122
     {
126 123
         echo '[FAIL] STEP#2 // Got wrong count of item:' . count($tagsItems) .  "\n";
127 124
         $status = 1;
128 125
         goto itemTagTest3;
129 126
     }
130
-}
131
-else
127
+} else
132 128
 {
133 129
     echo '[FAIL] STEP#2 // Expected $tagsItems to be an array, got: ' . gettype($tagsItems) .  "\n";
134 130
     $status = 1;
@@ -157,22 +153,19 @@  discard block
 block discarded – undo
157 153
                 goto itemTagTest4;
158 154
             }
159 155
             echo "[PASS] STEP#3 // Successfully retrieved 1 tagged item keys\n";
160
-        }
161
-        else
156
+        } else
162 157
         {
163 158
             echo '[FAIL] STEP#3 // Got wrong array key, expected "tag-test3", got "' . key($tagsItems) .  "\"\n";
164 159
             $status = 1;
165 160
             goto itemTagTest4;
166 161
         }
167
-    }
168
-    else
162
+    } else
169 163
     {
170 164
         echo '[FAIL] STEP#3 // Got wrong count of item:' . count($tagsItems) .  "\n";
171 165
         $status = 1;
172 166
         goto itemTagTest4;
173 167
     }
174
-}
175
-else
168
+} else
176 169
 {
177 170
     echo '[FAIL] STEP#3 // Expected $tagsItems to be an array, got: ' . gettype($tagsItems) .  "\n";
178 171
     $status = 1;
@@ -192,8 +185,7 @@  discard block
 block discarded – undo
192 185
 {
193 186
     echo "[FAIL] STEP#4 // Getter getItemsByTag() found item(s), possible memory leak \n";
194 187
     $status = 1;
195
-}
196
-else
188
+} else
197 189
 {
198 190
     echo "[PASS] STEP#4 // Getter getItemsByTag() found no item \n";
199 191
 }
@@ -205,8 +197,7 @@  discard block
 block discarded – undo
205 197
     {
206 198
         echo "[FAIL] STEP#4 // Item 'tag-test{$i}' should've been deleted and is still in cache storage \n";
207 199
         $status = 1;
208
-    }
209
-    else
200
+    } else
210 201
     {
211 202
         echo "[PASS] STEP#4 // Item 'tag-test{$i}' have been deleted and is no longer in cache storage \n";
212 203
     }
@@ -226,8 +217,7 @@  discard block
 block discarded – undo
226 217
 {
227 218
     echo "[FAIL] STEP#5 // Getter getItemsByTag() found item(s), possible memory leak \n";
228 219
     $status = 1;
229
-}
230
-else
220
+} else
231 221
 {
232 222
     echo "[PASS] STEP#5 // Getter getItemsByTag() found no item \n";
233 223
 }
@@ -239,8 +229,7 @@  discard block
 block discarded – undo
239 229
     {
240 230
         echo "[FAIL] STEP#5 // Item 'tag-test{$i}' should've been deleted and is still in cache storage \n";
241 231
         $status = 1;
242
-    }
243
-    else
232
+    } else
244 233
     {
245 234
         echo "[PASS] STEP#5 // Item 'tag-test{$i}' have been deleted and is no longer in cache storage \n";
246 235
     }
@@ -263,8 +252,7 @@  discard block
 block discarded – undo
263 252
 {
264 253
     echo "[FAIL] STEP#6 // Getter getItem() found item 'item-test_3', possible memory leak \n";
265 254
     $status = 1;
266
-}
267
-else
255
+} else
268 256
 {
269 257
     echo "[PASS] STEP#6 // Getter getItem() did not found item 'item-test_3' \n";
270 258
 }
@@ -285,8 +273,7 @@  discard block
 block discarded – undo
285 273
     {
286 274
         echo "[FAIL] STEP#7 // Item '{$item->getKey()}' does not have the string part '{$appendStr}' in it's value \n";
287 275
         $status = 1;
288
-    }
289
-    else
276
+    } else
290 277
     {
291 278
         echo "[PASS] STEP#7 // Item 'tag-test{$item->getKey()}' does have the string part '{$appendStr}' in it's value \n";
292 279
     }
@@ -308,8 +295,7 @@  discard block
 block discarded – undo
308 295
     {
309 296
         echo "[FAIL] STEP#7 // Item '{$item->getKey()}' does not have the string part '{$prependStr}' in it's value \n";
310 297
         $status = 1;
311
-    }
312
-    else
298
+    } else
313 299
     {
314 300
         echo "[PASS] STEP#7 // Item 'tag-test{$item->getKey()}' does have the string part '{$prependStr}' in it's value \n";
315 301
     }
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 chdir(__DIR__);
12 12
 require_once __DIR__ . '/../src/autoload.php';
13 13
 $testHelper = new TestHelper('Items tags features');
14
-$defaultDriver = (!empty($argv[ 1 ]) ? ucfirst($argv[ 1 ]) : 'Files');
14
+$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files');
15 15
 $driverInstance = CacheManager::getInstance($defaultDriver);
16 16
 
17 17
 /**
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
 $createItemsCallback();
66 66
 
67 67
 $tagsItems = $driverInstance->getItemsByTag('tag-test_all');
68
-if(is_array($tagsItems))
68
+if (is_array($tagsItems))
69 69
 {
70
-    if(count($tagsItems) === 3)
70
+    if (count($tagsItems) === 3)
71 71
     {
72
-        foreach($tagsItems as $tagsItem)
72
+        foreach ($tagsItems as $tagsItem)
73 73
         {
74
-            if(!in_array($tagsItem->getKey(), ['tag-test1', 'tag-test2', 'tag-test3'])){
74
+            if (!in_array($tagsItem->getKey(), ['tag-test1', 'tag-test2', 'tag-test3'])) {
75 75
                 $testHelper->printFailText('STEP#1 // Got unexpected tagged item key:' . $tagsItem->getKey());
76 76
                 goto itemTagTest2;
77 77
             }
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
 
101 101
 $tagsItems = $driverInstance->getItemsByTagsAll(['tag-test_all', 'tag-test_all2', 'tag-test_all3']);
102 102
 
103
-if(is_array($tagsItems))
103
+if (is_array($tagsItems))
104 104
 {
105
-    if(count($tagsItems) === 3)
105
+    if (count($tagsItems) === 3)
106 106
     {
107
-        foreach($tagsItems as $tagsItem)
107
+        foreach ($tagsItems as $tagsItem)
108 108
         {
109
-            if(!in_array($tagsItem->getKey(), ['tag-test1', 'tag-test2', 'tag-test3'])){
109
+            if (!in_array($tagsItem->getKey(), ['tag-test1', 'tag-test2', 'tag-test3'])) {
110 110
                 $testHelper->printFailText('STEP#2 // Got unexpected tagged item key:' . $tagsItem->getKey());
111 111
                 goto itemTagTest3;
112 112
             }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
     }
116 116
     else
117 117
     {
118
-        $testHelper->printFailText('STEP#2 // Got wrong count of item:' . count($tagsItems) );
118
+        $testHelper->printFailText('STEP#2 // Got wrong count of item:' . count($tagsItems));
119 119
         goto itemTagTest3;
120 120
     }
121 121
 }
@@ -135,13 +135,13 @@  discard block
 block discarded – undo
135 135
 
136 136
 $tagsItems = $driverInstance->getItemsByTagsAll(['tag-test_all', 'tag-test_all2', 'tag-test_all3', 'tag-test_all4']);
137 137
 
138
-if(is_array($tagsItems))
138
+if (is_array($tagsItems))
139 139
 {
140
-    if(count($tagsItems) === 1)
140
+    if (count($tagsItems) === 1)
141 141
     {
142
-        if(isset($tagsItems['tag-test3']))
142
+        if (isset($tagsItems['tag-test3']))
143 143
         {
144
-            if($tagsItems['tag-test3']->getKey() !== 'tag-test3'){
144
+            if ($tagsItems['tag-test3']->getKey() !== 'tag-test3') {
145 145
                 $testHelper->printFailText('STEP#3 // Got unexpected tagged item key:' . $tagsItems['tag-test3']->getKey());
146 146
                 goto itemTagTest4;
147 147
             }
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 $createItemsCallback();
175 175
 $driverInstance->deleteItemsByTag('tag-test_all');
176 176
 
177
-if(count($driverInstance->getItemsByTag('tag-test_all')) > 0)
177
+if (count($driverInstance->getItemsByTag('tag-test_all')) > 0)
178 178
 {
179 179
     $testHelper->printFailText('[FAIL] STEP#4 // Getter getItemsByTag() found item(s), possible memory leak');
180 180
 }
@@ -184,9 +184,9 @@  discard block
 block discarded – undo
184 184
 }
185 185
 
186 186
 $i = 0;
187
-while(++$i <= 3)
187
+while (++$i <= 3)
188 188
 {
189
-    if($driverInstance->getItem("tag-test{$i}")->isHit())
189
+    if ($driverInstance->getItem("tag-test{$i}")->isHit())
190 190
     {
191 191
         $testHelper->printFailText("STEP#4 // Item 'tag-test{$i}' should've been deleted and is still in cache storage");
192 192
     }
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 
207 207
 $driverInstance->deleteItemsByTagsAll(['tag-test_all', 'tag-test_all2', 'tag-test_all3']);
208 208
 
209
-if(count($driverInstance->getItemsByTag('tag-test_all')) > 0)
209
+if (count($driverInstance->getItemsByTag('tag-test_all')) > 0)
210 210
 {
211 211
     $testHelper->printFailText('STEP#5 // Getter getItemsByTag() found item(s), possible memory leak');
212 212
 }
@@ -216,9 +216,9 @@  discard block
 block discarded – undo
216 216
 }
217 217
 
218 218
 $i = 0;
219
-while(++$i <= 3)
219
+while (++$i <= 3)
220 220
 {
221
-    if($driverInstance->getItem("tag-test{$i}")->isHit())
221
+    if ($driverInstance->getItem("tag-test{$i}")->isHit())
222 222
     {
223 223
         $testHelper->printFailText("STEP#5 // Item 'tag-test{$i}' should've been deleted and is still in cache storage");
224 224
     }
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
  */
242 242
 $driverInstance->deleteItemsByTagsAll(['tag-test_all', 'tag-test_all2', 'tag-test_all3', 'tag-test_all4']);
243 243
 
244
-if($driverInstance->getItem('item-test_3')->isHit())
244
+if ($driverInstance->getItem('item-test_3')->isHit())
245 245
 {
246 246
     $testHelper->printFailText('STEP#6 // Getter getItem() found item \'item-test_3\', possible memory leak');
247 247
 }
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
 $appendStr = '$*#*$';
261 261
 $driverInstance->appendItemsByTagsAll(['tag-test_all', 'tag-test_all2', 'tag-test_all3'], $appendStr);
262 262
 
263
-foreach($driverInstance->getItems(['tag-test1', 'tag-test2', 'tag-test3']) as $item)
263
+foreach ($driverInstance->getItems(['tag-test1', 'tag-test2', 'tag-test3']) as $item)
264 264
 {
265
-    if(strpos($item->get(), $appendStr) === false)
265
+    if (strpos($item->get(), $appendStr) === false)
266 266
     {
267 267
         $testHelper->printFailText("STEP#7 // Item '{$item->getKey()}' does not have the string part '{$appendStr}' in it's value");
268 268
     }
@@ -282,9 +282,9 @@  discard block
 block discarded – undo
282 282
 $prependStr = '&+_+&';
283 283
 $driverInstance->prependItemsByTagsAll(['tag-test_all', 'tag-test_all2', 'tag-test_all3'], $prependStr);
284 284
 
285
-foreach($driverInstance->getItems(['tag-test1', 'tag-test2', 'tag-test3']) as $item)
285
+foreach ($driverInstance->getItems(['tag-test1', 'tag-test2', 'tag-test3']) as $item)
286 286
 {
287
-    if(strpos($item->get(), $prependStr) === false)
287
+    if (strpos($item->get(), $prependStr) === false)
288 288
     {
289 289
         $testHelper->printFailText("STEP#8 // Item '{$item->getKey()}' does not have the string part '{$prependStr}' in it's value");
290 290
     }
Please login to merge, or discard this patch.